Allow custom "comment char"
Some users do want to write a line that begin with a pound sign, #, in their commit log message. Many tracking system recognise a token of #<bugid> form, for example. The support we offer these use cases is not very friendly to the end users. They have a choice between - Don't do it. Avoid such a line by rewrapping or indenting; and - Use --cleanup=whitespace but remove all the hint lines we add. Give them a way to set a custom comment char, e.g. $ git -c core.commentchar="%" commit so that they do not have to do either of the two workarounds. [jc: although I started the topic, all the tests and documentation updates, many of the call sites of the new strbuf_add_commented_*() functions, and the change to git-submodule.sh scripted Porcelain are from Ralf.] Signed-off-by: Junio C Hamano <gitster@pobox.com> Signed-off-by: Ralf Thielow <ralf.thielow@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
@ -246,19 +246,13 @@ static int do_sign(struct strbuf *buffer)
|
||||
}
|
||||
|
||||
static const char tag_template[] =
|
||||
N_("\n"
|
||||
"#\n"
|
||||
"# Write a tag message\n"
|
||||
"# Lines starting with '#' will be ignored.\n"
|
||||
"#\n");
|
||||
N_("\nWrite a tag message\n"
|
||||
"Lines starting with '%c' will be ignored.\n");
|
||||
|
||||
static const char tag_template_nocleanup[] =
|
||||
N_("\n"
|
||||
"#\n"
|
||||
"# Write a tag message\n"
|
||||
"# Lines starting with '#' will be kept; you may remove them"
|
||||
" yourself if you want to.\n"
|
||||
"#\n");
|
||||
N_("\nWrite a tag message\n"
|
||||
"Lines starting with '%c' will be kept; you may remove them"
|
||||
" yourself if you want to.\n");
|
||||
|
||||
static int git_tag_config(const char *var, const char *value, void *cb)
|
||||
{
|
||||
@ -346,14 +340,18 @@ static void create_tag(const unsigned char *object, const char *tag,
|
||||
if (fd < 0)
|
||||
die_errno(_("could not create file '%s'"), path);
|
||||
|
||||
if (!is_null_sha1(prev))
|
||||
if (!is_null_sha1(prev)) {
|
||||
write_tag_body(fd, prev);
|
||||
else if (opt->cleanup_mode == CLEANUP_ALL)
|
||||
write_or_die(fd, _(tag_template),
|
||||
strlen(_(tag_template)));
|
||||
else
|
||||
write_or_die(fd, _(tag_template_nocleanup),
|
||||
strlen(_(tag_template_nocleanup)));
|
||||
} else {
|
||||
struct strbuf buf = STRBUF_INIT;
|
||||
strbuf_addch(&buf, '\n');
|
||||
if (opt->cleanup_mode == CLEANUP_ALL)
|
||||
strbuf_commented_addf(&buf, _(tag_template), comment_line_char);
|
||||
else
|
||||
strbuf_commented_addf(&buf, _(tag_template_nocleanup), comment_line_char);
|
||||
write_or_die(fd, buf.buf, buf.len);
|
||||
strbuf_release(&buf);
|
||||
}
|
||||
close(fd);
|
||||
|
||||
if (launch_editor(path, buf, NULL)) {
|
||||
|
Reference in New Issue
Block a user