aboutsummaryrefslogtreecommitdiffstats
path: root/t
diff options
context:
space:
mode:
authorDerrick Stolee <stolee@gmail.com>2025-09-12 10:30:09 +0000
committerJunio C Hamano <gitster@pobox.com>2025-09-15 12:10:56 -0700
commit5b5a7f5ebd2e2701ac6fa522866f22b885147c01 (patch)
tree8246439b3f1b89c4a94c63ad61dc6110ea83ea77 /t
parentdir: add generic "walk all files" helper (diff)
downloadgit-5b5a7f5ebd2e2701ac6fa522866f22b885147c01.tar.gz
git-5b5a7f5ebd2e2701ac6fa522866f22b885147c01.zip
sparse-checkout: add --verbose option to 'clean'
The 'git sparse-checkout clean' subcommand is focused on directories, deleting any tracked sparse directories to clean up the worktree and make the sparse index feature work optimally. However, this directory-focused approach can leave users wondering why those directories exist at all. In my experience, these files are left over due to ignore or exclude patterns, Windows file handles, or possibly merge conflict resolutions. Add a new '--verbose' option for users to see all the files that are being deleted (with '--force') or would be deleted (with '--dry-run'). Based on usage, users may request further context on this list of files for states such as tracked/untracked, unstaged/staged/conflicted, etc. Signed-off-by: Derrick Stolee <stolee@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't')
-rwxr-xr-xt/t1091-sparse-checkout-builtin.sh14
1 files changed, 11 insertions, 3 deletions
diff --git a/t/t1091-sparse-checkout-builtin.sh b/t/t1091-sparse-checkout-builtin.sh
index e6b768a8da..7b15fa669c 100755
--- a/t/t1091-sparse-checkout-builtin.sh
+++ b/t/t1091-sparse-checkout-builtin.sh
@@ -1053,11 +1053,11 @@ test_expect_success 'check-rules null termination' '
test_expect_success 'clean' '
git -C repo sparse-checkout set --cone deep/deeper1 &&
git -C repo sparse-checkout reapply &&
- mkdir repo/deep/deeper2 repo/folder1 &&
+ mkdir -p repo/deep/deeper2 repo/folder1/extra/inside &&
# Add untracked files
touch repo/deep/deeper2/file &&
- touch repo/folder1/file &&
+ touch repo/folder1/extra/inside/file &&
test_must_fail git -C repo sparse-checkout clean 2>err &&
grep "refusing to clean" err &&
@@ -1074,7 +1074,15 @@ test_expect_success 'clean' '
git -C repo sparse-checkout clean --dry-run >out &&
test_cmp expect out &&
test_path_exists repo/deep/deeper2 &&
- test_path_exists repo/folder1 &&
+ test_path_exists repo/folder1/extra/inside/file &&
+
+ cat >expect <<-\EOF &&
+ Would remove deep/deeper2/file
+ Would remove folder1/extra/inside/file
+ EOF
+
+ git -C repo sparse-checkout clean --dry-run --verbose >out &&
+ test_cmp expect out &&
cat >expect <<-\EOF &&
Removing deep/deeper2/