views:

1452

answers:

7

The default git diff behavior is to open each diff file in serial (wait for previous file to be closed before opening next file).

I'm looking for a way to open all the files at once - in BeyondCompare for example this would open all the files in tabs within the same BC window.

This would make it easier to review a complex set of changes; flick back and forwards between the diff files and ignore unimportant files.

+1  A: 

I did find this method (GitDiff.bat and GitDiff.rb) that copies the files out to old/new temp dirs and then does a folder compare on them.

But I'd rather view the working files directly (from the working dir), as BeyondCompare has the handy feature of being able to edit the file from within the diff window which is great for quick cleanups.

Edit: a similar method here in response to my question on the git mailing list.

Seba Illingworth
+1  A: 

Noticed here that Araxis Merge has a '-nowait' command option:

-nowait Prevents compare from waiting for a comparison to be closed

Maybe this returns an immediate exit code and would work, anyone experienced this? Can't find similar option for BeyondCompare...

Seba Illingworth
A: 

You can use gitk and see all the differences at the same time

Aragorn
Yes I find gitk useful, but when it comes to diff-ing BC is what I want to see :)
Seba Illingworth
+1  A: 

If all you want to do is open all the files that are currently modified, try something like:

vi $(git status | sed -n '/.*modified: */s///p')

If you are making commits of "complex sets of changes", you might want to reconsider your workflow. One of the really nice features of git is that it makes it easy for the developer to reduce complex change sets to a series of simple patches. Rather than trying to edit all of the files that are currently modified, you might want to look into

git add --patch
which will allow you to selectively stage hunks.

William Pursell
+6  A: 

Edit: I packaged this story into a blog post here, it seemed a good excuse for a first blog :)


Here is what I've settled on:

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

This gets the list of modified files and calls the external diff tool on each separate file.

The key to it is the & command param which tells the external diff command to run in a background task, thus allowing successive diffs to run immediately. In the case of BeyondCompare this causes all the files to open in tabs within the same BC window, which is what I want.

To make it easy to use, I saved the script to a file called diffall.sh and copied that to /my-git-install-dir/cmd/ folder so that it is in my path, then created a git alias for it called diffall :

git config --global alias.diffall '!sh diffall.sh'

Now I can run it by typing (accepts optional params, eg HEAD or --staged):

git diffall

and fall back on the normal external diff etc:

git difftool


Edit: updated (details at blog) to handle paths with spaces, additional no-prompt setting, and multiple input params.

git diff --name-only "$@" | while read filename; do
    git difftool "$@" --no-prompt "$filename" &
done
Seba Illingworth
Turns out you can do away with the alias, just call the script file 'git-diffall' and git automatically picks it up. Details in the blog post.
Seba Illingworth
Thanks for posting. Unfortunatley, it doesn't work with WinMerge's -s option. All of the temp files except the first get deleted before WinMerge gets to look at them.
Carlos Rendon
Woody Zenfell III
+1  A: 

This same question was asked on the git mail list.

I put together a shell script based on that email thread which performs a directory diff between arbitrary commits.

The git-diffall project is hosted on GitHub.

I also posted the script as a "contrib" patch to the Git list, but there was no response (apparently there is not much interest).

Here is the project description:

The git-diffall script provides a directory based diff mechanism for git. The script relies on the diff.tool configuration option to determine what diff viewer is used.

This script is compatible with all the forms used to specify a range of revisions to diff:

1) git diffall: shows diff between working tree and staged changes
2) git diffall --cached [<commit>]: shows diff between staged changes and HEAD (or other named commit)
3) git diffall <commit>: shows diff between working tree and named commit
4) git diffall <commit> <commit>: show diff between two named commits
5) git diffall <commit>..<commit>: same as above
6) git diffall <commit>...<commit>: show the changes on the branch containing and up to the second , starting at a common ancestor of both <commit>

Note: all forms take an optional path limiter [--] [<path>]

This script is based on an example provided by Thomas Rast on the Git list.

Tim Henigan
A: 

I've written a powershell script that will duplicate two working trees and compare with DiffMerge. So you can do:

GitNdiff master~3 .

To compare the master branch three checkins ago with the current working tree, for instance.

Its shiny and new and probably full of bugs. One drawback is that files in your working tree that have not been added yet are copied out to both working trees. It can also be slow.

http://github.com/fschwiet/GitNdiff

Frank Schwieterman