Skip to content

Commit 42feafe

Browse files
derrickstoleedscho
authored andcommitted
Merge branch 'sparse-index/merge' into vfs-2.33.0
Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
2 parents 456ffe9 + 9b281f4 commit 42feafe

File tree

4 files changed

+25
-1
lines changed

4 files changed

+25
-1
lines changed

Documentation/config/index.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
index.deleteSparseDirectories::
2+
When enabled, the cone mode sparse-checkout feature will delete
3+
directories that are outside of the sparse-checkout cone, unless
4+
such a directory contains an untracked, non-ignored file. Defaults
5+
to true.
6+
17
index.recordEndOfIndexEntries::
28
Specifies whether the index file should include an "End Of Index
39
Entry" section. This reduces index load time on multiprocessor

builtin/sparse-checkout.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ static int sparse_checkout_list(int argc, const char **argv, const char *prefix)
106106

107107
static void clean_tracked_sparse_directories(struct repository *r)
108108
{
109-
int i, was_full = 0;
109+
int i, value, was_full = 0;
110110
struct strbuf path = STRBUF_INIT;
111111
size_t pathlen;
112112
struct string_list_item *item;
@@ -122,6 +122,13 @@ static void clean_tracked_sparse_directories(struct repository *r)
122122
!r->index->sparse_checkout_patterns->use_cone_patterns)
123123
return;
124124

125+
/*
126+
* Users can disable this behavior.
127+
*/
128+
if (!repo_config_get_bool(r, "index.deletesparsedirectories", &value) &&
129+
!value)
130+
return;
131+
125132
/*
126133
* Use the sparse index as a data structure to assist finding
127134
* directories that are safe to delete. This conversion to a

diff.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3922,6 +3922,13 @@ static int reuse_worktree_file(struct index_state *istate,
39223922
if (!FAST_WORKING_DIRECTORY && !want_file && has_object_pack(oid))
39233923
return 0;
39243924

3925+
/*
3926+
* If this path does not match our sparse-checkout definition,
3927+
* then the file will not be in the working directory.
3928+
*/
3929+
if (!path_in_sparse_checkout(name, istate))
3930+
return 0;
3931+
39253932
/*
39263933
* Similarly, if we'd have to convert the file contents anyway, that
39273934
* makes the optimization not worthwhile.

t/t1091-sparse-checkout-builtin.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -761,6 +761,10 @@ test_expect_success 'cone mode clears ignored subdirectories' '
761761
git -C repo status --porcelain=v2 >out &&
762762
test_must_be_empty out &&
763763
764+
git -C repo -c index.deleteSparseDirectories=false sparse-checkout reapply &&
765+
test_path_is_dir repo/folder1 &&
766+
test_path_is_dir repo/deep/deeper2 &&
767+
764768
git -C repo sparse-checkout reapply &&
765769
test_path_is_missing repo/folder1 &&
766770
test_path_is_missing repo/deep/deeper2 &&

0 commit comments

Comments
 (0)