summaryrefslogtreecommitdiff
path: root/git-rename-script
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@osdl.org>2005-08-21 12:55:33 -0700
committerJunio C Hamano <junkio@cox.net>2005-08-21 13:41:28 -0700
commit5be4efbefafcd5b81fe3d97e8395da1887b4902a (patch)
tree36cd199ae3cb995d898d5f295a40307a36d223ba /git-rename-script
parent1dfcfbce2d643b7c7b56dc828f36ced9de2bf9f2 (diff)
downloadgit-5be4efbefafcd5b81fe3d97e8395da1887b4902a.tar.gz
[PATCH] Make "git-ls-files" work in subdirectories
This makes git-ls-files work inside a relative directory, and also adds some rudimentary filename globbing support. For example, in the kernel you can now do cd arch/i386 git-ls-files and it will show all files under that subdirectory (and it will have removed the "arch/i386/" prefix unless you give it the "--full-name" option, so that you can feed the result to "xargs grep" or similar). The filename globbing is kind of strange: it does _not_ follow normal globbing rules, although it does look "almost" like a normal file glob (and it uses the POSIX.2 "fnmatch()" function). The glob pattern (there can be only one) is always split into a "directory part" and a "glob part", where the directory part is defined as any full directory path without any '*' or '?' characters. The "glob" part is whatever is left over. For example, when doing git-ls-files 'arch/i386/p*/*.c' the "directory part" is is "arch/i386/", and the "glob part" is "p*/*.c". The directory part will be added to the prefix, and handled efficiently (ie we will not be searching outside of that subdirectory), while the glob part (if anything is left over) will be used to trigger "fnmatch()" matches. This is efficient and very useful, but can result in somewhat non-intuitive behaviour. For example: git-ls-files 'arch/i386/*.[ch]' will find all .c and .h files under arch/i386/, _including_ things in lower subdirectories (ie it will match "arch/i386/kernel/process.c", because "kernel/process.c" will match the "*.c" specifier). Also, while git-ls-files arch/i386/ will show all files under that subdirectory, doing the same without the final slash would try to show the file "i386" under the "arch/" subdirectory, and since there is no such file (even if there is such a _directory_) it will not match anything at all. These semantics may not seem intuitive, but they are actually very practical. In particular, it makes it very simple to do git-ls-files fs/*.c | xargs grep some_pattern and it does what you want. Signed-off-by: Linus Torvalds <torvalds@osdl.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
Diffstat (limited to 'git-rename-script')
0 files changed, 0 insertions, 0 deletions