From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS31976 209.132.180.0/23 X-Spam-Status: No, score=-3.3 required=3.0 tests=AWL,BAYES_00, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI shortcircuit=no autolearn=ham autolearn_force=no version=3.4.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by dcvr.yhbt.net (Postfix) with ESMTP id 7C46D1F597 for ; Tue, 17 Jul 2018 16:24:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729669AbeGQQ6J (ORCPT ); Tue, 17 Jul 2018 12:58:09 -0400 Received: from mout.gmx.net ([212.227.15.19]:45151 "EHLO mout.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729641AbeGQQ6J (ORCPT ); Tue, 17 Jul 2018 12:58:09 -0400 Received: from [192.168.0.129] ([37.201.195.94]) by mail.gmx.com (mrgmx002 [212.227.17.190]) with ESMTPSA (Nemesis) id 0Lp3x6-1gI5O31LcK-00er2S; Tue, 17 Jul 2018 18:24:35 +0200 Date: Tue, 17 Jul 2018 18:24:33 +0200 (DST) From: Johannes Schindelin X-X-Sender: virtualbox@gitforwindows.org To: Eric Sunshine cc: gitgitgadget@gmail.com, Git List , Junio C Hamano Subject: Re: [PATCH v3 09/20] range-diff: adjust the output of the commit pairs In-Reply-To: Message-ID: References: <6b31cbf72c4752771965de333b3cb6e82cf90b2b.1530617166.git.gitgitgadget@gmail.com> User-Agent: Alpine 2.21.1 (DEB 209 2017-03-23) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Provags-ID: V03:K1:gTrVxZCDRKm7Qoz/L7VwP7pDMZMPhd+AfS1uCzjof+dk45CqqIY S5ANWSOc6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precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Hi Eric, On Mon, 16 Jul 2018, Eric Sunshine wrote: > On Tue, Jul 3, 2018 at 7:26 AM Johannes Schindelin via GitGitGadget > wrote: > > This change brings `git range-diff` yet another step closer to > > feature parity with tbdiff: it now shows the oneline, too, and indicates > > with `=` when the commits have identical diffs. > > > > Signed-off-by: Johannes Schindelin > > --- > > diff --git a/range-diff.c b/range-diff.c > > @@ -251,9 +253,57 @@ static void get_correspondences(struct string_list *a, struct string_list *b, > > +static void output_pair_header(struct strbuf *buf, > > + struct patch_util *a_util, > > + struct patch_util *b_util) > > { > > - return find_unique_abbrev(&util->oid, DEFAULT_ABBREV); > > + static char *dashes; > > + struct object_id *oid = a_util ? &a_util->oid : &b_util->oid; > > + struct commit *commit; > > + > > + if (!dashes) { > > + char *p; > > + > > + dashes = xstrdup(find_unique_abbrev(oid, DEFAULT_ABBREV)); > > It's nice to see that the bulk of the range-diff functionality has > been libified in this re-roll (residing in range-diff.c rather than Can we *please* stop calling it "re-roll"? Thanks. (Or are you really "never gonna give you up, never gonna let you down"?) > builtin/range-diff.c as in earlier versions), so it's somewhat > surprising to see libified code holding onto the 'dashes' buffer like > this in a static variable. An alternative would have been for the > caller to pass in the same buffer to output_pair_header() for re-use, > and then dispose of it at the end of processing. Sure, to be honest, I had completely forgotten about what I did there, and had to read up on it to fix it. > > > + for (p = dashes; *p; p++) > > + *p = '-'; > > + } > > + > > + strbuf_reset(buf); > > ...much like 'buf' is allocated by the caller, passed in and re-used > for each invocation, then released by the caller at the end. Yep, I now pass in another strbuf, `dashes`. Thanks, Dscho