1 <!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">
5 <meta http-equiv=
"Content-Type" content=
"text/html; charset=UTF-8" />
6 <meta name=
"generator" content=
"AsciiDoc 8.4.5" />
7 <title>gitdiffcore(
7)
</title>
8 <style type=
"text/css">
10 p
, li
, dt
, dd
, div
, pre
, h1
, h2
, h3
, h4
, h5
, h6
{
12 border: 1px solid red;
17 margin: 1em 5% 1em 5%;
22 text-decoration: underline
;
42 h1
, h2
, h3
, h4
, h5
, h6
{
44 font-family: sans-serif
;
51 border-bottom: 2px solid silver
;
69 border: 1px solid silver
;
88 font-family: sans-serif
;
94 span#revnumber
, span#revdate
, span#revremark
{
95 font-family: sans-serif
;
99 font-family: sans-serif
;
101 border-top: 2px solid silver
;
107 padding-bottom: 0.5em;
111 padding-bottom: 0.5em;
116 margin-bottom: 1.5em;
118 div
.tableblock
, div
.imageblock
, div
.exampleblock
, div
.verseblock
,
119 div
.quoteblock
, div
.literalblock
, div
.listingblock
, div
.sidebarblock
,
120 div
.admonitionblock
{
122 margin-bottom: 1.5em;
124 div
.admonitionblock
{
126 margin-bottom: 2.5em;
129 div
.content
{ /* Block element content. */
133 /* Block element titles. */
134 div
.title
, caption
.title
{
136 font-family: sans-serif
;
140 margin-bottom: 0.5em;
146 td div
.title:first-child
{
149 div
.content div
.title:first-child
{
152 div
.content
+ div
.title
{
156 div
.sidebarblock
> div
.content
{
158 border: 1px solid silver
;
162 div
.listingblock
> div
.content
{
163 border: 1px solid silver
;
172 div
.quoteblock
> div
.attribution
{
181 div
.verseblock
> div
.content
{
184 div
.verseblock
> div
.attribution
{
188 /* DEPRECATED: Pre version 8.2.7 verse style literal block. */
189 div
.verseblock
+ div
.attribution
{
193 div
.admonitionblock
.icon
{
197 text-decoration: underline
;
199 padding-right: 0.5em;
201 div
.admonitionblock td
.content
{
203 border-left: 2px solid silver
;
206 div
.exampleblock
> div
.content
{
207 border-left: 2px solid silver
;
211 div
.imageblock div
.content
{ padding-left: 0; }
212 span
.image img
{ border-style: none
; }
213 a
.image:visited
{ color: white
; }
217 margin-bottom: 0.8em;
230 list-style-position: outside
;
233 list-style-type: decimal
;
236 list-style-type: lower-alpha
;
239 list-style-type: upper-alpha
;
242 list-style-type: lower-roman
;
245 list-style-type: upper-roman
;
248 div
.compact ul
, div
.compact ol
,
249 div
.compact p
, div
.compact p
,
250 div
.compact div
, div
.compact div
{
252 margin-bottom: 0.1em;
255 div
.tableblock
> table
{
256 border: 3px solid
#527bbd;
259 font-family: sans-serif
;
271 /* Because the table frame attribute is overriden by CSS in most browsers. */
272 div
.tableblock
> table
[frame
="void"] {
275 div
.tableblock
> table
[frame
="hsides"] {
276 border-left-style: none
;
277 border-right-style: none
;
279 div
.tableblock
> table
[frame
="vsides"] {
280 border-top-style: none
;
281 border-bottom-style: none
;
287 margin-bottom: 0.8em;
290 padding-bottom: 15px;
292 dt
.hdlist1
.strong
, td
.hdlist1
.strong
{
298 padding-right: 0.8em;
304 div
.hdlist
.compact tr
{
314 div#footer-badges
{ display: none
; }
319 font-family: sans-serif
;
323 margin-bottom: 0.1em;
326 div
.toclevel1
, div
.toclevel2
, div
.toclevel3
, div
.toclevel4
{
342 /* Overrides for manpage documents */
345 padding-bottom: 0.5em;
346 border-top: 2px solid silver
;
347 border-bottom: 2px solid silver
;
357 div#toc
{ display: none
; }
360 /* Workarounds for IE6's broken and incomplete CSS2. */
362 div
.sidebar-content
{
364 border: 1px solid silver
;
367 div
.sidebar-title
, div
.image-title
{
369 font-family: sans-serif
;
372 margin-bottom: 0.5em;
375 div
.listingblock div
.content
{
376 border: 1px solid silver
;
381 div
.quoteblock-attribution
{
386 div
.verseblock-content
{
389 div
.verseblock-attribution
{
394 div
.exampleblock-content
{
395 border-left: 2px solid silver
;
399 /* IE6 sets dynamically generated links as visited. */
400 div#toc
a:visited
{ color: blue
; }
406 gitdiffcore(
7) Manual Page
409 <div class=
"sectionbody">
415 <h2 id=
"_synopsis">SYNOPSIS
</h2>
416 <div class=
"sectionbody">
417 <div class=
"paragraph"><p><em>git diff
</em> *
</p></div>
419 <h2 id=
"_description">DESCRIPTION
</h2>
420 <div class=
"sectionbody">
421 <div class=
"paragraph"><p>The diff commands
<em>git diff-index
</em>,
<em>git diff-files
</em>, and
<em>git diff-tree
</em>
422 can be told to manipulate differences they find in
423 unconventional ways before showing
<em>diff
</em> output. The manipulation
424 is collectively called
"diffcore transformation". This short note
425 describes what they are and how to use them to produce
<em>diff
</em> output
426 that is easier to understand than the conventional kind.
</p></div>
428 <h2 id=
"_the_chain_of_operation">The chain of operation
</h2>
429 <div class=
"sectionbody">
430 <div class=
"paragraph"><p>The
<em>git diff-
*</em> family works by first comparing two sets of
432 <div class=
"ulist"><ul>
435 <em>git diff-index
</em> compares contents of a
"tree" object and the
436 working directory (when
<em>--cached
</em> flag is not used) or a
437 "tree" object and the index file (when
<em>--cached
</em> flag is
443 <em>git diff-files
</em> compares contents of the index file and the
449 <em>git diff-tree
</em> compares contents of two
"tree" objects;
453 <div class=
"paragraph"><p>In all of these cases, the commands themselves first optionally limit
454 the two sets of files by any pathspecs given on their command-lines,
455 and compare corresponding paths in the two resulting sets of files.
</p></div>
456 <div class=
"paragraph"><p>The pathspecs are used to limit the world diff operates in. They remove
457 the filepairs outside the specified sets of pathnames. E.g. If the
458 input set of filepairs included:
</p></div>
459 <div class=
"listingblock">
460 <div class=
"content">
461 <pre><tt>:
100644 100644 bcd1234...
0123456... M junkfile
</tt></pre>
463 <div class=
"paragraph"><p>but the command invocation was
<tt>git diff-files myfile
</tt>, then the
464 junkfile entry would be removed from the list because only
"myfile"
465 is under consideration.
</p></div>
466 <div class=
"paragraph"><p>The result of comparison is passed from these commands to what is
467 internally called
"diffcore", in a format similar to what is output
468 when the -p option is not used. E.g.
</p></div>
469 <div class=
"listingblock">
470 <div class=
"content">
471 <pre><tt>in-place edit :
100644 100644 bcd1234...
0123456... M file0
472 create :
000000 100644 0000000...
1234567... A file4
473 delete :
100644 000000 1234567...
0000000... D file5
474 unmerged :
000000 000000 0000000...
0000000... U file6
</tt></pre>
476 <div class=
"paragraph"><p>The diffcore mechanism is fed a list of such comparison results
477 (each of which is called
"filepair", although at this point each
478 of them talks about a single file), and transforms such a list
479 into another list. There are currently
5 such transformations:
</p></div>
480 <div class=
"ulist"><ul>
493 diffcore-merge-broken
507 <div class=
"paragraph"><p>These are applied in sequence. The set of filepairs
<em>git diff-
*</em>
508 commands find are used as the input to diffcore-break, and
509 the output from diffcore-break is used as the input to the
510 next transformation. The final result is then passed to the
511 output routine and generates either diff-raw format (see Output
512 format sections of the manual for
<em>git diff-
*</em> commands) or
513 diff-patch format.
</p></div>
515 <h2 id=
"_diffcore_break_for_splitting_up_complete_rewrites">diffcore-break: For Splitting Up
"Complete Rewrites"</h2>
516 <div class=
"sectionbody">
517 <div class=
"paragraph"><p>The second transformation in the chain is diffcore-break, and is
518 controlled by the -B option to the
<em>git diff-
*</em> commands. This is
519 used to detect a filepair that represents
"complete rewrite" and
520 break such filepair into two filepairs that represent delete and
521 create. E.g. If the input contained this filepair:
</p></div>
522 <div class=
"listingblock">
523 <div class=
"content">
524 <pre><tt>:
100644 100644 bcd1234...
0123456... M file0
</tt></pre>
526 <div class=
"paragraph"><p>and if it detects that the file
"file0" is completely rewritten,
527 it changes it to:
</p></div>
528 <div class=
"listingblock">
529 <div class=
"content">
530 <pre><tt>:
100644 000000 bcd1234...
0000000... D file0
531 :
000000 100644 0000000...
0123456... A file0
</tt></pre>
533 <div class=
"paragraph"><p>For the purpose of breaking a filepair, diffcore-break examines
534 the extent of changes between the contents of the files before
535 and after modification (i.e. the contents that have
"bcd1234…"
536 and
"0123456…" as their SHA1 content ID, in the above
537 example). The amount of deletion of original contents and
538 insertion of new material are added together, and if it exceeds
539 the
"break score", the filepair is broken into two. The break
540 score defaults to
50% of the size of the smaller of the original
541 and the result (i.e. if the edit shrinks the file, the size of
542 the result is used; if the edit lengthens the file, the size of
543 the original is used), and can be customized by giving a number
544 after
"-B" option (e.g.
"-B75" to tell it to use
75%).
</p></div>
546 <h2 id=
"_diffcore_rename_for_detection_renames_and_copies">diffcore-rename: For Detection Renames and Copies
</h2>
547 <div class=
"sectionbody">
548 <div class=
"paragraph"><p>This transformation is used to detect renames and copies, and is
549 controlled by the -M option (to detect renames) and the -C option
550 (to detect copies as well) to the
<em>git diff-
*</em> commands. If the
551 input contained these filepairs:
</p></div>
552 <div class=
"listingblock">
553 <div class=
"content">
554 <pre><tt>:
100644 000000 0123456...
0000000... D fileX
555 :
000000 100644 0000000...
0123456... A file0
</tt></pre>
557 <div class=
"paragraph"><p>and the contents of the deleted file fileX is similar enough to
558 the contents of the created file file0, then rename detection
559 merges these filepairs and creates:
</p></div>
560 <div class=
"listingblock">
561 <div class=
"content">
562 <pre><tt>:
100644 100644 0123456...
0123456... R100 fileX file0
</tt></pre>
564 <div class=
"paragraph"><p>When the
"-C" option is used, the original contents of modified files,
565 and deleted files (and also unmodified files, if the
566 "--find-copies-harder" option is used) are considered as candidates
567 of the source files in rename/copy operation. If the input were like
568 these filepairs, that talk about a modified file fileY and a newly
569 created file file0:
</p></div>
570 <div class=
"listingblock">
571 <div class=
"content">
572 <pre><tt>:
100644 100644 0123456...
1234567... M fileY
573 :
000000 100644 0000000... bcd3456... A file0
</tt></pre>
575 <div class=
"paragraph"><p>the original contents of fileY and the resulting contents of
576 file0 are compared, and if they are similar enough, they are
577 changed to:
</p></div>
578 <div class=
"listingblock">
579 <div class=
"content">
580 <pre><tt>:
100644 100644 0123456...
1234567... M fileY
581 :
100644 100644 0123456... bcd3456... C100 fileY file0
</tt></pre>
583 <div class=
"paragraph"><p>In both rename and copy detection, the same
"extent of changes"
584 algorithm used in diffcore-break is used to determine if two
585 files are
"similar enough", and can be customized to use
586 a similarity score different from the default of
50% by giving a
587 number after the
"-M" or
"-C" option (e.g.
"-M8" to tell it to use
588 8/
10 =
80%).
</p></div>
589 <div class=
"paragraph"><p>Note. When the
"-C" option is used with
<tt>--find-copies-harder
</tt>
590 option,
<em>git diff-
*</em> commands feed unmodified filepairs to
591 diffcore mechanism as well as modified ones. This lets the copy
592 detector consider unmodified files as copy source candidates at
593 the expense of making it slower. Without
<tt>--find-copies-harder
</tt>,
594 <em>git diff-
*</em> commands can detect copies only if the file that was
595 copied happened to have been modified in the same changeset.
</p></div>
597 <h2 id=
"_diffcore_merge_broken_for_putting_complete_rewrites_back_together">diffcore-merge-broken: For Putting
"Complete Rewrites" Back Together
</h2>
598 <div class=
"sectionbody">
599 <div class=
"paragraph"><p>This transformation is used to merge filepairs broken by
600 diffcore-break, and not transformed into rename/copy by
601 diffcore-rename, back into a single modification. This always
602 runs when diffcore-break is used.
</p></div>
603 <div class=
"paragraph"><p>For the purpose of merging broken filepairs back, it uses a
604 different
"extent of changes" computation from the ones used by
605 diffcore-break and diffcore-rename. It counts only the deletion
606 from the original, and does not count insertion. If you removed
607 only
10 lines from a
100-line document, even if you added
910
608 new lines to make a new
1000-line document, you did not do a
609 complete rewrite. diffcore-break breaks such a case in order to
610 help diffcore-rename to consider such filepairs as candidate of
611 rename/copy detection, but if filepairs broken that way were not
612 matched with other filepairs to create rename/copy, then this
613 transformation merges them back into the original
614 "modification".
</p></div>
615 <div class=
"paragraph"><p>The
"extent of changes" parameter can be tweaked from the
616 default
80% (that is, unless more than
80% of the original
617 material is deleted, the broken pairs are merged back into a
618 single modification) by giving a second number to -B option,
619 like these:
</p></div>
620 <div class=
"ulist"><ul>
623 -B50/
60 (give
50%
"break score" to diffcore-break, use
60%
624 for diffcore-merge-broken).
629 -B/
60 (the same as above, since diffcore-break defaults to
50%).
633 <div class=
"paragraph"><p>Note that earlier implementation left a broken pair as a separate
634 creation and deletion patches. This was an unnecessary hack and
635 the latest implementation always merges all the broken pairs
636 back into modifications, but the resulting patch output is
637 formatted differently for easier review in case of such
638 a complete rewrite by showing the entire contents of old version
639 prefixed with
<em>-
</em>, followed by the entire contents of new
640 version prefixed with
<em>+
</em>.
</p></div>
642 <h2 id=
"_diffcore_pickaxe_for_detecting_addition_deletion_of_specified_string">diffcore-pickaxe: For Detecting Addition/Deletion of Specified String
</h2>
643 <div class=
"sectionbody">
644 <div class=
"paragraph"><p>This transformation is used to find filepairs that represent
645 changes that touch a specified string, and is controlled by the
646 -S option and the
<tt>--pickaxe-all
</tt> option to the
<em>git diff-
*</em>
648 <div class=
"paragraph"><p>When diffcore-pickaxe is in use, it checks if there are
649 filepairs whose
"result" side and whose
"origin" side have
650 different number of specified string. Such a filepair represents
651 "the string appeared in this changeset". It also checks for the
652 opposite case that loses the specified string.
</p></div>
653 <div class=
"paragraph"><p>When
<tt>--pickaxe-all
</tt> is not in effect, diffcore-pickaxe leaves
654 only such filepairs that touch the specified string in its
655 output. When
<tt>--pickaxe-all
</tt> is used, diffcore-pickaxe leaves all
656 filepairs intact if there is such a filepair, or makes the
657 output empty otherwise. The latter behaviour is designed to
658 make reviewing of the changes in the context of the whole
659 changeset easier.
</p></div>
661 <h2 id=
"_diffcore_order_for_sorting_the_output_based_on_filenames">diffcore-order: For Sorting the Output Based on Filenames
</h2>
662 <div class=
"sectionbody">
663 <div class=
"paragraph"><p>This is used to reorder the filepairs according to the user
’s
664 (or project
’s) taste, and is controlled by the -O option to the
665 <em>git diff-
*</em> commands.
</p></div>
666 <div class=
"paragraph"><p>This takes a text file each of whose lines is a shell glob
667 pattern. Filepairs that match a glob pattern on an earlier line
668 in the file are output before ones that match a later line, and
669 filepairs that do not match any glob pattern are output last.
</p></div>
670 <div class=
"paragraph"><p>As an example, a typical orderfile for the core git probably
671 would look like this:
</p></div>
672 <div class=
"listingblock">
673 <div class=
"content">
682 <h2 id=
"_see_also">SEE ALSO
</h2>
683 <div class=
"sectionbody">
684 <div class=
"paragraph"><p><a href=
"git-diff.html">git-diff(
1)
</a>,
685 <a href=
"git-diff-files.html">git-diff-files(
1)
</a>,
686 <a href=
"git-diff-index.html">git-diff-index(
1)
</a>,
687 <a href=
"git-diff-tree.html">git-diff-tree(
1)
</a>,
688 <a href=
"git-format-patch.html">git-format-patch(
1)
</a>,
689 <a href=
"git-log.html">git-log(
1)
</a>,
690 <a href=
"gitglossary.html">gitglossary(
7)
</a>,
691 <a href=
"user-manual.html">The Git User
’s Manual
</a></p></div>
693 <h2 id=
"_git">GIT
</h2>
694 <div class=
"sectionbody">
695 <div class=
"paragraph"><p>Part of the
<a href=
"git.html">git(
1)
</a> suite.
</p></div>
698 <div id=
"footer-text">
699 Last updated
2010-
09-
30 00:
01:
59 UTC