ls-files: honour per-directory ignore file from higher directories.
When git-ls-files -o --exclude-per-directory=.gitignore is run from a subdirectory, it did not read from .gitignore from its parent directory. Reading from them makes output from these two commands consistent: $ git ls-files -o --exclude-per-directory=.gitignore Documentation $ cd Documentation && git ls-files -o --exclude-per-directory=.gitignore Signed-off-by: Junio C Hamano <junkio@cox.net>
Junio C Hamano committed
Feb 9, 2006 at 00:08 UTC
701ca744e386c2429ca44072ea987bbb4bdac7ce
1 file changed
+21
-1
ls-files.c
+21
-1
@@ -474,8 +474,28 @@ static void show_files(void)
474
const char *path = ".", *base = "";
475
int baselen = prefix_len;
476
477
- if (baselen)
477
+ if (baselen) {
478
path = base = prefix;
479
+ if (exclude_per_dir) {
480
+ char *p, *pp = xmalloc(baselen+1);
481
+ memcpy(pp, prefix, baselen+1);
482
+ p = pp;
483
+ while (1) {
484
+ char save = *p;
485
+ *p = 0;
486
+ push_exclude_per_directory(pp, p-pp);
487
+ *p++ = save;
488
+ if (!save)
489
+ break;
490
+ p = strchr(p, '/');
491
+ if (p)
492
+ p++;
493
+ else
494
+ p = pp + baselen;
495
+ }
496
+ free(pp);
497
+ }
498
+ }
499
read_directory(path, base, baselen);
500
qsort(dir, nr_dir, sizeof(struct nond_on_fs *), cmp_name);
501
if (show_others)