threads / discuss / 756

-p diff output and the 'Index:' line

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

## tl;dr

9 messages between May 29, 2005 and May 30, 2005.

replies: 8people: 4as markdown or json

Petr Baudis· May 29, 2005, 07:15 UTC · lore
  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· May 29, 2005, 07:41 UTC · re: Petr Baudis · lore

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

>>>>> "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· May 29, 2005, 07:52 UTC · re: Junio C Hamano · lore

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

On Sun, May 29, 2005 3:41 am, Junio C Hamano said:
Show 15 quoted lines
>>>>>> "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
Thomas Glanzmann· May 29, 2005, 12:36 UTC · re: Sean · lore

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

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

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

# COLORDEFINITIONS BLACK="" RED="" GREEN="" YELLO="" BLUE="" PURPLE="" CYAN="" WHITE="" END="" REVERSE=""

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
Petr Baudis· May 29, 2005, 12:02 UTC · re: Junio C Hamano · lore

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

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

Show 9 quoted lines
> >>>>> "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.
Show 5 quoted lines
> 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
Junio C Hamano· May 29, 2005, 18:04 UTC · re: Petr Baudis · lore

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

>>>>> "PB" == Petr Baudis <pasky@ucw.cz> writes:
Show 5 quoted lines
>> 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· May 29, 2005, 19:03 UTC · re: Junio C Hamano · lore

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

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

Show 6 quoted lines
> 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.
Show 11 quoted lines
> 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· May 30, 2005, 07:42 UTC · re: Petr Baudis · lore

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

>>>>> "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· May 30, 2005, 08:30 UTC · re: Junio C Hamano · lore

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

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

Show 13 quoted lines
> >>>>> "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

← back to recent threads