test: use --numstat instead of --stat in "git stash show" tests
git's diff --stat output is intended for human consumption and since v1.7.9.2~13 (2012-02-01) varies by locale. Add a test checking that git stash show defaults to --stat and tweak the rest of the "stash show" tests that showed a diffstat to use numstat. This way, there are fewer tests to tweak if the diffstat format changes again. This also improves test coverage when running tests with git configured not to write its output in the C locale (e.g., via GETTEXT_POISON=Yes). Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Jonathan Nieder committed
Mar 13, 2012 at 00:01 UTC
1145211456580530ab01ef713adae4812d5758b2
1 file changed
+19
-7
t/t3903-stash.sh
+19
-7
@@ -432,7 +432,7 @@ test_expect_success 'stash branch - stashes on stack, stash-like argument' '
432
test $(git ls-files --modified | wc -l) -eq 1
433
'
434
435
-test_expect_success 'stash show - stashes on stack, stash-like argument' '
435
+test_expect_success 'stash show format defaults to --stat' '
436
git stash clear &&
437
test_when_finished "git reset --hard HEAD" &&
438
git reset --hard &&
@@ -450,6 +450,21 @@ test_expect_success 'stash show - stashes on stack, stash-like argument' '
450
test_i18ncmp expected actual
451
'
452
453
+test_expect_success 'stash show - stashes on stack, stash-like argument' '
454
+ git stash clear &&
455
+ test_when_finished "git reset --hard HEAD" &&
456
+ git reset --hard &&
457
+ echo foo >> file &&
458
+ git stash &&
459
+ test_when_finished "git stash drop" &&
460
+ echo bar >> file &&
461
+ STASH_ID=$(git stash create) &&
462
+ git reset --hard &&
463
+ echo "1 0 file" >expected &&
464
+ git stash show --numstat ${STASH_ID} >actual &&
465
+ test_cmp expected actual
466
+'
467
+
468
test_expect_success 'stash show -p - stashes on stack, stash-like argument' '
469
git stash clear &&
470
test_when_finished "git reset --hard HEAD" &&
@@ -480,12 +495,9 @@ test_expect_success 'stash show - no stashes on stack, stash-like argument' '
495
echo foo >> file &&
496
STASH_ID=$(git stash create) &&
497
git reset --hard &&
483
- cat >expected <<-EOF &&
484
- file | 1 +
485
- 1 file changed, 1 insertion(+)
486
- EOF
487
- git stash show ${STASH_ID} >actual &&
488
- test_i18ncmp expected actual
498
+ echo "1 0 file" >expected &&
499
+ git stash show --numstat ${STASH_ID} >actual &&
500
+ test_cmp expected actual
501
'
502
503
test_expect_success 'stash show -p - no stashes on stack, stash-like argument' '