X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=t%2Ft3903-stash.sh;h=903a122efe0c54cb44eb6c3e7ed04bdbab81439d;hb=5c28a8b054cb69a37638b0261fc370422c8fab58;hp=a283dca25fe9b5d75841626337e0e68244fdbbf2;hpb=e3f213c7aff9e09b3bde7253a0a922467dd13671;p=git.git diff --git a/t/t3903-stash.sh b/t/t3903-stash.sh index a283dca25..903a122ef 100755 --- a/t/t3903-stash.sh +++ b/t/t3903-stash.sh @@ -416,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" && @@ -425,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' ' @@ -491,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