mirror of
https://github.com/git/git
synced 2024-08-25 02:35:46 +00:00
![Jeff King](/assets/img/avatar_default.png)
If we try to parse an integer config argument and get a number outside of the representable range, we die with the cryptic message: "bad config value for '%s'". We can improve two things: 1. Show the value that produced the error (e.g., bad config value '3g' for 'foo.bar'). 2. Mention the reason the value was rejected (e.g., "invalid unit" versus "out of range"). A few tests need to be updated with the new output, but that should not be representative of real-world breakage, as scripts should not be depending on the exact text of our stderr output, which is subject to i18n anyway. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
93 lines
1.7 KiB
Bash
Executable file
93 lines
1.7 KiB
Bash
Executable file
#!/bin/sh
|
|
#
|
|
# Copyright (c) 2012 Mozilla Foundation
|
|
#
|
|
|
|
test_description='diff.context configuration'
|
|
|
|
. ./test-lib.sh
|
|
|
|
test_expect_success 'setup' '
|
|
cat >template <<-\EOF &&
|
|
firstline
|
|
b
|
|
c
|
|
d
|
|
e
|
|
f
|
|
preline
|
|
TARGET
|
|
postline
|
|
i
|
|
j
|
|
k
|
|
l
|
|
m
|
|
n
|
|
EOF
|
|
sed "/TARGET/d" >x <template &&
|
|
git update-index --add x &&
|
|
git commit -m initial &&
|
|
|
|
sed "s/TARGET/ADDED/" >x <template &&
|
|
git update-index --add x &&
|
|
git commit -m next &&
|
|
|
|
sed "s/TARGET/MODIFIED/" >x <template
|
|
'
|
|
|
|
test_expect_success 'the default number of context lines is 3' '
|
|
git diff >output &&
|
|
! grep "^ d" output &&
|
|
grep "^ e" output &&
|
|
grep "^ j" output &&
|
|
! grep "^ k" output
|
|
'
|
|
|
|
test_expect_success 'diff.context honored by "log"' '
|
|
git log -1 -p >output &&
|
|
! grep firstline output &&
|
|
git config diff.context 8 &&
|
|
git log -1 -p >output &&
|
|
grep "^ firstline" output
|
|
'
|
|
|
|
test_expect_success 'The -U option overrides diff.context' '
|
|
git config diff.context 8 &&
|
|
git log -U4 -1 >output &&
|
|
! grep "^ firstline" output
|
|
'
|
|
|
|
test_expect_success 'diff.context honored by "diff"' '
|
|
git config diff.context 8 &&
|
|
git diff >output &&
|
|
grep "^ firstline" output
|
|
'
|
|
|
|
test_expect_success 'plumbing not affected' '
|
|
git config diff.context 8 &&
|
|
git diff-files -p >output &&
|
|
! grep "^ firstline" output
|
|
'
|
|
|
|
test_expect_success 'non-integer config parsing' '
|
|
git config diff.context no &&
|
|
test_must_fail git diff 2>output &&
|
|
test_i18ngrep "bad numeric config value" output
|
|
'
|
|
|
|
test_expect_success 'negative integer config parsing' '
|
|
git config diff.context -1 &&
|
|
test_must_fail git diff 2>output &&
|
|
test_i18ngrep "bad config file" output
|
|
'
|
|
|
|
test_expect_success '-U0 is valid, so is diff.context=0' '
|
|
git config diff.context 0 &&
|
|
git diff >output &&
|
|
grep "^-ADDED" output &&
|
|
grep "^+MODIFIED" output
|
|
'
|
|
|
|
test_done
|