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

Re: [PATCH 1/4] Improve message-id generation flow control for format-patch

From
Junio C Hamano <gitster@pobox.com>
Date
Feb 6, 2008, 20:31 UTC
Message-ID
<7vsl05vncj.fsf@gitster.siamese.dyndns.org>
In-Reply-To
<alpine.LNX.1.00.0802061140360.13593@iabervon.org>
Daniel Barkalow <barkalow@iabervon.org> writes:
Show 31 quoted lines
> Signed-off-by: Daniel Barkalow <barkalow@iabervon.org>
> ---
>  builtin-log.c |   29 ++++++++++++++---------------
>  1 files changed, 14 insertions(+), 15 deletions(-)
>
> diff --git a/builtin-log.c b/builtin-log.c
> index dcc9f81..1f74d66 100644
> --- a/builtin-log.c
> +++ b/builtin-log.c
> @@ -576,16 +576,19 @@ static void get_patch_ids(struct rev_info *rev, struct patch_ids *ids, const cha
>  	o2->flags = flags2;
>  }
>  
> -static void gen_message_id(char *dest, unsigned int length, char *base)
> +static void gen_message_id(struct rev_info *info, char *base)
>  {
>  	const char *committer = git_committer_info(IDENT_WARN_ON_NO_NAME);
>  	const char *email_start = strrchr(committer, '<');
>  	const char *email_end = strrchr(committer, '>');
> -	if(!email_start || !email_end || email_start > email_end - 1)
> +	struct strbuf buf;
> +	if (!email_start || !email_end || email_start > email_end - 1)
>  		die("Could not extract email from committer identity.");
> -	snprintf(dest, length, "%s.%lu.git.%.*s", base,
> -		 (unsigned long) time(NULL),
> -		 (int)(email_end - email_start - 1), email_start + 1);
> +	strbuf_init(&buf, 0);
> +	strbuf_addf(&buf, "%s.%lu.git.%.*s", base,
> +		    (unsigned long) time(NULL),
> +		    (int)(email_end - email_start - 1), email_start + 1);
> +	info->message_id = buf.buf;

I wonder how the rule established by b315c5c (strbuf change: be sure ->buf is never ever NULL) and at the beginning of strbuf.h applies here. I think the current implementation of strbuf happens to allow this, and it is very handy. Perhaps the rule stated there should be loosened and allow copying the buf away when you know you have stuff in there (i.e. ->buf != slopbuf). Pierre, what do you think?

What the patch does itself is much nicer than the original.
Previous: Daniel BarkalowNext: Pierre Habouzit
Message 2 of 7 in “Improve message-id generation flow control for format-patch”
  1. 1/4 Improve message-id generation flow control for format-patchDaniel Barkalow, Feb 6, 2008
  2. Junio C HamanoFeb 6, 2008
  3. Pierre HabouzitFeb 6, 2008
  4. Daniel BarkalowFeb 6, 2008
  5. Pierre HabouzitFeb 6, 2008
  6. Pierre HabouzitFeb 6, 2008
  7. Daniel BarkalowFeb 6, 2008

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.