On Wednesday, 18 November 2009 at 7:16, Jonathan Nieder wrote: > Christian Ohm wrote: > > As the subject says, the exclude options to ls-files seem broken. For > > example, > > in a repo with PNG files, "git ls-files" obviously lists those, but "git > > ls-files -x '*.png'" does as well. --exclude also doesn't help, putting the > > pattern into a file and using -X also fails. > That is by design. Everywhere else in git, files excluded by .gitignore but > in the index are not ignored, and so with git ls-files, too. This was > broken for a while, impacting other commands; see > <http://thread.gmane.org/gmane.comp.version-control.git/129889>, for > example. > > Hackish workaround: use '-i', which (since v1.6.5.3) does not apply this > logic, with --exclude-from=file, file as follows: > > !*.png > * > > The logic being "I do not want to track anything but image files; now please > let me know what seems to be tracked by mistake." > > Does that take care of your need? What do you use this command to do?
Ok... I have a repo (Warzone 2100) with random files, some source code, some data (e.g. png files). Now I want to use cscope to navigate the source, so I use the following (generic) script to index the files: if [ ! "$PROJDIR" ] ; then PROJDIR="`pwd`" fi if [ -d .git ] ; then git ls-files | sort | cscope -R -b -i- -f"$PROJDIR"/cscope.out else ( cd /; find "$PROJDIR" -name '\.git' -name '\.svn' -name '\.hg' -prune -o -name \*.c -o -name \*.h -o -name \*.l -o -name \*.y -o -name \*.cpp -o -name \*.cc | sort | cscope -R -b -i- -f"$PROJDIR"/cscope.out ) fi That works, and the git ls-files line is much more convenient than the find below, since it lists only the tracked files, not anything else. But I'd also like to exclude the data files, since they take unneccessary time to process, and occasionally lead to false positives. So I looked at the git-ls-files man page, and saw the exclude options, which looked exactly like what I wanted: "show me all files in the repo, except the following." Reading further, the "Exclude patterns" section says "git-ls-files can use a list of "exclude patterns" when traversing the directory tree and finding files to show when the flags --others or --ignored are specified", so it is somewhat documented, though missing from the description of the exclusion options above (and if this is intentionally limited, some kind of explanation would be nice). Of course, I can just filter out unwanted files with grep or something, but the -X option would have made it very easy to just have a project-specific .cscope-ignore file that I can just feed to git ls-files. Best regards, Christian Ohm -- To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org