Skip to content

Commit 7c094c3

Browse files
committed
sparse-index for diff: initial attempt
THIS CHANGE IS NOT IN FINAL FORM AND IS CURRENTLY JUST INTENDED FOR FEEDBACK. To understand the context laid out below I have purposefully included both source and test changes in this initial commit. Based on the feedback I get, I will either split this commit or create an entirely new branch with the necessary changes when it is ready to officially submit. This change enables running the `diff` builtin command without expanding the full index in a cone-mode sparse checkout. It is an attempt to add the basic infrastructure to "light up" sparse index for the command. However, based on some testing, this may need to change. After reviewing #417, I decided to add `ensure_full_index` to this initial commit in an attempt to maintain current behavior. However, as I started building and testing with and without this update, I noticed unexpected results. The `ensure_not_expanded` tests I added are passing with `ensure_full_index` both enabled and disabled. That felt wrong, so I used `TRACE2` to try and understand what was happening and have attached the results. It looks as though no code paths in `diff.c` are actually being used. On the bright side, however, it doesn't look as though `ensure_full_index` is ever being called. I recognize my lack of knowledge wrt `cache-tree` and `read-cache` may be the reason I'm unsure what the correct path forward is. In light of this, any guidance is appreciated.
1 parent a5b4290 commit 7c094c3

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

builtin/diff.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -436,6 +436,9 @@ int cmd_diff(int argc, const char **argv, const char *prefix)
436436
}
437437

438438
prefix = setup_git_directory_gently(&nongit);
439+
440+
prepare_repo_settings(the_repository);
441+
the_repository->settings.command_requires_full_index = 0;
439442

440443
if (!no_index) {
441444
/*

t/t1092-sparse-checkout-compatibility.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -693,6 +693,11 @@ test_expect_success 'sparse-index is not expanded' '
693693
echo >>sparse-index/untracked.txt &&
694694
ensure_not_expanded add . &&
695695
696+
echo "a test change" >> sparse-index/README.md &&
697+
ensure_not_expanded diff &&
698+
git -C sparse-index add README.md &&
699+
ensure_not_expanded diff --staged &&
700+
696701
ensure_not_expanded checkout -f update-deep &&
697702
(
698703
sane_unset GIT_TEST_MERGE_ALGORITHM &&

0 commit comments

Comments
 (0)