forked from git/git
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgit-diff-index.1
More file actions
1498 lines (1495 loc) · 34.9 KB
/
git-diff-index.1
File metadata and controls
1498 lines (1495 loc) · 34.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
'\" t
.\" Title: git-diff-index
.\" Author: [see the "Author" section]
.\" Generator: DocBook XSL Stylesheets v1.75.2 <http://docbook.sf.net/>
.\" Date: 11/06/2010
.\" Manual: Git Manual
.\" Source: Git 1.7.3.2.161.g3089c
.\" Language: English
.\"
.TH "GIT\-DIFF\-INDEX" "1" "11/06/2010" "Git 1\&.7\&.3\&.2\&.161\&.g308" "Git Manual"
.\" -----------------------------------------------------------------
.\" * set default formatting
.\" -----------------------------------------------------------------
.\" disable hyphenation
.nh
.\" disable justification (adjust text to left margin only)
.ad l
.\" -----------------------------------------------------------------
.\" * MAIN CONTENT STARTS HERE *
.\" -----------------------------------------------------------------
.SH "NAME"
git-diff-index \- Compares content and mode of blobs between the index and repository
.SH "SYNOPSIS"
.sp
\fIgit diff\-index\fR [\-m] [\-\-cached] [<common diff options>] <tree\-ish> [<path>\&...]
.SH "DESCRIPTION"
.sp
Compares the content and mode of the blobs found via a tree object with the content of the current index and, optionally ignoring the stat state of the file on disk\&. When paths are specified, compares only those named paths\&. Otherwise all entries in the index are compared\&.
.SH "OPTIONS"
.PP
\-p, \-u, \-\-patch
.RS 4
Generate patch (see section on generating patches)\&.
.RE
.PP
\-U<n>, \-\-unified=<n>
.RS 4
Generate diffs with <n> lines of context instead of the usual three\&. Implies
\-p\&.
.RE
.PP
\-\-raw
.RS 4
Generate the raw format\&. This is the default\&.
.RE
.PP
\-\-patch\-with\-raw
.RS 4
Synonym for
\-p \-\-raw\&.
.RE
.PP
\-\-patience
.RS 4
Generate a diff using the "patience diff" algorithm\&.
.RE
.PP
\-\-stat[=<width>[,<name\-width>]]
.RS 4
Generate a diffstat\&. You can override the default output width for 80\-column terminal by
\-\-stat=<width>\&. The width of the filename part can be controlled by giving another width to it separated by a comma\&.
.RE
.PP
\-\-numstat
.RS 4
Similar to
\-\-stat, but shows number of added and deleted lines in decimal notation and pathname without abbreviation, to make it more machine friendly\&. For binary files, outputs two
\-
instead of saying
0 0\&.
.RE
.PP
\-\-shortstat
.RS 4
Output only the last line of the
\-\-stat
format containing total number of modified files, as well as number of added and deleted lines\&.
.RE
.PP
\-\-dirstat[=<limit>]
.RS 4
Output the distribution of relative amount of changes (number of lines added or removed) for each sub\-directory\&. Directories with changes below a cut\-off percent (3% by default) are not shown\&. The cut\-off percent can be set with
\-\-dirstat=<limit>\&. Changes in a child directory are not counted for the parent directory, unless
\-\-cumulative
is used\&.
.RE
.PP
\-\-dirstat\-by\-file[=<limit>]
.RS 4
Same as
\-\-dirstat, but counts changed files instead of lines\&.
.RE
.PP
\-\-summary
.RS 4
Output a condensed summary of extended header information such as creations, renames and mode changes\&.
.RE
.PP
\-\-patch\-with\-stat
.RS 4
Synonym for
\-p \-\-stat\&.
.RE
.PP
\-z
.RS 4
When
\-\-raw,
\-\-numstat,
\-\-name\-only
or
\-\-name\-status
has been given, do not munge pathnames and use NULs as output field terminators\&.
.sp
Without this option, each pathname output will have TAB, LF, double quotes, and backslash characters replaced with
\et,
\en,
\e", and
\e\e, respectively, and the pathname will be enclosed in double quotes if any of those replacements occurred\&.
.RE
.PP
\-\-name\-only
.RS 4
Show only names of changed files\&.
.RE
.PP
\-\-name\-status
.RS 4
Show only names and status of changed files\&. See the description of the
\-\-diff\-filter
option on what the status letters mean\&.
.RE
.PP
\-\-submodule[=<format>]
.RS 4
Chose the output format for submodule differences\&. <format> can be one of
\fIshort\fR
and
\fIlog\fR\&.
\fIshort\fR
just shows pairs of commit names, this format is used when this option is not given\&.
\fIlog\fR
is the default value for this option and lists the commits in that commit range like the
\fIsummary\fR
option of
\fBgit-submodule\fR(1)
does\&.
.RE
.PP
\-\-color[=<when>]
.RS 4
Show colored diff\&. The value must be always (the default), never, or auto\&.
.RE
.PP
\-\-no\-color
.RS 4
Turn off colored diff, even when the configuration file gives the default to color output\&. Same as
\-\-color=never\&.
.RE
.PP
\-\-word\-diff[=<mode>]
.RS 4
Show a word diff, using the <mode> to delimit changed words\&. By default, words are delimited by whitespace; see
\-\-word\-diff\-regex
below\&. The <mode> defaults to
\fIplain\fR, and must be one of:
.PP
color
.RS 4
Highlight changed words using only colors\&. Implies
\-\-color\&.
.RE
.PP
plain
.RS 4
Show words as
[\-removed\-]
and
{added}\&. Makes no attempts to escape the delimiters if they appear in the input, so the output may be ambiguous\&.
.RE
.PP
porcelain
.RS 4
Use a special line\-based format intended for script consumption\&. Added/removed/unchanged runs are printed in the usual unified diff format, starting with a
+/\-/` ` character at the beginning of the line and extending to the end of the line\&. Newlines in the input are represented by a tilde
~
on a line of its own\&.
.RE
.PP
none
.RS 4
Disable word diff again\&.
.RE
.sp
Note that despite the name of the first mode, color is used to highlight the changed parts in all modes if enabled\&.
.RE
.PP
\-\-word\-diff\-regex=<regex>
.RS 4
Use <regex> to decide what a word is, instead of considering runs of non\-whitespace to be a word\&. Also implies
\-\-word\-diff
unless it was already enabled\&.
.sp
Every non\-overlapping match of the <regex> is considered a word\&. Anything between these matches is considered whitespace and ignored(!) for the purposes of finding differences\&. You may want to append
|[^[:space:]]
to your regular expression to make sure that it matches all non\-whitespace characters\&. A match that contains a newline is silently truncated(!) at the newline\&.
.sp
The regex can also be set via a diff driver or configuration option, see
\fBgitattributes\fR(1)
or
\fBgit-config\fR(1)\&. Giving it explicitly overrides any diff driver or configuration setting\&. Diff drivers override configuration settings\&.
.RE
.PP
\-\-color\-words[=<regex>]
.RS 4
Equivalent to
\-\-word\-diff=color
plus (if a regex was specified)
\-\-word\-diff\-regex=<regex>\&.
.RE
.PP
\-\-no\-renames
.RS 4
Turn off rename detection, even when the configuration file gives the default to do so\&.
.RE
.PP
\-\-check
.RS 4
Warn if changes introduce trailing whitespace or an indent that uses a space before a tab\&. Exits with non\-zero status if problems are found\&. Not compatible with \-\-exit\-code\&.
.RE
.PP
\-\-full\-index
.RS 4
Instead of the first handful of characters, show the full pre\- and post\-image blob object names on the "index" line when generating patch format output\&.
.RE
.PP
\-\-binary
.RS 4
In addition to
\-\-full\-index, output a binary diff that can be applied with
git\-apply\&.
.RE
.PP
\-\-abbrev[=<n>]
.RS 4
Instead of showing the full 40\-byte hexadecimal object name in diff\-raw format output and diff\-tree header lines, show only a partial prefix\&. This is independent of the
\-\-full\-index
option above, which controls the diff\-patch output format\&. Non default number of digits can be specified with
\-\-abbrev=<n>\&.
.RE
.PP
\-B[<n>][/<m>], \-\-break\-rewrites[=[<n>][/<m>]]
.RS 4
Break complete rewrite changes into pairs of delete and create\&. This serves two purposes:
.sp
It affects the way a change that amounts to a total rewrite of a file not as a series of deletion and insertion mixed together with a very few lines that happen to match textually as the context, but as a single deletion of everything old followed by a single insertion of everything new, and the number
m
controls this aspect of the \-B option (defaults to 60%)\&.
\-B/70%
specifies that less than 30% of the original should remain in the result for git to consider it a total rewrite (i\&.e\&. otherwise the resulting patch will be a series of deletion and insertion mixed together with context lines)\&.
.sp
When used with \-M, a totally\-rewritten file is also considered as the source of a rename (usually \-M only considers a file that disappeared as the source of a rename), and the number
n
controls this aspect of the \-B option (defaults to 50%)\&.
\-B20%
specifies that a change with addition and deletion compared to 20% or more of the file\(cqs size are eligible for being picked up as a possible source of a rename to another file\&.
.RE
.PP
\-M[<n>], \-\-detect\-renames[=<n>]
.RS 4
Detect renames\&. If
n
is specified, it is a is a threshold on the similarity index (i\&.e\&. amount of addition/deletions compared to the file\(cqs size)\&. For example,
\-M90%
means git should consider a delete/add pair to be a rename if more than 90% of the file hasn\(cqt changed\&.
.RE
.PP
\-C[<n>], \-\-detect\-copies[=<n>]
.RS 4
Detect copies as well as renames\&. See also
\-\-find\-copies\-harder\&. If
n
is specified, it has the same meaning as for
\-M<n>\&.
.RE
.PP
\-\-diff\-filter=[(A|C|D|M|R|T|U|X|B)\&...[*]]
.RS 4
Select only files that are Added (A), Copied (C), Deleted (D), Modified (M), Renamed (R), have their type (i\&.e\&. regular file, symlink, submodule, \&...) changed (T), are Unmerged (U), are Unknown (X), or have had their pairing Broken (B)\&. Any combination of the filter characters (including none) can be used\&. When
*
(All\-or\-none) is added to the combination, all paths are selected if there is any file that matches other criteria in the comparison; if there is no file that matches other criteria, nothing is selected\&.
.RE
.PP
\-\-find\-copies\-harder
.RS 4
For performance reasons, by default,
\-C
option finds copies only if the original file of the copy was modified in the same changeset\&. This flag makes the command inspect unmodified files as candidates for the source of copy\&. This is a very expensive operation for large projects, so use it with caution\&. Giving more than one
\-C
option has the same effect\&.
.RE
.PP
\-l<num>
.RS 4
The
\-M
and
\-C
options require O(n^2) processing time where n is the number of potential rename/copy targets\&. This option prevents rename/copy detection from running if the number of rename/copy targets exceeds the specified number\&.
.RE
.PP
\-S<string>
.RS 4
Look for differences that introduce or remove an instance of <string>\&. Note that this is different than the string simply appearing in diff output; see the
\fIpickaxe\fR
entry in
\fBgitdiffcore\fR(7)
for more details\&.
.RE
.PP
\-G<regex>
.RS 4
Look for differences whose added or removed line matches the given <regex>\&.
.RE
.PP
\-\-pickaxe\-all
.RS 4
When
\-S
or
\-G
finds a change, show all the changes in that changeset, not just the files that contain the change in <string>\&.
.RE
.PP
\-\-pickaxe\-regex
.RS 4
Make the <string> not a plain string but an extended POSIX regex to match\&.
.RE
.PP
\-O<orderfile>
.RS 4
Output the patch in the order specified in the <orderfile>, which has one shell glob pattern per line\&.
.RE
.PP
\-R
.RS 4
Swap two inputs; that is, show differences from index or on\-disk file to tree contents\&.
.RE
.PP
\-\-relative[=<path>]
.RS 4
When run from a subdirectory of the project, it can be told to exclude changes outside the directory and show pathnames relative to it with this option\&. When you are not in a subdirectory (e\&.g\&. in a bare repository), you can name which subdirectory to make the output relative to by giving a <path> as an argument\&.
.RE
.PP
\-a, \-\-text
.RS 4
Treat all files as text\&.
.RE
.PP
\-\-ignore\-space\-at\-eol
.RS 4
Ignore changes in whitespace at EOL\&.
.RE
.PP
\-b, \-\-ignore\-space\-change
.RS 4
Ignore changes in amount of whitespace\&. This ignores whitespace at line end, and considers all other sequences of one or more whitespace characters to be equivalent\&.
.RE
.PP
\-w, \-\-ignore\-all\-space
.RS 4
Ignore whitespace when comparing lines\&. This ignores differences even if one line has whitespace where the other line has none\&.
.RE
.PP
\-\-inter\-hunk\-context=<lines>
.RS 4
Show the context between diff hunks, up to the specified number of lines, thereby fusing hunks that are close to each other\&.
.RE
.PP
\-\-exit\-code
.RS 4
Make the program exit with codes similar to diff(1)\&. That is, it exits with 1 if there were differences and 0 means no differences\&.
.RE
.PP
\-\-quiet
.RS 4
Disable all output of the program\&. Implies
\-\-exit\-code\&.
.RE
.PP
\-\-ext\-diff
.RS 4
Allow an external diff helper to be executed\&. If you set an external diff driver with
\fBgitattributes\fR(5), you need to use this option with
\fBgit-log\fR(1)
and friends\&.
.RE
.PP
\-\-no\-ext\-diff
.RS 4
Disallow external diff drivers\&.
.RE
.PP
\-\-ignore\-submodules[=<when>]
.RS 4
Ignore changes to submodules in the diff generation\&. <when> can be either "none", "untracked", "dirty" or "all", which is the default Using "none" will consider the submodule modified when it either contains untracked or modified files or its HEAD differs from the commit recorded in the superproject and can be used to override any settings of the
\fIignore\fR
option in
\fBgit-config\fR(1)
or
\fBgitmodules\fR(5)\&. When "untracked" is used submodules are not considered dirty when they only contain untracked content (but they are still scanned for modified content)\&. Using "dirty" ignores all changes to the work tree of submodules, only changes to the commits stored in the superproject are shown (this was the behavior until 1\&.7\&.0)\&. Using "all" hides all changes to submodules\&.
.RE
.PP
\-\-src\-prefix=<prefix>
.RS 4
Show the given source prefix instead of "a/"\&.
.RE
.PP
\-\-dst\-prefix=<prefix>
.RS 4
Show the given destination prefix instead of "b/"\&.
.RE
.PP
\-\-no\-prefix
.RS 4
Do not show any source or destination prefix\&.
.RE
.sp
For more detailed explanation on these common options, see also \fBgitdiffcore\fR(7)\&.
.PP
<tree\-ish>
.RS 4
The id of a tree object to diff against\&.
.RE
.PP
\-\-cached
.RS 4
do not consider the on\-disk file at all
.RE
.PP
\-m
.RS 4
By default, files recorded in the index but not checked out are reported as deleted\&. This flag makes
\fIgit diff\-index\fR
say that all non\-checked\-out files are up to date\&.
.RE
.SH "RAW OUTPUT FORMAT"
.sp
The raw output format from "git\-diff\-index", "git\-diff\-tree", "git\-diff\-files" and "git diff \-\-raw" are very similar\&.
.sp
These commands all compare two sets of things; what is compared differs:
.PP
git\-diff\-index <tree\-ish>
.RS 4
compares the <tree\-ish> and the files on the filesystem\&.
.RE
.PP
git\-diff\-index \-\-cached <tree\-ish>
.RS 4
compares the <tree\-ish> and the index\&.
.RE
.PP
git\-diff\-tree [\-r] <tree\-ish\-1> <tree\-ish\-2> [<pattern>\&...]
.RS 4
compares the trees named by the two arguments\&.
.RE
.PP
git\-diff\-files [<pattern>\&...]
.RS 4
compares the index and the files on the filesystem\&.
.RE
.sp
The "git\-diff\-tree" command begins its output by printing the hash of what is being compared\&. After that, all the commands print one output line per changed file\&.
.sp
An output line is formatted this way:
.sp
.if n \{\
.RS 4
.\}
.nf
in\-place edit :100644 100644 bcd1234\&.\&.\&. 0123456\&.\&.\&. M file0
copy\-edit :100644 100644 abcd123\&.\&.\&. 1234567\&.\&.\&. C68 file1 file2
rename\-edit :100644 100644 abcd123\&.\&.\&. 1234567\&.\&.\&. R86 file1 file3
create :000000 100644 0000000\&.\&.\&. 1234567\&.\&.\&. A file4
delete :100644 000000 1234567\&.\&.\&. 0000000\&.\&.\&. D file5
unmerged :000000 000000 0000000\&.\&.\&. 0000000\&.\&.\&. U file6
.fi
.if n \{\
.RE
.\}
.sp
.sp
That is, from the left to the right:
.sp
.RS 4
.ie n \{\
\h'-04' 1.\h'+01'\c
.\}
.el \{\
.sp -1
.IP " 1." 4.2
.\}
a colon\&.
.RE
.sp
.RS 4
.ie n \{\
\h'-04' 2.\h'+01'\c
.\}
.el \{\
.sp -1
.IP " 2." 4.2
.\}
mode for "src"; 000000 if creation or unmerged\&.
.RE
.sp
.RS 4
.ie n \{\
\h'-04' 3.\h'+01'\c
.\}
.el \{\
.sp -1
.IP " 3." 4.2
.\}
a space\&.
.RE
.sp
.RS 4
.ie n \{\
\h'-04' 4.\h'+01'\c
.\}
.el \{\
.sp -1
.IP " 4." 4.2
.\}
mode for "dst"; 000000 if deletion or unmerged\&.
.RE
.sp
.RS 4
.ie n \{\
\h'-04' 5.\h'+01'\c
.\}
.el \{\
.sp -1
.IP " 5." 4.2
.\}
a space\&.
.RE
.sp
.RS 4
.ie n \{\
\h'-04' 6.\h'+01'\c
.\}
.el \{\
.sp -1
.IP " 6." 4.2
.\}
sha1 for "src"; 0{40} if creation or unmerged\&.
.RE
.sp
.RS 4
.ie n \{\
\h'-04' 7.\h'+01'\c
.\}
.el \{\
.sp -1
.IP " 7." 4.2
.\}
a space\&.
.RE
.sp
.RS 4
.ie n \{\
\h'-04' 8.\h'+01'\c
.\}
.el \{\
.sp -1
.IP " 8." 4.2
.\}
sha1 for "dst"; 0{40} if creation, unmerged or "look at work tree"\&.
.RE
.sp
.RS 4
.ie n \{\
\h'-04' 9.\h'+01'\c
.\}
.el \{\
.sp -1
.IP " 9." 4.2
.\}
a space\&.
.RE
.sp
.RS 4
.ie n \{\
\h'-04'10.\h'+01'\c
.\}
.el \{\
.sp -1
.IP "10." 4.2
.\}
status, followed by optional "score" number\&.
.RE
.sp
.RS 4
.ie n \{\
\h'-04'11.\h'+01'\c
.\}
.el \{\
.sp -1
.IP "11." 4.2
.\}
a tab or a NUL when
\fI\-z\fR
option is used\&.
.RE
.sp
.RS 4
.ie n \{\
\h'-04'12.\h'+01'\c
.\}
.el \{\
.sp -1
.IP "12." 4.2
.\}
path for "src"
.RE
.sp
.RS 4
.ie n \{\
\h'-04'13.\h'+01'\c
.\}
.el \{\
.sp -1
.IP "13." 4.2
.\}
a tab or a NUL when
\fI\-z\fR
option is used; only exists for C or R\&.
.RE
.sp
.RS 4
.ie n \{\
\h'-04'14.\h'+01'\c
.\}
.el \{\
.sp -1
.IP "14." 4.2
.\}
path for "dst"; only exists for C or R\&.
.RE
.sp
.RS 4
.ie n \{\
\h'-04'15.\h'+01'\c
.\}
.el \{\
.sp -1
.IP "15." 4.2
.\}
an LF or a NUL when
\fI\-z\fR
option is used, to terminate the record\&.
.RE
.sp
Possible status letters are:
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
A: addition of a file
.RE
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
C: copy of a file into a new one
.RE
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
D: deletion of a file
.RE
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
M: modification of the contents or mode of a file
.RE
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
R: renaming of a file
.RE
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
T: change in the type of the file
.RE
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
U: file is unmerged (you must complete the merge before it can be committed)
.RE
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
X: "unknown" change type (most probably a bug, please report it)
.RE
.sp
Status letters C and R are always followed by a score (denoting the percentage of similarity between the source and target of the move or copy), and are the only ones to be so\&.
.sp
<sha1> is shown as all 0\(cqs if a file is new on the filesystem and it is out of sync with the index\&.
.sp
Example:
.sp
.if n \{\
.RS 4
.\}
.nf
:100644 100644 5be4a4\&.\&.\&.\&.\&.\&. 000000\&.\&.\&.\&.\&.\&. M file\&.c
.fi
.if n \{\
.RE
.\}
.sp
.sp
When \-z option is not used, TAB, LF, and backslash characters in pathnames are represented as \et, \en, and \e\e, respectively\&.
.SH "DIFF FORMAT FOR MERGES"
.sp
"git\-diff\-tree", "git\-diff\-files" and "git\-diff \-\-raw" can take \fI\-c\fR or \fI\-\-cc\fR option to generate diff output also for merge commits\&. The output differs from the format described above in the following way:
.sp
.RS 4
.ie n \{\
\h'-04' 1.\h'+01'\c
.\}
.el \{\
.sp -1
.IP " 1." 4.2
.\}
there is a colon for each parent
.RE
.sp
.RS 4
.ie n \{\
\h'-04' 2.\h'+01'\c
.\}
.el \{\
.sp -1
.IP " 2." 4.2
.\}
there are more "src" modes and "src" sha1
.RE
.sp
.RS 4
.ie n \{\
\h'-04' 3.\h'+01'\c
.\}
.el \{\
.sp -1
.IP " 3." 4.2
.\}
status is concatenated status characters for each parent
.RE
.sp
.RS 4
.ie n \{\
\h'-04' 4.\h'+01'\c
.\}
.el \{\
.sp -1
.IP " 4." 4.2
.\}
no optional "score" number
.RE
.sp
.RS 4
.ie n \{\
\h'-04' 5.\h'+01'\c
.\}
.el \{\
.sp -1
.IP " 5." 4.2
.\}
single path, only for "dst"
.RE
.sp
Example:
.sp
.if n \{\
.RS 4
.\}
.nf
::100644 100644 100644 fabadb8\&.\&.\&. cc95eb0\&.\&.\&. 4866510\&.\&.\&. MM describe\&.c
.fi
.if n \{\
.RE
.\}
.sp
.sp
Note that \fIcombined diff\fR lists only files which were modified from all parents\&.
.SH "GENERATING PATCHES WITH -P"
.sp
When "git\-diff\-index", "git\-diff\-tree", or "git\-diff\-files" are run with a \fI\-p\fR option, "git diff" without the \fI\-\-raw\fR option, or "git log" with the "\-p" option, they do not produce the output described above; instead they produce a patch file\&. You can customize the creation of such patches via the GIT_EXTERNAL_DIFF and the GIT_DIFF_OPTS environment variables\&.
.sp
What the \-p option produces is slightly different from the traditional diff format:
.sp
.RS 4
.ie n \{\
\h'-04' 1.\h'+01'\c
.\}
.el \{\
.sp -1
.IP " 1." 4.2
.\}
It is preceded with a "git diff" header that looks like this:
.sp
.if n \{\
.RS 4
.\}
.nf
diff \-\-git a/file1 b/file2
.fi
.if n \{\
.RE
.\}
.sp
The
a/
and
b/
filenames are the same unless rename/copy is involved\&. Especially, even for a creation or a deletion,
/dev/null
is
\fInot\fR
used in place of the
a/
or
b/
filenames\&.
.sp
When rename/copy is involved,
file1
and
file2
show the name of the source file of the rename/copy and the name of the file that rename/copy produces, respectively\&.
.RE
.sp
.RS 4
.ie n \{\
\h'-04' 2.\h'+01'\c
.\}
.el \{\
.sp -1
.IP " 2." 4.2
.\}
It is followed by one or more extended header lines:
.sp
.if n \{\
.RS 4
.\}
.nf
old mode <mode>
new mode <mode>
deleted file mode <mode>
new file mode <mode>
copy from <path>
copy to <path>
rename from <path>
rename to <path>
similarity index <number>
dissimilarity index <number>
index <hash>\&.\&.<hash> <mode>
.fi
.if n \{\
.RE
.\}
.sp
File modes are printed as 6\-digit octal numbers including the file type and file permission bits\&.
.sp
Path names in extended headers do not include the
a/
and
b/
prefixes\&.
.sp
The similarity index is the percentage of unchanged lines, and the dissimilarity index is the percentage of changed lines\&. It is a rounded down integer, followed by a percent sign\&. The similarity index value of 100% is thus reserved for two equal files, while 100% dissimilarity means that no line from the old file made it into the new one\&.
.sp
The index line includes the SHA\-1 checksum before and after the change\&. The <mode> is included if the file mode does not change; otherwise, separate lines indicate the old and the new mode\&.
.RE
.sp
.RS 4
.ie n \{\
\h'-04' 3.\h'+01'\c
.\}
.el \{\
.sp -1
.IP " 3." 4.2
.\}
TAB, LF, double quote and backslash characters in pathnames are represented as
\et,
\en,
\e"
and
\e\e, respectively\&. If there is need for such substitution then the whole pathname is put in double quotes\&.
.RE
.sp
.RS 4
.ie n \{\
\h'-04' 4.\h'+01'\c
.\}
.el \{\
.sp -1
.IP " 4." 4.2
.\}
All the
file1
files in the output refer to files before the commit, and all the
file2
files refer to files after the commit\&. It is incorrect to apply each change to each file sequentially\&. For example, this patch will swap a and b:
.sp
.if n \{\
.RS 4
.\}
.nf
diff \-\-git a/a b/b
rename from a
rename to b
diff \-\-git a/b b/a
rename from b
rename to a
.fi
.if n \{\
.RE
.\}
.RE
.SH "COMBINED DIFF FORMAT"
.sp
"git\-diff\-tree", "git\-diff\-files" and "git\-diff" can take \fI\-c\fR or \fI\-\-cc\fR option to produce \fIcombined diff\fR\&. For showing a merge commit with "git log \-p", this is the default format; you can force showing full diff with the \fI\-m\fR option\&. A \fIcombined diff\fR format looks like this:
.sp
.if n \{\
.RS 4
.\}
.nf
diff \-\-combined describe\&.c
index fabadb8,cc95eb0\&.\&.4866510
\-\-\- a/describe\&.c
+++ b/describe\&.c
@@@ \-98,20 \-98,12 +98,20 @@@
return (a_date > b_date) ? \-1 : (a_date == b_date) ? 0 : 1;
}
\- static void describe(char *arg)
\-static void describe(struct commit *cmit, int last_one)
++static void describe(char *arg, int last_one)