Getting the Most Out of a Git Diff
Develop | Posted December 11, 2008

Code Collaborator supports a variety of file difference formats. If you are using Git for version control then you can pipe the output of git-diff directly into the ccollab adddiffs command. As an example, to create a new review with all the modified files in the current directory, use:

 git-diff | ccollab adddiffs new -

By default, git-diff only provides a few lines of context around the modified lines. So you will end up with something that looks like this in the Code Collaborator Diff Viewer:


All those "unspecified line placeholder" entries are kind of a bummer if you were interested in seeing more than 3 lines of context around the changes. The fix is easy, add the -U parameter to git-diff to specify the number of lines of context:

 git-diff -U1000 | ccollab adddiffs new -

The end result is much more useful:


One final note: the example above was created using Git version and Code Collaborator version 4.0. In the upcoming version 5.0 of Code Collaborator, using Git diffs in a review will be even easier with a new ccollab addgitdiffs command.