Skip to content

Commit 104dde9

Browse files
vdyedscho
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 <vdye@github.com>
1 parent 4b06059 commit 104dde9

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

t/t1092-sparse-checkout-compatibility.sh

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1766,6 +1766,46 @@ test_expect_success 'sparse index is not expanded: sparse-checkout' '
17661766
ensure_not_expanded sparse-checkout set
17671767
'
17681768

1769+
# NEEDSWORK: although the full repository's index is _not_ expanded as part of
1770+
# stash, a temporary index, which is _not_ sparse, is created when stashing and
1771+
# applying a stash of untracked files. As a result, the test reports that it
1772+
# finds an instance of `ensure_full_index`, but it does not carry with it the
1773+
# performance implications of expanding the full repository index.
1774+
test_expect_success 'sparse index is not expanded: stash -u' '
1775+
init_repos &&
1776+
1777+
mkdir -p sparse-index/folder1 &&
1778+
echo >>sparse-index/README.md &&
1779+
echo >>sparse-index/a &&
1780+
echo >>sparse-index/folder1/new &&
1781+
1782+
GIT_TRACE2_EVENT="$(pwd)/trace2.txt" GIT_TRACE2_EVENT_NESTING=10 \
1783+
git -C sparse-index stash -u &&
1784+
test_region index ensure_full_index trace2.txt &&
1785+
1786+
GIT_TRACE2_EVENT="$(pwd)/trace2.txt" GIT_TRACE2_EVENT_NESTING=10 \
1787+
git -C sparse-index stash pop &&
1788+
test_region index ensure_full_index trace2.txt
1789+
'
1790+
1791+
# NEEDSWORK: similar to `git add`, untracked files outside of the sparse
1792+
# checkout definition are successfully stashed and unstashed.
1793+
test_expect_success 'stash -u outside sparse checkout definition' '
1794+
init_repos &&
1795+
1796+
write_script edit-contents <<-\EOF &&
1797+
echo text >>$1
1798+
EOF
1799+
1800+
run_on_sparse mkdir -p folder1 &&
1801+
run_on_all ../edit-contents folder1/new &&
1802+
test_all_match git stash -u &&
1803+
test_all_match git status --porcelain=v2 &&
1804+
1805+
test_all_match git stash pop -q &&
1806+
test_all_match git status --porcelain=v2
1807+
'
1808+
17691809
# NEEDSWORK: a sparse-checkout behaves differently from a full checkout
17701810
# in this scenario, but it shouldn't.
17711811
test_expect_success 'reset mixed and checkout orphan' '

0 commit comments

Comments
 (0)