Skip to content

Commit 46fab37

Browse files
committed
stash: integrate with sparse index
Most of the functionality of `git stash` exists in already-sparse aware subcommands, so enabling sparse index in `cmd_stash` allows the index to remain sparse in most usages of `git stash`. Tests added to `t1092` reflect commonly-used commands that are already sparse index-compatible. Signed-off-by: Victoria Dye <[email protected]>
1 parent 4f5cb33 commit 46fab37

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

builtin/stash.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1703,6 +1703,9 @@ int cmd_stash(int argc, const char **argv, const char *prefix)
17031703
argc = parse_options(argc, argv, prefix, options, git_stash_usage,
17041704
PARSE_OPT_KEEP_UNKNOWN | PARSE_OPT_KEEP_DASHDASH);
17051705

1706+
prepare_repo_settings(the_repository);
1707+
the_repository->settings.command_requires_full_index = 0;
1708+
17061709
index_file = get_index_file();
17071710
strbuf_addf(&stash_index_path, "%s.stash.%" PRIuMAX, index_file,
17081711
(uintmax_t)pid);

t/t1092-sparse-checkout-compatibility.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1159,6 +1159,16 @@ test_expect_success 'sparse-index is not expanded' '
11591159
echo >>sparse-index/untracked.txt &&
11601160
ensure_not_expanded add . &&
11611161
1162+
echo >>sparse-index/a &&
1163+
ensure_not_expanded stash &&
1164+
ensure_not_expanded stash list &&
1165+
ensure_not_expanded stash show stash@{0} &&
1166+
ensure_not_expanded stash drop stash@{0} &&
1167+
1168+
ensure_not_expanded stash create &&
1169+
oid=$(git -C sparse-index stash create) &&
1170+
ensure_not_expanded stash store -m "test" $oid &&
1171+
ensure_not_expanded reset --hard &&
11621172
ensure_not_expanded checkout-index -f a &&
11631173
ensure_not_expanded checkout-index -f --all &&
11641174
for ref in update-deep update-folder1 update-folder2 update-deep

0 commit comments

Comments
 (0)