# [Question] How to parse range-diff output

4 messages from 2024-02-26 to 2024-02-29. Participants: ZheNing Hu, Kristoffer Haugsbakk, Junio C Hamano.
Thread: https://gitlist.dev/t/61006

## ZheNing Hu, 2024-02-26 07:25

Subject: [Question] How to parse range-diff output
Message-ID: <CAOLTT8SQyBSWC=aqB2SRYmp3kR6RZ+L_-9yckWQf-X9rbzeNBw@mail.gmail.com>
URL: https://gitlist.dev/e/CAOLTT8SQyBSWC%3DaqB2SRYmp3kR6RZ%2BL_-9yckWQf-X9rbzeNBw%40mail.gmail.com

```
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

```

## Kristoffer Haugsbakk, 2024-02-26 13:16

Subject: Re: [Question] How to parse range-diff output
Message-ID: <11783b8e-472d-4b75-bb48-88138daf16ae@app.fastmail.com>
URL: https://gitlist.dev/e/11783b8e-472d-4b75-bb48-88138daf16ae%40app.fastmail.com
In-Reply-To: <CAOLTT8SQyBSWC=aqB2SRYmp3kR6RZ+L_-9yckWQf-X9rbzeNBw@mail.gmail.com>

```
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.

-- 
Kristoffer Haugsbakk

```

## Junio C Hamano, 2024-02-26 16:16

Subject: Re: [Question] How to parse range-diff output
Message-ID: <xmqqmsrnfbfh.fsf@gitster.g>
URL: https://gitlist.dev/e/xmqqmsrnfbfh.fsf%40gitster.g
In-Reply-To: <11783b8e-472d-4b75-bb48-88138daf16ae@app.fastmail.com>

```
"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.


```

## ZheNing Hu, 2024-02-29 11:00

Subject: Re: [Question] How to parse range-diff output
Message-ID: <CAOLTT8Sn89Qq68YpTCsiK+_WAPdrsTN1xWxpkuEbhwBWpZgK=A@mail.gmail.com>
URL: https://gitlist.dev/e/CAOLTT8Sn89Qq68YpTCsiK%2B_WAPdrsTN1xWxpkuEbhwBWpZgK%3DA%40mail.gmail.com
In-Reply-To: <11783b8e-472d-4b75-bb48-88138daf16ae@app.fastmail.com>

```
Kristoffer Haugsbakk <code@khaugsbakk.name> 于2024年2月26日周一 21:16写道：
>
> 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.
>

It is very regrettable that some crucial metadata from the range-diff
patch cannot be extracted. I can only hope that future range-diff will have
the capability of being machine-readable. Thank you!

> --
> Kristoffer Haugsbakk

```
