@matheusbsbs / matheus-bagliano / commits / 3fcb88785d
Fork 0

t/t3903-stash: improve testing of git-stash show

Recently, the 'stash show' functionality was broken for the case when a stash-like argument was supplied. Since, commit 9bf09e, 'stash show' when supplied a stash-like argument prints nothing and still exists with a zero status. Unfortunately, the flaw slipped through the test suite cracks since the output of 'stash show' was not verified to be correct. Improve and expand on the existing tests so that this flaws is detected. Signed-off-by: Brandon Casey <casey@nrlssc.navy.mil> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Brandon Casey committed Sep 24, 2010 at 15:40 UTC 3fcb88785da831ad7d53cf18b4398099179c9c87
1 file changed +58 -4
t/t3903-stash.sh
+58 -4
@@ -406,7 +406,7 @@ test_expect_success 'stash branch - stashes on stack, stash-like argument' '
406 test $(git ls-files --modified | wc -l) -eq 1
407 '
408
409 -test_expect_success 'stash show - stashes on stack, stash-like argument' '
409 +test_expect_failure 'stash show - stashes on stack, stash-like argument' '
410 git stash clear &&
411 test_when_finished "git reset --hard HEAD" &&
412 git reset --hard &&
@@ -416,16 +416,70 @@ test_expect_success 'stash show - stashes on stack, stash-like argument' '
416 echo bar >> file &&
417 STASH_ID=$(git stash create) &&
418 git reset --hard &&
419 - git stash show ${STASH_ID}
419 + cat >expected <<-EOF &&
420 + file | 1 +
421 + 1 files changed, 1 insertions(+), 0 deletions(-)
422 + EOF
423 + git stash show ${STASH_ID} >actual &&
424 + test_cmp expected actual
425 '
421 -test_expect_success 'stash show - no stashes on stack, stash-like argument' '
426 +
427 +test_expect_failure 'stash show -p - stashes on stack, stash-like argument' '
428 + git stash clear &&
429 + test_when_finished "git reset --hard HEAD" &&
430 + git reset --hard &&
431 + echo foo >> file &&
432 + git stash &&
433 + test_when_finished "git stash drop" &&
434 + echo bar >> file &&
435 + STASH_ID=$(git stash create) &&
436 + git reset --hard &&
437 + cat >expected <<-EOF &&
438 + diff --git a/file b/file
439 + index 7601807..935fbd3 100644
440 + --- a/file
441 + +++ b/file
442 + @@ -1 +1,2 @@
443 + baz
444 + +bar
445 + EOF
446 + git stash show -p ${STASH_ID} >actual &&
447 + test_cmp expected actual
448 +'
449 +
450 +test_expect_failure 'stash show - no stashes on stack, stash-like argument' '
451 + git stash clear &&
452 + test_when_finished "git reset --hard HEAD" &&
453 + git reset --hard &&
454 + echo foo >> file &&
455 + STASH_ID=$(git stash create) &&
456 + git reset --hard &&
457 + cat >expected <<-EOF &&
458 + file | 1 +
459 + 1 files changed, 1 insertions(+), 0 deletions(-)
460 + EOF
461 + git stash show ${STASH_ID} >actual &&
462 + test_cmp expected actual
463 +'
464 +
465 +test_expect_failure 'stash show -p - no stashes on stack, stash-like argument' '
466 git stash clear &&
467 test_when_finished "git reset --hard HEAD" &&
468 git reset --hard &&
469 echo foo >> file &&
470 STASH_ID=$(git stash create) &&
471 git reset --hard &&
428 - git stash show ${STASH_ID}
472 + cat >expected <<-EOF &&
473 + diff --git a/file b/file
474 + index 7601807..71b52c4 100644
475 + --- a/file
476 + +++ b/file
477 + @@ -1 +1,2 @@
478 + baz
479 + +foo
480 + EOF
481 + git stash show -p ${STASH_ID} >actual &&
482 + test_cmp expected actual
483 '
484
485 test_expect_success 'stash drop - fail early if specified stash is not a stash reference' '