add: make --chmod and --renormalize honor sparse checkouts
Signed-off-by: Matheus Tavares <matheus.bernardino@usp.br> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Matheus Tavares committed
Apr 8, 2021 at 17:41 UTC
d73dbafc2c25eb45090d6aa9d56fc21b40c78083
2 files changed
+7
-2
builtin/add.c
+5
@@ -46,6 +46,9 @@ static int chmod_pathspec(struct pathspec *pathspec, char flip, int show_only)
46
struct cache_entry *ce = active_cache[i];
47
int err;
48
49
+ if (ce_skip_worktree(ce))
50
+ continue;
51
+
52
if (pathspec && !ce_path_match(&the_index, ce, pathspec, NULL))
53
continue;
54
@@ -144,6 +147,8 @@ static int renormalize_tracked_files(const struct pathspec *pathspec, int flags)
147
for (i = 0; i < active_nr; i++) {
148
struct cache_entry *ce = active_cache[i];
149
150
+ if (ce_skip_worktree(ce))
151
+ continue;
152
if (ce_stage(ce))
153
continue; /* do not touch unmerged paths */
154
if (!S_ISREG(ce->ce_mode) && !S_ISLNK(ce->ce_mode))
t/t3705-add-sparse-checkout.sh
+2
-2
@@ -78,14 +78,14 @@ test_expect_success 'git add --refresh does not update sparse entries' '
78
test_cmp before after
79
'
80
81
-test_expect_failure 'git add --chmod does not update sparse entries' '
81
+test_expect_success 'git add --chmod does not update sparse entries' '
82
setup_sparse_entry &&
83
git add --chmod=+x sparse_entry &&
84
test_sparse_entry_unchanged &&
85
! test -x sparse_entry
86
'
87
88
-test_expect_failure 'git add --renormalize does not update sparse entries' '
88
+test_expect_success 'git add --renormalize does not update sparse entries' '
89
test_config core.autocrlf false &&
90
setup_sparse_entry "LINEONE\r\nLINETWO\r\n" &&
91
echo "sparse_entry text=auto" >.gitattributes &&