Skip to content

Commit 11fd53a

Browse files
committed
Merge branch 'ds/sparse-diff-index'
The underlying machinery for "git diff-index" has long been made to expand the sparse index as needed, but the command fully expanded the sparse index upfront, which now has been taught not to do. * ds/sparse-diff-index: diff-index: integrate with the sparse index
2 parents 839b808 + b44c926 commit 11fd53a

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

builtin/diff-index.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ int cmd_diff_index(int argc, const char **argv, const char *prefix)
2525
usage(diff_cache_usage);
2626

2727
git_config(git_diff_basic_config, NULL); /* no "diff" UI options */
28+
29+
prepare_repo_settings(the_repository);
30+
the_repository->settings.command_requires_full_index = 0;
31+
2832
repo_init_revisions(the_repository, &rev, prefix);
2933
rev.abbrev = 0;
3034
prefix = precompose_argv_prefix(argc, argv, prefix);

t/t1092-sparse-checkout-compatibility.sh

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -803,6 +803,8 @@ test_expect_success 'update-index --remove outside sparse definition' '
803803
test_sparse_match git diff --cached --name-status &&
804804
test_cmp expect sparse-checkout-out &&
805805
806+
test_sparse_match git diff-index --cached HEAD &&
807+
806808
# Reset the state
807809
test_all_match git reset --hard &&
808810
@@ -812,6 +814,8 @@ test_expect_success 'update-index --remove outside sparse definition' '
812814
test_sparse_match git diff --cached --name-status &&
813815
test_must_be_empty sparse-checkout-out &&
814816
817+
test_sparse_match git diff-index --cached HEAD &&
818+
815819
# Reset the state
816820
test_all_match git reset --hard &&
817821
@@ -823,7 +827,9 @@ test_expect_success 'update-index --remove outside sparse definition' '
823827
D folder1/a
824828
EOF
825829
test_sparse_match git diff --cached --name-status &&
826-
test_cmp expect sparse-checkout-out
830+
test_cmp expect sparse-checkout-out &&
831+
832+
test_sparse_match git diff-index --cached HEAD
827833
'
828834

829835
test_expect_success 'update-index with directories' '
@@ -1551,7 +1557,7 @@ test_expect_success 'sparse-index is not expanded: describe' '
15511557
ensure_not_expanded describe
15521558
'
15531559

1554-
test_expect_success 'sparse index is not expanded: diff' '
1560+
test_expect_success 'sparse index is not expanded: diff and diff-index' '
15551561
init_repos &&
15561562
15571563
write_script edit-contents <<-\EOF &&
@@ -1568,6 +1574,7 @@ test_expect_success 'sparse index is not expanded: diff' '
15681574
test_all_match git diff --cached &&
15691575
ensure_not_expanded diff &&
15701576
ensure_not_expanded diff --cached &&
1577+
ensure_not_expanded diff-index --cached HEAD &&
15711578
15721579
# Add file outside cone
15731580
test_all_match git reset --hard &&
@@ -1582,6 +1589,7 @@ test_expect_success 'sparse index is not expanded: diff' '
15821589
test_all_match git diff --cached &&
15831590
ensure_not_expanded diff &&
15841591
ensure_not_expanded diff --cached &&
1592+
ensure_not_expanded diff-index --cached HEAD &&
15851593
15861594
# Merge conflict outside cone
15871595
# The sparse checkout will report a warning that is not in the
@@ -1594,7 +1602,8 @@ test_expect_success 'sparse index is not expanded: diff' '
15941602
test_all_match git diff &&
15951603
test_all_match git diff --cached &&
15961604
ensure_not_expanded diff &&
1597-
ensure_not_expanded diff --cached
1605+
ensure_not_expanded diff --cached &&
1606+
ensure_not_expanded diff-index --cached HEAD
15981607
'
15991608

16001609
test_expect_success 'sparse index is not expanded: show and rev-parse' '

0 commit comments

Comments
 (0)