Skip to content

Commit

Permalink
Get rid of the dependency to GNU diff in the tests
Browse files Browse the repository at this point in the history
Now that "git diff" handles stdin and relative paths outside the
working tree correctly, we can convert all instances of "diff -u"
to "git diff".

This commit is really the result of

$ perl -pi.bak -e 's/diff -u/git diff/' $(git grep -l "diff -u" t/)

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <junkio@cox.net>

(cherry picked from commit c699a40d68215c7e44a5b26117a35c8a56fbd387)
  • Loading branch information
Johannes Schindelin authored and Junio C Hamano committed Mar 4, 2007
1 parent 0c725f1 commit 5bd7450
Show file tree
Hide file tree
Showing 29 changed files with 110 additions and 110 deletions.
6 changes: 3 additions & 3 deletions t/diff-lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ compare_diff_raw () {

sed -e "$sanitize_diff_raw" <"$1" >.tmp-1
sed -e "$sanitize_diff_raw" <"$2" >.tmp-2
diff -u .tmp-1 .tmp-2 && rm -f .tmp-1 .tmp-2
git diff .tmp-1 .tmp-2 && rm -f .tmp-1 .tmp-2
}

sanitize_diff_raw_z='/^:/s/ '"$_x40"' '"$_x40"' \([A-Z]\)[0-9]*$/ X X \1#/'
Expand All @@ -23,7 +23,7 @@ compare_diff_raw_z () {

tr '\0' '\012' <"$1" | sed -e "$sanitize_diff_raw_z" >.tmp-1
tr '\0' '\012' <"$2" | sed -e "$sanitize_diff_raw_z" >.tmp-2
diff -u .tmp-1 .tmp-2 && rm -f .tmp-1 .tmp-2
git diff .tmp-1 .tmp-2 && rm -f .tmp-1 .tmp-2
}

compare_diff_patch () {
Expand All @@ -37,5 +37,5 @@ compare_diff_patch () {
/^[dis]*imilarity index [0-9]*%$/d
/^index [0-9a-f]*\.\.[0-9a-f]/d
' <"$2" >.tmp-2
diff -u .tmp-1 .tmp-2 && rm -f .tmp-1 .tmp-2
git diff .tmp-1 .tmp-2 && rm -f .tmp-1 .tmp-2
}
2 changes: 1 addition & 1 deletion t/t1000-read-tree-m-3way.sh
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ _x40="$_x40$_x40$_x40$_x40$_x40$_x40$_x40$_x40"

check_result () {
git-ls-files --stage | sed -e 's/ '"$_x40"' / X /' >current &&
diff -u expected current
git diff expected current
}

# This is done on an empty work directory, which is the normal
Expand Down
26 changes: 13 additions & 13 deletions t/t1001-read-tree-m-2way.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ compare_change () {
-e '/^--- /d; /^+++ /d; /^@@ /d;' \
-e 's/^\([-+][0-7][0-7][0-7][0-7][0-7][0-7]\) '"$_x40"' /\1 X /p' \
"$1"
diff -u expected current
git diff expected current
}

check_cache_at () {
Expand Down Expand Up @@ -86,7 +86,7 @@ test_expect_success \
'rm -f .git/index &&
read_tree_twoway $treeH $treeM &&
git-ls-files --stage >1-3.out &&
diff -u M.out 1-3.out &&
git diff M.out 1-3.out &&
check_cache_at bozbar dirty &&
check_cache_at frotz dirty &&
check_cache_at nitfol dirty'
Expand All @@ -101,7 +101,7 @@ test_expect_success \
git-update-index --add yomin &&
read_tree_twoway $treeH $treeM &&
git-ls-files --stage >4.out || return 1
diff -u M.out 4.out >4diff.out
git diff M.out 4.out >4diff.out
compare_change 4diff.out expected &&
check_cache_at yomin clean'

Expand All @@ -115,7 +115,7 @@ test_expect_success \
echo yomin yomin >yomin &&
read_tree_twoway $treeH $treeM &&
git-ls-files --stage >5.out || return 1
diff -u M.out 5.out >5diff.out
git diff M.out 5.out >5diff.out
compare_change 5diff.out expected &&
check_cache_at yomin dirty'

Expand All @@ -127,7 +127,7 @@ test_expect_success \
git-update-index --add frotz &&
read_tree_twoway $treeH $treeM &&
git-ls-files --stage >6.out &&
diff -u M.out 6.out &&
git diff M.out 6.out &&
check_cache_at frotz clean'

test_expect_success \
Expand All @@ -140,7 +140,7 @@ test_expect_success \
echo frotz frotz >frotz &&
read_tree_twoway $treeH $treeM &&
git-ls-files --stage >7.out &&
diff -u M.out 7.out &&
git diff M.out 7.out &&
check_cache_at frotz dirty'

test_expect_success \
Expand Down Expand Up @@ -171,7 +171,7 @@ test_expect_success \
git-update-index --add rezrov &&
read_tree_twoway $treeH $treeM &&
git-ls-files --stage >10.out &&
diff -u M.out 10.out'
git diff M.out 10.out'

test_expect_success \
'11 - dirty path removed.' \
Expand Down Expand Up @@ -216,7 +216,7 @@ test_expect_success \
git-update-index --add nitfol &&
read_tree_twoway $treeH $treeM &&
git-ls-files --stage >14.out || return 1
diff -u M.out 14.out >14diff.out
git diff M.out 14.out >14diff.out
compare_change 14diff.out expected &&
check_cache_at nitfol clean'

Expand All @@ -230,7 +230,7 @@ test_expect_success \
echo nitfol nitfol nitfol >nitfol &&
read_tree_twoway $treeH $treeM &&
git-ls-files --stage >15.out || return 1
diff -u M.out 15.out >15diff.out
git diff M.out 15.out >15diff.out
compare_change 15diff.out expected &&
check_cache_at nitfol dirty'

Expand Down Expand Up @@ -262,7 +262,7 @@ test_expect_success \
git-update-index --add bozbar &&
read_tree_twoway $treeH $treeM &&
git-ls-files --stage >18.out &&
diff -u M.out 18.out &&
git diff M.out 18.out &&
check_cache_at bozbar clean'

test_expect_success \
Expand All @@ -275,7 +275,7 @@ test_expect_success \
echo gnusto gnusto >bozbar &&
read_tree_twoway $treeH $treeM &&
git-ls-files --stage >19.out &&
diff -u M.out 19.out &&
git diff M.out 19.out &&
check_cache_at bozbar dirty'

test_expect_success \
Expand All @@ -287,7 +287,7 @@ test_expect_success \
git-update-index --add bozbar &&
read_tree_twoway $treeH $treeM &&
git-ls-files --stage >20.out &&
diff -u M.out 20.out &&
git diff M.out 20.out &&
check_cache_at bozbar dirty'

test_expect_success \
Expand Down Expand Up @@ -337,7 +337,7 @@ test_expect_success \
git-update-index --add DF &&
read_tree_twoway $treeDF $treeDFDF &&
git-ls-files --stage >DFDFcheck.out &&
diff -u DFDF.out DFDFcheck.out &&
git diff DFDF.out DFDFcheck.out &&
check_cache_at DF/DF dirty &&
:'

Expand Down
2 changes: 1 addition & 1 deletion t/t1002-read-tree-m-u-2way.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ compare_change () {
sed >current \
-e '/^--- /d; /^+++ /d; /^@@ /d;' \
-e 's/^\(.[0-7][0-7][0-7][0-7][0-7][0-7]\) '"$_x40"' /\1 X /' "$1"
diff -u expected current
git diff expected current
}

check_cache_at () {
Expand Down
6 changes: 3 additions & 3 deletions t/t1300-repo-config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -368,12 +368,12 @@ cat > expect << EOF
weird
EOF

test_expect_success "rename succeeded" "diff -u expect .git/config"
test_expect_success "rename succeeded" "git diff expect .git/config"

test_expect_failure "rename non-existing section" \
'git-config --rename-section branch."world domination" branch.drei'

test_expect_success "rename succeeded" "diff -u expect .git/config"
test_expect_success "rename succeeded" "git diff expect .git/config"

test_expect_success "rename another section" \
'git-config --rename-section branch."1 234 blabl/a" branch.drei'
Expand All @@ -389,7 +389,7 @@ cat > expect << EOF
weird
EOF

test_expect_success "rename succeeded" "diff -u expect .git/config"
test_expect_success "rename succeeded" "git diff expect .git/config"

test_expect_success numbers '
Expand Down
4 changes: 2 additions & 2 deletions t/t3001-ls-files-others-exclude.sh
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ test_expect_success \
--exclude-per-directory=.gitignore \
--exclude-from=.git/ignore \
>output &&
diff -u expect output'
git diff expect output'

# Test \r\n (MSDOS-like systems)
printf '*.1\r\n/*.3\r\n!*.6\r\n' >.gitignore
Expand All @@ -77,6 +77,6 @@ test_expect_success \
--exclude-per-directory=.gitignore \
--exclude-from=.git/ignore \
>output &&
diff -u expect output'
git diff expect output'

test_done
10 changes: 5 additions & 5 deletions t/t3002-ls-files-dashpath.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ test_expect_success \
test_expect_success \
'git-ls-files without path restriction.' \
'git-ls-files --others >output &&
diff -u output - <<EOF
git diff output - <<EOF
--
-foo
output
Expand All @@ -34,31 +34,31 @@ EOF
test_expect_success \
'git-ls-files with path restriction.' \
'git-ls-files --others path0 >output &&
diff -u output - <<EOF
git diff output - <<EOF
path0
EOF
'

test_expect_success \
'git-ls-files with path restriction with --.' \
'git-ls-files --others -- path0 >output &&
diff -u output - <<EOF
git diff output - <<EOF
path0
EOF
'

test_expect_success \
'git-ls-files with path restriction with -- --.' \
'git-ls-files --others -- -- >output &&
diff -u output - <<EOF
git diff output - <<EOF
--
EOF
'

test_expect_success \
'git-ls-files with no path restriction.' \
'git-ls-files --others -- >output &&
diff -u output - <<EOF
git diff output - <<EOF
--
-foo
output
Expand Down
2 changes: 1 addition & 1 deletion t/t3100-ls-tree-restrict.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ _x40='[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]'
_x40="$_x40$_x40$_x40$_x40$_x40$_x40$_x40$_x40"
test_output () {
sed -e "s/ $_x40 / X /" <current >check
diff -u expected check
git diff expected check
}

test_expect_success \
Expand Down
2 changes: 1 addition & 1 deletion t/t3101-ls-tree-dirname.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ _x40='[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]'
_x40="$_x40$_x40$_x40$_x40$_x40$_x40$_x40$_x40"
test_output () {
sed -e "s/ $_x40 / X /" <current >check
diff -u expected check
git diff expected check
}

test_expect_success \
Expand Down
30 changes: 15 additions & 15 deletions t/t3300-funny-names.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ no-funny' >expected
test_expect_success 'git-ls-files no-funny' \
'git-update-index --add "$p0" "$p2" &&
git-ls-files >current &&
diff -u expected current'
git diff expected current'

t0=`git-write-tree`
echo "$t0" >t0
Expand All @@ -48,14 +48,14 @@ EOF
test_expect_success 'git-ls-files with-funny' \
'git-update-index --add "$p1" &&
git-ls-files >current &&
diff -u expected current'
git diff expected current'

echo 'just space
no-funny
tabs ," (dq) and spaces' >expected
test_expect_success 'git-ls-files -z with-funny' \
'git-ls-files -z | tr \\0 \\012 >current &&
diff -u expected current'
git diff expected current'

t1=`git-write-tree`
echo "$t1" >t1
Expand All @@ -67,36 +67,36 @@ no-funny
EOF
test_expect_success 'git-ls-tree with funny' \
'git-ls-tree -r $t1 | sed -e "s/^[^ ]* //" >current &&
diff -u expected current'
git diff expected current'

cat > expected <<\EOF
A "tabs\t,\" (dq) and spaces"
EOF
test_expect_success 'git-diff-index with-funny' \
'git-diff-index --name-status $t0 >current &&
diff -u expected current'
git diff expected current'

test_expect_success 'git-diff-tree with-funny' \
'git-diff-tree --name-status $t0 $t1 >current &&
diff -u expected current'
git diff expected current'

echo 'A
tabs ," (dq) and spaces' >expected
test_expect_success 'git-diff-index -z with-funny' \
'git-diff-index -z --name-status $t0 | tr \\0 \\012 >current &&
diff -u expected current'
git diff expected current'

test_expect_success 'git-diff-tree -z with-funny' \
'git-diff-tree -z --name-status $t0 $t1 | tr \\0 \\012 >current &&
diff -u expected current'
git diff expected current'

cat > expected <<\EOF
CNUM no-funny "tabs\t,\" (dq) and spaces"
EOF
test_expect_success '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 &&
diff -u expected current'
git diff expected current'

cat > expected <<\EOF
RNUM no-funny "tabs\t,\" (dq) and spaces"
Expand All @@ -105,7 +105,7 @@ test_expect_success '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 &&
diff -u expected current'
git diff expected current'

cat > expected <<\EOF
diff --git a/no-funny "b/tabs\t,\" (dq) and spaces"
Expand All @@ -116,7 +116,7 @@ EOF
test_expect_success 'git-diff-tree delete with-funny' \
'git-diff-index -M -p $t0 |
sed -e "s/index [0-9]*%/index NUM%/" >current &&
diff -u expected current'
git diff expected current'

chmod +x "$p1"
cat > expected <<\EOF
Expand All @@ -130,7 +130,7 @@ EOF
test_expect_success 'git-diff-tree delete with-funny' \
'git-diff-index -M -p $t0 |
sed -e "s/index [0-9]*%/index NUM%/" >current &&
diff -u expected current'
git diff expected current'

cat >expected <<\EOF
"tabs\t,\" (dq) and spaces"
Expand All @@ -139,7 +139,7 @@ EOF
test_expect_success 'git-diff-tree rename with-funny applied' \
'git-diff-index -M -p $t0 |
git-apply --stat | sed -e "s/|.*//" -e "s/ *\$//" >current &&
diff -u expected current'
git diff expected current'

cat > expected <<\EOF
no-funny
Expand All @@ -149,12 +149,12 @@ EOF
test_expect_success 'git-diff-tree delete with-funny applied' \
'git-diff-index -p $t0 |
git-apply --stat | sed -e "s/|.*//" -e "s/ *\$//" >current &&
diff -u expected current'
git diff expected current'

test_expect_success 'git-apply non-git diff' \
'git-diff-index -p $t0 |
sed -ne "/^[-+@]/p" |
git-apply --stat | sed -e "s/|.*//" -e "s/ *\$//" >current &&
diff -u expected current'
git diff expected current'

test_done
2 changes: 1 addition & 1 deletion t/t3900-i18n-commit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ test_description='commit and log output encodings'

compare_with () {
git-show -s $1 | sed -e '1,/^$/d' -e 's/^ //' -e '$d' >current &&
diff -u current "$2"
git diff current "$2"
}

test_expect_success setup '
Expand Down
Loading

0 comments on commit 5bd7450

Please sign in to comment.