Re: [RFC PATCH 2/5] format-patch: add --range-diff option to embed diff in cover letter
- From
Johannes Schindelin <johannes.schindelin@gmx.de>
- Date
- Jul 26, 2018, 10:55 UTC
- Message-ID
- <nycvar.QRO.7.76.6.1807261249490.71@tvgsbejvaqbjf.bet>
- In-Reply-To
- <CAPig+cTKGd8N78XvW-rmBEZC7ykcJsE+na1V_vCVXTUhGrFe4Q@mail.gmail.com>
Hi Eric,
On Tue, 17 Jul 2018, Eric Sunshine wrote:
Show 14 quoted lines
> On Tue, Jul 17, 2018 at 6:31 AM Johannes Schindelin
> <Johannes.Schindelin@gmx.de> wrote:
> > On Wed, 30 May 2018, Eric Sunshine wrote:
>
> > > + if (range_diff) {
> > > + struct argv_array ranges = ARGV_ARRAY_INIT;
> > > + infer_diff_ranges(&ranges, range_diff, head);
> > > + if (get_range_diff(&diff, &ranges))
> > > + die(_("failed to generate range-diff"));
> >
> > BTW I like to have an extra space in front of all the range-diff lines, to
> > make it easier to discern them from the rest.
>
> I'm not sure what you mean. Perhaps I'm misreading your comment.Sorry, I was really unclear.
In the cover letters sent out by GitGitGadget (or earlier, my mail-patch-series.sh command), I took pains to indent the entire range-diff (or interdiff) with a single space. That is, the footer "Range-diff vs v<n>:" is not indented at all, but all subsequent lines of the range-diff have a leading space.
The original reason was to stop confusing `git apply` when sending an interdiff as part of a single patch without a cover letter (in which case mail-patch-series.sh inserted the interdiff below the `---` marker, and the interdiff would have looked like the start of the real diff otherwise).
In the meantime, I got used to this indentation so much that I do not want to miss it, it is a relatively easy and intuitive visual marker.
This, however, will be harder to achieve now that you are using the libified range-diff.
Show 9 quoted lines
> > > @@ -1438,6 +1480,7 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix) > > > + const char *range_diff = NULL; > > > > Maybe `range_diff_opt`? It's not exactly the range diff that is contained > > in this variable. > > I could, though I was trying to keep it shorter rather than longer. > This is still the same in the re-roll, but I can rename it if you > insist.
I think it will confuse me in the future if I read `range_diff` and even the data type suggests that it could hold the output of a `git range-diff <options>` run.
So I would like to insist.
Show 20 quoted lines
> > > +format_patch () {
> > > + title=$1 &&
> > > + range=$2 &&
> > > + test_expect_success "format-patch --range-diff ($title)" '
> > > + git format-patch --stdout --cover-letter --range-diff=$range \
> > > + master..unmodified >actual &&
> > > + grep "= 1: .* s/5/A" actual &&
> > > + grep "= 2: .* s/4/A" actual &&
> > > + grep "= 3: .* s/11/B" actual &&
> > > + grep "= 4: .* s/12/B" actual
> >
> > I guess this might make sense if `format_patch` was not a function, but it
> > is specifically marked as a function... so... shouldn't these `grep`s also
> > be using function parameters?
>
> A later patch adds a second test which specifies the same ranges but
> in a different way, so the result will be the same, hence the
> hard-coded grep'ing. The function avoids repetition across the two
> tests. I suppose I could do this a bit differently, though, to avoid
> pretending it's a general-purpose function.If you can think of a way that would make this easier to read for, say, myself if I ever find myself debugging a regression caught by this test, I would appreciate that.
Ciao, Dscho