Skip to content

Commit 0752000

Browse files
committed
Merge branch 'jk/stash-loosen-safety' into maint
* jk/stash-loosen-safety: stash: drop dirty worktree check on apply
2 parents 391b493 + e0e2a9c commit 0752000

File tree

2 files changed

+17
-7
lines changed

2 files changed

+17
-7
lines changed

git-stash.sh

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -344,9 +344,7 @@ apply_stash () {
344344

345345
assert_stash_like "$@"
346346

347-
git update-index -q --refresh &&
348-
git diff-files --quiet --ignore-submodules ||
349-
die 'Cannot apply to a dirty working tree, please stage your changes'
347+
git update-index -q --refresh || die 'unable to refresh index'
350348

351349
# current index state
352350
c_tree=$(git write-tree) ||

t/t3903-stash.sh

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,26 @@ test_expect_success 'parents of stash' '
3737
test_cmp output expect
3838
'
3939

40-
test_expect_success 'apply needs clean working directory' '
41-
echo 4 > other-file &&
40+
test_expect_success 'apply does not need clean working directory' '
41+
echo 4 >other-file &&
4242
git add other-file &&
43-
echo 5 > other-file &&
44-
test_must_fail git stash apply
43+
echo 5 >other-file &&
44+
git stash apply &&
45+
echo 3 >expect &&
46+
test_cmp expect file
47+
'
48+
49+
test_expect_success 'apply does not clobber working directory changes' '
50+
git reset --hard &&
51+
echo 4 >file &&
52+
test_must_fail git stash apply &&
53+
echo 4 >expect &&
54+
test_cmp expect file
4555
'
4656

4757
test_expect_success 'apply stashed changes' '
58+
git reset --hard &&
59+
echo 5 >other-file &&
4860
git add other-file &&
4961
test_tick &&
5062
git commit -m other-file &&

0 commit comments

Comments
 (0)