Merge branch 'jn/diffstat-tests'
Some tests checked the "diff --stat" output when they do not have to, which unnecessarily made things harder to verify under GETTEXT_POISON. By Jonathan Nieder * jn/diffstat-tests: diffstat summary line varies by locale: miscellany test: use numstat instead of diffstat in binary-diff test test: use --numstat instead of --stat in "git stash show" tests test: test cherry-pick functionality and output separately test: modernize funny-names test style test: use numstat instead of diffstat in funny-names test test: use test_i18ncmp when checking --stat output
This commit is contained in:
commit
09b90fb3c0
@ -15,184 +15,204 @@ p0='no-funny'
|
||||
p1='tabs ," (dq) and spaces'
|
||||
p2='just space'
|
||||
|
||||
cat >"$p0" <<\EOF
|
||||
1. A quick brown fox jumps over the lazy cat, oops dog.
|
||||
2. A quick brown fox jumps over the lazy cat, oops dog.
|
||||
3. A quick brown fox jumps over the lazy cat, oops dog.
|
||||
EOF
|
||||
test_expect_success 'setup' '
|
||||
cat >"$p0" <<-\EOF &&
|
||||
1. A quick brown fox jumps over the lazy cat, oops dog.
|
||||
2. A quick brown fox jumps over the lazy cat, oops dog.
|
||||
3. A quick brown fox jumps over the lazy cat, oops dog.
|
||||
EOF
|
||||
|
||||
cat 2>/dev/null >"$p1" "$p0"
|
||||
echo 'Foo Bar Baz' >"$p2"
|
||||
{ cat "$p0" >"$p1" || :; } &&
|
||||
{ echo "Foo Bar Baz" >"$p2" || :; } &&
|
||||
|
||||
if test -f "$p1" && cmp "$p0" "$p1"
|
||||
if test -f "$p1" && cmp "$p0" "$p1"
|
||||
then
|
||||
test_set_prereq TABS_IN_FILENAMES
|
||||
fi
|
||||
'
|
||||
|
||||
if ! test_have_prereq TABS_IN_FILENAMES
|
||||
then
|
||||
test_set_prereq TABS_IN_FILENAMES
|
||||
else
|
||||
# since FAT/NTFS does not allow tabs in filenames, skip this test
|
||||
say 'Your filesystem does not allow tabs in filenames'
|
||||
skip_all='Your filesystem does not allow tabs in filenames'
|
||||
test_done
|
||||
fi
|
||||
|
||||
test_expect_success TABS_IN_FILENAMES 'setup expect' "
|
||||
echo 'just space
|
||||
no-funny' >expected
|
||||
"
|
||||
test_expect_success 'setup: populate index and tree' '
|
||||
git update-index --add "$p0" "$p2" &&
|
||||
t0=$(git write-tree)
|
||||
'
|
||||
|
||||
test_expect_success TABS_IN_FILENAMES 'git ls-files no-funny' \
|
||||
'git update-index --add "$p0" "$p2" &&
|
||||
test_expect_success 'ls-files prints space in filename verbatim' '
|
||||
printf "%s\n" "just space" no-funny >expected &&
|
||||
git ls-files >current &&
|
||||
test_cmp expected current'
|
||||
|
||||
test_expect_success TABS_IN_FILENAMES 'setup expect' '
|
||||
t0=`git write-tree` &&
|
||||
echo "$t0" >t0 &&
|
||||
|
||||
cat > expected <<\EOF
|
||||
just space
|
||||
no-funny
|
||||
"tabs\t,\" (dq) and spaces"
|
||||
EOF
|
||||
test_cmp expected current
|
||||
'
|
||||
|
||||
test_expect_success TABS_IN_FILENAMES 'git ls-files with-funny' \
|
||||
'git update-index --add "$p1" &&
|
||||
test_expect_success 'setup: add funny filename' '
|
||||
git update-index --add "$p1" &&
|
||||
t1=$(git write-tree)
|
||||
'
|
||||
|
||||
test_expect_success 'ls-files quotes funny filename' '
|
||||
cat >expected <<-\EOF &&
|
||||
just space
|
||||
no-funny
|
||||
"tabs\t,\" (dq) and spaces"
|
||||
EOF
|
||||
git ls-files >current &&
|
||||
test_cmp expected current'
|
||||
|
||||
test_expect_success TABS_IN_FILENAMES 'setup expect' "
|
||||
echo 'just space
|
||||
no-funny
|
||||
tabs ,\" (dq) and spaces' >expected
|
||||
"
|
||||
|
||||
test_expect_success TABS_IN_FILENAMES 'git ls-files -z with-funny' \
|
||||
'git ls-files -z | perl -pe y/\\000/\\012/ >current &&
|
||||
test_cmp expected current'
|
||||
|
||||
test_expect_success TABS_IN_FILENAMES 'setup expect' '
|
||||
t1=`git write-tree` &&
|
||||
echo "$t1" >t1 &&
|
||||
|
||||
cat > expected <<\EOF
|
||||
just space
|
||||
no-funny
|
||||
"tabs\t,\" (dq) and spaces"
|
||||
EOF
|
||||
test_cmp expected current
|
||||
'
|
||||
|
||||
test_expect_success TABS_IN_FILENAMES 'git ls-tree with funny' \
|
||||
'git ls-tree -r $t1 | sed -e "s/^[^ ]* //" >current &&
|
||||
test_cmp expected current'
|
||||
|
||||
test_expect_success TABS_IN_FILENAMES 'setup expect' '
|
||||
cat > expected <<\EOF
|
||||
A "tabs\t,\" (dq) and spaces"
|
||||
EOF
|
||||
test_expect_success 'ls-files -z does not quote funny filename' '
|
||||
cat >expected <<-\EOF &&
|
||||
just space
|
||||
no-funny
|
||||
tabs ," (dq) and spaces
|
||||
EOF
|
||||
git ls-files -z >ls-files.z &&
|
||||
perl -pe "y/\000/\012/" <ls-files.z >current &&
|
||||
test_cmp expected current
|
||||
'
|
||||
|
||||
test_expect_success TABS_IN_FILENAMES 'git diff-index with-funny' \
|
||||
'git diff-index --name-status $t0 >current &&
|
||||
test_cmp expected current'
|
||||
|
||||
test_expect_success TABS_IN_FILENAMES 'git diff-tree with-funny' \
|
||||
'git diff-tree --name-status $t0 $t1 >current &&
|
||||
test_cmp expected current'
|
||||
|
||||
test_expect_success TABS_IN_FILENAMES 'setup expect' "
|
||||
echo 'A
|
||||
tabs ,\" (dq) and spaces' >expected
|
||||
"
|
||||
|
||||
test_expect_success TABS_IN_FILENAMES 'git diff-index -z with-funny' \
|
||||
'git diff-index -z --name-status $t0 | perl -pe y/\\000/\\012/ >current &&
|
||||
test_cmp expected current'
|
||||
|
||||
test_expect_success TABS_IN_FILENAMES 'git diff-tree -z with-funny' \
|
||||
'git diff-tree -z --name-status $t0 $t1 | perl -pe y/\\000/\\012/ >current &&
|
||||
test_cmp expected current'
|
||||
|
||||
test_expect_success TABS_IN_FILENAMES 'setup expect' '
|
||||
cat > expected <<\EOF
|
||||
CNUM no-funny "tabs\t,\" (dq) and spaces"
|
||||
EOF
|
||||
test_expect_success 'ls-tree quotes funny filename' '
|
||||
cat >expected <<-\EOF &&
|
||||
just space
|
||||
no-funny
|
||||
"tabs\t,\" (dq) and spaces"
|
||||
EOF
|
||||
git ls-tree -r $t1 >ls-tree &&
|
||||
sed -e "s/^[^ ]* //" <ls-tree >current &&
|
||||
test_cmp expected current
|
||||
'
|
||||
|
||||
test_expect_success TABS_IN_FILENAMES 'git diff-tree -C with-funny' \
|
||||
'git diff-tree -C --find-copies-harder --name-status \
|
||||
$t0 $t1 | sed -e 's/^C[0-9]*/CNUM/' >current &&
|
||||
test_cmp expected current'
|
||||
|
||||
test_expect_success TABS_IN_FILENAMES 'setup expect' '
|
||||
cat > expected <<\EOF
|
||||
RNUM no-funny "tabs\t,\" (dq) and spaces"
|
||||
EOF
|
||||
test_expect_success 'diff-index --name-status quotes funny filename' '
|
||||
cat >expected <<-\EOF &&
|
||||
A "tabs\t,\" (dq) and spaces"
|
||||
EOF
|
||||
git diff-index --name-status $t0 >current &&
|
||||
test_cmp expected current
|
||||
'
|
||||
|
||||
test_expect_success TABS_IN_FILENAMES 'git diff-tree delete with-funny' \
|
||||
'git update-index --force-remove "$p0" &&
|
||||
git diff-index -M --name-status \
|
||||
$t0 | sed -e 's/^R[0-9]*/RNUM/' >current &&
|
||||
test_cmp expected current'
|
||||
|
||||
test_expect_success TABS_IN_FILENAMES 'setup expect' '
|
||||
cat > expected <<\EOF
|
||||
diff --git a/no-funny "b/tabs\t,\" (dq) and spaces"
|
||||
similarity index NUM%
|
||||
rename from no-funny
|
||||
rename to "tabs\t,\" (dq) and spaces"
|
||||
EOF
|
||||
test_expect_success 'diff-tree --name-status quotes funny filename' '
|
||||
cat >expected <<-\EOF &&
|
||||
A "tabs\t,\" (dq) and spaces"
|
||||
EOF
|
||||
git diff-tree --name-status $t0 $t1 >current &&
|
||||
test_cmp expected current
|
||||
'
|
||||
|
||||
test_expect_success TABS_IN_FILENAMES 'git diff-tree delete with-funny' \
|
||||
'git diff-index -M -p $t0 |
|
||||
sed -e "s/index [0-9]*%/index NUM%/" >current &&
|
||||
test_cmp expected current'
|
||||
|
||||
test_expect_success TABS_IN_FILENAMES 'setup expect' '
|
||||
chmod +x "$p1" &&
|
||||
cat > expected <<\EOF
|
||||
diff --git a/no-funny "b/tabs\t,\" (dq) and spaces"
|
||||
old mode 100644
|
||||
new mode 100755
|
||||
similarity index NUM%
|
||||
rename from no-funny
|
||||
rename to "tabs\t,\" (dq) and spaces"
|
||||
EOF
|
||||
test_expect_success 'diff-index -z does not quote funny filename' '
|
||||
cat >expected <<-\EOF &&
|
||||
A
|
||||
tabs ," (dq) and spaces
|
||||
EOF
|
||||
git diff-index -z --name-status $t0 >diff-index.z &&
|
||||
perl -pe "y/\000/\012/" <diff-index.z >current &&
|
||||
test_cmp expected current
|
||||
'
|
||||
|
||||
test_expect_success TABS_IN_FILENAMES 'git diff-tree delete with-funny' \
|
||||
'git diff-index -M -p $t0 |
|
||||
sed -e "s/index [0-9]*%/index NUM%/" >current &&
|
||||
test_cmp expected current'
|
||||
|
||||
test_expect_success TABS_IN_FILENAMES 'setup expect' '
|
||||
cat >expected <<\EOF
|
||||
"tabs\t,\" (dq) and spaces"
|
||||
1 file changed, 0 insertions(+), 0 deletions(-)
|
||||
EOF
|
||||
test_expect_success 'diff-tree -z does not quote funny filename' '
|
||||
cat >expected <<-\EOF &&
|
||||
A
|
||||
tabs ," (dq) and spaces
|
||||
EOF
|
||||
git diff-tree -z --name-status $t0 $t1 >diff-tree.z &&
|
||||
perl -pe y/\\000/\\012/ <diff-tree.z >current &&
|
||||
test_cmp expected current
|
||||
'
|
||||
|
||||
test_expect_success TABS_IN_FILENAMES 'git diff-tree rename with-funny applied' \
|
||||
'git diff-index -M -p $t0 |
|
||||
git apply --stat | sed -e "s/|.*//" -e "s/ *\$//" >current &&
|
||||
test_cmp expected current'
|
||||
|
||||
test_expect_success TABS_IN_FILENAMES 'setup expect' '
|
||||
cat > expected <<\EOF
|
||||
no-funny
|
||||
"tabs\t,\" (dq) and spaces"
|
||||
2 files changed, 3 insertions(+), 3 deletions(-)
|
||||
EOF
|
||||
test_expect_success 'diff-tree --find-copies-harder quotes funny filename' '
|
||||
cat >expected <<-\EOF &&
|
||||
CNUM no-funny "tabs\t,\" (dq) and spaces"
|
||||
EOF
|
||||
git diff-tree -C --find-copies-harder --name-status $t0 $t1 >out &&
|
||||
sed -e "s/^C[0-9]*/CNUM/" <out >current &&
|
||||
test_cmp expected current
|
||||
'
|
||||
|
||||
test_expect_success TABS_IN_FILENAMES 'git diff-tree delete with-funny applied' \
|
||||
'git diff-index -p $t0 |
|
||||
git apply --stat | sed -e "s/|.*//" -e "s/ *\$//" >current &&
|
||||
test_cmp expected current'
|
||||
test_expect_success 'setup: remove unfunny index entry' '
|
||||
git update-index --force-remove "$p0"
|
||||
'
|
||||
|
||||
test_expect_success TABS_IN_FILENAMES 'git apply non-git diff' \
|
||||
'git diff-index -p $t0 |
|
||||
sed -ne "/^[-+@]/p" |
|
||||
git apply --stat | sed -e "s/|.*//" -e "s/ *\$//" >current &&
|
||||
test_cmp expected current'
|
||||
test_expect_success 'diff-tree -M quotes funny filename' '
|
||||
cat >expected <<-\EOF &&
|
||||
RNUM no-funny "tabs\t,\" (dq) and spaces"
|
||||
EOF
|
||||
git diff-index -M --name-status $t0 >out &&
|
||||
sed -e "s/^R[0-9]*/RNUM/" <out >current &&
|
||||
test_cmp expected current
|
||||
'
|
||||
|
||||
test_expect_success 'diff-index -M -p quotes funny filename' '
|
||||
cat >expected <<-\EOF &&
|
||||
diff --git a/no-funny "b/tabs\t,\" (dq) and spaces"
|
||||
similarity index NUM%
|
||||
rename from no-funny
|
||||
rename to "tabs\t,\" (dq) and spaces"
|
||||
EOF
|
||||
git diff-index -M -p $t0 >diff &&
|
||||
sed -e "s/index [0-9]*%/index NUM%/" <diff >current &&
|
||||
test_cmp expected current
|
||||
'
|
||||
|
||||
test_expect_success 'setup: mode change' '
|
||||
chmod +x "$p1"
|
||||
'
|
||||
|
||||
test_expect_success 'diff-index -M -p with mode change quotes funny filename' '
|
||||
cat >expected <<-\EOF &&
|
||||
diff --git a/no-funny "b/tabs\t,\" (dq) and spaces"
|
||||
old mode 100644
|
||||
new mode 100755
|
||||
similarity index NUM%
|
||||
rename from no-funny
|
||||
rename to "tabs\t,\" (dq) and spaces"
|
||||
EOF
|
||||
git diff-index -M -p $t0 >diff &&
|
||||
sed -e "s/index [0-9]*%/index NUM%/" <diff >current &&
|
||||
test_cmp expected current
|
||||
'
|
||||
|
||||
test_expect_success 'diffstat for rename quotes funny filename' '
|
||||
cat >expected <<-\EOF &&
|
||||
"tabs\t,\" (dq) and spaces"
|
||||
1 file changed, 0 insertions(+), 0 deletions(-)
|
||||
EOF
|
||||
git diff-index -M -p $t0 >diff &&
|
||||
git apply --stat <diff >diffstat &&
|
||||
sed -e "s/|.*//" -e "s/ *\$//" <diffstat >current &&
|
||||
test_i18ncmp expected current
|
||||
'
|
||||
|
||||
test_expect_success 'numstat for rename quotes funny filename' '
|
||||
cat >expected <<-\EOF &&
|
||||
0 0 "tabs\t,\" (dq) and spaces"
|
||||
EOF
|
||||
git diff-index -M -p $t0 >diff &&
|
||||
git apply --numstat <diff >current &&
|
||||
test_cmp expected current
|
||||
'
|
||||
|
||||
test_expect_success 'numstat without -M quotes funny filename' '
|
||||
cat >expected <<-\EOF &&
|
||||
0 3 no-funny
|
||||
3 0 "tabs\t,\" (dq) and spaces"
|
||||
EOF
|
||||
git diff-index -p $t0 >diff &&
|
||||
git apply --numstat <diff >current &&
|
||||
test_cmp expected current
|
||||
'
|
||||
|
||||
test_expect_success 'numstat for non-git rename diff quotes funny filename' '
|
||||
cat >expected <<-\EOF &&
|
||||
0 3 no-funny
|
||||
3 0 "tabs\t,\" (dq) and spaces"
|
||||
EOF
|
||||
git diff-index -p $t0 >git-diff &&
|
||||
sed -ne "/^[-+@]/p" <git-diff >diff &&
|
||||
git apply --numstat <diff >current &&
|
||||
test_cmp expected current
|
||||
'
|
||||
|
||||
test_done
|
||||
|
@ -35,6 +35,16 @@ test_expect_success setup '
|
||||
'
|
||||
|
||||
test_expect_success 'cherry-pick first..fourth works' '
|
||||
git checkout -f master &&
|
||||
git reset --hard first &&
|
||||
test_tick &&
|
||||
git cherry-pick first..fourth &&
|
||||
git diff --quiet other &&
|
||||
git diff --quiet HEAD other &&
|
||||
check_head_differs_from fourth
|
||||
'
|
||||
|
||||
test_expect_success 'output to keep user entertained during multi-pick' '
|
||||
cat <<-\EOF >expected &&
|
||||
[master OBJID] second
|
||||
Author: A U Thor <author@example.com>
|
||||
@ -51,15 +61,22 @@ test_expect_success 'cherry-pick first..fourth works' '
|
||||
git reset --hard first &&
|
||||
test_tick &&
|
||||
git cherry-pick first..fourth >actual &&
|
||||
git diff --quiet other &&
|
||||
git diff --quiet HEAD other &&
|
||||
|
||||
sed -e "s/$_x05[0-9a-f][0-9a-f]/OBJID/" <actual >actual.fuzzy &&
|
||||
test_cmp expected actual.fuzzy &&
|
||||
check_head_differs_from fourth
|
||||
test_line_count -ge 3 actual.fuzzy &&
|
||||
test_i18ncmp expected actual.fuzzy
|
||||
'
|
||||
|
||||
test_expect_success 'cherry-pick --strategy resolve first..fourth works' '
|
||||
git checkout -f master &&
|
||||
git reset --hard first &&
|
||||
test_tick &&
|
||||
git cherry-pick --strategy resolve first..fourth &&
|
||||
git diff --quiet other &&
|
||||
git diff --quiet HEAD other &&
|
||||
check_head_differs_from fourth
|
||||
'
|
||||
|
||||
test_expect_success 'output during multi-pick indicates merge strategy' '
|
||||
cat <<-\EOF >expected &&
|
||||
Trying simple merge.
|
||||
[master OBJID] second
|
||||
@ -79,11 +96,8 @@ test_expect_success 'cherry-pick --strategy resolve first..fourth works' '
|
||||
git reset --hard first &&
|
||||
test_tick &&
|
||||
git cherry-pick --strategy resolve first..fourth >actual &&
|
||||
git diff --quiet other &&
|
||||
git diff --quiet HEAD other &&
|
||||
sed -e "s/$_x05[0-9a-f][0-9a-f]/OBJID/" <actual >actual.fuzzy &&
|
||||
test_cmp expected actual.fuzzy &&
|
||||
check_head_differs_from fourth
|
||||
test_i18ncmp expected actual.fuzzy
|
||||
'
|
||||
|
||||
test_expect_success 'cherry-pick --ff first..fourth works' '
|
||||
|
@ -432,7 +432,7 @@ test_expect_success 'stash branch - stashes on stack, stash-like argument' '
|
||||
test $(git ls-files --modified | wc -l) -eq 1
|
||||
'
|
||||
|
||||
test_expect_success 'stash show - stashes on stack, stash-like argument' '
|
||||
test_expect_success 'stash show format defaults to --stat' '
|
||||
git stash clear &&
|
||||
test_when_finished "git reset --hard HEAD" &&
|
||||
git reset --hard &&
|
||||
@ -447,6 +447,21 @@ test_expect_success 'stash show - stashes on stack, stash-like argument' '
|
||||
1 file changed, 1 insertion(+)
|
||||
EOF
|
||||
git stash show ${STASH_ID} >actual &&
|
||||
test_i18ncmp expected actual
|
||||
'
|
||||
|
||||
test_expect_success 'stash show - 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 &&
|
||||
echo "1 0 file" >expected &&
|
||||
git stash show --numstat ${STASH_ID} >actual &&
|
||||
test_cmp expected actual
|
||||
'
|
||||
|
||||
@ -480,11 +495,8 @@ test_expect_success 'stash show - no stashes on stack, stash-like argument' '
|
||||
echo foo >> file &&
|
||||
STASH_ID=$(git stash create) &&
|
||||
git reset --hard &&
|
||||
cat >expected <<-EOF &&
|
||||
file | 1 +
|
||||
1 file changed, 1 insertion(+)
|
||||
EOF
|
||||
git stash show ${STASH_ID} >actual &&
|
||||
echo "1 0 file" >expected &&
|
||||
git stash show --numstat ${STASH_ID} >actual &&
|
||||
test_cmp expected actual
|
||||
'
|
||||
|
||||
|
@ -8,6 +8,13 @@ test_description='Binary diff and apply
|
||||
|
||||
. ./test-lib.sh
|
||||
|
||||
cat >expect.binary-numstat <<\EOF
|
||||
1 1 a
|
||||
- - b
|
||||
1 1 c
|
||||
- - d
|
||||
EOF
|
||||
|
||||
test_expect_success 'prepare repository' \
|
||||
'echo AIT >a && echo BIT >b && echo CIT >c && echo DIT >d &&
|
||||
git update-index --add a b c d &&
|
||||
@ -23,13 +30,23 @@ cat > expected <<\EOF
|
||||
d | Bin
|
||||
4 files changed, 2 insertions(+), 2 deletions(-)
|
||||
EOF
|
||||
test_expect_success 'diff without --binary' \
|
||||
'git diff | git apply --stat --summary >current &&
|
||||
test_cmp expected current'
|
||||
test_expect_success '"apply --stat" output for binary file change' '
|
||||
git diff >diff &&
|
||||
git apply --stat --summary <diff >current &&
|
||||
test_i18ncmp expected current
|
||||
'
|
||||
|
||||
test_expect_success 'diff with --binary' \
|
||||
'git diff --binary | git apply --stat --summary >current &&
|
||||
test_cmp expected current'
|
||||
test_expect_success 'apply --numstat notices binary file change' '
|
||||
git diff >diff &&
|
||||
git apply --numstat <diff >current &&
|
||||
test_cmp expect.binary-numstat current
|
||||
'
|
||||
|
||||
test_expect_success 'apply --numstat understands diff --binary format' '
|
||||
git diff --binary >diff &&
|
||||
git apply --numstat <diff >current &&
|
||||
test_cmp expect.binary-numstat current
|
||||
'
|
||||
|
||||
# apply needs to be able to skip the binary material correctly
|
||||
# in order to report the line number of a corrupt patch.
|
||||
|
@ -128,7 +128,12 @@ do
|
||||
} >"$actual" &&
|
||||
if test -f "$expect"
|
||||
then
|
||||
test_cmp "$expect" "$actual" &&
|
||||
case $cmd in
|
||||
*format-patch* | *-stat*)
|
||||
test_i18ncmp "$expect" "$actual";;
|
||||
*)
|
||||
test_cmp "$expect" "$actual";;
|
||||
esac &&
|
||||
rm -f "$actual"
|
||||
else
|
||||
# this is to help developing new tests.
|
||||
|
@ -518,11 +518,6 @@ test_expect_success 'shortlog of cover-letter wraps overly-long onelines' '
|
||||
'
|
||||
|
||||
cat > expect << EOF
|
||||
---
|
||||
file | 16 ++++++++++++++++
|
||||
1 file changed, 16 insertions(+)
|
||||
|
||||
diff --git a/file b/file
|
||||
index 40f36c6..2dc5c23 100644
|
||||
--- a/file
|
||||
+++ b/file
|
||||
@ -537,7 +532,9 @@ EOF
|
||||
test_expect_success 'format-patch respects -U' '
|
||||
|
||||
git format-patch -U4 -2 &&
|
||||
sed -e "1,/^\$/d" -e "/^+5/q" < 0001-This-is-an-excessively-long-subject-line-for-a-messa.patch > output &&
|
||||
sed -e "1,/^diff/d" -e "/^+5/q" \
|
||||
<0001-This-is-an-excessively-long-subject-line-for-a-messa.patch \
|
||||
>output &&
|
||||
test_cmp expect output
|
||||
|
||||
'
|
||||
|
@ -57,22 +57,33 @@ test_expect_success TABS_IN_FILENAMES 'git diff --summary -M HEAD' '
|
||||
test_cmp expect actual
|
||||
'
|
||||
|
||||
test_expect_success TABS_IN_FILENAMES 'setup expected files' '
|
||||
cat >expect <<\EOF
|
||||
pathname.1 => "Rpathname\twith HT.0" | 0
|
||||
pathname.3 => "Rpathname\nwith LF.0" | 0
|
||||
"pathname\twith HT.3" => "Rpathname\nwith LF.1" | 0
|
||||
pathname.2 => Rpathname with SP.0 | 0
|
||||
"pathname\twith HT.2" => Rpathname with SP.1 | 0
|
||||
pathname.0 => Rpathname.0 | 0
|
||||
"pathname\twith HT.0" => Rpathname.1 | 0
|
||||
7 files changed, 0 insertions(+), 0 deletions(-)
|
||||
EOF
|
||||
'
|
||||
|
||||
test_expect_success TABS_IN_FILENAMES 'git diff --stat -M HEAD' '
|
||||
git diff --stat -M HEAD >actual &&
|
||||
test_expect_success TABS_IN_FILENAMES 'git diff --numstat -M HEAD' '
|
||||
cat >expect <<-\EOF &&
|
||||
0 0 pathname.1 => "Rpathname\twith HT.0"
|
||||
0 0 pathname.3 => "Rpathname\nwith LF.0"
|
||||
0 0 "pathname\twith HT.3" => "Rpathname\nwith LF.1"
|
||||
0 0 pathname.2 => Rpathname with SP.0
|
||||
0 0 "pathname\twith HT.2" => Rpathname with SP.1
|
||||
0 0 pathname.0 => Rpathname.0
|
||||
0 0 "pathname\twith HT.0" => Rpathname.1
|
||||
EOF
|
||||
git diff --numstat -M HEAD >actual &&
|
||||
test_cmp expect actual
|
||||
'
|
||||
|
||||
test_expect_success TABS_IN_FILENAMES 'git diff --stat -M HEAD' '
|
||||
cat >expect <<-\EOF &&
|
||||
pathname.1 => "Rpathname\twith HT.0" | 0
|
||||
pathname.3 => "Rpathname\nwith LF.0" | 0
|
||||
"pathname\twith HT.3" => "Rpathname\nwith LF.1" | 0
|
||||
pathname.2 => Rpathname with SP.0 | 0
|
||||
"pathname\twith HT.2" => Rpathname with SP.1 | 0
|
||||
pathname.0 => Rpathname.0 | 0
|
||||
"pathname\twith HT.0" => Rpathname.1 | 0
|
||||
7 files changed, 0 insertions(+), 0 deletions(-)
|
||||
EOF
|
||||
git diff --stat -M HEAD >actual &&
|
||||
test_i18ncmp expect actual
|
||||
'
|
||||
|
||||
test_done
|
||||
|
@ -91,7 +91,11 @@ EOF
|
||||
test_expect_success 'diffstat does not run textconv' '
|
||||
echo file diff=fail >.gitattributes &&
|
||||
git diff --stat HEAD^ HEAD >actual &&
|
||||
test_cmp expect.stat actual
|
||||
test_i18ncmp expect.stat actual &&
|
||||
|
||||
head -n1 <expect.stat >expect.line1 &&
|
||||
head -n1 <actual >actual.line1 &&
|
||||
test_cmp expect.line1 actual.line1
|
||||
'
|
||||
# restore working setup
|
||||
echo file diff=foo >.gitattributes
|
||||
|
@ -44,10 +44,16 @@ test_expect_success 'rewrite diff can show binary patch' '
|
||||
grep "GIT binary patch" diff
|
||||
'
|
||||
|
||||
test_expect_success 'rewrite diff --stat shows binary changes' '
|
||||
test_expect_success 'rewrite diff --numstat shows binary changes' '
|
||||
git diff -B --numstat --summary >diff &&
|
||||
grep -e "- - " diff &&
|
||||
grep " rewrite file" diff
|
||||
'
|
||||
|
||||
test_expect_success 'diff --stat counts binary rewrite as 0 lines' '
|
||||
git diff -B --stat --summary >diff &&
|
||||
grep "Bin" diff &&
|
||||
grep "0 insertions.*0 deletions" diff &&
|
||||
test_i18ngrep "0 insertions.*0 deletions" diff &&
|
||||
grep " rewrite file" diff
|
||||
'
|
||||
|
||||
|
@ -23,9 +23,8 @@ test_expect_success 'move the files into a "sub" directory' '
|
||||
'
|
||||
|
||||
cat > expected <<\EOF
|
||||
bar => sub/bar | Bin 5 -> 5 bytes
|
||||
foo => sub/foo | 0
|
||||
2 files changed, 0 insertions(+), 0 deletions(-)
|
||||
- - bar => sub/bar
|
||||
0 0 foo => sub/foo
|
||||
|
||||
diff --git a/bar b/sub/bar
|
||||
similarity index 100%
|
||||
@ -38,7 +37,8 @@ rename to sub/foo
|
||||
EOF
|
||||
|
||||
test_expect_success 'git show -C -C report renames' '
|
||||
git show -C -C --raw --binary --stat | tail -n 12 > current &&
|
||||
git show -C -C --raw --binary --numstat >patch-with-stat &&
|
||||
tail -n 11 patch-with-stat >current &&
|
||||
test_cmp expected current
|
||||
'
|
||||
|
||||
|
@ -29,6 +29,18 @@ test_expect_success "-p $*" "
|
||||
"
|
||||
}
|
||||
|
||||
check_numstat() {
|
||||
expect=$1; shift
|
||||
cat >expected <<EOF
|
||||
1 0 $expect
|
||||
EOF
|
||||
test_expect_success "--numstat $*" "
|
||||
echo '1 0 $expect' >expected &&
|
||||
git diff --numstat $* HEAD^ >actual &&
|
||||
test_cmp expected actual
|
||||
"
|
||||
}
|
||||
|
||||
check_stat() {
|
||||
expect=$1; shift
|
||||
cat >expected <<EOF
|
||||
@ -37,7 +49,7 @@ cat >expected <<EOF
|
||||
EOF
|
||||
test_expect_success "--stat $*" "
|
||||
git diff --stat $* HEAD^ >actual &&
|
||||
test_cmp expected actual
|
||||
test_i18ncmp expected actual
|
||||
"
|
||||
}
|
||||
|
||||
@ -52,7 +64,7 @@ test_expect_success "--raw $*" "
|
||||
"
|
||||
}
|
||||
|
||||
for type in diff stat raw; do
|
||||
for type in diff numstat stat raw; do
|
||||
check_$type file2 --relative=subdir/
|
||||
check_$type file2 --relative=subdir
|
||||
check_$type dir/file2 --relative=sub
|
||||
|
@ -252,50 +252,47 @@ EOF
|
||||
'
|
||||
|
||||
cat <<EOF >expect_diff_stat
|
||||
changed/text | 2 +-
|
||||
dst/copy/changed/text | 10 ++++++++++
|
||||
dst/copy/rearranged/text | 10 ++++++++++
|
||||
dst/copy/unchanged/text | 10 ++++++++++
|
||||
dst/move/changed/text | 10 ++++++++++
|
||||
dst/move/rearranged/text | 10 ++++++++++
|
||||
dst/move/unchanged/text | 10 ++++++++++
|
||||
rearranged/text | 2 +-
|
||||
src/move/changed/text | 10 ----------
|
||||
src/move/rearranged/text | 10 ----------
|
||||
src/move/unchanged/text | 10 ----------
|
||||
11 files changed, 62 insertions(+), 32 deletions(-)
|
||||
1 1 changed/text
|
||||
10 0 dst/copy/changed/text
|
||||
10 0 dst/copy/rearranged/text
|
||||
10 0 dst/copy/unchanged/text
|
||||
10 0 dst/move/changed/text
|
||||
10 0 dst/move/rearranged/text
|
||||
10 0 dst/move/unchanged/text
|
||||
1 1 rearranged/text
|
||||
0 10 src/move/changed/text
|
||||
0 10 src/move/rearranged/text
|
||||
0 10 src/move/unchanged/text
|
||||
EOF
|
||||
|
||||
cat <<EOF >expect_diff_stat_M
|
||||
changed/text | 2 +-
|
||||
dst/copy/changed/text | 10 ++++++++++
|
||||
dst/copy/rearranged/text | 10 ++++++++++
|
||||
dst/copy/unchanged/text | 10 ++++++++++
|
||||
{src => dst}/move/changed/text | 2 +-
|
||||
{src => dst}/move/rearranged/text | 2 +-
|
||||
{src => dst}/move/unchanged/text | 0
|
||||
rearranged/text | 2 +-
|
||||
8 files changed, 34 insertions(+), 4 deletions(-)
|
||||
1 1 changed/text
|
||||
10 0 dst/copy/changed/text
|
||||
10 0 dst/copy/rearranged/text
|
||||
10 0 dst/copy/unchanged/text
|
||||
1 1 {src => dst}/move/changed/text
|
||||
1 1 {src => dst}/move/rearranged/text
|
||||
0 0 {src => dst}/move/unchanged/text
|
||||
1 1 rearranged/text
|
||||
EOF
|
||||
|
||||
cat <<EOF >expect_diff_stat_CC
|
||||
changed/text | 2 +-
|
||||
{src => dst}/copy/changed/text | 2 +-
|
||||
{src => dst}/copy/rearranged/text | 2 +-
|
||||
{src => dst}/copy/unchanged/text | 0
|
||||
{src => dst}/move/changed/text | 2 +-
|
||||
{src => dst}/move/rearranged/text | 2 +-
|
||||
{src => dst}/move/unchanged/text | 0
|
||||
rearranged/text | 2 +-
|
||||
8 files changed, 6 insertions(+), 6 deletions(-)
|
||||
1 1 changed/text
|
||||
1 1 {src => dst}/copy/changed/text
|
||||
1 1 {src => dst}/copy/rearranged/text
|
||||
0 0 {src => dst}/copy/unchanged/text
|
||||
1 1 {src => dst}/move/changed/text
|
||||
1 1 {src => dst}/move/rearranged/text
|
||||
0 0 {src => dst}/move/unchanged/text
|
||||
1 1 rearranged/text
|
||||
EOF
|
||||
|
||||
test_expect_success 'sanity check setup (--stat)' '
|
||||
git diff --stat HEAD^..HEAD >actual_diff_stat &&
|
||||
test_expect_success 'sanity check setup (--numstat)' '
|
||||
git diff --numstat HEAD^..HEAD >actual_diff_stat &&
|
||||
test_cmp expect_diff_stat actual_diff_stat &&
|
||||
git diff --stat -M HEAD^..HEAD >actual_diff_stat_M &&
|
||||
git diff --numstat -M HEAD^..HEAD >actual_diff_stat_M &&
|
||||
test_cmp expect_diff_stat_M actual_diff_stat_M &&
|
||||
git diff --stat -C -C HEAD^..HEAD >actual_diff_stat_CC &&
|
||||
git diff --numstat -C -C HEAD^..HEAD >actual_diff_stat_CC &&
|
||||
test_cmp expect_diff_stat_CC actual_diff_stat_CC
|
||||
'
|
||||
|
||||
|
@ -19,7 +19,7 @@ test_expect_success setup '
|
||||
2 files changed, 2 insertions(+)
|
||||
EOF
|
||||
git diff --stat --stat-count=2 >actual &&
|
||||
test_cmp expect actual
|
||||
test_i18ncmp expect actual
|
||||
'
|
||||
|
||||
test_done
|
||||
|
@ -17,13 +17,13 @@ do
|
||||
test_expect_success "$title" '
|
||||
git apply --stat --summary \
|
||||
<"$TEST_DIRECTORY/t4100/t-apply-$num.patch" >current &&
|
||||
test_cmp "$TEST_DIRECTORY"/t4100/t-apply-$num.expect current
|
||||
test_i18ncmp "$TEST_DIRECTORY"/t4100/t-apply-$num.expect current
|
||||
'
|
||||
|
||||
test_expect_success "$title with recount" '
|
||||
sed -e "$UNC" <"$TEST_DIRECTORY/t4100/t-apply-$num.patch" |
|
||||
git apply --recount --stat --summary >current &&
|
||||
test_cmp "$TEST_DIRECTORY"/t4100/t-apply-$num.expect current
|
||||
test_i18ncmp "$TEST_DIRECTORY"/t4100/t-apply-$num.expect current
|
||||
'
|
||||
done <<\EOF
|
||||
rename
|
||||
|
@ -216,7 +216,7 @@ test_expect_success 'pull request format' '
|
||||
git request-pull initial "$downstream_url" >../request
|
||||
) &&
|
||||
<request sed -nf fuzz.sed >request.fuzzy &&
|
||||
test_cmp expect request.fuzzy
|
||||
test_i18ncmp expect request.fuzzy
|
||||
|
||||
'
|
||||
|
||||
|
@ -66,7 +66,7 @@ EOF
|
||||
test_expect_success 'merge output uses pretty names' '
|
||||
git reset --hard c1 &&
|
||||
git merge c2 c3 c4 >actual &&
|
||||
test_cmp actual expected
|
||||
test_i18ncmp expected actual
|
||||
'
|
||||
|
||||
cat >expected <<\EOF
|
||||
@ -80,7 +80,7 @@ EOF
|
||||
|
||||
test_expect_success 'merge up-to-date output uses pretty names' '
|
||||
git merge c4 c5 >actual &&
|
||||
test_cmp actual expected
|
||||
test_i18ncmp expected actual
|
||||
'
|
||||
|
||||
cat >expected <<\EOF
|
||||
@ -97,7 +97,7 @@ EOF
|
||||
test_expect_success 'merge fast-forward output uses pretty names' '
|
||||
git reset --hard c0 &&
|
||||
git merge c1 c2 >actual &&
|
||||
test_cmp actual expected
|
||||
test_i18ncmp expected actual
|
||||
'
|
||||
|
||||
test_done
|
||||
|
Loading…
Reference in New Issue
Block a user