Commit Diff


commit - c50a74557db04e5ab02a1b0c53cb4fbdd64088ac
commit + 6092c29954d72000fdc1b6fe2a9c10ff56aabc65
blob - 814eb2087943991b565469794ce542b904c409f4
blob + c6d1f7ea574e7ec116144f4448f4ca17215ea404
--- lib/fileindex.c
+++ lib/fileindex.c
@@ -989,7 +989,7 @@ 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,
     const char *path, const char *rootpath, struct got_repository *repo,
-    struct got_fileindex_diff_dir_cb *cb, void *cb_arg)
+    int ignore, struct got_fileindex_diff_dir_cb *cb, void *cb_arg)
 {
 	const struct got_error *err = NULL;
 	struct dirent *de = dle->data;
@@ -1011,7 +1011,7 @@ walk_dir(struct got_pathlist_entry **next, struct got_
 	} else
 		type = de->d_type;
 
-	if (type == DT_DIR) {
+	if (type == DT_DIR && !ignore) {
 		char *subpath;
 		char *subdirpath;
 		struct got_pathlist_head subdirlist;
@@ -1077,6 +1077,7 @@ diff_fileindex_dir(struct got_fileindex *fileindex,
 	struct dirent *de = NULL;
 	size_t path_len = strlen(path);
 	struct got_pathlist_entry *dle;
+	int ignore;
 
 	if (cb->diff_traverse) {
 		err = cb->diff_traverse(cb_arg, path, dirfd);
@@ -1106,18 +1107,19 @@ diff_fileindex_dir(struct got_fileindex *fileindex,
 					break;
 				*ie = walk_fileindex(fileindex, *ie);
 				err = walk_dir(&dle, fileindex, ie, dle, dirfd,
-				    path, rootpath, repo, cb, cb_arg);
+				    path, rootpath, repo, 0, cb, cb_arg);
 			} else if (cmp < 0 ) {
 				err = cb->diff_old(cb_arg, *ie, path);
 				if (err)
 					break;
 				*ie = walk_fileindex(fileindex, *ie);
 			} else {
-				err = cb->diff_new(cb_arg, de, path, dirfd);
+				err = cb->diff_new(&ignore, cb_arg, de, path,
+				    dirfd);
 				if (err)
 					break;
 				err = walk_dir(&dle, fileindex, ie, dle, dirfd,
-				    path, rootpath, repo, cb, cb_arg);
+				    path, rootpath, repo, ignore, cb, cb_arg);
 			}
 			if (err)
 				break;
@@ -1128,11 +1130,11 @@ diff_fileindex_dir(struct got_fileindex *fileindex,
 			*ie = walk_fileindex(fileindex, *ie);
 		} else if (dle) {
 			de = dle->data;
-			err = cb->diff_new(cb_arg, de, path, dirfd);
+			err = cb->diff_new(&ignore, cb_arg, de, path, dirfd);
 			if (err)
 				break;
 			err = walk_dir(&dle, fileindex, ie, dle, dirfd, path,
-			    rootpath, repo, cb, cb_arg);
+			    rootpath, repo, ignore, cb, cb_arg);
 			if (err)
 				break;
 		}
blob - d03058e83c5f5c0a69baf66795455eb3ab8b7af7
blob + 0c22385de5665de7e4366e6db2b42d3737058e0f
--- lib/got_lib_fileindex.h
+++ lib/got_lib_fileindex.h
@@ -148,7 +148,7 @@ typedef const struct got_error *(*got_fileindex_diff_d
     struct got_fileindex_entry *, struct dirent *, const char *, int);
 typedef const struct got_error *(*got_fileindex_diff_dir_old_cb)(void *,
     struct got_fileindex_entry *, const char *);
-typedef const struct got_error *(*got_fileindex_diff_dir_new_cb)(void *,
+typedef const struct got_error *(*got_fileindex_diff_dir_new_cb)(int *, void *,
     struct dirent *, const char *, int);
 typedef const struct got_error *(*got_fileindex_diff_dir_traverse)(void *,
     const char *, int);
blob - bf1b968b1dcb7b8b268250267bca14c5c8447b66
blob + f3111e0b046c0a015967d9caba4e8e93a57c937d
--- lib/worktree.c
+++ lib/worktree.c
@@ -3615,11 +3615,15 @@ add_ignores(struct got_pathlist_head *ignores, const c
 }
 
 static const struct got_error *
-status_new(void *arg, struct dirent *de, const char *parent_path, int dirfd)
+status_new(int *ignore, void *arg, struct dirent *de, const char *parent_path,
+    int dirfd)
 {
 	const struct got_error *err = NULL;
 	struct diff_dir_cb_arg *a = arg;
 	char *path = NULL;
+
+	if (ignore != NULL)
+		*ignore = 0;
 
 	if (a->cancel_cb && a->cancel_cb(a->cancel_arg))
 		return got_error(GOT_ERR_CANCELLED);
@@ -3631,9 +3635,12 @@ status_new(void *arg, struct dirent *de, const char *p
 		path = de->d_name;
 	}
 
-	if (de->d_type != DT_DIR &&
-	    got_path_is_child(path, a->status_path, a->status_path_len)
-	    && !match_ignores(a->ignores, path))
+	if (de->d_type == DT_DIR) {
+		if (!a->no_ignores && ignore != NULL &&
+		    match_ignores(a->ignores, path))
+			*ignore = 1;
+	} else if (!match_ignores(a->ignores, path) &&
+	    got_path_is_child(path, a->status_path, a->status_path_len))
 		err = (*a->status_cb)(a->status_arg, GOT_STATUS_UNVERSIONED,
 		    GOT_STATUS_NO_CHANGE, path, NULL, NULL, NULL, -1, NULL);
 	if (parent_path[0])
@@ -4211,7 +4218,7 @@ got_worktree_schedule_delete(struct got_worktree *work
 
 	TAILQ_FOREACH(pe, paths, entry) {
 		err = worktree_status(worktree, pe->path, fileindex, repo,
-			schedule_for_deletion, &sda, NULL, NULL, 0, 1);
+			schedule_for_deletion, &sda, NULL, NULL, 1, 1);
 		if (err)
 			break;
 	}
@@ -4875,7 +4882,7 @@ got_worktree_revert(struct got_worktree *worktree,
 	rfa.unlink_added_files = 0;
 	TAILQ_FOREACH(pe, paths, entry) {
 		err = worktree_status(worktree, pe->path, fileindex, repo,
-		    revert_file, &rfa, NULL, NULL, 0, 0);
+		    revert_file, &rfa, NULL, NULL, 1, 0);
 		if (err)
 			break;
 	}
@@ -5889,7 +5896,7 @@ got_worktree_commit(struct got_object_id **new_commit_
 	cc_arg.allow_bad_symlinks = allow_bad_symlinks;
 	TAILQ_FOREACH(pe, paths, entry) {
 		err = worktree_status(worktree, pe->path, fileindex, repo,
-		    collect_commitables, &cc_arg, NULL, NULL, 0, 0);
+		    collect_commitables, &cc_arg, NULL, NULL, 1, 0);
 		if (err)
 			goto done;
 	}
@@ -6828,7 +6835,7 @@ got_worktree_rebase_abort(struct got_worktree *worktre
 	rfa.repo = repo;
 	rfa.unlink_added_files = 0;
 	err = worktree_status(worktree, "", fileindex, repo,
-	    revert_file, &rfa, NULL, NULL, 0, 0);
+	    revert_file, &rfa, NULL, NULL, 1, 0);
 	if (err)
 		goto sync;
 
@@ -7182,7 +7189,7 @@ got_worktree_histedit_abort(struct got_worktree *workt
 	rfa.repo = repo;
 	rfa.unlink_added_files = 0;
 	err = worktree_status(worktree, "", fileindex, repo,
-	    revert_file, &rfa, NULL, NULL, 0, 0);
+	    revert_file, &rfa, NULL, NULL, 1, 0);
 	if (err)
 		goto sync;
 
@@ -7581,7 +7588,7 @@ got_worktree_merge_commit(struct got_object_id **new_c
 	cc_arg.have_staged_files = have_staged_files;
 	cc_arg.allow_bad_symlinks = allow_bad_symlinks;
 	err = worktree_status(worktree, "", fileindex, repo,
-	    collect_commitables, &cc_arg, NULL, NULL, 0, 0);
+	    collect_commitables, &cc_arg, NULL, NULL, 1, 0);
 	if (err)
 		goto done;
 
@@ -7890,7 +7897,7 @@ got_worktree_merge_abort(struct got_worktree *worktree
 	rfa.repo = repo;
 	rfa.unlink_added_files = 1;
 	err = worktree_status(worktree, "", fileindex, repo,
-	    revert_file, &rfa, NULL, NULL, 0, 0);
+	    revert_file, &rfa, NULL, NULL, 1, 0);
 	if (err)
 		goto sync;
 
@@ -8177,7 +8184,7 @@ got_worktree_stage(struct got_worktree *worktree,
 	oka.have_changes = 0;
 	TAILQ_FOREACH(pe, paths, entry) {
 		err = worktree_status(worktree, pe->path, fileindex, repo,
-		    check_stage_ok, &oka, NULL, NULL, 0, 0);
+		    check_stage_ok, &oka, NULL, NULL, 1, 0);
 		if (err)
 			goto done;
 	}
@@ -8197,7 +8204,7 @@ got_worktree_stage(struct got_worktree *worktree,
 	spa.allow_bad_symlinks = allow_bad_symlinks;
 	TAILQ_FOREACH(pe, paths, entry) {
 		err = worktree_status(worktree, pe->path, fileindex, repo,
-		    stage_path, &spa, NULL, NULL, 0, 0);
+		    stage_path, &spa, NULL, NULL, 1, 0);
 		if (err)
 			goto done;
 	}
@@ -8689,7 +8696,7 @@ got_worktree_unstage(struct got_worktree *worktree,
 	upa.patch_arg = patch_arg;
 	TAILQ_FOREACH(pe, paths, entry) {
 		err = worktree_status(worktree, pe->path, fileindex, repo,
-		    unstage_path, &upa, NULL, NULL, 0, 0);
+		    unstage_path, &upa, NULL, NULL, 1, 0);
 		if (err)
 			goto done;
 	}