Skip to content

Commit fde97d8

Browse files
loopsJunio C Hamano
authored andcommitted
Update documentation to remove incorrect GIT_DIFF_OPTS example.
Git no longer calls an external diff program to generate patches. Remove the documentation which suggests that you can pass arbitrary diff options via the GIT_DIFF_OPTS environment variable. Signed-off-by: Sean Estabrooks <seanlkml@sympatico.ca> Signed-off-by: Junio C Hamano <junkio@cox.net>
1 parent 3c23bea commit fde97d8

File tree

2 files changed

+34
-55
lines changed

2 files changed

+34
-55
lines changed

Documentation/diff-format.txt

Lines changed: 6 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -65,62 +65,17 @@ Generating patches with -p
6565

6666
When "git-diff-index", "git-diff-tree", or "git-diff-files" are run
6767
with a '-p' option, they do not produce the output described above;
68-
instead they produce a patch file.
68+
instead they produce a patch file. You can customize the creation
69+
of such patches via the GIT_EXTERNAL_DIFF and the GIT_DIFF_OPTS
70+
environment variables.
6971

70-
The patch generation can be customized at two levels.
71-
72-
1. When the environment variable 'GIT_EXTERNAL_DIFF' is not set,
73-
these commands internally invoke "diff" like this:
74-
75-
diff -L a/<path> -L b/<path> -pu <old> <new>
76-
+
77-
For added files, `/dev/null` is used for <old>. For removed
78-
files, `/dev/null` is used for <new>
79-
+
80-
The "diff" formatting options can be customized via the
81-
environment variable 'GIT_DIFF_OPTS'. For example, if you
82-
prefer context diff:
83-
84-
GIT_DIFF_OPTS=-c git-diff-index -p HEAD
85-
86-
87-
2. When the environment variable 'GIT_EXTERNAL_DIFF' is set, the
88-
program named by it is called, instead of the diff invocation
89-
described above.
90-
+
91-
For a path that is added, removed, or modified,
92-
'GIT_EXTERNAL_DIFF' is called with 7 parameters:
93-
94-
path old-file old-hex old-mode new-file new-hex new-mode
95-
+
96-
where:
97-
98-
<old|new>-file:: are files GIT_EXTERNAL_DIFF can use to read the
99-
contents of <old|new>,
100-
<old|new>-hex:: are the 40-hexdigit SHA1 hashes,
101-
<old|new>-mode:: are the octal representation of the file modes.
102-
103-
+
104-
The file parameters can point at the user's working file
105-
(e.g. `new-file` in "git-diff-files"), `/dev/null` (e.g. `old-file`
106-
when a new file is added), or a temporary file (e.g. `old-file` in the
107-
index). 'GIT_EXTERNAL_DIFF' should not worry about unlinking the
108-
temporary file --- it is removed when 'GIT_EXTERNAL_DIFF' exits.
109-
110-
For a path that is unmerged, 'GIT_EXTERNAL_DIFF' is called with 1
111-
parameter, <path>.
112-
113-
114-
git specific extension to diff format
115-
-------------------------------------
116-
117-
What -p option produces is slightly different from the
118-
traditional diff format.
72+
What the -p option produces is slightly different from the traditional
73+
diff format.
11974

12075
1. It is preceded with a "git diff" header, that looks like
12176
this:
12277

123-
diff --git a/file1 b/file2
78+
diff --git a/file1 b/file2
12479
+
12580
The `a/` and `b/` filenames are the same unless rename/copy is
12681
involved. Especially, even for a creation or a deletion,

Documentation/git.txt

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -639,11 +639,35 @@ git Commits
639639
git Diffs
640640
~~~~~~~~~
641641
'GIT_DIFF_OPTS'::
642+
Only valid setting is "--unified=??" or "-u??" to set the
643+
number of context lines shown when a unified diff is created.
644+
This takes precedence over any "-U" or "--unified" option
645+
value passed on the git diff command line.
646+
642647
'GIT_EXTERNAL_DIFF'::
643-
see the "generating patches" section in :
644-
gitlink:git-diff-index[1];
645-
gitlink:git-diff-files[1];
646-
gitlink:git-diff-tree[1]
648+
When the environment variable 'GIT_EXTERNAL_DIFF' is set, the
649+
program named by it is called, instead of the diff invocation
650+
described above. For a path that is added, removed, or modified,
651+
'GIT_EXTERNAL_DIFF' is called with 7 parameters:
652+
653+
path old-file old-hex old-mode new-file new-hex new-mode
654+
+
655+
where:
656+
657+
<old|new>-file:: are files GIT_EXTERNAL_DIFF can use to read the
658+
contents of <old|new>,
659+
<old|new>-hex:: are the 40-hexdigit SHA1 hashes,
660+
<old|new>-mode:: are the octal representation of the file modes.
661+
662+
+
663+
The file parameters can point at the user's working file
664+
(e.g. `new-file` in "git-diff-files"), `/dev/null` (e.g. `old-file`
665+
when a new file is added), or a temporary file (e.g. `old-file` in the
666+
index). 'GIT_EXTERNAL_DIFF' should not worry about unlinking the
667+
temporary file --- it is removed when 'GIT_EXTERNAL_DIFF' exits.
668+
+
669+
For a path that is unmerged, 'GIT_EXTERNAL_DIFF' is called with 1
670+
parameter, <path>.
647671

648672
other
649673
~~~~~

0 commit comments

Comments
 (0)