Skip to content

Commit faa72e4

Browse files
vdyeldennington
authored andcommitted
stash: expand testing for git stash -u
Test cases specific to handling untracked files in `git stash` a) ensure that files outside the sparse checkout definition are handled as-expected and b) document the index expansion inside of `git stash -u`. Note that, in b), it is not the full repository index that is expanded - it is the temporary, standalone index containing the stashed untracked files only. Signed-off-by: Victoria Dye <[email protected]>
1 parent 57582c2 commit faa72e4

File tree

2 files changed

+41
-0
lines changed

2 files changed

+41
-0
lines changed

t/perf/p2000-sparse-operations.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ test_perf_on_all () {
107107

108108
test_perf_on_all git status
109109
test_perf_on_all 'git stash && git stash pop'
110+
test_perf_on_all 'echo >>new && git stash -u && git stash pop'
110111
test_perf_on_all git add -A
111112
test_perf_on_all git add .
112113
test_perf_on_all git commit -a -m A

t/t1092-sparse-checkout-compatibility.sh

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1557,6 +1557,46 @@ test_expect_success 'sparse index is not expanded: read-tree' '
15571557
ensure_not_expanded read-tree --prefix=deep/deeper2 -u deepest
15581558
'
15591559

1560+
# NEEDSWORK: although the full repository's index is _not_ expanded as part of
1561+
# stash, a temporary index, which is _not_ sparse, is created when stashing and
1562+
# applying a stash of untracked files. As a result, the test reports that it
1563+
# finds an instance of `ensure_full_index`, but it does not carry with it the
1564+
# performance implications of expanding the full repository index.
1565+
test_expect_success 'sparse index is not expanded: stash -u' '
1566+
init_repos &&
1567+
1568+
mkdir -p sparse-index/folder1 &&
1569+
echo >>sparse-index/README.md &&
1570+
echo >>sparse-index/a &&
1571+
echo >>sparse-index/folder1/new &&
1572+
1573+
GIT_TRACE2_EVENT="$(pwd)/trace2.txt" GIT_TRACE2_EVENT_NESTING=10 \
1574+
git -C sparse-index stash -u &&
1575+
test_region index ensure_full_index trace2.txt &&
1576+
1577+
GIT_TRACE2_EVENT="$(pwd)/trace2.txt" GIT_TRACE2_EVENT_NESTING=10 \
1578+
git -C sparse-index stash pop &&
1579+
test_region index ensure_full_index trace2.txt
1580+
'
1581+
1582+
# NEEDSWORK: similar to `git add`, untracked files outside of the sparse
1583+
# checkout definition are successfully stashed and unstashed.
1584+
test_expect_success 'stash -u outside sparse checkout definition' '
1585+
init_repos &&
1586+
1587+
write_script edit-contents <<-\EOF &&
1588+
echo text >>$1
1589+
EOF
1590+
1591+
run_on_sparse mkdir -p folder1 &&
1592+
run_on_all ../edit-contents folder1/new &&
1593+
test_all_match git stash -u &&
1594+
test_all_match git status --porcelain=v2 &&
1595+
1596+
test_all_match git stash pop -q &&
1597+
test_all_match git status --porcelain=v2
1598+
'
1599+
15601600
# NEEDSWORK: a sparse-checkout behaves differently from a full checkout
15611601
# in this scenario, but it shouldn't.
15621602
test_expect_success 'reset mixed and checkout orphan' '

0 commit comments

Comments
 (0)