aboutsummaryrefslogtreecommitdiffstats
path: root/builtin/add.c
diff options
context:
space:
mode:
authorDerrick Stolee <dstolee@microsoft.com>2021-09-24 15:39:07 +0000
committerJunio C Hamano <gitster@pobox.com>2021-09-28 10:31:02 -0700
commit49fdd51a235fe2ca91a6d1b16315204f0f016a96 (patch)
treea98ca6a6ec6c35b59843be5f415ac34332291d24 /builtin/add.c
parent105e8b014b1d584174aca81081ee5428caea03cb (diff)
downloadgit-49fdd51a235fe2ca91a6d1b16315204f0f016a96.tar.gz
add: skip tracked paths outside sparse-checkout cone
When 'git add' adds a tracked file that is outside of the sparse-checkout cone, it checks the SKIP_WORKTREE bit to see if the file exists outside of the sparse-checkout cone. This is usually correct, except in the case of a merge conflict outside of the cone. Modify add_pathspec_matched_against_index() to be more careful about paths by checking the sparse-checkout patterns in addition to the SKIP_WORKTREE bit. This causes 'git add' to no longer allow files outside of the cone that removed the SKIP_WORKTREE bit due to a merge conflict. With only this change, users will only be able to add the file after adding the file to the sparse-checkout cone. A later change will allow users to force adding even though the file is outside of the sparse-checkout cone. Signed-off-by: Derrick Stolee <dstolee@microsoft.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/add.c')
-rw-r--r--builtin/add.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/builtin/add.c b/builtin/add.c
index 8ea9cae0e7..09c3fad632 100644
--- a/builtin/add.c
+++ b/builtin/add.c
@@ -94,6 +94,10 @@ static void update_callback(struct diff_queue_struct *q,
for (i = 0; i < q->nr; i++) {
struct diff_filepair *p = q->queue[i];
const char *path = p->one->path;
+
+ if (!path_in_sparse_checkout(path, &the_index))
+ continue;
+
switch (fix_unmerged_status(p, data)) {
default:
die(_("unexpected diff status %c"), p->status);