Skip to content

Commit 2c8615f

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 1539785 commit 2c8615f

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
@@ -1924,6 +1924,46 @@ test_expect_success 'sparse index is not expanded: sparse-checkout' '
19241924
ensure_not_expanded sparse-checkout set
19251925
'
19261926

1927+
# NEEDSWORK: although the full repository's index is _not_ expanded as part of
1928+
# stash, a temporary index, which is _not_ sparse, is created when stashing and
1929+
# applying a stash of untracked files. As a result, the test reports that it
1930+
# finds an instance of `ensure_full_index`, but it does not carry with it the
1931+
# performance implications of expanding the full repository index.
1932+
test_expect_success 'sparse index is not expanded: stash -u' '
1933+
init_repos &&
1934+
1935+
mkdir -p sparse-index/folder1 &&
1936+
echo >>sparse-index/README.md &&
1937+
echo >>sparse-index/a &&
1938+
echo >>sparse-index/folder1/new &&
1939+
1940+
GIT_TRACE2_EVENT="$(pwd)/trace2.txt" GIT_TRACE2_EVENT_NESTING=10 \
1941+
git -C sparse-index stash -u &&
1942+
test_region index ensure_full_index trace2.txt &&
1943+
1944+
GIT_TRACE2_EVENT="$(pwd)/trace2.txt" GIT_TRACE2_EVENT_NESTING=10 \
1945+
git -C sparse-index stash pop &&
1946+
test_region index ensure_full_index trace2.txt
1947+
'
1948+
1949+
# NEEDSWORK: similar to `git add`, untracked files outside of the sparse
1950+
# checkout definition are successfully stashed and unstashed.
1951+
test_expect_success 'stash -u outside sparse checkout definition' '
1952+
init_repos &&
1953+
1954+
write_script edit-contents <<-\EOF &&
1955+
echo text >>$1
1956+
EOF
1957+
1958+
run_on_sparse mkdir -p folder1 &&
1959+
run_on_all ../edit-contents folder1/new &&
1960+
test_all_match git stash -u &&
1961+
test_all_match git status --porcelain=v2 &&
1962+
1963+
test_all_match git stash pop -q &&
1964+
test_all_match git status --porcelain=v2
1965+
'
1966+
19271967
# NEEDSWORK: a sparse-checkout behaves differently from a full checkout
19281968
# in this scenario, but it shouldn't.
19291969
test_expect_success 'reset mixed and checkout orphan' '

0 commit comments

Comments
 (0)