# -p diff output and the 'Index:' line

9 messages from 2005-05-29 to 2005-05-30. Participants: Petr Baudis, Junio C Hamano, Sean, Thomas Glanzmann.
Thread: https://gitlist.dev/t/756

## Petr Baudis, 2005-05-29 07:15

Subject: -p diff output and the 'Index:' line
Message-ID: <20050529071520.GC1036@pasky.ji.cz>
URL: https://gitlist.dev/e/20050529071520.GC1036%40pasky.ji.cz

```
  Hello,

  so I've tried how would cg-diff output look like if I used the
git-diff -p argument, and I found that I miss the 'Index:' line.
Actually, what I really miss is the separator ==== line just below, but
it'd probably look weird without the 'Index:' line. I became used to the
separators and they enable me to quickly visually notice the files
boundary, which is more drudging if you have just the 'diff --git' line.

  What do you think? Would you hate it to show up in the diffs, or are
you ok with it?

  Thanks,

-- 
				Petr "Pasky" Baudis
Stuff: http://pasky.or.cz/
C++: an octopus made by nailing extra legs onto a dog. -- Steve Taylor

```

## Junio C Hamano, 2005-05-29 07:41

Subject: Re: -p diff output and the 'Index:' line
Message-ID: <7vd5raqy28.fsf@assigned-by-dhcp.cox.net>
URL: https://gitlist.dev/e/7vd5raqy28.fsf%40assigned-by-dhcp.cox.net
In-Reply-To: <20050529071520.GC1036@pasky.ji.cz>

```
>>>>> "PB" == Petr Baudis <pasky@ucw.cz> writes:

PB>   What do you think? Would you hate it to show up in the diffs, or are
PB> you ok with it?

I cannot tell if you are asking about cg-diff or changing the
built-in diff-* output.  The Subject: line suggests you are
talking about the latter, but if that is the case I have to
admit that I am not that sympathetic to Index: nor separator.

Like Linus, I do "/^diff --git .*" in my less sessions, which
gives a very nice highlighted separator line without wasting a
single line on the terminal.  If any of the readers on the list
didn't know about this trick (especially the trailing .* part),
please try it.  I'm certain everybody would love it.


```

## Sean, 2005-05-29 07:52

Subject: Re: -p diff output and the 'Index:' line
Message-ID: <2788.10.10.10.24.1117353158.squirrel@linux1>
URL: https://gitlist.dev/e/2788.10.10.10.24.1117353158.squirrel%40linux1
In-Reply-To: <7vd5raqy28.fsf@assigned-by-dhcp.cox.net>

```
On Sun, May 29, 2005 3:41 am, Junio C Hamano said:
>>>>>> "PB" == Petr Baudis <pasky@ucw.cz> writes:
>
> PB>   What do you think? Would you hate it to show up in the diffs, or are
> PB> you ok with it?
>
> I cannot tell if you are asking about cg-diff or changing the
> built-in diff-* output.  The Subject: line suggests you are
> talking about the latter, but if that is the case I have to
> admit that I am not that sympathetic to Index: nor separator.
>
> Like Linus, I do "/^diff --git .*" in my less sessions, which
> gives a very nice highlighted separator line without wasting a
> single line on the terminal.  If any of the readers on the list
> didn't know about this trick (especially the trailing .* part),
> please try it.  I'm certain everybody would love it.

It's good to know you can wrap this into a shell script too, which saves
you having to type the search string in "less" each time... something
like:

git-diff-tree "$@" | git-diff-helper | less -p "^diff --git .*"

Sean



```

## Petr Baudis, 2005-05-29 12:02

Subject: Re: -p diff output and the 'Index:' line
Message-ID: <20050529120248.GD1036@pasky.ji.cz>
URL: https://gitlist.dev/e/20050529120248.GD1036%40pasky.ji.cz
In-Reply-To: <7vd5raqy28.fsf@assigned-by-dhcp.cox.net>

```
Dear diary, on Sun, May 29, 2005 at 09:41:03AM CEST, I got a letter
where Junio C Hamano <junkio@cox.net> told me that...
> >>>>> "PB" == Petr Baudis <pasky@ucw.cz> writes:
> 
> PB>   What do you think? Would you hate it to show up in the diffs, or are
> PB> you ok with it?
> 
> I cannot tell if you are asking about cg-diff or changing the
> built-in diff-* output.  The Subject: line suggests you are
> talking about the latter, but if that is the case I have to
> admit that I am not that sympathetic to Index: nor separator.

Yes, I'm talking about the latter.

> Like Linus, I do "/^diff --git .*" in my less sessions, which
> gives a very nice highlighted separator line without wasting a
> single line on the terminal.  If any of the readers on the list
> didn't know about this trick (especially the trailing .* part),
> please try it.  I'm certain everybody would love it.

When I do just cg-diff to see what I changed I usually do not pipe it to
less, and typing that / stuff seems insane (although /^d.* could give a
good approximation). OTOH I think I'll go for the diff output
colorification (at the Cogito level), so the separator indeed isn't
strictly necessary. I can live without it. :-)

-- 
				Petr "Pasky" Baudis
Stuff: http://pasky.or.cz/
C++: an octopus made by nailing extra legs onto a dog. -- Steve Taylor

```

## Thomas Glanzmann, 2005-05-29 12:36

Subject: Re: -p diff output and the 'Index:' line
Message-ID: <20050529123624.GJ4881@cip.informatik.uni-erlangen.de>
URL: https://gitlist.dev/e/20050529123624.GJ4881%40cip.informatik.uni-erlangen.de
In-Reply-To: <2788.10.10.10.24.1117353158.squirrel@linux1>

```
Hello,
I actually use the following bash script to browse the diffs with
what-changed:

(faui03) [~/work/monitor] git-whatchanged -p | cdiff
...


# COLORDEFINITIONS
BLACK="[0;30m"
RED="[0;31m"
GREEN="[0;32m"
YELLO="[0;33m"
BLUE="[0;34m"
PURPLE="[0;35m"
CYAN="[0;36m"
WHITE="[0;37m"
END="[0m"
REVERSE="[7m"

cdiff()
{
	cat $1 | \
	sed -e " \
		s/^\(diff-tree\)\(.*\)/\1${RED}\2${END}/; \
	        s/^+.*/$RED&$END/;  \
		s/^-.*/$BLUE&$END/;  \
		s/^@.*/$GREEN&$END/;  \
		s/^Date.*/$RED&$END/;  \
		s/^Author.*/$RED&$END/; \
		" | less -R -i -p "^diff-tree"

		# This would highlight manpages but the last line clashes with cdiff
		# --tg 00:52 05-05-26
		#s/^[A-Z]\+[A-Z ]\+$/$RED&$END/; \
		#s/[A-Z]\+([0-9])/$RED&$END/g; \
		# s/\W--\?[0-9a-zA-Z=-]\+/$BLUE&$END/g; \
}

Gruesse,
	Thomas

```

## Junio C Hamano, 2005-05-29 18:04

Subject: Re: -p diff output and the 'Index:' line
Message-ID: <7vekbpq56r.fsf@assigned-by-dhcp.cox.net>
URL: https://gitlist.dev/e/7vekbpq56r.fsf%40assigned-by-dhcp.cox.net
In-Reply-To: <20050529120248.GD1036@pasky.ji.cz>

```
>>>>> "PB" == Petr Baudis <pasky@ucw.cz> writes:

>> Like Linus, I do "/^diff --git .*" in my less sessions, which
>> gives a very nice highlighted separator line without wasting a
>> single line on the terminal.  If any of the readers on the list
>> didn't know about this trick (especially the trailing .* part),
>> please try it.  I'm certain everybody would love it.

PB> When I do just cg-diff to see what I changed I usually do not pipe it to
PB> less, and typing that / stuff seems insane (although /^d.* could give a
PB> good approximation).

You said you do not do "less", so the following may not apply to
your usage, but I disagree your comment about "typing that /
stuff seems insane".  Sean's workaround to use "less -p '^diff
--git .*'" in a script, combined with typing 'n' in a "less"
session to find the next such line, would make it very pleasant
to use.

PB> OTOH I think I'll go for the diff output colorification (at
PB> the Cogito level), so the separator indeed isn't strictly
PB> necessary. I can live without it. :-)

When I want to make a customized diff output out of the "diff-*
-p' command, I find it a lot easier to use the GIT_EXTERNAL_DIFF
mechanism than parsing what comes out of "diff-* -p" and munging
it.  I am not _telling_, _ordering_, nor even _asking_ you to
use GIT_EXTERNAL_DIFF; just suggesting you to consider that as a
way to possibly make your implementation easier.  I'd start from
the supplied git-external-diff-script and go from there.


```

## Petr Baudis, 2005-05-29 19:03

Subject: Re: -p diff output and the 'Index:' line
Message-ID: <20050529190305.GP1036@pasky.ji.cz>
URL: https://gitlist.dev/e/20050529190305.GP1036%40pasky.ji.cz
In-Reply-To: <7vekbpq56r.fsf@assigned-by-dhcp.cox.net>

```
Dear diary, on Sun, May 29, 2005 at 08:04:44PM CEST, I got a letter
where Junio C Hamano <junkio@cox.net> told me that...
> You said you do not do "less", so the following may not apply to
> your usage, but I disagree your comment about "typing that /
> stuff seems insane".  Sean's workaround to use "less -p '^diff
> --git .*'" in a script, combined with typing 'n' in a "less"
> session to find the next such line, would make it very pleasant
> to use.

(As long as you don't want to search for something else. ;-)

But yes, I like the less -p hack.

> PB> OTOH I think I'll go for the diff output colorification (at
> PB> the Cogito level), so the separator indeed isn't strictly
> PB> necessary. I can live without it. :-)
> 
> When I want to make a customized diff output out of the "diff-*
> -p' command, I find it a lot easier to use the GIT_EXTERNAL_DIFF
> mechanism than parsing what comes out of "diff-* -p" and munging
> it.  I am not _telling_, _ordering_, nor even _asking_ you to
> use GIT_EXTERNAL_DIFF; just suggesting you to consider that as a
> way to possibly make your implementation easier.  I'd start from
> the supplied git-external-diff-script and go from there.

It's just something along the lines of "Me Og. Og sees /^+/. Og makes
the line green." written in gawk (actually I'm not sure if pure awk
wouldn't do, but I actually don't know the language), so I don't think
the external diff thing would've helped me with that in any way.

-- 
				Petr "Pasky" Baudis
Stuff: http://pasky.or.cz/
C++: an octopus made by nailing extra legs onto a dog. -- Steve Taylor

```

## Junio C Hamano, 2005-05-30 07:42

Subject: Re: -p diff output and the 'Index:' line
Message-ID: <7v7jhh6ty5.fsf@assigned-by-dhcp.cox.net>
URL: https://gitlist.dev/e/7v7jhh6ty5.fsf%40assigned-by-dhcp.cox.net
In-Reply-To: <20050529190305.GP1036@pasky.ji.cz>

```
>>>>> "PB" == Petr Baudis <pasky@ucw.cz> writes:

PB> It's just something along the lines of "Me Og. Og sees /^+/. Og makes
PB> the line green." written in gawk (actually I'm not sure if pure awk
PB> wouldn't do, but I actually don't know the language), so I don't think
PB> the external diff thing would've helped me with that in any way.

Ah, I see.  I thought you were talking about the Index: and
separator lines.  Colorizing diff/patch part, you need to parse
the diff output with sed/awk/perl and annotate it anyway, and it
does not matter if you annotate within GIT_EXTERNAL_DIFF or
outside.  I agree with you that using GIT_EXTERNAL_DIFF
mechanism would not help you here.





```

## Petr Baudis, 2005-05-30 08:30

Subject: Re: -p diff output and the 'Index:' line
Message-ID: <20050530083052.GC1036@pasky.ji.cz>
URL: https://gitlist.dev/e/20050530083052.GC1036%40pasky.ji.cz
In-Reply-To: <7v7jhh6ty5.fsf@assigned-by-dhcp.cox.net>

```
Dear diary, on Mon, May 30, 2005 at 09:42:26AM CEST, I got a letter
where Junio C Hamano <junkio@cox.net> told me that...
> >>>>> "PB" == Petr Baudis <pasky@ucw.cz> writes:
> 
> PB> It's just something along the lines of "Me Og. Og sees /^+/. Og makes
> PB> the line green." written in gawk (actually I'm not sure if pure awk
> PB> wouldn't do, but I actually don't know the language), so I don't think
> PB> the external diff thing would've helped me with that in any way.
> 
> Ah, I see.  I thought you were talking about the Index: and
> separator lines.  Colorizing diff/patch part, you need to parse
> the diff output with sed/awk/perl and annotate it anyway, and it
> does not matter if you annotate within GIT_EXTERNAL_DIFF or
> outside.  I agree with you that using GIT_EXTERNAL_DIFF
> mechanism would not help you here.

Well, I want to finally converge with the diff format to what git uses.
So I'm just colorizing the /^diff --git/ line with a unusually bright
color, which will hopefully make up for the Index: and separator lines.

-- 
				Petr "Pasky" Baudis
Stuff: http://pasky.or.cz/
C++: an octopus made by nailing extra legs onto a dog. -- Steve Taylor

```
