Re: [PATCH v4 00/13] Sparse-checkout: modify 'git add', 'git rm', and 'git mv' behavior
From: Elijah Newren <hidden>
Date: 2021-09-27 15:51:37
On Fri, Sep 24, 2021 at 8:39 AM Derrick Stolee via GitGitGadget [off-list ref] wrote: ...
Updates in v4 ============= * Instead of using 'git status' and 'grep' to detect staged changes, we use 'git diff --staged'. t1092 uses an additional --diff-filter because it tests with merge conflicts, so it needs this extra flag. * Patches 3 and 4 are merged into the new patch 3 to avoid temporarily having a poorly named method.
...
Range-diff vs v3:
1: ea940f10a7c ! 1: 642b05fc020 t3705: test that 'sparse_entry' is unstaged
@@ t/t3705-add-sparse-checkout.sh: setup_gitignore () {
}
+test_sparse_entry_unstaged () {
-+ git status --porcelain >actual &&
-+ ! grep "^[MDARCU][M ] sparse_entry\$" actual
++ git diff --staged -- sparse_entry >diff &&
++ test_must_be_empty diff
+}
+
test_expect_success 'setup' "
2: c7dedb41291 ! 2: 58389edc76c t1092: behavior for adding sparse files
@@ t/t1092-sparse-checkout-compatibility.sh: test_sparse_match () {
+ file=$1 &&
+ for repo in sparse-checkout sparse-index
+ do
-+ git -C $repo status --porcelain >$repo-out &&
-+ ! grep "^A $file\$" $repo-out &&
-+ ! grep "^M $file\$" $repo-out || return 1
++ # Skip "unmerged" paths
++ git -C $repo diff --staged --diff-filter=ACDMRTXB -- "$file" >diff &&Wouldn't this be more naturally spelled as --diff-filter=u ? (Note: lowercase 'u', not uppercase.) Then you could drop the comment too. Other than that nit, this round looks good to me. Feel free to add a Reviewed-by: Elijah Newren <redacted>