blob: 7405535ce66d7b7847fc46d5aa6035b8c9b99dd9 [file] [log] [blame]
Junio C Hamano1a4e8412005-12-27 08:17:231<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
2 "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
3<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
4<head>
5<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
Junio C Hamano6ec31b92006-02-10 05:52:016<meta name="generator" content="AsciiDoc 7.0.2" />
Junio C Hamano1a4e8412005-12-27 08:17:237<style type="text/css">
8/* Debug borders */
9p, li, dt, dd, div, pre, h1, h2, h3, h4, h5, h6 {
10/*
11 border: 1px solid red;
12*/
13}
14
15body {
16 margin: 1em 5% 1em 5%;
17}
18
19a { color: blue; }
20a:visited { color: fuchsia; }
21
22em {
23 font-style: italic;
24}
25
26strong {
27 font-weight: bold;
28}
29
30tt {
31 color: navy;
32}
33
34h1, h2, h3, h4, h5, h6 {
35 color: #527bbd;
36 font-family: sans-serif;
37 margin-top: 1.2em;
38 margin-bottom: 0.5em;
39 line-height: 1.3;
40}
41
42h1 {
43 border-bottom: 2px solid silver;
44}
45h2 {
46 border-bottom: 2px solid silver;
47 padding-top: 0.5em;
48}
49
50div.sectionbody {
51 font-family: serif;
52 margin-left: 0;
53}
54
55hr {
56 border: 1px solid silver;
57}
58
59p {
60 margin-top: 0.5em;
61 margin-bottom: 0.5em;
62}
63
64pre {
65 padding: 0;
66 margin: 0;
67}
68
69span#author {
70 color: #527bbd;
71 font-family: sans-serif;
72 font-weight: bold;
73 font-size: 1.2em;
74}
75span#email {
76}
77span#revision {
78 font-family: sans-serif;
79}
80
81div#footer {
82 font-family: sans-serif;
83 font-size: small;
84 border-top: 2px solid silver;
85 padding-top: 0.5em;
86 margin-top: 4.0em;
87}
88div#footer-text {
89 float: left;
90 padding-bottom: 0.5em;
91}
92div#footer-badges {
93 float: right;
94 padding-bottom: 0.5em;
95}
96
97div#preamble,
98div.tableblock, div.imageblock, div.exampleblock, div.verseblock,
99div.quoteblock, div.literalblock, div.listingblock, div.sidebarblock,
100div.admonitionblock {
101 margin-right: 10%;
102 margin-top: 1.5em;
103 margin-bottom: 1.5em;
104}
105div.admonitionblock {
106 margin-top: 2.5em;
107 margin-bottom: 2.5em;
108}
109
110div.content { /* Block element content. */
111 padding: 0;
112}
113
114/* Block element titles. */
115div.title, caption.title {
116 font-family: sans-serif;
117 font-weight: bold;
118 text-align: left;
119 margin-top: 1.0em;
120 margin-bottom: 0.5em;
121}
122div.title + * {
123 margin-top: 0;
124}
125
126td div.title:first-child {
127 margin-top: 0.0em;
128}
129div.content div.title:first-child {
130 margin-top: 0.0em;
131}
132div.content + div.title {
133 margin-top: 0.0em;
134}
135
136div.sidebarblock > div.content {
137 background: #ffffee;
138 border: 1px solid silver;
139 padding: 0.5em;
140}
141
142div.listingblock > div.content {
143 border: 1px solid silver;
144 background: #f4f4f4;
145 padding: 0.5em;
146}
147
148div.quoteblock > div.content {
149 padding-left: 2.0em;
150}
151div.quoteblock .attribution {
152 text-align: right;
153}
154
155div.admonitionblock .icon {
156 vertical-align: top;
157 font-size: 1.1em;
158 font-weight: bold;
159 text-decoration: underline;
160 color: #527bbd;
161 padding-right: 0.5em;
162}
163div.admonitionblock td.content {
164 padding-left: 0.5em;
165 border-left: 2px solid silver;
166}
167
168div.exampleblock > div.content {
169 border-left: 2px solid silver;
170 padding: 0.5em;
171}
172
173div.verseblock div.content {
174 white-space: pre;
175}
176
177div.imageblock div.content { padding-left: 0; }
178div.imageblock img { border: 1px solid silver; }
179span.image img { border-style: none; }
180
181dl {
182 margin-top: 0.8em;
183 margin-bottom: 0.8em;
184}
185dt {
186 margin-top: 0.5em;
187 margin-bottom: 0;
188 font-style: italic;
189}
190dd > *:first-child {
191 margin-top: 0;
192}
193
194ul, ol {
195 list-style-position: outside;
196}
197ol.olist2 {
198 list-style-type: lower-alpha;
199}
200
201div.tableblock > table {
202 border-color: #527bbd;
203 border-width: 3px;
204}
205thead {
206 font-family: sans-serif;
207 font-weight: bold;
208}
209tfoot {
210 font-weight: bold;
211}
212
213div.hlist {
214 margin-top: 0.8em;
215 margin-bottom: 0.8em;
216}
217td.hlist1 {
218 vertical-align: top;
219 font-style: italic;
220 padding-right: 0.8em;
221}
222td.hlist2 {
223 vertical-align: top;
224}
225
226@media print {
227 div#footer-badges { display: none; }
228}
229include::./stylesheets/xhtml11-manpage.css[]
230/* Workarounds for IE6's broken and incomplete CSS2. */
231
232div.sidebar-content {
233 background: #ffffee;
234 border: 1px solid silver;
235 padding: 0.5em;
236}
237div.sidebar-title, div.image-title {
238 font-family: sans-serif;
239 font-weight: bold;
240 margin-top: 0.0em;
241 margin-bottom: 0.5em;
242}
243
244div.listingblock div.content {
245 border: 1px solid silver;
246 background: #f4f4f4;
247 padding: 0.5em;
248}
249
250div.quoteblock-content {
251 padding-left: 2.0em;
252}
253
254div.exampleblock-content {
255 border-left: 2px solid silver;
256 padding-left: 0.5em;
257}
258</style>
259<title>git-diff-files(1)</title>
260</head>
261<body>
262<div id="header">
263<h1>
264git-diff-files(1) Manual Page
265</h1>
266<h2>NAME</h2>
267<div class="sectionbody">
268<p>git-diff-files -
269 Compares files in the working tree and the index
270</p>
271</div>
272</div>
273<h2>SYNOPSIS</h2>
274<div class="sectionbody">
Junio C Hamanofb56a962006-01-28 10:38:19275<p><em>git-diff-files</em> [-q] [-0|-1|-2|-3|-c|--cc] [&lt;common diff options&gt;] [&lt;path&gt;&#8230;]</p>
Junio C Hamano1a4e8412005-12-27 08:17:23276</div>
277<h2>DESCRIPTION</h2>
278<div class="sectionbody">
279<p>Compares the files in the working tree and the index. When paths
280are specified, compares only those named paths. Otherwise all
281entries in the index are compared. The output format is the
282same as "git-diff-index" and "git-diff-tree".</p>
283</div>
284<h2>OPTIONS</h2>
285<div class="sectionbody">
286<dl>
287<dt>
288-p
289</dt>
290<dd>
291<p>
292 Generate patch (see section on generating patches)
293</p>
294</dd>
295<dt>
296-u
297</dt>
298<dd>
299<p>
300 Synonym for "-p".
301</p>
302</dd>
303<dt>
Junio C Hamano9ae1a062006-07-10 08:12:34304--raw
305</dt>
306<dd>
307<p>
308 Generate the raw format.
309</p>
310</dd>
311<dt>
Junio C Hamano54559c82006-04-13 07:45:12312--patch-with-raw
313</dt>
314<dd>
315<p>
Junio C Hamano9ae1a062006-07-10 08:12:34316 Synonym for "-p --raw".
Junio C Hamano54559c82006-04-13 07:45:12317</p>
318</dd>
319<dt>
Junio C Hamano4a9a76a2006-10-01 05:40:29320--stat[=width[,name-width]]
Junio C Hamanoba7c8d82006-04-15 06:17:42321</dt>
322<dd>
323<p>
Junio C Hamano4a9a76a2006-10-01 05:40:29324 Generate a diffstat. You can override the default
325 output width for 80-column terminal by "--stat=width".
326 The width of the filename part can be controlled by
327 giving another width to it separated by a comma.
Junio C Hamanoba7c8d82006-04-15 06:17:42328</p>
329</dd>
330<dt>
Junio C Hamanofbe00522006-10-19 05:58:48331--numstat
332</dt>
333<dd>
334<p>
335 Similar to --stat, but shows number of added and
336 deleted lines in decimal notation and pathname without
Junio C Hamanod793de52006-12-26 09:11:43337 abbreviation, to make it more machine friendly. For
338 binary files, outputs two <tt>-</tt> instead of saying
339 <tt>0 0</tt>.
Junio C Hamanofbe00522006-10-19 05:58:48340</p>
341</dd>
342<dt>
Junio C Hamano7d23f5e2006-12-16 07:44:04343--shortstat
344</dt>
345<dd>
346<p>
347 Output only the last line of the --stat format containing total
348 number of modified files, as well as number of added and deleted
349 lines.
350</p>
351</dd>
352<dt>
Junio C Hamano6959c6c2006-05-17 10:34:11353--summary
354</dt>
355<dd>
356<p>
357 Output a condensed summary of extended header information
358 such as creations, renames and mode changes.
359</p>
360</dd>
361<dt>
Junio C Hamanod1308c92006-04-16 11:01:09362--patch-with-stat
363</dt>
364<dd>
365<p>
Junio C Hamano9ae1a062006-07-10 08:12:34366 Synonym for "-p --stat".
Junio C Hamanod1308c92006-04-16 11:01:09367</p>
368</dd>
369<dt>
Junio C Hamano1a4e8412005-12-27 08:17:23370-z
371</dt>
372<dd>
373<p>
374 \0 line termination on output
375</p>
376</dd>
377<dt>
378--name-only
379</dt>
380<dd>
381<p>
382 Show only names of changed files.
383</p>
384</dd>
385<dt>
386--name-status
387</dt>
388<dd>
389<p>
390 Show only names and status of changed files.
391</p>
392</dd>
393<dt>
Junio C Hamano9ae1a062006-07-10 08:12:34394--color
395</dt>
396<dd>
397<p>
398 Show colored diff.
399</p>
400</dd>
401<dt>
402--no-color
403</dt>
404<dd>
405<p>
406 Turn off colored diff, even when the configuration file
407 gives the default to color output.
408</p>
409</dd>
410<dt>
Junio C Hamano85e45fa2006-08-13 07:47:41411--color-words
412</dt>
413<dd>
414<p>
415 Show colored word diff, i.e. color words which have changed.
416</p>
417</dd>
418<dt>
Junio C Hamano9ae1a062006-07-10 08:12:34419--no-renames
420</dt>
421<dd>
422<p>
423 Turn off rename detection, even when the configuration
424 file gives the default to do so.
425</p>
426</dd>
427<dt>
Junio C Hamanoa890c4f2007-01-28 10:29:21428--check
429</dt>
430<dd>
431<p>
432 Warn if changes introduce trailing whitespace
433 or an indent that uses a space before a tab.
434</p>
435</dd>
436<dt>
Junio C Hamano1a4e8412005-12-27 08:17:23437--full-index
438</dt>
439<dd>
440<p>
441 Instead of the first handful characters, show full
442 object name of pre- and post-image blob on the "index"
443 line when generating a patch format output.
444</p>
445</dd>
446<dt>
Junio C Hamano9ae1a062006-07-10 08:12:34447--binary
448</dt>
449<dd>
450<p>
451 In addition to --full-index, output "binary diff" that
452 can be applied with "git apply".
453</p>
454</dd>
455<dt>
Junio C Hamano1a4e8412005-12-27 08:17:23456--abbrev[=&lt;n&gt;]
457</dt>
458<dd>
459<p>
460 Instead of showing the full 40-byte hexadecimal object
461 name in diff-raw format output and diff-tree header
Junio C Hamano235a91e2006-01-07 01:13:58462 lines, show only handful hexdigits prefix. This is
Junio C Hamano1a4e8412005-12-27 08:17:23463 independent of --full-index option above, which controls
464 the diff-patch output format. Non default number of
465 digits can be specified with --abbrev=&lt;n&gt;.
466</p>
467</dd>
468<dt>
469-B
470</dt>
471<dd>
472<p>
473 Break complete rewrite changes into pairs of delete and create.
474</p>
475</dd>
476<dt>
477-M
478</dt>
479<dd>
480<p>
481 Detect renames.
482</p>
483</dd>
484<dt>
485-C
486</dt>
487<dd>
488<p>
489 Detect copies as well as renames.
490</p>
491</dd>
492<dt>
Junio C Hamano6ec31b92006-02-10 05:52:01493--diff-filter=[ACDMRTUXB*]
494</dt>
495<dd>
496<p>
497 Select only files that are Added (<tt>A</tt>), Copied (<tt>C</tt>),
498 Deleted (<tt>D</tt>), Modified (<tt>M</tt>), Renamed (<tt>R</tt>), have their
499 type (mode) changed (<tt>T</tt>), are Unmerged (<tt>U</tt>), are
500 Unknown (<tt>X</tt>), or have had their pairing Broken (<tt>B</tt>).
501 Any combination of the filter characters may be used.
502 When <tt>*</tt> (All-or-none) is added to the combination, all
503 paths are selected if there is any file that matches
504 other criteria in the comparison; if there is no file
505 that matches other criteria, nothing is selected.
506</p>
507</dd>
508<dt>
Junio C Hamano1a4e8412005-12-27 08:17:23509--find-copies-harder
510</dt>
511<dd>
512<p>
513 For performance reasons, by default, -C option finds copies only
514 if the original file of the copy was modified in the same
515 changeset. This flag makes the command
516 inspect unmodified files as candidates for the source of
517 copy. This is a very expensive operation for large
518 projects, so use it with caution.
519</p>
520</dd>
521<dt>
522-l&lt;num&gt;
523</dt>
524<dd>
525<p>
526 -M and -C options require O(n^2) processing time where n
527 is the number of potential rename/copy targets. This
528 option prevents rename/copy detection from running if
529 the number of rename/copy targets exceeds the specified
530 number.
531</p>
532</dd>
533<dt>
534-S&lt;string&gt;
535</dt>
536<dd>
537<p>
538 Look for differences that contain the change in &lt;string&gt;.
539</p>
540</dd>
541<dt>
542--pickaxe-all
543</dt>
544<dd>
545<p>
546 When -S finds a change, show all the changes in that
547 changeset, not just the files that contain the change
548 in &lt;string&gt;.
549</p>
550</dd>
551<dt>
Junio C Hamanobfe9e752006-04-05 21:43:28552--pickaxe-regex
553</dt>
554<dd>
555<p>
556 Make the &lt;string&gt; not a plain string but an extended POSIX
557 regex to match.
558</p>
559</dd>
560<dt>
Junio C Hamano1a4e8412005-12-27 08:17:23561-O&lt;orderfile&gt;
562</dt>
563<dd>
564<p>
565 Output the patch in the order specified in the
566 &lt;orderfile&gt;, which has one shell glob pattern per line.
567</p>
568</dd>
569<dt>
570-R
571</dt>
572<dd>
573<p>
574 Swap two inputs; that is, show differences from index or
575 on-disk file to tree contents.
576</p>
577</dd>
Junio C Hamanoc26f5482006-07-09 09:38:14578<dt>
579--text
580</dt>
581<dd>
582<p>
583 Treat all files as text.
584</p>
585</dd>
586<dt>
587-a
588</dt>
589<dd>
590<p>
591 Shorthand for "--text".
592</p>
593</dd>
Junio C Hamanod9c2d2f2006-12-06 08:59:07594<dt>
595--ignore-space-change
596</dt>
597<dd>
598<p>
599 Ignore changes in amount of white space. This ignores white
600 space at line end, and consider all other sequences of one or
601 more white space characters to be equivalent.
602</p>
603</dd>
604<dt>
605-b
606</dt>
607<dd>
608<p>
609 Shorthand for "--ignore-space-change".
610</p>
611</dd>
612<dt>
613--ignore-all-space
614</dt>
615<dd>
616<p>
617 Ignore white space when comparing lines. This ignores
618 difference even if one line has white space where the other
619 line has none.
620</p>
621</dd>
622<dt>
623-w
624</dt>
625<dd>
626<p>
627 Shorthand for "--ignore-all-space".
628</p>
629</dd>
Junio C Hamano1a4e8412005-12-27 08:17:23630</dl>
631<p>For more detailed explanation on these common options, see also
632<a href="diffcore.html">diffcore documentation</a>.</p>
633<dl>
634<dt>
635-1 -2 -3 or --base --ours --theirs, and -0
636</dt>
637<dd>
638<p>
639 Diff against the "base" version, "our branch" or "their
640 branch" respectively. With these options, diffs for
641 merged entries are not shown.
642</p>
643<p>The default is to diff against our branch (-2) and the
644cleanly resolved paths. The option -0 can be given to
645omit diff output for unmerged entries and just show "Unmerged".</p>
646</dd>
647<dt>
Junio C Hamanofb56a962006-01-28 10:38:19648-c,--cc
649</dt>
650<dd>
651<p>
652 This compares stage 2 (our branch), stage 3 (their
653 branch) and the working tree file and outputs a combined
654 diff, similar to the way <em>diff-tree</em> shows a merge
655 commit with these flags.
656</p>
657</dd>
658<dt>
Junio C Hamano1a4e8412005-12-27 08:17:23659-q
660</dt>
661<dd>
662<p>
Junio C Hamano51c2ab02006-07-09 20:38:54663 Remain silent even on nonexistent files
Junio C Hamano1a4e8412005-12-27 08:17:23664</p>
665</dd>
666</dl>
667</div>
668<h2>Output format</h2>
669<div class="sectionbody">
670<p>The output format from "git-diff-index", "git-diff-tree" and
671"git-diff-files" are very similar.</p>
672<p>These commands all compare two sets of things; what is
673compared differs:</p>
674<dl>
675<dt>
676git-diff-index &lt;tree-ish&gt;
677</dt>
678<dd>
679<p>
680 compares the &lt;tree-ish&gt; and the files on the filesystem.
681</p>
682</dd>
683<dt>
684git-diff-index --cached &lt;tree-ish&gt;
685</dt>
686<dd>
687<p>
688 compares the &lt;tree-ish&gt; and the index.
689</p>
690</dd>
691<dt>
692git-diff-tree [-r] &lt;tree-ish-1&gt; &lt;tree-ish-2&gt; [&lt;pattern&gt;&#8230;]
693</dt>
694<dd>
695<p>
696 compares the trees named by the two arguments.
697</p>
698</dd>
699<dt>
700git-diff-files [&lt;pattern&gt;&#8230;]
701</dt>
702<dd>
703<p>
704 compares the index and the files on the filesystem.
705</p>
706</dd>
707</dl>
708<p>An output line is formatted this way:</p>
709<div class="listingblock">
710<div class="content">
711<pre><tt>in-place edit :100644 100644 bcd1234... 0123456... M file0
712copy-edit :100644 100644 abcd123... 1234567... C68 file1 file2
713rename-edit :100644 100644 abcd123... 1234567... R86 file1 file3
714create :000000 100644 0000000... 1234567... A file4
715delete :100644 000000 1234567... 0000000... D file5
716unmerged :000000 000000 0000000... 0000000... U file6</tt></pre>
717</div></div>
718<p>That is, from the left to the right:</p>
719<ol>
720<li>
721<p>
722a colon.
723</p>
724</li>
725<li>
726<p>
727mode for "src"; 000000 if creation or unmerged.
728</p>
729</li>
730<li>
731<p>
732a space.
733</p>
734</li>
735<li>
736<p>
737mode for "dst"; 000000 if deletion or unmerged.
738</p>
739</li>
740<li>
741<p>
742a space.
743</p>
744</li>
745<li>
746<p>
747sha1 for "src"; 0{40} if creation or unmerged.
748</p>
749</li>
750<li>
751<p>
752a space.
753</p>
754</li>
755<li>
756<p>
757sha1 for "dst"; 0{40} if creation, unmerged or "look at work tree".
758</p>
759</li>
760<li>
761<p>
762a space.
763</p>
764</li>
765<li>
766<p>
767status, followed by optional "score" number.
768</p>
769</li>
770<li>
771<p>
772a tab or a NUL when <em>-z</em> option is used.
773</p>
774</li>
775<li>
776<p>
777path for "src"
778</p>
779</li>
780<li>
781<p>
782a tab or a NUL when <em>-z</em> option is used; only exists for C or R.
783</p>
784</li>
785<li>
786<p>
787path for "dst"; only exists for C or R.
788</p>
789</li>
790<li>
791<p>
792an LF or a NUL when <em>-z</em> option is used, to terminate the record.
793</p>
794</li>
795</ol>
796<p>&lt;sha1&gt; is shown as all 0's if a file is new on the filesystem
797and it is out of sync with the index.</p>
798<p>Example:</p>
799<div class="listingblock">
800<div class="content">
801<pre><tt>:100644 100644 5be4a4...... 000000...... M file.c</tt></pre>
802</div></div>
803<p>When <tt>-z</tt> option is not used, TAB, LF, and backslash characters
804in pathnames are represented as <tt>\t</tt>, <tt>\n</tt>, and <tt>\\</tt>,
805respectively.</p>
806</div>
807<h2>Generating patches with -p</h2>
808<div class="sectionbody">
809<p>When "git-diff-index", "git-diff-tree", or "git-diff-files" are run
810with a <em>-p</em> option, they do not produce the output described above;
Junio C Hamano1c437122006-11-28 02:22:25811instead they produce a patch file. You can customize the creation
812of such patches via the GIT_EXTERNAL_DIFF and the GIT_DIFF_OPTS
813environment variables.</p>
814<p>What the -p option produces is slightly different from the traditional
815diff format.</p>
Junio C Hamano1a4e8412005-12-27 08:17:23816<ol>
817<li>
818<p>
Junio C Hamano235a91e2006-01-07 01:13:58819It is preceded with a "git diff" header, that looks like
Junio C Hamano1a4e8412005-12-27 08:17:23820 this:
821</p>
822<div class="literalblock">
823<div class="content">
824<pre><tt>diff --git a/file1 b/file2</tt></pre>
825</div></div>
826<p>The <tt>a/</tt> and <tt>b/</tt> filenames are the same unless rename/copy is
827involved. Especially, even for a creation or a deletion,
828<tt>/dev/null</tt> is _not_ used in place of <tt>a/</tt> or <tt>b/</tt> filenames.</p>
829<p>When rename/copy is involved, <tt>file1</tt> and <tt>file2</tt> show the
830name of the source file of the rename/copy and the name of
831the file that rename/copy produces, respectively.</p>
832</li>
833<li>
834<p>
835It is followed by one or more extended header lines:
836</p>
837<div class="literalblock">
838<div class="content">
839<pre><tt>old mode &lt;mode&gt;
840new mode &lt;mode&gt;
841deleted file mode &lt;mode&gt;
842new file mode &lt;mode&gt;
843copy from &lt;path&gt;
844copy to &lt;path&gt;
845rename from &lt;path&gt;
846rename to &lt;path&gt;
847similarity index &lt;number&gt;
848dissimilarity index &lt;number&gt;
849index &lt;hash&gt;..&lt;hash&gt; &lt;mode&gt;</tt></pre>
850</div></div>
851</li>
852<li>
853<p>
Junio C Hamanoa053d542006-10-27 09:29:13854TAB, LF, double quote and backslash characters in pathnames
855 are represented as <tt>\t</tt>, <tt>\n</tt>, <tt>\"</tt> and <tt>\\</tt>, respectively.
856 If there is need for such substitution then the whole
857 pathname is put in double quotes.
Junio C Hamano1a4e8412005-12-27 08:17:23858</p>
859</li>
860</ol>
861</div>
Junio C Hamanofb56a962006-01-28 10:38:19862<h2>combined diff format</h2>
863<div class="sectionbody">
864<p>git-diff-tree and git-diff-files can take <em>-c</em> or <em>--cc</em> option
865to produce <em>combined diff</em>, which looks like this:</p>
866<div class="listingblock">
867<div class="content">
868<pre><tt>diff --combined describe.c
Junio C Hamano29f14312006-10-26 08:47:29869index fabadb8,cc95eb0..4866510
870--- a/describe.c
871+++ b/describe.c
872@@@ -98,20 -98,12 +98,20 @@@
873 return (a_date &gt; b_date) ? -1 : (a_date == b_date) ? 0 : 1;
Junio C Hamanofb56a962006-01-28 10:38:19874 }
875
876- static void describe(char *arg)
877 -static void describe(struct commit *cmit, int last_one)
878++static void describe(char *arg, int last_one)
879 {
Junio C Hamano29f14312006-10-26 08:47:29880 + unsigned char sha1[20];
881 + struct commit *cmit;
882 struct commit_list *list;
883 static int initialized = 0;
884 struct commit_name *n;
885
886 + if (get_sha1(arg, sha1) &lt; 0)
887 + usage(describe_usage);
888 + cmit = lookup_commit_reference(sha1);
889 + if (!cmit)
890 + usage(describe_usage);
891 +
892 if (!initialized) {
893 initialized = 1;
894 for_each_ref(get_name);</tt></pre>
Junio C Hamanofb56a962006-01-28 10:38:19895</div></div>
Junio C Hamano29f14312006-10-26 08:47:29896<ol>
897<li>
898<p>
899It is preceded with a "git diff" header, that looks like
900 this (when <em>-c</em> option is used):
901</p>
902<div class="literalblock">
903<div class="content">
904<pre><tt>diff --combined file</tt></pre>
905</div></div>
906<p>or like this (when <em>--cc</em> option is used):</p>
907<div class="literalblock">
908<div class="content">
909<pre><tt>diff --c file</tt></pre>
910</div></div>
911</li>
912<li>
913<p>
914It is followed by one or more extended header lines
915 (this example shows a merge with two parents):
916</p>
917<div class="literalblock">
918<div class="content">
919<pre><tt>index &lt;hash&gt;,&lt;hash&gt;..&lt;hash&gt;
920mode &lt;mode&gt;,&lt;mode&gt;..&lt;mode&gt;
921new file mode &lt;mode&gt;
922deleted file mode &lt;mode&gt;,&lt;mode&gt;</tt></pre>
923</div></div>
924<p>The <tt>mode &lt;mode&gt;,&lt;mode&gt;..&lt;mode&gt;</tt> line appears only if at least one of
Junio C Hamanoee1e4282007-02-04 08:32:04925the &lt;mode&gt; is different from the rest. Extended headers with
Junio C Hamano29f14312006-10-26 08:47:29926information about detected contents movement (renames and
927copying detection) are designed to work with diff of two
928&lt;tree-ish&gt; and are not used by combined diff format.</p>
929</li>
930<li>
931<p>
932It is followed by two-line from-file/to-file header
933</p>
934<div class="literalblock">
935<div class="content">
936<pre><tt>--- a/file
937+++ b/file</tt></pre>
938</div></div>
939<p>Similar to two-line header for traditional <em>unified</em> diff
940format, <tt>/dev/null</tt> is used to signal created or deleted
941files.</p>
942</li>
943<li>
944<p>
945Chunk header format is modified to prevent people from
946 accidentally feeding it to <tt>patch -p1</tt>. Combined diff format
947 was created for review of merge commit changes, and was not
948 meant for apply. The change is similar to the change in the
949 extended <em>index</em> header:
950</p>
951<div class="literalblock">
952<div class="content">
953<pre><tt>@@@ &lt;from-file-range&gt; &lt;from-file-range&gt; &lt;to-file-range&gt; @@@</tt></pre>
954</div></div>
955<p>There are (number of parents + 1) <tt>@</tt> characters in the chunk
956header for combined diff format.</p>
957</li>
958</ol>
Junio C Hamanofb56a962006-01-28 10:38:19959<p>Unlike the traditional <em>unified</em> diff format, which shows two
960files A and B with a single column that has <tt>-</tt> (minus &#8212;
961appears in A but removed in B), <tt>+</tt> (plus &#8212; missing in A but
Junio C Hamano29f14312006-10-26 08:47:29962added to B), or <tt>" "</tt> (space &#8212; unchanged) prefix, this format
Junio C Hamanofb56a962006-01-28 10:38:19963compares two or more files file1, file2,&#8230; with one file X, and
964shows how X differs from each of fileN. One column for each of
965fileN is prepended to the output line to note how X's line is
966different from it.</p>
967<p>A <tt>-</tt> character in the column N means that the line appears in
Junio C Hamano29f14312006-10-26 08:47:29968fileN but it does not appear in the result. A <tt>+</tt> character
Junio C Hamanofb56a962006-01-28 10:38:19969in the column N means that the line appears in the last file,
Junio C Hamano29f14312006-10-26 08:47:29970and fileN does not have that line (in other words, the line was
971added, from the point of view of that parent).</p>
Junio C Hamanofb56a962006-01-28 10:38:19972<p>In the above example output, the function signature was changed
973from both files (hence two <tt>-</tt> removals from both file1 and
974file2, plus <tt>++</tt> to mean one line that was added does not appear
975in either file1 nor file2). Also two other lines are the same
976from file1 but do not appear in file2 (hence prefixed with <tt> +</tt>).</p>
977<p>When shown by <tt>git diff-tree -c</tt>, it compares the parents of a
978merge commit with the merge result (i.e. file1..fileN are the
979parents). When shown by <tt>git diff-files -c</tt>, it compares the
980two unresolved merge parents with the working tree file
981(i.e. file1 is stage 2 aka "our version", file2 is stage 3 aka
982"their version").</p>
983</div>
Junio C Hamano1a4e8412005-12-27 08:17:23984<h2>Author</h2>
985<div class="sectionbody">
986<p>Written by Linus Torvalds &lt;torvalds@osdl.org&gt;</p>
987</div>
988<h2>Documentation</h2>
989<div class="sectionbody">
990<p>Documentation by David Greaves, Junio C Hamano and the git-list &lt;git@vger.kernel.org&gt;.</p>
991</div>
992<h2>GIT</h2>
993<div class="sectionbody">
994<p>Part of the <a href="git.html">git(7)</a> suite</p>
995</div>
996<div id="footer">
997<div id="footer-text">
Junio C Hamanoee1e4282007-02-04 08:32:04998Last updated 04-Feb-2007 08:31:41 UTC
Junio C Hamano1a4e8412005-12-27 08:17:23999</div>
1000</div>
1001</body>
1002</html>