summaryrefslogtreecommitdiff
path: root/t/t7507-commit-verbose.sh
diff options
context:
space:
mode:
authorLibravatar Junio C Hamano <gitster@pobox.com>2008-12-02 23:47:25 -0800
committerLibravatar Junio C Hamano <gitster@pobox.com>2008-12-02 23:47:25 -0800
commit2ab4de57ea2c423fe8abae5278507106972ef1fe (patch)
tree9828a4bdbebae0e83ec9d509b4192d8cdf7276d9 /t/t7507-commit-verbose.sh
parentxdiff: give up scanning similar lines early (diff)
parentcommit: Fix stripping of patch in verbose mode. (diff)
downloadtgif-2ab4de57ea2c423fe8abae5278507106972ef1fe.tar.xz
Merge branch 'jk/maint-commit-v-strip' into maint
* jk/maint-commit-v-strip: commit: Fix stripping of patch in verbose mode.
Diffstat (limited to 't/t7507-commit-verbose.sh')
-rwxr-xr-xt/t7507-commit-verbose.sh73
1 files changed, 73 insertions, 0 deletions
diff --git a/t/t7507-commit-verbose.sh b/t/t7507-commit-verbose.sh
new file mode 100755
index 0000000000..519adba80b
--- /dev/null
+++ b/t/t7507-commit-verbose.sh
@@ -0,0 +1,73 @@
+#!/bin/sh
+
+test_description='verbose commit template'
+. ./test-lib.sh
+
+cat >check-for-diff <<EOF
+#!$SHELL_PATH
+exec grep '^diff --git' "\$1"
+EOF
+chmod +x check-for-diff
+test_set_editor "$PWD/check-for-diff"
+
+cat >message <<'EOF'
+subject
+
+body
+EOF
+
+test_expect_success 'setup' '
+ echo content >file &&
+ git add file &&
+ git commit -F message
+'
+
+test_expect_failure 'initial commit shows verbose diff' '
+ git commit --amend -v
+'
+
+test_expect_success 'second commit' '
+ echo content modified >file &&
+ git add file &&
+ git commit -F message
+'
+
+check_message() {
+ git log -1 --pretty=format:%s%n%n%b >actual &&
+ test_cmp "$1" actual
+}
+
+test_expect_success 'verbose diff is stripped out' '
+ git commit --amend -v &&
+ check_message message
+'
+
+test_expect_success 'verbose diff is stripped out (mnemonicprefix)' '
+ git config diff.mnemonicprefix true &&
+ git commit --amend -v &&
+ check_message message
+'
+
+cat >diff <<'EOF'
+This is an example commit message that contains a diff.
+
+diff --git c/file i/file
+new file mode 100644
+index 0000000..f95c11d
+--- /dev/null
++++ i/file
+@@ -0,0 +1 @@
++this is some content
+EOF
+
+test_expect_success 'diff in message is retained without -v' '
+ git commit --amend -F diff &&
+ check_message diff
+'
+
+test_expect_failure 'diff in message is retained with -v' '
+ git commit --amend -F diff -v &&
+ check_message diff
+'
+
+test_done