Reputation: 9785
When you invoke git diff
, it's using the diff
utility to compare files, however, not in the default way. It's using a number of extra options, some I can name are:
But I'm not sure these are the only changes. What are the others and what command line arguments does git
pass to diff
to achieve it's default output? And if I would want to compare, say, a.txt
with b.txt
and make the diff file the way git makes it, what command line should I use?
Upvotes: 1
Views: 1177
Reputation: 51935
Git does not use the default *nix or GNU diff, but implements its own diff algorithm.
The code for this is located mainly in the files builtin/diff.c
, builtin/diff-tree.c
, builtin/diff-index.c
and builtin/diff-files.c
in the Git source tree.
It can thereby do some fancy things like advanced word-diff and has a reliable implementation for all platforms.
The default (line-based) unified-diff format patches it can produce are compatible with most other imlementations of the format. IIRC, GNU diff (or was it patch?) also added some more tolerance to some extras that Git puts in the diff, so as to be more resilient when applying git-generated patches.
Upvotes: 4