git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Derrick Stolee <stolee@gmail.com>
To: "René Scharfe" <l.s.r@web.de>, "Git List" <git@vger.kernel.org>
Cc: Junio C Hamano <gitster@pobox.com>, Stefan Beller <sbeller@google.com>
Subject: Re: [PATCH] describe: use strbuf_add_unique_abbrev() for adding short hashes
Date: Tue, 16 Jan 2018 08:48:35 -0500	[thread overview]
Message-ID: <6f91c34e-3ab0-30fc-4678-4424ac350cd9@gmail.com> (raw)
In-Reply-To: <422ae05b-6541-38f3-7638-4bee1b766d91@web.de>

On 1/15/2018 12:10 PM, René Scharfe wrote:
> Call strbuf_add_unique_abbrev() to add an abbreviated hash to a strbuf
> instead of taking a detour through find_unique_abbrev() and its static
> buffer.  This is shorter and a bit more efficient.
>
> Patch generated by Coccinelle (and contrib/coccinelle/strbuf.cocci).
>
> Signed-off-by: Rene Scharfe <l.s.r@web.de>
> ---
> The changed line was added by 4dbc59a4cc (builtin/describe.c: factor
> out describe_commit).
>
> "make coccicheck" doesn't propose any other changes for current master.
>
>   builtin/describe.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/builtin/describe.c b/builtin/describe.c
> index 3b0b204b1e..21e37f5dae 100644
> --- a/builtin/describe.c
> +++ b/builtin/describe.c
> @@ -380,7 +380,7 @@ static void describe_commit(struct object_id *oid, struct strbuf *dst)
>   	if (!match_cnt) {
>   		struct object_id *cmit_oid = &cmit->object.oid;
>   		if (always) {
> -			strbuf_addstr(dst, find_unique_abbrev(cmit_oid->hash, abbrev));
> +			strbuf_add_unique_abbrev(dst, cmit_oid->hash, abbrev);
>   			if (suffix)
>   				strbuf_addstr(dst, suffix);
>   			return;

René,

Thanks for this cleanup! I just learned about strbuf_add_unique_abbrev() 
and like that it uses the reentrant find_unique_abbrev_r() instead.

Looks good to me.
-Stolee


  reply	other threads:[~2018-01-16 13:48 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-15 17:10 [PATCH] describe: use strbuf_add_unique_abbrev() for adding short hashes René Scharfe
2018-01-16 13:48 ` Derrick Stolee [this message]
2018-01-16 17:11 ` SZEDER Gábor
2018-01-18 21:40   ` René Scharfe
2018-01-18 22:40     ` SZEDER Gábor
2018-01-18 23:02       ` Lars Schneider
2018-01-19 17:53       ` René Scharfe
2018-01-22 17:50         ` [PATCH] Use MOVE_ARRAY SZEDER Gábor
2018-01-22 22:44           ` Jeff King
2018-01-22 23:26             ` Junio C Hamano
2018-01-22 23:34               ` Jeff King

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=6f91c34e-3ab0-30fc-4678-4424ac350cd9@gmail.com \
    --to=stolee@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=l.s.r@web.de \
    --cc=sbeller@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).