do not skip ignored directories in 'got status' if they contain tracked files Fixes regression introduced by commit 41f061b2f459318f3738f59d7676efccc4beb344 where tracked files inside an ignored directory were reported as missing.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
diff --git a/lib/fileindex.c b/lib/fileindex.c
index fba8eb7..91a35e4 100644
--- a/lib/fileindex.c
+++ b/lib/fileindex.c
@@ -987,6 +987,30 @@ free_dirlist(struct got_pathlist_head *dirlist)
got_pathlist_free(dirlist);
}
+static int
+have_tracked_file_in_dir(struct got_fileindex *fileindex, const char *path)
+{
+ struct got_fileindex_entry *ie;
+ size_t path_len = strlen(path);
+ int cmp;
+
+ ie = RB_ROOT(&fileindex->entries);
+ while (ie) {
+ if (got_path_is_child(ie->path, path, path_len))
+ return 1;
+ cmp = got_path_cmp(path, ie->path, path_len,
+ got_fileindex_entry_path_len(ie));
+ if (cmp < 0)
+ ie = RB_LEFT(ie, entry);
+ else if (cmp > 0)
+ ie = RB_RIGHT(ie, entry);
+ else
+ break;
+ }
+
+ return 0;
+}
+
static const struct got_error *
walk_dir(struct got_pathlist_entry **next, struct got_fileindex *fileindex,
struct got_fileindex_entry **ie, struct got_pathlist_entry *dle, int fd,
@@ -1013,6 +1037,11 @@ walk_dir(struct got_pathlist_entry **next, struct got_fileindex *fileindex,
} else
type = de->d_type;
+ /* Must traverse ignored directories if they contain tracked files. */
+ if (type == DT_DIR && ignore &&
+ have_tracked_file_in_dir(fileindex, path))
+ ignore = 0;
+
if (type == DT_DIR && !ignore) {
char *subpath;
char *subdirpath;
diff --git a/regress/cmdline/status.sh b/regress/cmdline/status.sh
index 8b67476..9e58172 100755
--- a/regress/cmdline/status.sh
+++ b/regress/cmdline/status.sh
@@ -531,6 +531,7 @@ test_status_cvsignore() {
mkdir -p $testroot/wt/epsilon/new/
echo "unversioned file" > $testroot/wt/epsilon/new/foo
echo "**/foo" > $testroot/wt/.cvsignore
+ echo "**/gamma" >> $testroot/wt/.cvsignore
echo "bar" > $testroot/wt/epsilon/.cvsignore
echo "moo" >> $testroot/wt/epsilon/.cvsignore