git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH v2] Allow custom "comment char"

From
Junio C Hamano <gitster@pobox.com>
Date
Jan 16, 2013, 20:30 UTC
Message-ID
<7vip6wx440.fsf@alter.siamese.dyndns.org>
In-Reply-To
<1358363928-16729-1-git-send-email-ralf.thielow@gmail.com>
Ralf Thielow <ralf.thielow@gmail.com> writes:
Show 34 quoted lines
> From: Junio C Hamano <gitster@pobox.com>
>
> 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.
>
> Signed-off-by: Junio C Hamano <gitster@pobox.com>
> Signed-off-by: Ralf Thielow <ralf.thielow@gmail.com>
> ---
> Junio, thanks for the code in your reply to the
> first version. It works very well and looks nice.
> I was also unhappy about this "\n%c\n" thing and
> pretty unsure with the code in "git-submodule.sh".
> But with this, it looks good to me. Thanks.
>
> Changes in v2:
> - extend "git stripspace" with an option to make
>   it's input being converted to commented lines
> - teach git-submodule.sh using this
> - rename strbuf_commented_addstr to strbuf_add_commented_lines
>   and improve it's design

Oh, I love it when something like this happens. Throw a "perhaps along these lines" patch and then a finished product that fills the gaps I didn't bother to fill magically appears, even with tests and updates to comments and documentation.

What good things did I do recently to deserve such a luck? ;-)
Show 12 quoted lines
> @@ -66,21 +67,52 @@ void stripspace(struct strbuf *sb, int skip_comments)
>  	strbuf_setlen(sb, j);
>  }
>  
> +static void comment_lines(struct strbuf *buf)
> +{
> +	char *msg;
> +	size_t len;
> +
> +	msg = strbuf_detach(buf, &len);
> +	strbuf_add_commented_lines(buf, msg, len);
> +}

This leaks msg (inherited from my "perhaps along these lines" patch). I think I can just add free(msg) at the end.

> +	if (strip_comments || mode == COMMENT_LINES)
> +		git_config(git_default_config, NULL);

Nice spotting. The "along these lines" patch broke "stripspace -s" under custom comment line char; this fixes it.

Thanks.
Previous: Ralf ThielowNext: Jens Lehmann
Message 14 of 18 in “commit: make default of "cleanup" option configurable”
  1. commit: make default of "cleanup" option configurableRalf Thielow, Jan 8, 2013
  2. Junio C HamanoJan 8, 2013
  3. Jonathan NiederJan 9, 2013
  4. Ralf ThielowJan 9, 2013
  5. Jonathan NiederJan 9, 2013
  6. Junio C HamanoJan 9, 2013
  7. Junio C HamanoJan 9, 2013
  8. Re* [PATCH] commit: make default of "cleanup" option configurableJunio C Hamano, Jan 10, 2013
  9. Allow custom "comment char"Ralf Thielow, Jan 15, 2013
  10. Junio C HamanoJan 15, 2013
  11. Junio C HamanoJan 16, 2013
  12. Ralf ThielowJan 16, 2013
  13. Allow custom "comment char"Ralf Thielow, Jan 16, 2013
  14. Junio C HamanoJan 16, 2013
  15. Jens LehmannJan 16, 2013
  16. [PATCHv2] commit: make default of "cleanup" option configurableRalf Thielow, Jan 9, 2013
  17. Junio C HamanoJan 10, 2013
  18. [PATCHv3] commit: make default of "cleanup" option configurableRalf Thielow, Jan 10, 2013

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.