]> git.ipfire.org Git - thirdparty/git.git/commitdiff
add: make --chmod and --renormalize honor sparse checkouts
authorMatheus Tavares <matheus.bernardino@usp.br>
Thu, 8 Apr 2021 20:41:24 +0000 (17:41 -0300)
committerJunio C Hamano <gitster@pobox.com>
Thu, 8 Apr 2021 21:18:03 +0000 (14:18 -0700)
Signed-off-by: Matheus Tavares <matheus.bernardino@usp.br>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/add.c
t/t3705-add-sparse-checkout.sh

index 24ed7e25f319dbe5bd3f3b12fbd4d8e3076e790e..5fec21a7928b0895414c61a00b71cfe1b539b1b0 100644 (file)
@@ -46,6 +46,9 @@ static int chmod_pathspec(struct pathspec *pathspec, char flip, int show_only)
                struct cache_entry *ce = active_cache[i];
                int err;
 
+               if (ce_skip_worktree(ce))
+                       continue;
+
                if (pathspec && !ce_path_match(&the_index, ce, pathspec, NULL))
                        continue;
 
@@ -144,6 +147,8 @@ static int renormalize_tracked_files(const struct pathspec *pathspec, int flags)
        for (i = 0; i < active_nr; i++) {
                struct cache_entry *ce = active_cache[i];
 
+               if (ce_skip_worktree(ce))
+                       continue;
                if (ce_stage(ce))
                        continue; /* do not touch unmerged paths */
                if (!S_ISREG(ce->ce_mode) && !S_ISLNK(ce->ce_mode))
index 6c5b8be863c07f3cb6ce0bd12ab0c458d126ce3f..00b10ac877d31895ccdf3b2ae74137845cdffde7 100755 (executable)
@@ -78,14 +78,14 @@ test_expect_success 'git add --refresh does not update sparse entries' '
        test_cmp before after
 '
 
-test_expect_failure 'git add --chmod does not update sparse entries' '
+test_expect_success 'git add --chmod does not update sparse entries' '
        setup_sparse_entry &&
        git add --chmod=+x sparse_entry &&
        test_sparse_entry_unchanged &&
        ! test -x sparse_entry
 '
 
-test_expect_failure 'git add --renormalize does not update sparse entries' '
+test_expect_success 'git add --renormalize does not update sparse entries' '
        test_config core.autocrlf false &&
        setup_sparse_entry "LINEONE\r\nLINETWO\r\n" &&
        echo "sparse_entry text=auto" >.gitattributes &&