1GIT-DIFF-TREE(1)                  Git Manual                  GIT-DIFF-TREE(1)
2
3
4

NAME

6       git-diff-tree - Compares the content and mode of blobs found via two
7       tree objects
8

SYNOPSIS

10       git diff-tree [--stdin] [-m] [-s] [-v] [--no-commit-id] [--pretty]
11                     [-t] [-r] [-c | --cc] [--root] [<common diff options>]
12                     <tree-ish> [<tree-ish>] [<path>...]
13
14

DESCRIPTION

16       Compares the content and mode of the blobs found via two tree objects.
17
18       If there is only one <tree-ish> given, the commit is compared with its
19       parents (see --stdin below).
20
21       Note that git diff-tree can use the tree encapsulated in a commit
22       object.
23

OPTIONS

25       -p, -u
26           Generate patch (see section on generating patches).
27
28       -U<n>, --unified=<n>
29           Generate diffs with <n> lines of context instead of the usual
30           three. Implies -p.
31
32       --raw
33           Generate the raw format. This is the default.
34
35       --patch-with-raw
36           Synonym for -p --raw.
37
38       --patience
39           Generate a diff using the "patience diff" algorithm.
40
41       --stat[=width[,name-width]]
42           Generate a diffstat. You can override the default output width for
43           80-column terminal by --stat=width. The width of the filename part
44           can be controlled by giving another width to it separated by a
45           comma.
46
47       --numstat
48           Similar to --stat, but shows number of added and deleted lines in
49           decimal notation and pathname without abbreviation, to make it more
50           machine friendly. For binary files, outputs two - instead of saying
51           0 0.
52
53       --shortstat
54           Output only the last line of the --stat format containing total
55           number of modified files, as well as number of added and deleted
56           lines.
57
58       --dirstat[=limit]
59           Output the distribution of relative amount of changes (number of
60           lines added or removed) for each sub-directory. Directories with
61           changes below a cut-off percent (3% by default) are not shown. The
62           cut-off percent can be set with --dirstat=limit. Changes in a child
63           directory is not counted for the parent directory, unless
64           --cumulative is used.
65
66       --dirstat-by-file[=limit]
67           Same as --dirstat, but counts changed files instead of lines.
68
69       --summary
70           Output a condensed summary of extended header information such as
71           creations, renames and mode changes.
72
73       --patch-with-stat
74           Synonym for -p --stat.
75
76       -z
77           When --raw, --numstat, --name-only or --name-status has been given,
78           do not munge pathnames and use NULs as output field terminators.
79
80           Without this option, each pathname output will have TAB, LF, double
81           quotes, and backslash characters replaced with \t, \n, \", and \\,
82           respectively, and the pathname will be enclosed in double quotes if
83           any of those replacements occurred.
84
85       --name-only
86           Show only names of changed files.
87
88       --name-status
89           Show only names and status of changed files. See the description of
90           the --diff-filter option on what the status letters mean.
91
92       --submodule[=<format>]
93           Chose the output format for submodule differences. <format> can be
94           one of short and log.  short just shows pairs of commit names, this
95           format is used when this option is not given.  log is the default
96           value for this option and lists the commits in that commit range
97           like the summary option of git-submodule(1) does.
98
99       --color[=<when>]
100           Show colored diff. The value must be always (the default), never,
101           or auto.
102
103       --no-color
104           Turn off colored diff, even when the configuration file gives the
105           default to color output. Same as --color=never.
106
107       --color-words[=<regex>]
108           Show colored word diff, i.e., color words which have changed. By
109           default, words are separated by whitespace.
110
111           When a <regex> is specified, every non-overlapping match of the
112           <regex> is considered a word. Anything between these matches is
113           considered whitespace and ignored(!) for the purposes of finding
114           differences. You may want to append |[^[:space:]] to your regular
115           expression to make sure that it matches all non-whitespace
116           characters. A match that contains a newline is silently
117           truncated(!) at the newline.
118
119           The regex can also be set via a diff driver or configuration
120           option, see gitattributes(1) or git-config(1). Giving it explicitly
121           overrides any diff driver or configuration setting. Diff drivers
122           override configuration settings.
123
124       --no-renames
125           Turn off rename detection, even when the configuration file gives
126           the default to do so.
127
128       --check
129           Warn if changes introduce trailing whitespace or an indent that
130           uses a space before a tab. Exits with non-zero status if problems
131           are found. Not compatible with --exit-code.
132
133       --full-index
134           Instead of the first handful of characters, show the full pre- and
135           post-image blob object names on the "index" line when generating
136           patch format output.
137
138       --binary
139           In addition to --full-index, output a binary diff that can be
140           applied with git-apply.
141
142       --abbrev[=<n>]
143           Instead of showing the full 40-byte hexadecimal object name in
144           diff-raw format output and diff-tree header lines, show only a
145           partial prefix. This is independent of the --full-index option
146           above, which controls the diff-patch output format. Non default
147           number of digits can be specified with --abbrev=<n>.
148
149       -B
150           Break complete rewrite changes into pairs of delete and create.
151
152       -M
153           Detect renames.
154
155       -C
156           Detect copies as well as renames. See also --find-copies-harder.
157
158       --diff-filter=[ACDMRTUXB*]
159           Select only files that are Added (A), Copied (C), Deleted (D),
160           Modified (M), Renamed (R), have their type (i.e. regular file,
161           symlink, submodule, ...) changed (T), are Unmerged (U), are Unknown
162           (X), or have had their pairing Broken (B). Any combination of the
163           filter characters may be used. When * (All-or-none) is added to the
164           combination, all paths are selected if there is any file that
165           matches other criteria in the comparison; if there is no file that
166           matches other criteria, nothing is selected.
167
168       --find-copies-harder
169           For performance reasons, by default, -C option finds copies only if
170           the original file of the copy was modified in the same changeset.
171           This flag makes the command inspect unmodified files as candidates
172           for the source of copy. This is a very expensive operation for
173           large projects, so use it with caution. Giving more than one -C
174           option has the same effect.
175
176       -l<num>
177           The -M and -C options require O(n^2) processing time where n is the
178           number of potential rename/copy targets. This option prevents
179           rename/copy detection from running if the number of rename/copy
180           targets exceeds the specified number.
181
182       -S<string>
183           Look for differences that introduce or remove an instance of
184           <string>. Note that this is different than the string simply
185           appearing in diff output; see the pickaxe entry in gitdiffcore(7)
186           for more details.
187
188       --pickaxe-all
189           When -S finds a change, show all the changes in that changeset, not
190           just the files that contain the change in <string>.
191
192       --pickaxe-regex
193           Make the <string> not a plain string but an extended POSIX regex to
194           match.
195
196       -O<orderfile>
197           Output the patch in the order specified in the <orderfile>, which
198           has one shell glob pattern per line.
199
200       -R
201           Swap two inputs; that is, show differences from index or on-disk
202           file to tree contents.
203
204       --relative[=<path>]
205           When run from a subdirectory of the project, it can be told to
206           exclude changes outside the directory and show pathnames relative
207           to it with this option. When you are not in a subdirectory (e.g. in
208           a bare repository), you can name which subdirectory to make the
209           output relative to by giving a <path> as an argument.
210
211       -a, --text
212           Treat all files as text.
213
214       --ignore-space-at-eol
215           Ignore changes in whitespace at EOL.
216
217       -b, --ignore-space-change
218           Ignore changes in amount of whitespace. This ignores whitespace at
219           line end, and considers all other sequences of one or more
220           whitespace characters to be equivalent.
221
222       -w, --ignore-all-space
223           Ignore whitespace when comparing lines. This ignores differences
224           even if one line has whitespace where the other line has none.
225
226       --inter-hunk-context=<lines>
227           Show the context between diff hunks, up to the specified number of
228           lines, thereby fusing hunks that are close to each other.
229
230       --exit-code
231           Make the program exit with codes similar to diff(1). That is, it
232           exits with 1 if there were differences and 0 means no differences.
233
234       --quiet
235           Disable all output of the program. Implies --exit-code.
236
237       --ext-diff
238           Allow an external diff helper to be executed. If you set an
239           external diff driver with gitattributes(5), you need to use this
240           option with git-log(1) and friends.
241
242       --no-ext-diff
243           Disallow external diff drivers.
244
245       --ignore-submodules
246           Ignore changes to submodules in the diff generation.
247
248       --src-prefix=<prefix>
249           Show the given source prefix instead of "a/".
250
251       --dst-prefix=<prefix>
252           Show the given destination prefix instead of "b/".
253
254       --no-prefix
255           Do not show any source or destination prefix.
256
257       For more detailed explanation on these common options, see also
258       gitdiffcore(7).
259
260       <tree-ish>
261           The id of a tree object.
262
263       <path>...
264           If provided, the results are limited to a subset of files matching
265           one of these prefix strings. i.e., file matches
266           /^<pattern1>|<pattern2>|.../ Note that this parameter does not
267           provide any wildcard or regexp features.
268
269       -r
270           recurse into sub-trees
271
272       -t
273           show tree entry itself as well as subtrees. Implies -r.
274
275       --root
276           When --root is specified the initial commit will be shown as a big
277           creation event. This is equivalent to a diff against the NULL tree.
278
279       --stdin
280           When --stdin is specified, the command does not take <tree-ish>
281           arguments from the command line. Instead, it reads lines containing
282           either two <tree>, one <commit>, or a list of <commit> from its
283           standard input. (Use a single space as separator.)
284
285           When two trees are given, it compares the first tree with the
286           second. When a single commit is given, it compares the commit with
287           its parents. The remaining commits, when given, are used as if they
288           are parents of the first commit.
289
290           When comparing two trees, the ID of both trees (separated by a
291           space and terminated by a newline) is printed before the
292           difference. When comparing commits, the ID of the first (or only)
293           commit, followed by a newline, is printed.
294
295           The following flags further affect the behavior when comparing
296           commits (but not trees).
297
298       -m
299           By default, git diff-tree --stdin does not show differences for
300           merge commits. With this flag, it shows differences to that commit
301           from all of its parents. See also -c.
302
303       -s
304           By default, git diff-tree --stdin shows differences, either in
305           machine-readable form (without -p) or in patch form (with -p). This
306           output can be suppressed. It is only useful with -v flag.
307
308       -v
309           This flag causes git diff-tree --stdin to also show the commit
310           message before the differences.
311
312       --pretty[=<format>], --format[=<format>]
313           Pretty-print the contents of the commit logs in a given format,
314           where <format> can be one of oneline, short, medium, full, fuller,
315           email, raw and format:<string>. When omitted, the format defaults
316           to medium.
317
318           Note: you can specify the default pretty format in the repository
319           configuration (see git-config(1)).
320
321       --abbrev-commit
322           Instead of showing the full 40-byte hexadecimal commit object name,
323           show only a partial prefix. Non default number of digits can be
324           specified with "--abbrev=<n>" (which also modifies diff output, if
325           it is displayed).
326
327           This should make "--pretty=oneline" a whole lot more readable for
328           people using 80-column terminals.
329
330       --oneline
331           This is a shorthand for "--pretty=oneline --abbrev-commit" used
332           together.
333
334       --encoding[=<encoding>]
335           The commit objects record the encoding used for the log message in
336           their encoding header; this option can be used to tell the command
337           to re-code the commit log message in the encoding preferred by the
338           user. For non plumbing commands this defaults to UTF-8.
339
340       --no-notes, --show-notes[=<ref>]
341           Show the notes (see git-notes(1)) that annotate the commit, when
342           showing the commit log message. This is the default for git log,
343           git show and git whatchanged commands when there is no --pretty,
344           --format nor --oneline option is given on the command line.
345
346           With an optional argument, add this ref to the list of notes. The
347           ref is taken to be in refs/notes/ if it is not qualified.
348
349       --[no-]standard-notes
350           Enable or disable populating the notes ref list from the
351           core.notesRef and notes.displayRef variables (or corresponding
352           environment overrides). Enabled by default. See git-config(1).
353
354       --no-commit-id
355
356           git diff-tree outputs a line with the commit ID when applicable.
357           This flag suppressed the commit ID output.
358
359       -c
360           This flag changes the way a merge commit is displayed (which means
361           it is useful only when the command is given one <tree-ish>, or
362           --stdin). It shows the differences from each of the parents to the
363           merge result simultaneously instead of showing pairwise diff
364           between a parent and the result one at a time (which is what the -m
365           option does). Furthermore, it lists only files which were modified
366           from all parents.
367
368       --cc
369           This flag changes the way a merge commit patch is displayed, in a
370           similar way to the -c option. It implies the -c and -p options and
371           further compresses the patch output by omitting uninteresting hunks
372           whose the contents in the parents have only two variants and the
373           merge result picks one of them without modification. When all hunks
374           are uninteresting, the commit itself and the commit log message is
375           not shown, just like in any other "empty diff" case.
376
377       --always
378           Show the commit itself and the commit log message even if the diff
379           itself is empty.
380

PRETTY FORMATS

382       If the commit is a merge, and if the pretty-format is not oneline,
383       email or raw, an additional line is inserted before the Author: line.
384       This line begins with "Merge: " and the sha1s of ancestral commits are
385       printed, separated by spaces. Note that the listed commits may not
386       necessarily be the list of the direct parent commits if you have
387       limited your view of history: for example, if you are only interested
388       in changes related to a certain directory or file.
389
390       Here are some additional details for each format:
391
392       ·    oneline
393
394               <sha1> <title line>
395
396           This is designed to be as compact as possible.
397
398       ·    short
399
400               commit <sha1>
401               Author: <author>
402
403               <title line>
404
405       ·    medium
406
407               commit <sha1>
408               Author: <author>
409               Date:   <author date>
410
411               <title line>
412
413               <full commit message>
414
415       ·    full
416
417               commit <sha1>
418               Author: <author>
419               Commit: <committer>
420
421               <title line>
422
423               <full commit message>
424
425       ·    fuller
426
427               commit <sha1>
428               Author:     <author>
429               AuthorDate: <author date>
430               Commit:     <committer>
431               CommitDate: <committer date>
432
433               <title line>
434
435               <full commit message>
436
437       ·    email
438
439               From <sha1> <date>
440               From: <author>
441               Date: <author date>
442               Subject: [PATCH] <title line>
443
444               <full commit message>
445
446       ·    raw
447
448           The raw format shows the entire commit exactly as stored in the
449           commit object. Notably, the SHA1s are displayed in full, regardless
450           of whether --abbrev or --no-abbrev are used, and parents
451           information show the true parent commits, without taking grafts nor
452           history simplification into account.
453
454       ·    format:
455
456           The format: format allows you to specify which information you want
457           to show. It works a little bit like printf format, with the notable
458           exception that you get a newline with %n instead of \n.
459
460           E.g, format:"The author of %h was %an, %ar%nThe title was >>%s<<%n"
461           would show something like this:
462
463               The author of fe6e0ee was Junio C Hamano, 23 hours ago
464               The title was >>t4119: test autocomputing -p<n> for traditional diff input.<<
465
466           The placeholders are:
467
468           ·    %H: commit hash
469
470           ·    %h: abbreviated commit hash
471
472           ·    %T: tree hash
473
474           ·    %t: abbreviated tree hash
475
476           ·    %P: parent hashes
477
478           ·    %p: abbreviated parent hashes
479
480           ·    %an: author name
481
482           ·    %aN: author name (respecting .mailmap, see git-shortlog(1) or
483               git-blame(1))
484
485           ·    %ae: author email
486
487           ·    %aE: author email (respecting .mailmap, see git-shortlog(1) or
488               git-blame(1))
489
490           ·    %ad: author date (format respects --date= option)
491
492           ·    %aD: author date, RFC2822 style
493
494           ·    %ar: author date, relative
495
496           ·    %at: author date, UNIX timestamp
497
498           ·    %ai: author date, ISO 8601 format
499
500           ·    %cn: committer name
501
502           ·    %cN: committer name (respecting .mailmap, see git-shortlog(1)
503               or git-blame(1))
504
505           ·    %ce: committer email
506
507           ·    %cE: committer email (respecting .mailmap, see git-shortlog(1)
508               or git-blame(1))
509
510           ·    %cd: committer date
511
512           ·    %cD: committer date, RFC2822 style
513
514           ·    %cr: committer date, relative
515
516           ·    %ct: committer date, UNIX timestamp
517
518           ·    %ci: committer date, ISO 8601 format
519
520           ·    %d: ref names, like the --decorate option of git-log(1)
521
522           ·    %e: encoding
523
524           ·    %s: subject
525
526           ·    %f: sanitized subject line, suitable for a filename
527
528           ·    %b: body
529
530           ·    %N: commit notes
531
532           ·    %gD: reflog selector, e.g., refs/stash@{1}
533
534           ·    %gd: shortened reflog selector, e.g., stash@{1}
535
536           ·    %gs: reflog subject
537
538           ·    %Cred: switch color to red
539
540           ·    %Cgreen: switch color to green
541
542           ·    %Cblue: switch color to blue
543
544           ·    %Creset: reset color
545
546           ·    %C(...): color specification, as described in color.branch.*
547               config option
548
549           ·    %m: left, right or boundary mark
550
551           ·    %n: newline
552
553           ·    %%: a raw %
554
555           ·    %x00: print a byte from a hex code
556
557           ·    %w([<w>[,<i1>[,<i2>]]]): switch line wrapping, like the -w
558               option of git-shortlog(1).
559
560           Note
561           Some placeholders may depend on other options given to the revision
562           traversal engine. For example, the %g* reflog options will insert
563           an empty string unless we are traversing reflog entries (e.g., by
564           git log -g). The %d placeholder will use the "short" decoration
565           format if --decorate was not already provided on the command line.
566
567       If you add a + (plus sign) after % of a placeholder, a line-feed is
568       inserted immediately before the expansion if and only if the
569       placeholder expands to a non-empty string.
570
571       If you add a - (minus sign) after % of a placeholder, line-feeds that
572       immediately precede the expansion are deleted if and only if the
573       placeholder expands to an empty string.
574
575       ·    tformat:
576
577           The tformat: format works exactly like format:, except that it
578           provides "terminator" semantics instead of "separator" semantics.
579           In other words, each commit has the message terminator character
580           (usually a newline) appended, rather than a separator placed
581           between entries. This means that the final entry of a single-line
582           format will be properly terminated with a new line, just as the
583           "oneline" format does. For example:
584
585               $ git log -2 --pretty=format:%h 4da45bef \
586                 | perl -pe ´$_ .= " -- NO NEWLINE\n" unless /\n/´
587               4da45be
588               7134973 -- NO NEWLINE
589
590               $ git log -2 --pretty=tformat:%h 4da45bef \
591                 | perl -pe ´$_ .= " -- NO NEWLINE\n" unless /\n/´
592               4da45be
593               7134973
594
595           In addition, any unrecognized string that has a % in it is
596           interpreted as if it has tformat: in front of it. For example,
597           these two are equivalent:
598
599               $ git log -2 --pretty=tformat:%h 4da45bef
600               $ git log -2 --pretty=%h 4da45bef
601
602

LIMITING OUTPUT

604       If you’re only interested in differences in a subset of files, for
605       example some architecture-specific files, you might do:
606
607           git diff-tree -r <tree-ish> <tree-ish> arch/ia64 include/asm-ia64
608
609       and it will only show you what changed in those two directories.
610
611       Or if you are searching for what changed in just kernel/sched.c, just
612       do
613
614           git diff-tree -r <tree-ish> <tree-ish> kernel/sched.c
615
616       and it will ignore all differences to other files.
617
618       The pattern is always the prefix, and is matched exactly. There are no
619       wildcards. Even stricter, it has to match a complete path component.
620       I.e. "foo" does not pick up foobar.h. "foo" does match foo/bar.h so it
621       can be used to name subdirectories.
622
623       An example of normal usage is:
624
625           torvalds@ppc970:~/git> git diff-tree 5319e4......
626           *100664->100664 blob    ac348b.......->a01513.......      git-fsck-objects.c
627
628       which tells you that the last commit changed just one file (it’s from
629       this one:
630
631           commit 3c6f7ca19ad4043e9e72fa94106f352897e651a8
632           tree 5319e4d609cdd282069cc4dce33c1db559539b03
633           parent b4e628ea30d5ab3606119d2ea5caeab141d38df7
634           author Linus Torvalds <torvalds@ppc970.osdl.org> Sat Apr 9 12:02:30 2005
635           committer Linus Torvalds <torvalds@ppc970.osdl.org> Sat Apr 9 12:02:30 2005
636
637           Make "git-fsck-objects" print out all the root commits it finds.
638
639           Once I do the reference tracking, I´ll also make it print out all the
640           HEAD commits it finds, which is even more interesting.
641
642
643       in case you care).
644

RAW OUTPUT FORMAT

646       The raw output format from "git-diff-index", "git-diff-tree",
647       "git-diff-files" and "git diff --raw" are very similar.
648
649       These commands all compare two sets of things; what is compared
650       differs:
651
652       git-diff-index <tree-ish>
653           compares the <tree-ish> and the files on the filesystem.
654
655       git-diff-index --cached <tree-ish>
656           compares the <tree-ish> and the index.
657
658       git-diff-tree [-r] <tree-ish-1> <tree-ish-2> [<pattern>...]
659           compares the trees named by the two arguments.
660
661       git-diff-files [<pattern>...]
662           compares the index and the files on the filesystem.
663
664       The "git-diff-tree" command begins its output by printing the hash of
665       what is being compared. After that, all the commands print one output
666       line per changed file.
667
668       An output line is formatted this way:
669
670           in-place edit  :100644 100644 bcd1234... 0123456... M file0
671           copy-edit      :100644 100644 abcd123... 1234567... C68 file1 file2
672           rename-edit    :100644 100644 abcd123... 1234567... R86 file1 file3
673           create         :000000 100644 0000000... 1234567... A file4
674           delete         :100644 000000 1234567... 0000000... D file5
675           unmerged       :000000 000000 0000000... 0000000... U file6
676
677
678       That is, from the left to the right:
679
680        1. a colon.
681
682        2. mode for "src"; 000000 if creation or unmerged.
683
684        3. a space.
685
686        4. mode for "dst"; 000000 if deletion or unmerged.
687
688        5. a space.
689
690        6. sha1 for "src"; 0{40} if creation or unmerged.
691
692        7. a space.
693
694        8. sha1 for "dst"; 0{40} if creation, unmerged or "look at work tree".
695
696        9. a space.
697
698       10. status, followed by optional "score" number.
699
700       11. a tab or a NUL when -z option is used.
701
702       12. path for "src"
703
704       13. a tab or a NUL when -z option is used; only exists for C or R.
705
706       14. path for "dst"; only exists for C or R.
707
708       15. an LF or a NUL when -z option is used, to terminate the record.
709
710       Possible status letters are:
711
712       ·   A: addition of a file
713
714       ·   C: copy of a file into a new one
715
716       ·   D: deletion of a file
717
718       ·   M: modification of the contents or mode of a file
719
720       ·   R: renaming of a file
721
722       ·   T: change in the type of the file
723
724       ·   U: file is unmerged (you must complete the merge before it can be
725           committed)
726
727       ·   X: "unknown" change type (most probably a bug, please report it)
728
729       Status letters C and R are always followed by a score (denoting the
730       percentage of similarity between the source and target of the move or
731       copy), and are the only ones to be so.
732
733       <sha1> is shown as all 0’s if a file is new on the filesystem and it is
734       out of sync with the index.
735
736       Example:
737
738           :100644 100644 5be4a4...... 000000...... M file.c
739
740
741       When -z option is not used, TAB, LF, and backslash characters in
742       pathnames are represented as \t, \n, and \\, respectively.
743

DIFF FORMAT FOR MERGES

745       "git-diff-tree", "git-diff-files" and "git-diff --raw" can take -c or
746       --cc option to generate diff output also for merge commits. The output
747       differs from the format described above in the following way:
748
749        1. there is a colon for each parent
750
751        2. there are more "src" modes and "src" sha1
752
753        3. status is concatenated status characters for each parent
754
755        4. no optional "score" number
756
757        5. single path, only for "dst"
758
759       Example:
760
761           ::100644 100644 100644 fabadb8... cc95eb0... 4866510... MM      describe.c
762
763
764       Note that combined diff lists only files which were modified from all
765       parents.
766

GENERATING PATCHES WITH -P

768       When "git-diff-index", "git-diff-tree", or "git-diff-files" are run
769       with a -p option, "git diff" without the --raw option, or "git log"
770       with the "-p" option, they do not produce the output described above;
771       instead they produce a patch file. You can customize the creation of
772       such patches via the GIT_EXTERNAL_DIFF and the GIT_DIFF_OPTS
773       environment variables.
774
775       What the -p option produces is slightly different from the traditional
776       diff format.
777
778        1. It is preceded with a "git diff" header, that looks like this:
779
780               diff --git a/file1 b/file2
781
782           The a/ and b/ filenames are the same unless rename/copy is
783           involved. Especially, even for a creation or a deletion, /dev/null
784           is not used in place of a/ or b/ filenames.
785
786           When rename/copy is involved, file1 and file2 show the name of the
787           source file of the rename/copy and the name of the file that
788           rename/copy produces, respectively.
789
790        2. It is followed by one or more extended header lines:
791
792               old mode <mode>
793               new mode <mode>
794               deleted file mode <mode>
795               new file mode <mode>
796               copy from <path>
797               copy to <path>
798               rename from <path>
799               rename to <path>
800               similarity index <number>
801               dissimilarity index <number>
802               index <hash>..<hash> <mode>
803
804        3. TAB, LF, double quote and backslash characters in pathnames are
805           represented as \t, \n, \" and \\, respectively. If there is need
806           for such substitution then the whole pathname is put in double
807           quotes.
808
809       The similarity index is the percentage of unchanged lines, and the
810       dissimilarity index is the percentage of changed lines. It is a rounded
811       down integer, followed by a percent sign. The similarity index value of
812       100% is thus reserved for two equal files, while 100% dissimilarity
813       means that no line from the old file made it into the new one.
814

COMBINED DIFF FORMAT

816       "git-diff-tree", "git-diff-files" and "git-diff" can take -c or --cc
817       option to produce combined diff. For showing a merge commit with "git
818       log -p", this is the default format; you can force showing full diff
819       with the -m option. A combined diff format looks like this:
820
821           diff --combined describe.c
822           index fabadb8,cc95eb0..4866510
823           --- a/describe.c
824           +++ b/describe.c
825           @@@ -98,20 -98,12 +98,20 @@@
826                   return (a_date > b_date) ? -1 : (a_date == b_date) ? 0 : 1;
827             }
828
829           - static void describe(char *arg)
830            -static void describe(struct commit *cmit, int last_one)
831           ++static void describe(char *arg, int last_one)
832             {
833            +      unsigned char sha1[20];
834            +      struct commit *cmit;
835                   struct commit_list *list;
836                   static int initialized = 0;
837                   struct commit_name *n;
838
839            +      if (get_sha1(arg, sha1) < 0)
840            +              usage(describe_usage);
841            +      cmit = lookup_commit_reference(sha1);
842            +      if (!cmit)
843            +              usage(describe_usage);
844            +
845                   if (!initialized) {
846                           initialized = 1;
847                           for_each_ref(get_name);
848
849
850
851        1. It is preceded with a "git diff" header, that looks like this (when
852           -c option is used):
853
854               diff --combined file
855
856           or like this (when --cc option is used):
857
858               diff --cc file
859
860        2. It is followed by one or more extended header lines (this example
861           shows a merge with two parents):
862
863               index <hash>,<hash>..<hash>
864               mode <mode>,<mode>..<mode>
865               new file mode <mode>
866               deleted file mode <mode>,<mode>
867
868           The mode <mode>,<mode>..<mode> line appears only if at least one of
869           the <mode> is different from the rest. Extended headers with
870           information about detected contents movement (renames and copying
871           detection) are designed to work with diff of two <tree-ish> and are
872           not used by combined diff format.
873
874        3. It is followed by two-line from-file/to-file header
875
876               --- a/file
877               +++ b/file
878
879           Similar to two-line header for traditional unified diff format,
880           /dev/null is used to signal created or deleted files.
881
882        4. Chunk header format is modified to prevent people from accidentally
883           feeding it to patch -p1. Combined diff format was created for
884           review of merge commit changes, and was not meant for apply. The
885           change is similar to the change in the extended index header:
886
887               @@@ <from-file-range> <from-file-range> <to-file-range> @@@
888
889           There are (number of parents + 1) @ characters in the chunk header
890           for combined diff format.
891
892       Unlike the traditional unified diff format, which shows two files A and
893       B with a single column that has - (minus — appears in A but removed in
894       B), + (plus — missing in A but added to B), or " " (space — unchanged)
895       prefix, this format compares two or more files file1, file2,... with
896       one file X, and shows how X differs from each of fileN. One column for
897       each of fileN is prepended to the output line to note how X’s line is
898       different from it.
899
900       A - character in the column N means that the line appears in fileN but
901       it does not appear in the result. A + character in the column N means
902       that the line appears in the result, and fileN does not have that line
903       (in other words, the line was added, from the point of view of that
904       parent).
905
906       In the above example output, the function signature was changed from
907       both files (hence two - removals from both file1 and file2, plus ++ to
908       mean one line that was added does not appear in either file1 nor
909       file2). Also eight other lines are the same from file1 but do not
910       appear in file2 (hence prefixed with +).
911
912       When shown by git diff-tree -c, it compares the parents of a merge
913       commit with the merge result (i.e. file1..fileN are the parents). When
914       shown by git diff-files -c, it compares the two unresolved merge
915       parents with the working tree file (i.e. file1 is stage 2 aka "our
916       version", file2 is stage 3 aka "their version").
917

OTHER DIFF FORMATS

919       The --summary option describes newly added, deleted, renamed and copied
920       files. The --stat option adds diffstat(1) graph to the output. These
921       options can be combined with other options, such as -p, and are meant
922       for human consumption.
923
924       When showing a change that involves a rename or a copy, --stat output
925       formats the pathnames compactly by combining common prefix and suffix
926       of the pathnames. For example, a change that moves arch/i386/Makefile
927       to arch/x86/Makefile while modifying 4 lines will be shown like this:
928
929           arch/{i386 => x86}/Makefile    |   4 +--
930
931
932       The --numstat option gives the diffstat(1) information but is designed
933       for easier machine consumption. An entry in --numstat output looks like
934       this:
935
936           1       2       README
937           3       1       arch/{i386 => x86}/Makefile
938
939
940       That is, from left to right:
941
942        1. the number of added lines;
943
944        2. a tab;
945
946        3. the number of deleted lines;
947
948        4. a tab;
949
950        5. pathname (possibly with rename/copy information);
951
952        6. a newline.
953
954       When -z output option is in effect, the output is formatted this way:
955
956           1       2       README NUL
957           3       1       NUL arch/i386/Makefile NUL arch/x86/Makefile NUL
958
959
960       That is:
961
962        1. the number of added lines;
963
964        2. a tab;
965
966        3. the number of deleted lines;
967
968        4. a tab;
969
970        5. a NUL (only exists if renamed/copied);
971
972        6. pathname in preimage;
973
974        7. a NUL (only exists if renamed/copied);
975
976        8. pathname in postimage (only exists if renamed/copied);
977
978        9. a NUL.
979
980       The extra NUL before the preimage path in renamed case is to allow
981       scripts that read the output to tell if the current record being read
982       is a single-path record or a rename/copy record without reading ahead.
983       After reading added and deleted lines, reading up to NUL would yield
984       the pathname, but if that is NUL, the record will show two paths.
985

AUTHOR

987       Written by Linus Torvalds <torvalds@osdl.org[1]>
988

DOCUMENTATION

990       Documentation by David Greaves, Junio C Hamano and the git-list
991       <git@vger.kernel.org[2]>.
992

GIT

994       Part of the git(1) suite
995

NOTES

997        1. torvalds@osdl.org
998           mailto:torvalds@osdl.org
999
1000        2. git@vger.kernel.org
1001           mailto:git@vger.kernel.org
1002
1003
1004
1005Git 1.7.1                         08/16/2017                  GIT-DIFF-TREE(1)
Impressum