Skip to content

Commit d73dbaf

Browse files
matheustavaresgitster
authored andcommitted
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>
1 parent 6594afc commit d73dbaf

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

builtin/add.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ static int chmod_pathspec(struct pathspec *pathspec, char flip, int show_only)
4646
struct cache_entry *ce = active_cache[i];
4747
int err;
4848

49+
if (ce_skip_worktree(ce))
50+
continue;
51+
4952
if (pathspec && !ce_path_match(&the_index, ce, pathspec, NULL))
5053
continue;
5154

@@ -144,6 +147,8 @@ static int renormalize_tracked_files(const struct pathspec *pathspec, int flags)
144147
for (i = 0; i < active_nr; i++) {
145148
struct cache_entry *ce = active_cache[i];
146149

150+
if (ce_skip_worktree(ce))
151+
continue;
147152
if (ce_stage(ce))
148153
continue; /* do not touch unmerged paths */
149154
if (!S_ISREG(ce->ce_mode) && !S_ISLNK(ce->ce_mode))

t/t3705-add-sparse-checkout.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,14 +78,14 @@ test_expect_success 'git add --refresh does not update sparse entries' '
7878
test_cmp before after
7979
'
8080

81-
test_expect_failure 'git add --chmod does not update sparse entries' '
81+
test_expect_success 'git add --chmod does not update sparse entries' '
8282
setup_sparse_entry &&
8383
git add --chmod=+x sparse_entry &&
8484
test_sparse_entry_unchanged &&
8585
! test -x sparse_entry
8686
'
8787

88-
test_expect_failure 'git add --renormalize does not update sparse entries' '
88+
test_expect_success 'git add --renormalize does not update sparse entries' '
8989
test_config core.autocrlf false &&
9090
setup_sparse_entry "LINEONE\r\nLINETWO\r\n" &&
9191
echo "sparse_entry text=auto" >.gitattributes &&

0 commit comments

Comments
 (0)