From: Junio C Hamano <gitster@pobox.com>
To: Patrick Steinhardt <ps@pks.im>
Cc: git@vger.kernel.org
Subject: Re: [PATCH 2/2] format-patch: move range/inter diff at the end of a single patch output
Date: Fri, 24 May 2024 14:46:43 -0700 [thread overview]
Message-ID: <xmqqo78ukhmk.fsf@gitster.g> (raw)
In-Reply-To: <ZlB2g5bTuBFz5m5_@tanuki> (Patrick Steinhardt's message of "Fri, 24 May 2024 13:14:11 +0200")
Patrick Steinhardt <ps@pks.im> writes:
> On Thu, May 23, 2024 at 03:50:07PM -0700, Junio C Hamano wrote:
> [snip]
>> @@ -1176,6 +1172,9 @@ int log_tree_commit(struct rev_info *opt, struct commit *commit)
>> opt->loginfo = NULL;
>> maybe_flush_or_die(opt->diffopt.file, "stdout");
>> opt->diffopt.no_free = no_free;
>> + if (shown)
>> + show_diff_of_diff(opt);
>
> Shouldn't we write the range-diff before `maybe_flush_or_die()`?
Hmph, perhaps. That would catch errors from write done in the
show_diff_of_diff() helper.
>> +
>> + # remove up to the last "patch" output line,
>> + # and remove everything below the signature mark.
>> + sed -e "1,/^+fleep\$/d" -e "/^-- /,\$d" 0001-fleep.patch >actual &&
>> +
>> + # fabricate Interdiff output.
>> + git diff boop~2 boop >inter &&
>> + {
>> + echo "Interdiff:" &&
>> + sed -e "s/^/ /" inter
>> + } >expect &&
>> test_cmp expect actual
>> '
>
> Do we also want to have a test that demonstrates the new behaviour for
> range-diffs?
I dunno. From the whitebox point of view I know it appears at the
same place, so it does not matter all that much.
> I also think that there's a bug here. The output from the above command
> is:
> ...
> --- a/blorp
> +++ b/blorp
> @@ -1 +1 @@
> -fnorp
> +fleep
> Interdiff against v1:
> diff --git a/blorp b/blorp
> ...
>
> The diff is before the separator for the signature, and there is no
> clear delimiter between the actual diff and the interdiff.
Earlier Eric expressed concern about writing this out _after_ the
mail signature mark "-- ", so the output deliberately goes before
it. There is no need for any marker after the last line of the
patch. "Interdiff against ..." is a clear enough delimiter.
FWIW, the parsing of patches has always paid attention to the
lengths recorded in @@ ... @@ hunk headers, and the parser notices
where the run of ("diff --git a/... b/..." followed by a patch) ends
and stops without problems. On the other hand, if you remove the
line "+fleep" in the above example and try to feed it to "git
apply", it would correctly notice that it failed to see the expected
one line of postimage and complains (because it sees "Interdiff
against..." when it expects to see a line that begins with a plus).
So, I do not see any problem with the output from this cocde at all.
Thanks for careful reading.
next prev parent reply other threads:[~2024-05-24 21:46 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-23 22:50 [PATCH 0/2] give range-diff at the end of single patch output Junio C Hamano
2024-05-23 22:50 ` [PATCH 1/2] show_log: factor out interdiff/range-diff generation Junio C Hamano
2024-05-23 22:50 ` [PATCH 2/2] format-patch: move range/inter diff at the end of a single patch output Junio C Hamano
2024-05-24 11:14 ` Patrick Steinhardt
2024-05-24 21:46 ` Junio C Hamano [this message]
2024-05-27 5:19 ` Patrick Steinhardt
2024-05-27 12:59 ` Dragan Simic
2024-05-27 17:43 ` Junio C Hamano
2024-05-28 13:27 ` Patrick Steinhardt
2024-05-28 16:50 ` Junio C Hamano
2024-05-29 5:33 ` Patrick Steinhardt
2024-05-29 14:29 ` Junio C Hamano
2024-05-30 20:05 ` Dragan Simic
2024-05-24 23:02 ` [PATCH v2 " Junio C Hamano
2024-05-23 23:22 ` [PATCH 0/2] give range-diff at the end of " Dragan Simic
2024-05-23 23:25 ` Junio C Hamano
2024-05-23 23:35 ` Dragan Simic
2024-05-24 3:56 ` Junio C Hamano
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xmqqo78ukhmk.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=ps@pks.im \
/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.
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 NNTP newsgroup(s).