зеркало из https://github.com/microsoft/git.git
Merge branch 'bc/commit-complete-lines-given-via-m-option'
'git commit -m "$str"' when $str was already terminated with a LF now avoids adding an extra LF to the message. * bc/commit-complete-lines-given-via-m-option: Documentation/git-commit.txt: rework the --cleanup section git-commit: only append a newline to -m mesg if necessary t7502: demonstrate breakage with a commit message with trailing newlines t/t7502: compare entire commit message with what was expected
This commit is contained in:
Коммит
54797b98b8
|
@ -172,16 +172,25 @@ OPTIONS
|
|||
linkgit:git-commit-tree[1].
|
||||
|
||||
--cleanup=<mode>::
|
||||
This option sets how the commit message is cleaned up.
|
||||
The '<mode>' can be one of 'verbatim', 'whitespace', 'strip',
|
||||
and 'default'. The 'default' mode will strip leading and
|
||||
trailing empty lines and #commentary from the commit message
|
||||
only if the message is to be edited. Otherwise only whitespace
|
||||
removed. The 'verbatim' mode does not change message at all,
|
||||
'whitespace' removes just leading/trailing whitespace lines
|
||||
and 'strip' removes both whitespace and commentary. The default
|
||||
can be changed by the 'commit.cleanup' configuration variable
|
||||
(see linkgit:git-config[1]).
|
||||
This option determines how the supplied commit message should be
|
||||
cleaned up before committing. The '<mode>' can be `strip`,
|
||||
`whitespace`, `verbatim`, or `default`.
|
||||
+
|
||||
--
|
||||
strip::
|
||||
Strip leading and trailing empty lines, trailing whitespace, and
|
||||
#commentary and collapse consecutive empty lines.
|
||||
whitespace::
|
||||
Same as `strip` except #commentary is not removed.
|
||||
verbatim::
|
||||
Do not change the message at all.
|
||||
default::
|
||||
Same as `strip` if the message is to be edited.
|
||||
Otherwise `whitespace`.
|
||||
--
|
||||
+
|
||||
The default can be changed by the 'commit.cleanup' configuration
|
||||
variable (see linkgit:git-config[1]).
|
||||
|
||||
-e::
|
||||
--edit::
|
||||
|
|
|
@ -124,8 +124,10 @@ static int opt_parse_m(const struct option *opt, const char *arg, int unset)
|
|||
if (unset)
|
||||
strbuf_setlen(buf, 0);
|
||||
else {
|
||||
if (buf->len)
|
||||
strbuf_addch(buf, '\n');
|
||||
strbuf_addstr(buf, arg);
|
||||
strbuf_addstr(buf, "\n\n");
|
||||
strbuf_complete_line(buf);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -177,12 +177,20 @@ test_expect_success 'verbose respects diff config' '
|
|||
git config --unset color.diff
|
||||
'
|
||||
|
||||
mesg_with_comment_and_newlines='
|
||||
# text
|
||||
|
||||
'
|
||||
|
||||
test_expect_success 'prepare file with comment line and trailing newlines' '
|
||||
printf "%s" "$mesg_with_comment_and_newlines" >expect
|
||||
'
|
||||
|
||||
test_expect_success 'cleanup commit messages (verbatim option,-t)' '
|
||||
|
||||
echo >>negative &&
|
||||
{ echo;echo "# text";echo; } >expect &&
|
||||
git commit --cleanup=verbatim -t expect -a &&
|
||||
git cat-file -p HEAD |sed -e "1,/^\$/d" |head -n 3 >actual &&
|
||||
git commit --cleanup=verbatim --no-status -t expect -a &&
|
||||
git cat-file -p HEAD |sed -e "1,/^\$/d" >actual &&
|
||||
test_cmp expect actual
|
||||
|
||||
'
|
||||
|
@ -199,7 +207,7 @@ test_expect_success 'cleanup commit messages (verbatim option,-F)' '
|
|||
test_expect_success 'cleanup commit messages (verbatim option,-m)' '
|
||||
|
||||
echo >>negative &&
|
||||
git commit --cleanup=verbatim -m "$(cat expect)" -a &&
|
||||
git commit --cleanup=verbatim -m "$mesg_with_comment_and_newlines" -a &&
|
||||
git cat-file -p HEAD |sed -e "1,/^\$/d">actual &&
|
||||
test_cmp expect actual
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче