3 test_description
='verbose commit template'
6 write_script
"check-for-diff" <<\EOF
&&
7 grep '^diff --git' "$1" >out
10 test_set_editor
"$PWD/check-for-diff"
18 test_expect_success
'setup' '
24 test_expect_success
'initial commit shows verbose diff' '
25 git commit --amend -v &&
26 test_line_count = 1 out
29 test_expect_success
'second commit' '
30 echo content modified >file &&
36 git log
-1 --pretty=format
:%s
%n
%n
%b
>actual
&&
40 test_expect_success
'verbose diff is stripped out' '
41 git commit --amend -v &&
42 check_message message &&
43 test_line_count = 1 out
46 test_expect_success
'verbose diff is stripped out (mnemonicprefix)' '
47 git config diff.mnemonicprefix true &&
48 git commit --amend -v &&
49 check_message message &&
50 test_line_count = 1 out
54 This is an example commit message that contains a diff.
56 diff --git c/file i/file
58 index 0000000..f95c11d
65 test_expect_success
'diff in message is retained without -v' '
66 git commit --amend -F diff &&
70 test_expect_success
'diff in message is retained with -v' '
71 git commit --amend -F diff -v &&
75 test_expect_success
'submodule log is stripped out too with -v' '
76 git config diff.submodule log &&
77 git submodule add ./. sub &&
78 git commit -m "sub added" &&
82 git commit -a -m "submodule commit"
87 test_must_fail git commit -a -v 2>err
89 test_i18ngrep "Aborting commit due to empty commit message." err
92 test_expect_success
'verbose diff is stripped out with set core.commentChar' '
96 test_must_fail git -c core.commentchar=";" commit -a -v 2>err
98 test_i18ngrep "Aborting commit due to empty commit message." err
101 test_expect_success
'status does not verbose without --verbose' '
102 git status >actual &&
103 ! grep "^diff --git" actual
106 test_expect_success
'setup -v -v' '
112 test_expect_success
"commit.verbose=$i and --verbose omitted" "
113 git -c commit.verbose=$i commit --amend &&
114 test_line_count = 1 out
118 for i
in false
-2 -1 0
120 test_expect_success
"commit.verbose=$i and --verbose omitted" "
121 git -c commit.verbose=$i commit --amend &&
122 test_line_count = 0 out
128 test_expect_success
"commit.verbose=$i and --verbose omitted" "
129 git -c commit.verbose=$i commit --amend &&
130 test_line_count = 2 out
134 for i
in true false
-2 -1 0 1 2 3
136 test_expect_success
"commit.verbose=$i and --verbose" "
137 git -c commit.verbose=$i commit --amend --verbose &&
138 test_line_count = 1 out
141 test_expect_success
"commit.verbose=$i and --no-verbose" "
142 git -c commit.verbose=$i commit --amend --no-verbose &&
143 test_line_count = 0 out
146 test_expect_success
"commit.verbose=$i and -v -v" "
147 git -c commit.verbose=$i commit --amend -v -v &&
148 test_line_count = 2 out
152 test_expect_success
"status ignores commit.verbose=true" '
153 git -c commit.verbose=true status >actual &&
154 ! grep "^diff --git actual"