Re: [PATCH v3 09/20] range-diff: adjust the output of the commit pairs
- From
Johannes Schindelin <johannes.schindelin@gmx.de>
- Date
- Jul 17, 2018, 16:24 UTC
- Message-ID
- <nycvar.QRO.7.76.6.1807171306380.71@tvgsbejvaqbjf.bet>
- In-Reply-To
- <CAPig+cTnRi=HuyZy+bMKeU9qutZb3K5C4qTb7gCQz7GyGN=FRw@mail.gmail.com>
Hi Eric,
On Mon, 16 Jul 2018, Eric Sunshine wrote:
Show 26 quoted lines
> On Tue, Jul 3, 2018 at 7:26 AM Johannes Schindelin via GitGitGadget
> <gitgitgadget@gmail.com> 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 <johannes.schindelin@gmx.de>
> > ---
> > 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 thanCan we *please* stop calling it "re-roll"? Thanks.
(Or are you really "never gonna give you up, never gonna let you down"?)
Show 5 quoted lines
> 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.
Show 9 quoted lines
> > > + 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