Skip to contentSkip to conversation

git diffall, open all diff files immediatly (eg tabbed window in BC)

DISCUSSION Seba Illingworth 2 participants 5 messages Jun 15, 2016

lore
Share & tools
lore
#1 lore raw

Hi,

Quoted 8 lines · Seba Illingworth

I came up with the following 'git-diffall' script to open all diff files immediately, rather than default behavior of opening them one at a time in serial.

    for name in $(git diff --name-only $1); do git difftool $1 $name & done

I blogged the details at
http://blog.codefarm.co.nz/2009/08/git-diff-and-difftool-open-all-files.html

You must have difftool.prompt (or mergetool.prompt) set to false, otherwise git would be prompting you during the loop.

To make it work irrespective of the configuration, pass --no-prompt or -y to difftool.

Also maybe something like:

for name in "$(git diff --name-only "$@")"; do

	git difftool "$@" "$name" &

done

The quotes should make it work paths that have spaces. The "$@" should let you pass arbitrary parameters to difftool.

Have fun,

Signature · 1 line
		David
#2 lore raw
Quoted 1 line · David Aguilar <davvid <at> gmail.com> writes:

To make it work irrespective of the configuration...

Hi David, great to get your comments, thanks for the pointers!

#3 lore raw

Re: git diffall, open all diff files immediatly (eg tabbed window?in BC)

Quoted 4 lines · Seba Illingworth
Quoted 1 line · David Aguilar <davvid <at> gmail.com> writes:

To make it work irrespective of the configuration...

Hi David, great to get your comments, thanks for the pointers!

One last note (I promise ;)):

I would recommend against saying 'git difftool head' on your blog beause that only works on OSX with its case-preserving yet case-insensitive filesystem. It might be worth mentioning that.

If you try 'git diff head' on a different filesystem (for example, if you tried it on Linux) you'll find that it doesn't work because the file is .git/HEAD; .git/head doesn't exist.

On OSX the filesystem tells git that .git/head exists even though it's actually finding .git/HEAD.

Signature · 1 line
		David
#4 lore raw

Re: git diffall, open all diff files immediatly (eg tabbed window?in BC)

Quoted 3 lines · David Aguilar <davvid <at> gmail.com> writes:

I would recommend against saying 'git difftool head' on your blog beause that only works on OSX with its case-preserving yet case-insensitive filesystem....

Thanks David, understood and updated to 'HEAD'. 'head' had worked for me with my sloppy Windows ways ;)

I struggled with your previous suggestion for handling paths with spaces; I couldn't get the for-loop to split the input into individual filenames on the line-break separator (after outer quotes expanded the result?).

But rewriting it this way seems to work well and handles spaces (Windows):

git diff --name-only "$@" | while read filename; do
git difftool "$@" --no-prompt "$filename" &
done

Hope you can comment on this variation?
And thanks for all the tips! Seba