Skip to contentSkip to conversation

-p diff output and the 'Index:' line

DISCUSSION Petr Baudis 4 participants 9 messages Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

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,

Signature · 3 lines
				Petr "Pasky" Baudis
Stuff: http://pasky.or.cz/
C++: an octopus made by nailing extra legs onto a dog. -- Steve Taylor
#1 lore raw
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"PB" == Petr Baudis <[email protected]> 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.

#2 lore raw

Dear diary, on Sun, May 29, 2005 at 09:41:03AM CEST, I got a letter where Junio C Hamano <[email protected]> told me that...

Quoted 9 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"PB" == Petr Baudis <[email protected]> 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.

Quoted 5 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. :-)

Signature · 3 lines
				Petr "Pasky" Baudis
Stuff: http://pasky.or.cz/
C++: an octopus made by nailing extra legs onto a dog. -- Steve Taylor
#3 lore raw
Quoted 7 lines
Quoted 7 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line

"PB" == Petr Baudis <[email protected]> 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.

#4 lore raw

Dear diary, on Sun, May 29, 2005 at 08:04:44PM CEST, I got a letter where Junio C Hamano <[email protected]> told me that...

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

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

Signature · 3 lines
				Petr "Pasky" Baudis
Stuff: http://pasky.or.cz/
C++: an octopus made by nailing extra legs onto a dog. -- Steve Taylor
#5 lore raw
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"PB" == Petr Baudis <[email protected]> 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.

#6 lore raw

Dear diary, on Mon, May 30, 2005 at 09:42:26AM CEST, I got a letter where Junio C Hamano <[email protected]> told me that...

Quoted 7 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"PB" == Petr Baudis <[email protected]> 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.

Quoted 6 lines

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.

Signature · 3 lines
				Petr "Pasky" Baudis
Stuff: http://pasky.or.cz/
C++: an octopus made by nailing extra legs onto a dog. -- Steve Taylor
#7 lore raw
In reply to Junio C Hamano
Quoted 10 lines · Junio C Hamano
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"PB" == Petr Baudis <[email protected]> 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.

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

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

#8 lore raw

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