Brendan Jurd wrote:
> On 10/24/07, Alvaro Herrera <alvherre@commandprompt.com> wrote:
>> Brendan Jurd escribió:
>>> Really? I just started playing around with git, and the output from git
>>> diff produced the same kind of diff file I would normally get from `svn
>>> di`
>> ... which is a unified diff.
>>
>>> or `cvs di -c`.
>> Huh, strange. That's a context diff.
>
> Right. I was confusing unified and context, because the unified diffs I'm
> looking at do actually show "context" lines above and below each change.
> Sorry for the noise.
You can get git to produce a context diff by using GIT_EXTERNAL_DIFF to specify
an external diff program. I use a little shell script called
git-context-diff.sh, containing:
#!/bin/bash
diff --context=5 -L a/$1 -L b/$1 -p $2 $5
exit 0
and then create a diff with:
GIT_EXTERNAL_DIFF=git-context-diff.sh git diff <head to diff against>
Just in case you wondered - writing that script as just "exec diff ..." fails,
because diff seems to exit with a nonzero exitcode if the files differ, and "git
diff" aborts in that case...
regards, Florian Pflug