X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=t%2Ft3903-stash.sh;h=903a122efe0c54cb44eb6c3e7ed04bdbab81439d;hb=f7bff60de95951d2c82601350cb3771b347e83ee;hp=d99f27a12f40d73094ef286a067f3c6771e61865;hpb=5879b6bbcaba7696e4abfa717748da166f915405;p=git.git diff --git a/t/t3903-stash.sh b/t/t3903-stash.sh index d99f27a12..903a122ef 100755 --- a/t/t3903-stash.sh +++ b/t/t3903-stash.sh @@ -69,9 +69,10 @@ test_expect_success 'apply stashed changes (including index)' ' test_expect_success 'unstashing in a subdirectory' ' git reset --hard HEAD && mkdir subdir && - cd subdir && - git stash apply && - cd .. + ( + cd subdir && + git stash apply + ) ' test_expect_success 'drop top stash' ' @@ -415,8 +416,37 @@ test_expect_success 'stash show - stashes on stack, stash-like argument' ' echo bar >> file && STASH_ID=$(git stash create) && git reset --hard && - git stash show ${STASH_ID} + cat >expected <<-EOF && + file | 1 + + 1 files changed, 1 insertions(+), 0 deletions(-) + EOF + git stash show ${STASH_ID} >actual && + test_cmp expected actual +' + +test_expect_success 'stash show -p - stashes on stack, stash-like argument' ' + git stash clear && + test_when_finished "git reset --hard HEAD" && + git reset --hard && + echo foo >> file && + git stash && + test_when_finished "git stash drop" && + echo bar >> file && + STASH_ID=$(git stash create) && + git reset --hard && + cat >expected <<-EOF && + diff --git a/file b/file + index 7601807..935fbd3 100644 + --- a/file + +++ b/file + @@ -1 +1,2 @@ + baz + +bar + EOF + git stash show -p ${STASH_ID} >actual && + test_cmp expected actual ' + test_expect_success 'stash show - no stashes on stack, stash-like argument' ' git stash clear && test_when_finished "git reset --hard HEAD" && @@ -424,7 +454,32 @@ test_expect_success 'stash show - no stashes on stack, stash-like argument' ' echo foo >> file && STASH_ID=$(git stash create) && git reset --hard && - git stash show ${STASH_ID} + cat >expected <<-EOF && + file | 1 + + 1 files changed, 1 insertions(+), 0 deletions(-) + EOF + git stash show ${STASH_ID} >actual && + test_cmp expected actual +' + +test_expect_success 'stash show -p - no stashes on stack, stash-like argument' ' + git stash clear && + test_when_finished "git reset --hard HEAD" && + git reset --hard && + echo foo >> file && + STASH_ID=$(git stash create) && + git reset --hard && + cat >expected <<-EOF && + diff --git a/file b/file + index 7601807..71b52c4 100644 + --- a/file + +++ b/file + @@ -1 +1,2 @@ + baz + +foo + EOF + git stash show -p ${STASH_ID} >actual && + test_cmp expected actual ' test_expect_success 'stash drop - fail early if specified stash is not a stash reference' ' @@ -490,4 +545,15 @@ test_expect_success 'invalid ref of the form stash@{n}, n >= N' ' git stash drop ' +test_expect_success 'stash branch should not drop the stash if the branch exists' ' + git stash clear && + echo foo >file && + git add file && + git commit -m initial && + echo bar >file && + git stash && + test_must_fail git stash branch master stash@{0} && + git rev-parse stash@{0} -- +' + test_done