builtin/blame.c: remove '--indent-heuristic' from usage string
[git/debian.git] / t / t7507-commit-verbose.sh
blobed2653d46fe6cd0ed1dd5dc2dfd73f7340b8fe31
1 #!/bin/sh
3 test_description='verbose commit template'
4 . ./test-lib.sh
6 write_script "check-for-diff" <<\EOF &&
7 grep '^diff --git' "$1" >out
8 exit 0
9 EOF
10 test_set_editor "$PWD/check-for-diff"
12 cat >message <<'EOF'
13 subject
15 body
16 EOF
18 test_expect_success 'setup' '
19 echo content >file &&
20 git add file &&
21 git commit -F message
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 &&
31 git add file &&
32 git commit -F message
35 check_message() {
36 git log -1 --pretty=format:%s%n%n%b >actual &&
37 test_cmp "$1" 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
53 cat >diff <<'EOF'
54 This is an example commit message that contains a diff.
56 diff --git c/file i/file
57 new file mode 100644
58 index 0000000..f95c11d
59 --- /dev/null
60 +++ i/file
61 @@ -0,0 +1 @@
62 +this is some content
63 EOF
65 test_expect_success 'diff in message is retained without -v' '
66 git commit --amend -F diff &&
67 check_message diff
70 test_expect_success 'diff in message is retained with -v' '
71 git commit --amend -F diff -v &&
72 check_message diff
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" &&
80 cd sub &&
81 echo "more" >>file &&
82 git commit -a -m "submodule commit"
83 ) &&
85 GIT_EDITOR=cat &&
86 export GIT_EDITOR &&
87 test_must_fail git commit -a -v 2>err
88 ) &&
89 test_i18ngrep "Aborting commit due to empty commit message." err
92 test_expect_success 'verbose diff is stripped out with set core.commentChar' '
94 GIT_EDITOR=cat &&
95 export GIT_EDITOR &&
96 test_must_fail git -c core.commentchar=";" commit -a -v 2>err
97 ) &&
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' '
107 echo dirty >file
110 for i in true 1
112 test_expect_success "commit.verbose=$i and --verbose omitted" "
113 git -c commit.verbose=$i commit --amend &&
114 test_line_count = 1 out
116 done
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
124 done
126 for i in 2 3
128 test_expect_success "commit.verbose=$i and --verbose omitted" "
129 git -c commit.verbose=$i commit --amend &&
130 test_line_count = 2 out
132 done
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
150 done
152 test_expect_success "status ignores commit.verbose=true" '
153 git -c commit.verbose=true status >actual &&
154 ! grep "^diff --git actual"
157 test_done