aboutsummaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2010-06-22 09:04:14 -0700
committerJunio C Hamano <gitster@pobox.com>2010-06-22 09:27:07 -0700
commit3c656899cdfbfdd40987625c4615a8c941d5968a (patch)
tree547b892074d90da576a25066e3504af9c60460f5 /t
parenta8c4d925caba244de842f8fa663c3e6bb7000b89 (diff)
parent296c6bb21a6980f6e5b42f0790d6365c1e3f696f (diff)
downloadgit-3c656899cdfbfdd40987625c4615a8c941d5968a.tar.gz
git-3c656899cdfbfdd40987625c4615a8c941d5968a.tar.xz
Merge branch 'cc/maint-diff-CC-binary' into maint
* cc/maint-diff-CC-binary: diff: fix "git show -C -C" output when renaming a binary file Conflicts: diff.c
Diffstat (limited to 't')
-rwxr-xr-xt/t4015-diff-whitespace.sh37
-rwxr-xr-xt/t4043-diff-rename-binary.sh45
2 files changed, 82 insertions, 0 deletions
diff --git a/t/t4015-diff-whitespace.sh b/t/t4015-diff-whitespace.sh
index 90f334237..7e78851a1 100755
--- a/t/t4015-diff-whitespace.sh
+++ b/t/t4015-diff-whitespace.sh
@@ -396,6 +396,43 @@ test_expect_success 'whitespace-only changes not reported' '
test_cmp expect actual
'
+cat <<EOF >expect
+diff --git a/x b/z
+similarity index NUM%
+rename from x
+rename to z
+index 380c32a..a97b785 100644
+EOF
+test_expect_success 'whitespace-only changes reported across renames' '
+ git reset --hard &&
+ for i in 1 2 3 4 5 6 7 8 9; do echo "$i$i$i$i$i$i"; done >x &&
+ git add x &&
+ git commit -m "base" &&
+ sed -e "5s/^/ /" x >z &&
+ git rm x &&
+ git add z &&
+ git diff -w -M --cached |
+ sed -e "/^similarity index /s/[0-9][0-9]*/NUM/" >actual &&
+ test_cmp expect actual
+'
+
+cat >expected <<\EOF
+diff --git a/empty b/void
+similarity index 100%
+rename from empty
+rename to void
+EOF
+
+test_expect_success 'rename empty' '
+ git reset --hard &&
+ >empty &&
+ git add empty &&
+ git commit -m empty &&
+ git mv empty void &&
+ git diff -w --cached -M >current &&
+ test_cmp expected current
+'
+
test_expect_success 'combined diff with autocrlf conversion' '
git reset --hard &&
diff --git a/t/t4043-diff-rename-binary.sh b/t/t4043-diff-rename-binary.sh
new file mode 100755
index 000000000..06012811a
--- /dev/null
+++ b/t/t4043-diff-rename-binary.sh
@@ -0,0 +1,45 @@
+#!/bin/sh
+#
+# Copyright (c) 2010 Jakub Narebski, Christian Couder
+#
+
+test_description='Move a binary file'
+
+. ./test-lib.sh
+
+
+test_expect_success 'prepare repository' '
+ git init &&
+ echo foo > foo &&
+ echo "barQ" | q_to_nul > bar &&
+ git add . &&
+ git commit -m "Initial commit"
+'
+
+test_expect_success 'move the files into a "sub" directory' '
+ mkdir sub &&
+ git mv bar foo sub/ &&
+ git commit -m "Moved to sub/"
+'
+
+cat > expected <<\EOF
+ bar => sub/bar | Bin 5 -> 5 bytes
+ foo => sub/foo | 0
+ 2 files changed, 0 insertions(+), 0 deletions(-)
+
+diff --git a/bar b/sub/bar
+similarity index 100%
+rename from bar
+rename to sub/bar
+diff --git a/foo b/sub/foo
+similarity index 100%
+rename from foo
+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 &&
+ test_cmp expected current
+'
+
+test_done