Skip to content

Commit 1145211

Browse files
jrngitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 2593633 commit 1145211

File tree

1 file changed

+19
-7
lines changed

1 file changed

+19
-7
lines changed

t/t3903-stash.sh

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,7 @@ test_expect_success 'stash branch - stashes on stack, stash-like argument' '
432432
test $(git ls-files --modified | wc -l) -eq 1
433433
'
434434

435-
test_expect_success 'stash show - stashes on stack, stash-like argument' '
435+
test_expect_success 'stash show format defaults to --stat' '
436436
git stash clear &&
437437
test_when_finished "git reset --hard HEAD" &&
438438
git reset --hard &&
@@ -450,6 +450,21 @@ test_expect_success 'stash show - stashes on stack, stash-like argument' '
450450
test_i18ncmp expected actual
451451
'
452452

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+
453468
test_expect_success 'stash show -p - stashes on stack, stash-like argument' '
454469
git stash clear &&
455470
test_when_finished "git reset --hard HEAD" &&
@@ -480,12 +495,9 @@ test_expect_success 'stash show - no stashes on stack, stash-like argument' '
480495
echo foo >> file &&
481496
STASH_ID=$(git stash create) &&
482497
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
489501
'
490502

491503
test_expect_success 'stash show -p - no stashes on stack, stash-like argument' '

0 commit comments

Comments
 (0)