Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/git/blob/master/t/t7507-commit-verbose.sh # git [Ported from github.com/git/git] Sync with Git 2.56.1 Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `master` Branches Tags History `git / t / t7507-commit-verbose.sh` 169 lines ยท 3711 bytes Raw Blame History 1 #!/bin/sh 2 3 test_description='verbose commit template' 4 5 . ./test-lib.sh 6 7 write_script "check-for-diff" <<\EOF && 8 grep '^diff --git' "$1" >out 9 exit 0 10 EOF 11 test_set_editor "$PWD/check-for-diff" 12 13 cat >message <<'EOF' 14 subject 15 16 body 17 EOF 18 19 test_expect_success 'setup' ' 20 echo content >file && 21 git add file && 22 git commit -F message 23 ' 24 25 test_expect_success 'initial commit shows verbose diff' ' 26 git commit --amend -v && 27 test_line_count = 1 out 28 ' 29 30 test_expect_success 'second commit' ' 31 echo content modified >file && 32 git add file && 33 git commit -F message 34 ' 35 36 check_message() { 37 git log -1 --pretty=format:%s%n%n%b >actual && 38 test_cmp "$1" actual 39 } 40 41 test_expect_success 'verbose diff is stripped out' ' 42 git commit --amend -v && 43 check_message message && 44 test_line_count = 1 out 45 ' 46 47 test_expect_success 'verbose diff is stripped out (mnemonicprefix)' ' 48 git config diff.mnemonicprefix true && 49 git commit --amend -v && 50 check_message message && 51 test_line_count = 1 out 52 ' 53 54 cat >diff <<'EOF' 55 This is an example commit message that contains a diff. 56 57 diff --git c/file i/file 58 new file mode 100644 59 index `0000000`..`f95c11d` 60 --- /dev/null 61 +++ i/file 62 @@ -0,0 +1 @@ 63 +this is some content 64 EOF 65 66 test_expect_success 'diff in message is retained without -v' ' 67 git commit --amend -F diff && 68 check_message diff 69 ' 70 71 test_expect_success 'diff in message is retained with -v' ' 72 git commit --amend -F diff -v && 73 check_message diff 74 ' 75 76 test_expect_success 'submodule log is stripped out too with -v' ' 77 git config diff.submodule log && 78 test_config_global protocol.file.allow always && 79 git submodule add ./. sub && 80 git commit -m "sub added" && 81 ( 82 cd sub && 83 echo "more" >>file && 84 git commit -a -m "submodule commit" 85 ) && 86 ( 87 GIT_EDITOR=cat && 88 export GIT_EDITOR && 89 test_must_fail git commit -a -v 2>err 90 ) && 91 test_grep "Aborting commit due to empty commit message." err 92 ' 93 94 test_expect_success 'verbose diff is stripped out with set core.commentChar' ' 95 ( 96 GIT_EDITOR=cat && 97 export GIT_EDITOR && 98 test_must_fail git -c core.commentchar=";" commit -a -v 2>err 99 ) && 100 test_grep "Aborting commit due to empty commit message." err 101 ' 102 103 test_expect_success 'verbose diff is stripped with multi-byte comment char' ' 104 ( 105 GIT_EDITOR=cat && 106 export GIT_EDITOR && 107 test_must_fail git -c core.commentchar="foo>" commit -a -v >out 2>err 108 ) && 109 test_grep "^foo> " out && 110 test_grep "Aborting commit due to empty commit message." err 111 ' 112 113 test_expect_success 'status does not verbose without --verbose' ' 114 git status >actual && 115 test_grep ! "^diff --git" actual 116 ' 117 118 test_expect_success 'setup -v -v' ' 119 echo dirty >file 120 ' 121 122 for i in true 1 123 do 124 test_expect_success "commit.verbose=$i and --verbose omitted" " 125 git -c commit.verbose=$i commit --amend && 126 test_line_count = 1 out 127 " 128 done 129 130 for i in false -2 -1 0 131 do 132 test_expect_success "commit.verbose=$i and --verbose omitted" " 133 git -c commit.verbose=$i commit --amend && 134 test_line_count = 0 out 135 " 136 done 137 138 for i in 2 3 139 do 140 test_expect_success "commit.verbose=$i and --verbose omitted" " 141 git -c commit.verbose=$i commit --amend && 142 test_line_count = 2 out 143 " 144 done 145 146 for i in true false -2 -1 0 1 2 3 147 do 148 test_expect_success "commit.verbose=$i and --verbose" " 149 git -c commit.verbose=$i commit --amend --verbose && 150 test_line_count = 1 out 151 " 152 153 test_expect_success "commit.verbose=$i and --no-verbose" " 154 git -c commit.verbose=$i commit --amend --no-verbose && 155 test_line_count = 0 out 156 " 157 158 test_expect_success "commit.verbose=$i and -v -v" " 159 git -c commit.verbose=$i commit --amend -v -v && 160 test_line_count = 2 out 161 " 162 done 163 164 test_expect_success "status ignores commit.verbose=true" ' 165 git -c commit.verbose=true status >actual && 166 test_grep ! "^diff --git" actual 167 ' 168 169 test_done