[PATCH v9 0/2] diff-files: integrate with sparse index
From: Shuqi Liang <hidden>
Date: 2023-05-02 17:24:04
Changes since v8:
* Fix white space problem.
* Simplified the refactored function based on Victoria's suggestion.
Shuqi Liang (2):
t1092: add tests for `git diff-files`
diff-files: integrate with sparse index
builtin/diff-files.c | 4 ++
t/perf/p2000-sparse-operations.sh | 2 +
t/t1092-sparse-checkout-compatibility.sh | 73 +++++++++++++++++++++++-
3 files changed, 77 insertions(+), 2 deletions(-)
Range-diff against v8:
1: d7f921c1a6 ! 1: d78513af83 t1092: add tests for `git diff-files`
@@ t/t1092-sparse-checkout-compatibility.sh: test_expect_success 'sparse-index is n
+
+ test_all_match git diff-files &&
+
-+ test_all_match git diff-files deep/a &&
++ test_all_match git diff-files deep/a &&
+
+ # test wildcard
+ test_all_match git diff-files "deep/*"
@@ t/t1092-sparse-checkout-compatibility.sh: test_expect_success 'sparse-index is n
+ EOF
+
+ # Add file to the index but outside of cone for sparse-checkout cases.
-+ # Add file to the index without sparse-checkout cases to ensure all have
++ # Add file to the index without sparse-checkout cases to ensure all have
+ # same output.
+ run_on_all mkdir -p folder1 &&
+ run_on_all cp a folder1/a &&
@@ t/t1092-sparse-checkout-compatibility.sh: test_expect_success 'sparse-index is n
+ run_on_all ../edit-contents folder1/a &&
+ test_all_match git diff-files &&
+ test_all_match git diff-files folder1/a &&
-+ test_all_match git diff-files "folder*/a"
++ test_all_match git diff-files "folder*/a"
+'
+
test_done
2: b44384ac94 ! 2: a2454befa0 diff-files: integrate with sparse index
@@ t/t1092-sparse-checkout-compatibility.sh: test_expect_success 'index.sparse disa
'
-ensure_not_expanded () {
-+ensure_index_state () {
-+ local expected_expansion="$1"
-+ shift
-+
++run_sparse_index_trace2 () {
rm -f trace2.txt &&
if test -z "$WITHOUT_UNTRACKED_TXT"
then
@@ t/t1092-sparse-checkout-compatibility.sh: ensure_not_expanded () {
+ git -C sparse-index "$@" \
>sparse-index-out \
2>sparse-index-error || return 1
- fi &&
-- test_region ! index ensure_full_index trace2.txt
-+
-+ if [ "$expected_expansion" = "expanded" ]
-+ then
-+ test_region index ensure_full_index trace2.txt
-+ else
-+ test_region ! index ensure_full_index trace2.txt
+- fi &&
+ fi
+}
+
+ensure_expanded () {
-+ ensure_index_state "expanded" "$@"
++ run_sparse_index_trace2 "$@" &&
++ test_region index ensure_full_index trace2.txt
+}
+
+ensure_not_expanded () {
-+ ensure_index_state "not_expanded" "$@"
++ run_sparse_index_trace2 "$@" &&
+ test_region ! index ensure_full_index trace2.txt
}
- test_expect_success 'sparse-index is not expanded' '
@@ t/t1092-sparse-checkout-compatibility.sh: test_expect_success 'diff-files with pathspec outside sparse definition' '
- test_all_match git diff-files "folder*/a"
+ test_all_match git diff-files "folder*/a"
'
+test_expect_success 'sparse index is not expanded: diff-files' '
--
2.39.0