3 test_description
='verbose commit template'
5 TEST_PASSES_SANITIZE_LEAK
=true
8 write_script
"check-for-diff" <<\EOF
&&
9 grep '^diff --git' "$1" >out
12 test_set_editor
"$PWD/check-for-diff"
20 test_expect_success
'setup' '
26 test_expect_success
'initial commit shows verbose diff' '
27 git commit --amend -v &&
28 test_line_count = 1 out
31 test_expect_success
'second commit' '
32 echo content modified >file &&
38 git log
-1 --pretty=format
:%s
%n
%n
%b
>actual
&&
42 test_expect_success
'verbose diff is stripped out' '
43 git commit --amend -v &&
44 check_message message &&
45 test_line_count = 1 out
48 test_expect_success
'verbose diff is stripped out (mnemonicprefix)' '
49 git config diff.mnemonicprefix true &&
50 git commit --amend -v &&
51 check_message message &&
52 test_line_count = 1 out
56 This is an example commit message that contains a diff.
58 diff --git c/file i/file
60 index 0000000..f95c11d
67 test_expect_success
'diff in message is retained without -v' '
68 git commit --amend -F diff &&
72 test_expect_success
'diff in message is retained with -v' '
73 git commit --amend -F diff -v &&
77 test_expect_success
'submodule log is stripped out too with -v' '
78 git config diff.submodule log &&
79 test_config_global protocol.file.allow always &&
80 git submodule add ./. sub &&
81 git commit -m "sub added" &&
85 git commit -a -m "submodule commit"
90 test_must_fail git commit -a -v 2>err
92 test_i18ngrep "Aborting commit due to empty commit message." err
95 test_expect_success
'verbose diff is stripped out with set core.commentChar' '
99 test_must_fail git -c core.commentchar=";" commit -a -v 2>err
101 test_i18ngrep "Aborting commit due to empty commit message." err
104 test_expect_success
'status does not verbose without --verbose' '
105 git status >actual &&
106 ! grep "^diff --git" actual
109 test_expect_success
'setup -v -v' '
115 test_expect_success
"commit.verbose=$i and --verbose omitted" "
116 git -c commit.verbose=$i commit --amend &&
117 test_line_count = 1 out
121 for i
in false
-2 -1 0
123 test_expect_success
"commit.verbose=$i and --verbose omitted" "
124 git -c commit.verbose=$i commit --amend &&
125 test_line_count = 0 out
131 test_expect_success
"commit.verbose=$i and --verbose omitted" "
132 git -c commit.verbose=$i commit --amend &&
133 test_line_count = 2 out
137 for i
in true false
-2 -1 0 1 2 3
139 test_expect_success
"commit.verbose=$i and --verbose" "
140 git -c commit.verbose=$i commit --amend --verbose &&
141 test_line_count = 1 out
144 test_expect_success
"commit.verbose=$i and --no-verbose" "
145 git -c commit.verbose=$i commit --amend --no-verbose &&
146 test_line_count = 0 out
149 test_expect_success
"commit.verbose=$i and -v -v" "
150 git -c commit.verbose=$i commit --amend -v -v &&
151 test_line_count = 2 out
155 test_expect_success
"status ignores commit.verbose=true" '
156 git -c commit.verbose=true status >actual &&
157 ! grep "^diff --git actual"