From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS31976 209.132.180.0/23 X-Spam-Status: No, score=-2.8 required=3.0 tests=AWL,BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_HI,T_RP_MATCHES_RCVD shortcircuit=no autolearn=no autolearn_force=no version=3.4.0 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by dcvr.yhbt.net (Postfix) with ESMTP id 7E4001F404 for ; Tue, 16 Jan 2018 13:48:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751885AbeAPNsk (ORCPT ); Tue, 16 Jan 2018 08:48:40 -0500 Received: from mail-qt0-f182.google.com ([209.85.216.182]:45795 "EHLO mail-qt0-f182.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751876AbeAPNsj (ORCPT ); Tue, 16 Jan 2018 08:48:39 -0500 Received: by mail-qt0-f182.google.com with SMTP id x27so10203021qtm.12 for ; Tue, 16 Jan 2018 05:48:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding:content-language; bh=+sEhi4sjAx8TCUQNt0nI3NexSrvLH/wIUg8T7AjNoYc=; b=KSaaTVrjQoOfMBaw5lK+MzTy9Wj0fmNqDvpSCsQDi86JEMmQcw83QC3kenuA4x5I1l sYVpcYnuwa+680hWqLQ0qKLvAAFg+9RtboK3EW5Cx8BKH9lakxnFVirJ3lHxA2LQKN1O HfDrqg/H58dlw9z7uyYrbLro/Ti5/nFtCfjYRtSQQubI9/u7vE9iK1EtQFpg/IfbTfej 6DOf1s8QFp4sJ5asnYl96ZmUr6MHtiNy6692sN2l2atzi7nSEgBZ3CE9ee87QtultM3j 3pMo5dl2ytqLk7E0hzvgkMXzekif4gxadnOAol6sdILosuMfsyzgr3d10BarIeMSgrI7 QhRA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=+sEhi4sjAx8TCUQNt0nI3NexSrvLH/wIUg8T7AjNoYc=; b=ma5YPcKzGCwTjRaGg0/BvsAXQp6Q6ILsYCjQvi/gIRiIxMSOwP8f/Dszc++6d0lUik LlDQheqisv2blrpeSgny70g7W8WJjVwTe8HsPqh0b88OAai4Eunr2oxLsUVz3RqFEg7v R3Y4Y06tUN93KE5pwKGcTySiawLiTisM+hUbeugqlGfrgFNa44/O6fCJ4/BAAy0KsRM0 dINbFWpxQuznzIY8Q5o9shqj0+pYTT5HvWbjOUKYb2k/gVETZf7M0yrNJoVZVFy1dq+t /E/PbOp2K/3265ZyXUIOGsxtYZKnSNJ4wGKAO2u8eTRp4ilRoQYrLGRwD6m5QuYqF7oO Cfwg== X-Gm-Message-State: AKwxyte9LsH6PJjxoJNTi0yt5RpuNB/lLU8ikcONB1CX3zxYyxRDdO+j lqKAMMGucf2uUTDpfQ9xnO0= X-Google-Smtp-Source: ACJfBouJPLgJw8htVmpCRHljjcwoL9uk8UdKbASOnjr4XvLj+IAcd88agVQLuTPd+YlMLdEEKeVpKg== X-Received: by 10.237.37.112 with SMTP id w45mr24764980qtc.242.1516110518062; Tue, 16 Jan 2018 05:48:38 -0800 (PST) Received: from ?IPv6:2001:4898:6808:13e:c4e6:7a22:56f1:df04? ([2001:4898:8010:0:ae1c:7a22:56f1:df04]) by smtp.gmail.com with ESMTPSA id q32sm1343859qkq.71.2018.01.16.05.48.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 16 Jan 2018 05:48:36 -0800 (PST) Subject: Re: [PATCH] describe: use strbuf_add_unique_abbrev() for adding short hashes To: =?UTF-8?Q?Ren=c3=a9_Scharfe?= , Git List Cc: Junio C Hamano , Stefan Beller References: <422ae05b-6541-38f3-7638-4bee1b766d91@web.de> From: Derrick Stolee Message-ID: <6f91c34e-3ab0-30fc-4678-4424ac350cd9@gmail.com> Date: Tue, 16 Jan 2018 08:48:35 -0500 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.5.2 MIME-Version: 1.0 In-Reply-To: <422ae05b-6541-38f3-7638-4bee1b766d91@web.de> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org 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 > --- > 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