threads / discuss / 20679

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

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

## tl;dr

5 messages between Aug 21, 2009 and Aug 22, 2009.

replies: 4people: 2as markdown or json

Seba Illingworth· Aug 21, 2009, 03:47 UTC · lore

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

David Aguilar· Aug 21, 2009, 05:40 UTC · re: Seba Illingworth · lore

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

Hi,
On Fri, Aug 21, 2009 at 03:47:07AM +0000, Seba Illingworth wrote:
Show 8 quoted lines
> 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,
-- 
		David
Seba Illingworth· Aug 21, 2009, 05:54 UTC · re: David Aguilar · lore

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

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!
David Aguilar· Aug 21, 2009, 23:45 UTC · re: Seba Illingworth · lore

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

On Fri, Aug 21, 2009 at 05:54:48AM +0000, Seba Illingworth wrote:
> 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.

-- 
		David
Seba Illingworth· Aug 22, 2009, 02:10 UTC · re: David Aguilar · lore

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

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

← back to recent threads