Commit Diff


commit - 4545b700107608ae12d074627db4e14d39f6b1fe
commit + 8528beeff973fe088f98bbf8081b0289a7c3c028
blob - c6d1f7ea574e7ec116144f4448f4ca17215ea404
blob + c1f88d0af838f822b1b8acf17870ecafaf1755c0
--- lib/fileindex.c
+++ lib/fileindex.c
@@ -984,7 +984,31 @@ free_dirlist(struct got_pathlist_head *dirlist)
 		free(dle->data);
 	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,
@@ -1011,6 +1035,11 @@ walk_dir(struct got_pathlist_entry **next, struct got_
 	} 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;
blob - 1768e16b391b7e17123333e6557cfd1a8ff913a3
blob + 8482b39abaec22fd45cad69589613c1baeb685ce
--- regress/cmdline/status.sh
+++ 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