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=
"verseblock">
418 <div class=
"verseblock-content"><em>git diff
</em> *
</div>
419 <div class=
"verseblock-attribution">
422 <h2 id=
"_description">DESCRIPTION
</h2>
423 <div class=
"sectionbody">
424 <div class=
"paragraph"><p>The diff commands
<em>git diff-index
</em>,
<em>git diff-files
</em>, and
<em>git diff-tree
</em>
425 can be told to manipulate differences they find in
426 unconventional ways before showing
<em>diff
</em> output. The manipulation
427 is collectively called
"diffcore transformation". This short note
428 describes what they are and how to use them to produce
<em>diff
</em> output
429 that is easier to understand than the conventional kind.
</p></div>
431 <h2 id=
"_the_chain_of_operation">The chain of operation
</h2>
432 <div class=
"sectionbody">
433 <div class=
"paragraph"><p>The
<em>git diff-
*</em> family works by first comparing two sets of
435 <div class=
"ulist"><ul>
438 <em>git diff-index
</em> compares contents of a
"tree" object and the
439 working directory (when
<em>--cached
</em> flag is not used) or a
440 "tree" object and the index file (when
<em>--cached
</em> flag is
446 <em>git diff-files
</em> compares contents of the index file and the
452 <em>git diff-tree
</em> compares contents of two
"tree" objects;
456 <div class=
"paragraph"><p>In all of these cases, the commands themselves first optionally limit
457 the two sets of files by any pathspecs given on their command-lines,
458 and compare corresponding paths in the two resulting sets of files.
</p></div>
459 <div class=
"paragraph"><p>The pathspecs are used to limit the world diff operates in. They remove
460 the filepairs outside the specified sets of pathnames. E.g. If the
461 input set of filepairs included:
</p></div>
462 <div class=
"listingblock">
463 <div class=
"content">
464 <pre><tt>:
100644 100644 bcd1234...
0123456... M junkfile
</tt></pre>
466 <div class=
"paragraph"><p>but the command invocation was
<tt>git diff-files myfile
</tt>, then the
467 junkfile entry would be removed from the list because only
"myfile"
468 is under consideration.
</p></div>
469 <div class=
"paragraph"><p>The result of comparison is passed from these commands to what is
470 internally called
"diffcore", in a format similar to what is output
471 when the -p option is not used. E.g.
</p></div>
472 <div class=
"listingblock">
473 <div class=
"content">
474 <pre><tt>in-place edit :
100644 100644 bcd1234...
0123456... M file0
475 create :
000000 100644 0000000...
1234567... A file4
476 delete :
100644 000000 1234567...
0000000... D file5
477 unmerged :
000000 000000 0000000...
0000000... U file6
</tt></pre>
479 <div class=
"paragraph"><p>The diffcore mechanism is fed a list of such comparison results
480 (each of which is called
"filepair", although at this point each
481 of them talks about a single file), and transforms such a list
482 into another list. There are currently
5 such transformations:
</p></div>
483 <div class=
"ulist"><ul>
496 diffcore-merge-broken
510 <div class=
"paragraph"><p>These are applied in sequence. The set of filepairs
<em>git diff-
*</em>
511 commands find are used as the input to diffcore-break, and
512 the output from diffcore-break is used as the input to the
513 next transformation. The final result is then passed to the
514 output routine and generates either diff-raw format (see Output
515 format sections of the manual for
<em>git diff-
*</em> commands) or
516 diff-patch format.
</p></div>
518 <h2 id=
"_diffcore_break_for_splitting_up_complete_rewrites">diffcore-break: For Splitting Up
"Complete Rewrites"</h2>
519 <div class=
"sectionbody">
520 <div class=
"paragraph"><p>The second transformation in the chain is diffcore-break, and is
521 controlled by the -B option to the
<em>git diff-
*</em> commands. This is
522 used to detect a filepair that represents
"complete rewrite" and
523 break such filepair into two filepairs that represent delete and
524 create. E.g. If the input contained this filepair:
</p></div>
525 <div class=
"listingblock">
526 <div class=
"content">
527 <pre><tt>:
100644 100644 bcd1234...
0123456... M file0
</tt></pre>
529 <div class=
"paragraph"><p>and if it detects that the file
"file0" is completely rewritten,
530 it changes it to:
</p></div>
531 <div class=
"listingblock">
532 <div class=
"content">
533 <pre><tt>:
100644 000000 bcd1234...
0000000... D file0
534 :
000000 100644 0000000...
0123456... A file0
</tt></pre>
536 <div class=
"paragraph"><p>For the purpose of breaking a filepair, diffcore-break examines
537 the extent of changes between the contents of the files before
538 and after modification (i.e. the contents that have
"bcd1234…"
539 and
"0123456…" as their SHA1 content ID, in the above
540 example). The amount of deletion of original contents and
541 insertion of new material are added together, and if it exceeds
542 the
"break score", the filepair is broken into two. The break
543 score defaults to
50% of the size of the smaller of the original
544 and the result (i.e. if the edit shrinks the file, the size of
545 the result is used; if the edit lengthens the file, the size of
546 the original is used), and can be customized by giving a number
547 after
"-B" option (e.g.
"-B75" to tell it to use
75%).
</p></div>
549 <h2 id=
"_diffcore_rename_for_detection_renames_and_copies">diffcore-rename: For Detection Renames and Copies
</h2>
550 <div class=
"sectionbody">
551 <div class=
"paragraph"><p>This transformation is used to detect renames and copies, and is
552 controlled by the -M option (to detect renames) and the -C option
553 (to detect copies as well) to the
<em>git diff-
*</em> commands. If the
554 input contained these filepairs:
</p></div>
555 <div class=
"listingblock">
556 <div class=
"content">
557 <pre><tt>:
100644 000000 0123456...
0000000... D fileX
558 :
000000 100644 0000000...
0123456... A file0
</tt></pre>
560 <div class=
"paragraph"><p>and the contents of the deleted file fileX is similar enough to
561 the contents of the created file file0, then rename detection
562 merges these filepairs and creates:
</p></div>
563 <div class=
"listingblock">
564 <div class=
"content">
565 <pre><tt>:
100644 100644 0123456...
0123456... R100 fileX file0
</tt></pre>
567 <div class=
"paragraph"><p>When the
"-C" option is used, the original contents of modified files,
568 and deleted files (and also unmodified files, if the
569 "--find-copies-harder" option is used) are considered as candidates
570 of the source files in rename/copy operation. If the input were like
571 these filepairs, that talk about a modified file fileY and a newly
572 created file file0:
</p></div>
573 <div class=
"listingblock">
574 <div class=
"content">
575 <pre><tt>:
100644 100644 0123456...
1234567... M fileY
576 :
000000 100644 0000000... bcd3456... A file0
</tt></pre>
578 <div class=
"paragraph"><p>the original contents of fileY and the resulting contents of
579 file0 are compared, and if they are similar enough, they are
580 changed to:
</p></div>
581 <div class=
"listingblock">
582 <div class=
"content">
583 <pre><tt>:
100644 100644 0123456...
1234567... M fileY
584 :
100644 100644 0123456... bcd3456... C100 fileY file0
</tt></pre>
586 <div class=
"paragraph"><p>In both rename and copy detection, the same
"extent of changes"
587 algorithm used in diffcore-break is used to determine if two
588 files are
"similar enough", and can be customized to use
589 a similarity score different from the default of
50% by giving a
590 number after the
"-M" or
"-C" option (e.g.
"-M8" to tell it to use
591 8/
10 =
80%).
</p></div>
592 <div class=
"paragraph"><p>Note. When the
"-C" option is used with
<tt>--find-copies-harder
</tt>
593 option,
<em>git diff-
*</em> commands feed unmodified filepairs to
594 diffcore mechanism as well as modified ones. This lets the copy
595 detector consider unmodified files as copy source candidates at
596 the expense of making it slower. Without
<tt>--find-copies-harder
</tt>,
597 <em>git diff-
*</em> commands can detect copies only if the file that was
598 copied happened to have been modified in the same changeset.
</p></div>
600 <h2 id=
"_diffcore_merge_broken_for_putting_complete_rewrites_back_together">diffcore-merge-broken: For Putting
"Complete Rewrites" Back Together
</h2>
601 <div class=
"sectionbody">
602 <div class=
"paragraph"><p>This transformation is used to merge filepairs broken by
603 diffcore-break, and not transformed into rename/copy by
604 diffcore-rename, back into a single modification. This always
605 runs when diffcore-break is used.
</p></div>
606 <div class=
"paragraph"><p>For the purpose of merging broken filepairs back, it uses a
607 different
"extent of changes" computation from the ones used by
608 diffcore-break and diffcore-rename. It counts only the deletion
609 from the original, and does not count insertion. If you removed
610 only
10 lines from a
100-line document, even if you added
910
611 new lines to make a new
1000-line document, you did not do a
612 complete rewrite. diffcore-break breaks such a case in order to
613 help diffcore-rename to consider such filepairs as candidate of
614 rename/copy detection, but if filepairs broken that way were not
615 matched with other filepairs to create rename/copy, then this
616 transformation merges them back into the original
617 "modification".
</p></div>
618 <div class=
"paragraph"><p>The
"extent of changes" parameter can be tweaked from the
619 default
80% (that is, unless more than
80% of the original
620 material is deleted, the broken pairs are merged back into a
621 single modification) by giving a second number to -B option,
622 like these:
</p></div>
623 <div class=
"ulist"><ul>
626 -B50/
60 (give
50%
"break score" to diffcore-break, use
60%
627 for diffcore-merge-broken).
632 -B/
60 (the same as above, since diffcore-break defaults to
50%).
636 <div class=
"paragraph"><p>Note that earlier implementation left a broken pair as a separate
637 creation and deletion patches. This was an unnecessary hack and
638 the latest implementation always merges all the broken pairs
639 back into modifications, but the resulting patch output is
640 formatted differently for easier review in case of such
641 a complete rewrite by showing the entire contents of old version
642 prefixed with
<em>-
</em>, followed by the entire contents of new
643 version prefixed with
<em>+
</em>.
</p></div>
645 <h2 id=
"_diffcore_pickaxe_for_detecting_addition_deletion_of_specified_string">diffcore-pickaxe: For Detecting Addition/Deletion of Specified String
</h2>
646 <div class=
"sectionbody">
647 <div class=
"paragraph"><p>This transformation is used to find filepairs that represent
648 changes that touch a specified string, and is controlled by the
649 -S option and the
<tt>--pickaxe-all
</tt> option to the
<em>git diff-
*</em>
651 <div class=
"paragraph"><p>When diffcore-pickaxe is in use, it checks if there are
652 filepairs whose
"result" side and whose
"origin" side have
653 different number of specified string. Such a filepair represents
654 "the string appeared in this changeset". It also checks for the
655 opposite case that loses the specified string.
</p></div>
656 <div class=
"paragraph"><p>When
<tt>--pickaxe-all
</tt> is not in effect, diffcore-pickaxe leaves
657 only such filepairs that touch the specified string in its
658 output. When
<tt>--pickaxe-all
</tt> is used, diffcore-pickaxe leaves all
659 filepairs intact if there is such a filepair, or makes the
660 output empty otherwise. The latter behaviour is designed to
661 make reviewing of the changes in the context of the whole
662 changeset easier.
</p></div>
664 <h2 id=
"_diffcore_order_for_sorting_the_output_based_on_filenames">diffcore-order: For Sorting the Output Based on Filenames
</h2>
665 <div class=
"sectionbody">
666 <div class=
"paragraph"><p>This is used to reorder the filepairs according to the user
’s
667 (or project
’s) taste, and is controlled by the -O option to the
668 <em>git diff-
*</em> commands.
</p></div>
669 <div class=
"paragraph"><p>This takes a text file each of whose lines is a shell glob
670 pattern. Filepairs that match a glob pattern on an earlier line
671 in the file are output before ones that match a later line, and
672 filepairs that do not match any glob pattern are output last.
</p></div>
673 <div class=
"paragraph"><p>As an example, a typical orderfile for the core git probably
674 would look like this:
</p></div>
675 <div class=
"listingblock">
676 <div class=
"content">
685 <h2 id=
"_see_also">SEE ALSO
</h2>
686 <div class=
"sectionbody">
687 <div class=
"paragraph"><p><a href=
"git-diff.html">git-diff(
1)
</a>,
688 <a href=
"git-diff-files.html">git-diff-files(
1)
</a>,
689 <a href=
"git-diff-index.html">git-diff-index(
1)
</a>,
690 <a href=
"git-diff-tree.html">git-diff-tree(
1)
</a>,
691 <a href=
"git-format-patch.html">git-format-patch(
1)
</a>,
692 <a href=
"git-log.html">git-log(
1)
</a>,
693 <a href=
"gitglossary.html">gitglossary(
7)
</a>,
694 <a href=
"user-manual.html">The Git User
’s Manual
</a></p></div>
696 <h2 id=
"_git">GIT
</h2>
697 <div class=
"sectionbody">
698 <div class=
"paragraph"><p>Part of the
<a href=
"git.html">git(
1)
</a> suite.
</p></div>
701 <div id=
"footer-text">
702 Last updated
2011-
07-
23 00:
49:
30 UTC