git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: "Kristoffer Haugsbakk" <code@khaugsbakk.name>
Cc: "ZheNing Hu" <adlternative@gmail.com>,
	 "Christian Couder" <christian.couder@gmail.com>,
	 "Johannes Schindelin" <Johannes.Schindelin@gmx.de>,
	 "Git List" <git@vger.kernel.org>
Subject: Re: [Question] How to parse range-diff output
Date: Mon, 26 Feb 2024 08:16:34 -0800	[thread overview]
Message-ID: <xmqqmsrnfbfh.fsf@gitster.g> (raw)
In-Reply-To: <11783b8e-472d-4b75-bb48-88138daf16ae@app.fastmail.com> (Kristoffer Haugsbakk's message of "Mon, 26 Feb 2024 14:16:06 +0100")

"Kristoffer Haugsbakk" <code@khaugsbakk.name> writes:

> On Mon, Feb 26, 2024, at 08:25, ZheNing Hu wrote:
>> Hi,
>>
>> I am currently looking to implement a service that provides a version
>> range comparison based on git range-diff. I can easily parse out
>> commit pair headers like "3: 0bf6289 ! 3: a076e88 dev5," but I am
>> unsure how to parse the details in the subsequent diff patch body.
>>
>> It is not a standard diff output where one can parse out the filename
>> from the diff header, It should be called a diff of diffs. We can see
>> various headers with file names such as "@@ File1 (new)", "## File2
>> (new) ##", or "@@ File3: function3" in different formats. This is
>> confusing. How should we correctly parse a range-diff patch, and do
>> you have any good suggestions?
>>
>> Thanks for any help.
>> --
>> ZheNing Hu
>
> Hi
>
> Note that “Output Stability” says that this output is not meant to be
> machine-readable. It’s for human consumption. It’s not textually stable.
>
> So a new version of Git might break your implementation without warning.

Good point.

In fact, those "##" things came long after the command was
introduced for exactly the purpose of helping human users to locate
which part of a "diff" the "diff of diff" is talking about, and the
output from the command has been unstable for the exact reason.


  reply	other threads:[~2024-02-26 16:16 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-26  7:25 [Question] How to parse range-diff output ZheNing Hu
2024-02-26 13:16 ` Kristoffer Haugsbakk
2024-02-26 16:16   ` Junio C Hamano [this message]
2024-02-29 11:00   ` ZheNing Hu

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=xmqqmsrnfbfh.fsf@gitster.g \
    --to=gitster@pobox.com \
    --cc=Johannes.Schindelin@gmx.de \
    --cc=adlternative@gmail.com \
    --cc=christian.couder@gmail.com \
    --cc=code@khaugsbakk.name \
    --cc=git@vger.kernel.org \
    /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).