Autogenerated HTML docs for v1.7.7-290-gc9e7aa
[git/jnareb-git.git] / git-fast-import.html
blob58d52efe98b4a9472e170a815244f7a839775d42
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">
4 <head>
5 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
6 <meta name="generator" content="AsciiDoc 8.5.2" />
7 <title>git-fast-import(1)</title>
8 <style type="text/css">
9 /* Debug borders */
10 p, li, dt, dd, div, pre, h1, h2, h3, h4, h5, h6 {
12 border: 1px solid red;
16 body {
17 margin: 1em 5% 1em 5%;
20 a {
21 color: blue;
22 text-decoration: underline;
24 a:visited {
25 color: fuchsia;
28 em {
29 font-style: italic;
30 color: navy;
33 strong {
34 font-weight: bold;
35 color: #083194;
38 tt {
39 color: navy;
42 h1, h2, h3, h4, h5, h6 {
43 color: #527bbd;
44 font-family: sans-serif;
45 margin-top: 1.2em;
46 margin-bottom: 0.5em;
47 line-height: 1.3;
50 h1, h2, h3 {
51 border-bottom: 2px solid silver;
53 h2 {
54 padding-top: 0.5em;
56 h3 {
57 float: left;
59 h3 + * {
60 clear: left;
63 div.sectionbody {
64 font-family: serif;
65 margin-left: 0;
68 hr {
69 border: 1px solid silver;
72 p {
73 margin-top: 0.5em;
74 margin-bottom: 0.5em;
77 ul, ol, li > p {
78 margin-top: 0;
81 pre {
82 padding: 0;
83 margin: 0;
86 span#author {
87 color: #527bbd;
88 font-family: sans-serif;
89 font-weight: bold;
90 font-size: 1.1em;
92 span#email {
94 span#revnumber, span#revdate, span#revremark {
95 font-family: sans-serif;
98 div#footer {
99 font-family: sans-serif;
100 font-size: small;
101 border-top: 2px solid silver;
102 padding-top: 0.5em;
103 margin-top: 4.0em;
105 div#footer-text {
106 float: left;
107 padding-bottom: 0.5em;
109 div#footer-badges {
110 float: right;
111 padding-bottom: 0.5em;
114 div#preamble {
115 margin-top: 1.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 {
121 margin-top: 1.0em;
122 margin-bottom: 1.5em;
124 div.admonitionblock {
125 margin-top: 2.0em;
126 margin-bottom: 2.0em;
127 margin-right: 10%;
128 color: #606060;
131 div.content { /* Block element content. */
132 padding: 0;
135 /* Block element titles. */
136 div.title, caption.title {
137 color: #527bbd;
138 font-family: sans-serif;
139 font-weight: bold;
140 text-align: left;
141 margin-top: 1.0em;
142 margin-bottom: 0.5em;
144 div.title + * {
145 margin-top: 0;
148 td div.title:first-child {
149 margin-top: 0.0em;
151 div.content div.title:first-child {
152 margin-top: 0.0em;
154 div.content + div.title {
155 margin-top: 0.0em;
158 div.sidebarblock > div.content {
159 background: #ffffee;
160 border: 1px solid silver;
161 padding: 0.5em;
164 div.listingblock > div.content {
165 border: 1px solid silver;
166 background: #f4f4f4;
167 padding: 0.5em;
170 div.quoteblock, div.verseblock {
171 padding-left: 1.0em;
172 margin-left: 1.0em;
173 margin-right: 10%;
174 border-left: 5px solid #dddddd;
175 color: #777777;
178 div.quoteblock > div.attribution {
179 padding-top: 0.5em;
180 text-align: right;
183 div.verseblock > div.content {
184 white-space: pre;
186 div.verseblock > div.attribution {
187 padding-top: 0.75em;
188 text-align: left;
190 /* DEPRECATED: Pre version 8.2.7 verse style literal block. */
191 div.verseblock + div.attribution {
192 text-align: left;
195 div.admonitionblock .icon {
196 vertical-align: top;
197 font-size: 1.1em;
198 font-weight: bold;
199 text-decoration: underline;
200 color: #527bbd;
201 padding-right: 0.5em;
203 div.admonitionblock td.content {
204 padding-left: 0.5em;
205 border-left: 3px solid #dddddd;
208 div.exampleblock > div.content {
209 border-left: 3px solid #dddddd;
210 padding-left: 0.5em;
213 div.imageblock div.content { padding-left: 0; }
214 span.image img { border-style: none; }
215 a.image:visited { color: white; }
217 dl {
218 margin-top: 0.8em;
219 margin-bottom: 0.8em;
221 dt {
222 margin-top: 0.5em;
223 margin-bottom: 0;
224 font-style: normal;
225 color: navy;
227 dd > *:first-child {
228 margin-top: 0.1em;
231 ul, ol {
232 list-style-position: outside;
234 ol.arabic {
235 list-style-type: decimal;
237 ol.loweralpha {
238 list-style-type: lower-alpha;
240 ol.upperalpha {
241 list-style-type: upper-alpha;
243 ol.lowerroman {
244 list-style-type: lower-roman;
246 ol.upperroman {
247 list-style-type: upper-roman;
250 div.compact ul, div.compact ol,
251 div.compact p, div.compact p,
252 div.compact div, div.compact div {
253 margin-top: 0.1em;
254 margin-bottom: 0.1em;
257 div.tableblock > table {
258 border: 3px solid #527bbd;
260 thead, p.table.header {
261 font-family: sans-serif;
262 font-weight: bold;
264 tfoot {
265 font-weight: bold;
267 td > div.verse {
268 white-space: pre;
270 p.table {
271 margin-top: 0;
273 /* Because the table frame attribute is overriden by CSS in most browsers. */
274 div.tableblock > table[frame="void"] {
275 border-style: none;
277 div.tableblock > table[frame="hsides"] {
278 border-left-style: none;
279 border-right-style: none;
281 div.tableblock > table[frame="vsides"] {
282 border-top-style: none;
283 border-bottom-style: none;
287 div.hdlist {
288 margin-top: 0.8em;
289 margin-bottom: 0.8em;
291 div.hdlist tr {
292 padding-bottom: 15px;
294 dt.hdlist1.strong, td.hdlist1.strong {
295 font-weight: bold;
297 td.hdlist1 {
298 vertical-align: top;
299 font-style: normal;
300 padding-right: 0.8em;
301 color: navy;
303 td.hdlist2 {
304 vertical-align: top;
306 div.hdlist.compact tr {
307 margin: 0;
308 padding-bottom: 0;
311 .comment {
312 background: yellow;
315 .footnote, .footnoteref {
316 font-size: 0.8em;
319 span.footnote, span.footnoteref {
320 vertical-align: super;
323 #footnotes {
324 margin: 20px 0 20px 0;
325 padding: 7px 0 0 0;
328 #footnotes div.footnote {
329 margin: 0 0 5px 0;
332 #footnotes hr {
333 border: none;
334 border-top: 1px solid silver;
335 height: 1px;
336 text-align: left;
337 margin-left: 0;
338 width: 20%;
339 min-width: 100px;
343 @media print {
344 div#footer-badges { display: none; }
347 div#toc {
348 margin-bottom: 2.5em;
351 div#toctitle {
352 color: #527bbd;
353 font-family: sans-serif;
354 font-size: 1.1em;
355 font-weight: bold;
356 margin-top: 1.0em;
357 margin-bottom: 0.1em;
360 div.toclevel1, div.toclevel2, div.toclevel3, div.toclevel4 {
361 margin-top: 0;
362 margin-bottom: 0;
364 div.toclevel2 {
365 margin-left: 2em;
366 font-size: 0.9em;
368 div.toclevel3 {
369 margin-left: 4em;
370 font-size: 0.9em;
372 div.toclevel4 {
373 margin-left: 6em;
374 font-size: 0.9em;
376 /* Overrides for manpage documents */
377 h1 {
378 padding-top: 0.5em;
379 padding-bottom: 0.5em;
380 border-top: 2px solid silver;
381 border-bottom: 2px solid silver;
383 h2 {
384 border-style: none;
386 div.sectionbody {
387 margin-left: 5%;
390 @media print {
391 div#toc { display: none; }
394 /* Workarounds for IE6's broken and incomplete CSS2. */
396 div.sidebar-content {
397 background: #ffffee;
398 border: 1px solid silver;
399 padding: 0.5em;
401 div.sidebar-title, div.image-title {
402 color: #527bbd;
403 font-family: sans-serif;
404 font-weight: bold;
405 margin-top: 0.0em;
406 margin-bottom: 0.5em;
409 div.listingblock div.content {
410 border: 1px solid silver;
411 background: #f4f4f4;
412 padding: 0.5em;
415 div.quoteblock-attribution {
416 padding-top: 0.5em;
417 text-align: right;
420 div.verseblock-content {
421 white-space: pre;
423 div.verseblock-attribution {
424 padding-top: 0.75em;
425 text-align: left;
428 div.exampleblock-content {
429 border-left: 3px solid #dddddd;
430 padding-left: 0.5em;
433 /* IE6 sets dynamically generated links as visited. */
434 div#toc a:visited { color: blue; }
435 </style>
436 <script type="text/javascript">
437 /*<![CDATA[*/
438 window.onload = function(){asciidoc.footnotes();}
439 var asciidoc = { // Namespace.
441 /////////////////////////////////////////////////////////////////////
442 // Table Of Contents generator
443 /////////////////////////////////////////////////////////////////////
445 /* Author: Mihai Bazon, September 2002
446 * http://students.infoiasi.ro/~mishoo
448 * Table Of Content generator
449 * Version: 0.4
451 * Feel free to use this script under the terms of the GNU General Public
452 * License, as long as you do not remove or alter this notice.
455 /* modified by Troy D. Hanson, September 2006. License: GPL */
456 /* modified by Stuart Rackham, 2006, 2009. License: GPL */
458 // toclevels = 1..4.
459 toc: function (toclevels) {
461 function getText(el) {
462 var text = "";
463 for (var i = el.firstChild; i != null; i = i.nextSibling) {
464 if (i.nodeType == 3 /* Node.TEXT_NODE */) // IE doesn't speak constants.
465 text += i.data;
466 else if (i.firstChild != null)
467 text += getText(i);
469 return text;
472 function TocEntry(el, text, toclevel) {
473 this.element = el;
474 this.text = text;
475 this.toclevel = toclevel;
478 function tocEntries(el, toclevels) {
479 var result = new Array;
480 var re = new RegExp('[hH]([2-'+(toclevels+1)+'])');
481 // Function that scans the DOM tree for header elements (the DOM2
482 // nodeIterator API would be a better technique but not supported by all
483 // browsers).
484 var iterate = function (el) {
485 for (var i = el.firstChild; i != null; i = i.nextSibling) {
486 if (i.nodeType == 1 /* Node.ELEMENT_NODE */) {
487 var mo = re.exec(i.tagName);
488 if (mo && (i.getAttribute("class") || i.getAttribute("className")) != "float") {
489 result[result.length] = new TocEntry(i, getText(i), mo[1]-1);
491 iterate(i);
495 iterate(el);
496 return result;
499 var toc = document.getElementById("toc");
500 var entries = tocEntries(document.getElementById("content"), toclevels);
501 for (var i = 0; i < entries.length; ++i) {
502 var entry = entries[i];
503 if (entry.element.id == "")
504 entry.element.id = "_toc_" + i;
505 var a = document.createElement("a");
506 a.href = "#" + entry.element.id;
507 a.appendChild(document.createTextNode(entry.text));
508 var div = document.createElement("div");
509 div.appendChild(a);
510 div.className = "toclevel" + entry.toclevel;
511 toc.appendChild(div);
513 if (entries.length == 0)
514 toc.parentNode.removeChild(toc);
518 /////////////////////////////////////////////////////////////////////
519 // Footnotes generator
520 /////////////////////////////////////////////////////////////////////
522 /* Based on footnote generation code from:
523 * http://www.brandspankingnew.net/archive/2005/07/format_footnote.html
526 footnotes: function () {
527 var cont = document.getElementById("content");
528 var noteholder = document.getElementById("footnotes");
529 var spans = cont.getElementsByTagName("span");
530 var refs = {};
531 var n = 0;
532 for (i=0; i<spans.length; i++) {
533 if (spans[i].className == "footnote") {
534 n++;
535 // Use [\s\S] in place of . so multi-line matches work.
536 // Because JavaScript has no s (dotall) regex flag.
537 note = spans[i].innerHTML.match(/\s*\[([\s\S]*)]\s*/)[1];
538 noteholder.innerHTML +=
539 "<div class='footnote' id='_footnote_" + n + "'>" +
540 "<a href='#_footnoteref_" + n + "' title='Return to text'>" +
541 n + "</a>. " + note + "</div>";
542 spans[i].innerHTML =
543 "[<a id='_footnoteref_" + n + "' href='#_footnote_" + n +
544 "' title='View footnote' class='footnote'>" + n + "</a>]";
545 var id =spans[i].getAttribute("id");
546 if (id != null) refs["#"+id] = n;
549 if (n == 0)
550 noteholder.parentNode.removeChild(noteholder);
551 else {
552 // Process footnoterefs.
553 for (i=0; i<spans.length; i++) {
554 if (spans[i].className == "footnoteref") {
555 var href = spans[i].getElementsByTagName("a")[0].getAttribute("href");
556 href = href.match(/#.*/)[0]; // Because IE return full URL.
557 n = refs[href];
558 spans[i].innerHTML =
559 "[<a href='#_footnote_" + n +
560 "' title='View footnote' class='footnote'>" + n + "</a>]";
567 /*]]>*/
568 </script>
569 </head>
570 <body>
571 <div id="header">
572 <h1>
573 git-fast-import(1) Manual Page
574 </h1>
575 <h2>NAME</h2>
576 <div class="sectionbody">
577 <p>git-fast-import -
578 Backend for fast Git data importers
579 </p>
580 </div>
581 </div>
582 <div id="content">
583 <h2 id="_synopsis">SYNOPSIS</h2>
584 <div class="sectionbody">
585 <div class="verseblock">
586 <div class="verseblock-content">frontend | <em>git fast-import</em> [options]</div>
587 <div class="verseblock-attribution">
588 </div></div>
589 </div>
590 <h2 id="_description">DESCRIPTION</h2>
591 <div class="sectionbody">
592 <div class="paragraph"><p>This program is usually not what the end user wants to run directly.
593 Most end users want to use one of the existing frontend programs,
594 which parses a specific type of foreign source and feeds the contents
595 stored there to <em>git fast-import</em>.</p></div>
596 <div class="paragraph"><p>fast-import reads a mixed command/data stream from standard input and
597 writes one or more packfiles directly into the current repository.
598 When EOF is received on standard input, fast import writes out
599 updated branch and tag refs, fully updating the current repository
600 with the newly imported data.</p></div>
601 <div class="paragraph"><p>The fast-import backend itself can import into an empty repository (one that
602 has already been initialized by <em>git init</em>) or incrementally
603 update an existing populated repository. Whether or not incremental
604 imports are supported from a particular foreign source depends on
605 the frontend program in use.</p></div>
606 </div>
607 <h2 id="_options">OPTIONS</h2>
608 <div class="sectionbody">
609 <div class="dlist"><dl>
610 <dt class="hdlist1">
611 --date-format=&lt;fmt&gt;
612 </dt>
613 <dd>
615 Specify the type of dates the frontend will supply to
616 fast-import within <tt>author</tt>, <tt>committer</tt> and <tt>tagger</tt> commands.
617 See &#8220;Date Formats&#8221; below for details about which formats
618 are supported, and their syntax.
619 </p>
620 </dd>
621 <dt class="hdlist1">
622 --force
623 </dt>
624 <dd>
626 Force updating modified existing branches, even if doing
627 so would cause commits to be lost (as the new commit does
628 not contain the old commit).
629 </p>
630 </dd>
631 <dt class="hdlist1">
632 --max-pack-size=&lt;n&gt;
633 </dt>
634 <dd>
636 Maximum size of each output packfile.
637 The default is unlimited.
638 </p>
639 </dd>
640 <dt class="hdlist1">
641 --big-file-threshold=&lt;n&gt;
642 </dt>
643 <dd>
645 Maximum size of a blob that fast-import will attempt to
646 create a delta for, expressed in bytes. The default is 512m
647 (512 MiB). Some importers may wish to lower this on systems
648 with constrained memory.
649 </p>
650 </dd>
651 <dt class="hdlist1">
652 --depth=&lt;n&gt;
653 </dt>
654 <dd>
656 Maximum delta depth, for blob and tree deltification.
657 Default is 10.
658 </p>
659 </dd>
660 <dt class="hdlist1">
661 --active-branches=&lt;n&gt;
662 </dt>
663 <dd>
665 Maximum number of branches to maintain active at once.
666 See &#8220;Memory Utilization&#8221; below for details. Default is 5.
667 </p>
668 </dd>
669 <dt class="hdlist1">
670 --export-marks=&lt;file&gt;
671 </dt>
672 <dd>
674 Dumps the internal marks table to &lt;file&gt; when complete.
675 Marks are written one per line as <tt>:markid SHA-1</tt>.
676 Frontends can use this file to validate imports after they
677 have been completed, or to save the marks table across
678 incremental runs. As &lt;file&gt; is only opened and truncated
679 at checkpoint (or completion) the same path can also be
680 safely given to --import-marks.
681 </p>
682 </dd>
683 <dt class="hdlist1">
684 --import-marks=&lt;file&gt;
685 </dt>
686 <dd>
688 Before processing any input, load the marks specified in
689 &lt;file&gt;. The input file must exist, must be readable, and
690 must use the same format as produced by --export-marks.
691 Multiple options may be supplied to import more than one
692 set of marks. If a mark is defined to different values,
693 the last file wins.
694 </p>
695 </dd>
696 <dt class="hdlist1">
697 --import-marks-if-exists=&lt;file&gt;
698 </dt>
699 <dd>
701 Like --import-marks but instead of erroring out, silently
702 skips the file if it does not exist.
703 </p>
704 </dd>
705 <dt class="hdlist1">
706 --relative-marks
707 </dt>
708 <dd>
710 After specifying --relative-marks the paths specified
711 with --import-marks= and --export-marks= are relative
712 to an internal directory in the current repository.
713 In git-fast-import this means that the paths are relative
714 to the .git/info/fast-import directory. However, other
715 importers may use a different location.
716 </p>
717 </dd>
718 <dt class="hdlist1">
719 --no-relative-marks
720 </dt>
721 <dd>
723 Negates a previous --relative-marks. Allows for combining
724 relative and non-relative marks by interweaving
725 --(no-)-relative-marks with the --(import|export)-marks=
726 options.
727 </p>
728 </dd>
729 <dt class="hdlist1">
730 --cat-blob-fd=&lt;fd&gt;
731 </dt>
732 <dd>
734 Specify the file descriptor that will be written to
735 when the <tt>cat-blob</tt> command is encountered in the stream.
736 The default behaviour is to write to <tt>stdout</tt>.
737 </p>
738 </dd>
739 <dt class="hdlist1">
740 --done
741 </dt>
742 <dd>
744 Require a <tt>done</tt> command at the end of the stream.
745 This option might be useful for detecting errors that
746 cause the frontend to terminate before it has started to
747 write a stream.
748 </p>
749 </dd>
750 <dt class="hdlist1">
751 --export-pack-edges=&lt;file&gt;
752 </dt>
753 <dd>
755 After creating a packfile, print a line of data to
756 &lt;file&gt; listing the filename of the packfile and the last
757 commit on each branch that was written to that packfile.
758 This information may be useful after importing projects
759 whose total object set exceeds the 4 GiB packfile limit,
760 as these commits can be used as edge points during calls
761 to <em>git pack-objects</em>.
762 </p>
763 </dd>
764 <dt class="hdlist1">
765 --quiet
766 </dt>
767 <dd>
769 Disable all non-fatal output, making fast-import silent when it
770 is successful. This option disables the output shown by
771 --stats.
772 </p>
773 </dd>
774 <dt class="hdlist1">
775 --stats
776 </dt>
777 <dd>
779 Display some basic statistics about the objects fast-import has
780 created, the packfiles they were stored into, and the
781 memory used by fast-import during this run. Showing this output
782 is currently the default, but can be disabled with --quiet.
783 </p>
784 </dd>
785 </dl></div>
786 </div>
787 <h2 id="_performance">Performance</h2>
788 <div class="sectionbody">
789 <div class="paragraph"><p>The design of fast-import allows it to import large projects in a minimum
790 amount of memory usage and processing time. Assuming the frontend
791 is able to keep up with fast-import and feed it a constant stream of data,
792 import times for projects holding 10+ years of history and containing
793 100,000+ individual commits are generally completed in just 1-2
794 hours on quite modest (~$2,000 USD) hardware.</p></div>
795 <div class="paragraph"><p>Most bottlenecks appear to be in foreign source data access (the
796 source just cannot extract revisions fast enough) or disk IO (fast-import
797 writes as fast as the disk will take the data). Imports will run
798 faster if the source data is stored on a different drive than the
799 destination Git repository (due to less IO contention).</p></div>
800 </div>
801 <h2 id="_development_cost">Development Cost</h2>
802 <div class="sectionbody">
803 <div class="paragraph"><p>A typical frontend for fast-import tends to weigh in at approximately 200
804 lines of Perl/Python/Ruby code. Most developers have been able to
805 create working importers in just a couple of hours, even though it
806 is their first exposure to fast-import, and sometimes even to Git. This is
807 an ideal situation, given that most conversion tools are throw-away
808 (use once, and never look back).</p></div>
809 </div>
810 <h2 id="_parallel_operation">Parallel Operation</h2>
811 <div class="sectionbody">
812 <div class="paragraph"><p>Like <em>git push</em> or <em>git fetch</em>, imports handled by fast-import are safe to
813 run alongside parallel <tt>git repack -a -d</tt> or <tt>git gc</tt> invocations,
814 or any other Git operation (including <em>git prune</em>, as loose objects
815 are never used by fast-import).</p></div>
816 <div class="paragraph"><p>fast-import does not lock the branch or tag refs it is actively importing.
817 After the import, during its ref update phase, fast-import tests each
818 existing branch ref to verify the update will be a fast-forward
819 update (the commit stored in the ref is contained in the new
820 history of the commit to be written). If the update is not a
821 fast-forward update, fast-import will skip updating that ref and instead
822 prints a warning message. fast-import will always attempt to update all
823 branch refs, and does not stop on the first failure.</p></div>
824 <div class="paragraph"><p>Branch updates can be forced with --force, but it&#8217;s recommended that
825 this only be used on an otherwise quiet repository. Using --force
826 is not necessary for an initial import into an empty repository.</p></div>
827 </div>
828 <h2 id="_technical_discussion">Technical Discussion</h2>
829 <div class="sectionbody">
830 <div class="paragraph"><p>fast-import tracks a set of branches in memory. Any branch can be created
831 or modified at any point during the import process by sending a
832 <tt>commit</tt> command on the input stream. This design allows a frontend
833 program to process an unlimited number of branches simultaneously,
834 generating commits in the order they are available from the source
835 data. It also simplifies the frontend programs considerably.</p></div>
836 <div class="paragraph"><p>fast-import does not use or alter the current working directory, or any
837 file within it. (It does however update the current Git repository,
838 as referenced by <tt>GIT_DIR</tt>.) Therefore an import frontend may use
839 the working directory for its own purposes, such as extracting file
840 revisions from the foreign source. This ignorance of the working
841 directory also allows fast-import to run very quickly, as it does not
842 need to perform any costly file update operations when switching
843 between branches.</p></div>
844 </div>
845 <h2 id="_input_format">Input Format</h2>
846 <div class="sectionbody">
847 <div class="paragraph"><p>With the exception of raw file data (which Git does not interpret)
848 the fast-import input format is text (ASCII) based. This text based
849 format simplifies development and debugging of frontend programs,
850 especially when a higher level language such as Perl, Python or
851 Ruby is being used.</p></div>
852 <div class="paragraph"><p>fast-import is very strict about its input. Where we say SP below we mean
853 <strong>exactly</strong> one space. Likewise LF means one (and only one) linefeed
854 and HT one (and only one) horizontal tab.
855 Supplying additional whitespace characters will cause unexpected
856 results, such as branch names or file names with leading or trailing
857 spaces in their name, or early termination of fast-import when it encounters
858 unexpected input.</p></div>
859 <h3 id="_stream_comments">Stream Comments</h3><div style="clear:left"></div>
860 <div class="paragraph"><p>To aid in debugging frontends fast-import ignores any line that
861 begins with <tt>#</tt> (ASCII pound/hash) up to and including the line
862 ending <tt>LF</tt>. A comment line may contain any sequence of bytes
863 that does not contain an LF and therefore may be used to include
864 any detailed debugging information that might be specific to the
865 frontend and useful when inspecting a fast-import data stream.</p></div>
866 <h3 id="_date_formats">Date Formats</h3><div style="clear:left"></div>
867 <div class="paragraph"><p>The following date formats are supported. A frontend should select
868 the format it will use for this import by passing the format name
869 in the --date-format=&lt;fmt&gt; command line option.</p></div>
870 <div class="dlist"><dl>
871 <dt class="hdlist1">
872 <tt>raw</tt>
873 </dt>
874 <dd>
876 This is the Git native format and is <tt>&lt;time&gt; SP &lt;offutc&gt;</tt>.
877 It is also fast-import&#8217;s default format, if --date-format was
878 not specified.
879 </p>
880 <div class="paragraph"><p>The time of the event is specified by <tt>&lt;time&gt;</tt> as the number of
881 seconds since the UNIX epoch (midnight, Jan 1, 1970, UTC) and is
882 written as an ASCII decimal integer.</p></div>
883 <div class="paragraph"><p>The local offset is specified by <tt>&lt;offutc&gt;</tt> as a positive or negative
884 offset from UTC. For example EST (which is 5 hours behind UTC)
885 would be expressed in <tt>&lt;tz&gt;</tt> by &#8220;-0500&#8221; while UTC is &#8220;+0000&#8221;.
886 The local offset does not affect <tt>&lt;time&gt;</tt>; it is used only as an
887 advisement to help formatting routines display the timestamp.</p></div>
888 <div class="paragraph"><p>If the local offset is not available in the source material, use
889 &#8220;+0000&#8221;, or the most common local offset. For example many
890 organizations have a CVS repository which has only ever been accessed
891 by users who are located in the same location and timezone. In this
892 case a reasonable offset from UTC could be assumed.</p></div>
893 <div class="paragraph"><p>Unlike the <tt>rfc2822</tt> format, this format is very strict. Any
894 variation in formatting will cause fast-import to reject the value.</p></div>
895 </dd>
896 <dt class="hdlist1">
897 <tt>rfc2822</tt>
898 </dt>
899 <dd>
901 This is the standard email format as described by RFC 2822.
902 </p>
903 <div class="paragraph"><p>An example value is &#8220;Tue Feb 6 11:22:18 2007 -0500&#8221;. The Git
904 parser is accurate, but a little on the lenient side. It is the
905 same parser used by <em>git am</em> when applying patches
906 received from email.</p></div>
907 <div class="paragraph"><p>Some malformed strings may be accepted as valid dates. In some of
908 these cases Git will still be able to obtain the correct date from
909 the malformed string. There are also some types of malformed
910 strings which Git will parse wrong, and yet consider valid.
911 Seriously malformed strings will be rejected.</p></div>
912 <div class="paragraph"><p>Unlike the <tt>raw</tt> format above, the timezone/UTC offset information
913 contained in an RFC 2822 date string is used to adjust the date
914 value to UTC prior to storage. Therefore it is important that
915 this information be as accurate as possible.</p></div>
916 <div class="paragraph"><p>If the source material uses RFC 2822 style dates,
917 the frontend should let fast-import handle the parsing and conversion
918 (rather than attempting to do it itself) as the Git parser has
919 been well tested in the wild.</p></div>
920 <div class="paragraph"><p>Frontends should prefer the <tt>raw</tt> format if the source material
921 already uses UNIX-epoch format, can be coaxed to give dates in that
922 format, or its format is easily convertible to it, as there is no
923 ambiguity in parsing.</p></div>
924 </dd>
925 <dt class="hdlist1">
926 <tt>now</tt>
927 </dt>
928 <dd>
930 Always use the current time and timezone. The literal
931 <tt>now</tt> must always be supplied for <tt>&lt;when&gt;</tt>.
932 </p>
933 <div class="paragraph"><p>This is a toy format. The current time and timezone of this system
934 is always copied into the identity string at the time it is being
935 created by fast-import. There is no way to specify a different time or
936 timezone.</p></div>
937 <div class="paragraph"><p>This particular format is supplied as it&#8217;s short to implement and
938 may be useful to a process that wants to create a new commit
939 right now, without needing to use a working directory or
940 <em>git update-index</em>.</p></div>
941 <div class="paragraph"><p>If separate <tt>author</tt> and <tt>committer</tt> commands are used in a <tt>commit</tt>
942 the timestamps may not match, as the system clock will be polled
943 twice (once for each command). The only way to ensure that both
944 author and committer identity information has the same timestamp
945 is to omit <tt>author</tt> (thus copying from <tt>committer</tt>) or to use a
946 date format other than <tt>now</tt>.</p></div>
947 </dd>
948 </dl></div>
949 <h3 id="_commands">Commands</h3><div style="clear:left"></div>
950 <div class="paragraph"><p>fast-import accepts several commands to update the current repository
951 and control the current import process. More detailed discussion
952 (with examples) of each command follows later.</p></div>
953 <div class="dlist"><dl>
954 <dt class="hdlist1">
955 <tt>commit</tt>
956 </dt>
957 <dd>
959 Creates a new branch or updates an existing branch by
960 creating a new commit and updating the branch to point at
961 the newly created commit.
962 </p>
963 </dd>
964 <dt class="hdlist1">
965 <tt>tag</tt>
966 </dt>
967 <dd>
969 Creates an annotated tag object from an existing commit or
970 branch. Lightweight tags are not supported by this command,
971 as they are not recommended for recording meaningful points
972 in time.
973 </p>
974 </dd>
975 <dt class="hdlist1">
976 <tt>reset</tt>
977 </dt>
978 <dd>
980 Reset an existing branch (or a new branch) to a specific
981 revision. This command must be used to change a branch to
982 a specific revision without making a commit on it.
983 </p>
984 </dd>
985 <dt class="hdlist1">
986 <tt>blob</tt>
987 </dt>
988 <dd>
990 Convert raw file data into a blob, for future use in a
991 <tt>commit</tt> command. This command is optional and is not
992 needed to perform an import.
993 </p>
994 </dd>
995 <dt class="hdlist1">
996 <tt>checkpoint</tt>
997 </dt>
998 <dd>
1000 Forces fast-import to close the current packfile, generate its
1001 unique SHA-1 checksum and index, and start a new packfile.
1002 This command is optional and is not needed to perform
1003 an import.
1004 </p>
1005 </dd>
1006 <dt class="hdlist1">
1007 <tt>progress</tt>
1008 </dt>
1009 <dd>
1011 Causes fast-import to echo the entire line to its own
1012 standard output. This command is optional and is not needed
1013 to perform an import.
1014 </p>
1015 </dd>
1016 <dt class="hdlist1">
1017 <tt>done</tt>
1018 </dt>
1019 <dd>
1021 Marks the end of the stream. This command is optional
1022 unless the <tt>done</tt> feature was requested using the
1023 <tt>--done</tt> command line option or <tt>feature done</tt> command.
1024 </p>
1025 </dd>
1026 <dt class="hdlist1">
1027 <tt>cat-blob</tt>
1028 </dt>
1029 <dd>
1031 Causes fast-import to print a blob in <em>cat-file --batch</em>
1032 format to the file descriptor set with <tt>--cat-blob-fd</tt> or
1033 <tt>stdout</tt> if unspecified.
1034 </p>
1035 </dd>
1036 <dt class="hdlist1">
1037 <tt>ls</tt>
1038 </dt>
1039 <dd>
1041 Causes fast-import to print a line describing a directory
1042 entry in <em>ls-tree</em> format to the file descriptor set with
1043 <tt>--cat-blob-fd</tt> or <tt>stdout</tt> if unspecified.
1044 </p>
1045 </dd>
1046 <dt class="hdlist1">
1047 <tt>feature</tt>
1048 </dt>
1049 <dd>
1051 Require that fast-import supports the specified feature, or
1052 abort if it does not.
1053 </p>
1054 </dd>
1055 <dt class="hdlist1">
1056 <tt>option</tt>
1057 </dt>
1058 <dd>
1060 Specify any of the options listed under OPTIONS that do not
1061 change stream semantic to suit the frontend&#8217;s needs. This
1062 command is optional and is not needed to perform an import.
1063 </p>
1064 </dd>
1065 </dl></div>
1066 <h3 id="_tt_commit_tt"><tt>commit</tt></h3><div style="clear:left"></div>
1067 <div class="paragraph"><p>Create or update a branch with a new commit, recording one logical
1068 change to the project.</p></div>
1069 <div class="literalblock">
1070 <div class="content">
1071 <pre><tt> 'commit' SP &lt;ref&gt; LF
1072 mark?
1073 ('author' (SP &lt;name&gt;)? SP LT &lt;email&gt; GT SP &lt;when&gt; LF)?
1074 'committer' (SP &lt;name&gt;)? SP LT &lt;email&gt; GT SP &lt;when&gt; LF
1075 data
1076 ('from' SP &lt;committish&gt; LF)?
1077 ('merge' SP &lt;committish&gt; LF)?
1078 (filemodify | filedelete | filecopy | filerename | filedeleteall | notemodify)*
1079 LF?</tt></pre>
1080 </div></div>
1081 <div class="paragraph"><p>where <tt>&lt;ref&gt;</tt> is the name of the branch to make the commit on.
1082 Typically branch names are prefixed with <tt>refs/heads/</tt> in
1083 Git, so importing the CVS branch symbol <tt>RELENG-1_0</tt> would use
1084 <tt>refs/heads/RELENG-1_0</tt> for the value of <tt>&lt;ref&gt;</tt>. The value of
1085 <tt>&lt;ref&gt;</tt> must be a valid refname in Git. As <tt>LF</tt> is not valid in
1086 a Git refname, no quoting or escaping syntax is supported here.</p></div>
1087 <div class="paragraph"><p>A <tt>mark</tt> command may optionally appear, requesting fast-import to save a
1088 reference to the newly created commit for future use by the frontend
1089 (see below for format). It is very common for frontends to mark
1090 every commit they create, thereby allowing future branch creation
1091 from any imported commit.</p></div>
1092 <div class="paragraph"><p>The <tt>data</tt> command following <tt>committer</tt> must supply the commit
1093 message (see below for <tt>data</tt> command syntax). To import an empty
1094 commit message use a 0 length data. Commit messages are free-form
1095 and are not interpreted by Git. Currently they must be encoded in
1096 UTF-8, as fast-import does not permit other encodings to be specified.</p></div>
1097 <div class="paragraph"><p>Zero or more <tt>filemodify</tt>, <tt>filedelete</tt>, <tt>filecopy</tt>, <tt>filerename</tt>,
1098 <tt>filedeleteall</tt> and <tt>notemodify</tt> commands
1099 may be included to update the contents of the branch prior to
1100 creating the commit. These commands may be supplied in any order.
1101 However it is recommended that a <tt>filedeleteall</tt> command precede
1102 all <tt>filemodify</tt>, <tt>filecopy</tt>, <tt>filerename</tt> and <tt>notemodify</tt> commands in
1103 the same commit, as <tt>filedeleteall</tt> wipes the branch clean (see below).</p></div>
1104 <div class="paragraph"><p>The <tt>LF</tt> after the command is optional (it used to be required).</p></div>
1105 <h4 id="_tt_author_tt"><tt>author</tt></h4>
1106 <div class="paragraph"><p>An <tt>author</tt> command may optionally appear, if the author information
1107 might differ from the committer information. If <tt>author</tt> is omitted
1108 then fast-import will automatically use the committer&#8217;s information for
1109 the author portion of the commit. See below for a description of
1110 the fields in <tt>author</tt>, as they are identical to <tt>committer</tt>.</p></div>
1111 <h4 id="_tt_committer_tt"><tt>committer</tt></h4>
1112 <div class="paragraph"><p>The <tt>committer</tt> command indicates who made this commit, and when
1113 they made it.</p></div>
1114 <div class="paragraph"><p>Here <tt>&lt;name&gt;</tt> is the person&#8217;s display name (for example
1115 &#8220;Com M Itter&#8221;) and <tt>&lt;email&gt;</tt> is the person&#8217;s email address
1116 (&#8220;<a href="mailto:cm@example.com">cm@example.com</a>&#8221;). <tt>LT</tt> and <tt>GT</tt> are the literal less-than (\x3c)
1117 and greater-than (\x3e) symbols. These are required to delimit
1118 the email address from the other fields in the line. Note that
1119 <tt>&lt;name&gt;</tt> and <tt>&lt;email&gt;</tt> are free-form and may contain any sequence
1120 of bytes, except <tt>LT</tt>, <tt>GT</tt> and <tt>LF</tt>. <tt>&lt;name&gt;</tt> is typically UTF-8 encoded.</p></div>
1121 <div class="paragraph"><p>The time of the change is specified by <tt>&lt;when&gt;</tt> using the date format
1122 that was selected by the --date-format=&lt;fmt&gt; command line option.
1123 See &#8220;Date Formats&#8221; above for the set of supported formats, and
1124 their syntax.</p></div>
1125 <h4 id="_tt_from_tt"><tt>from</tt></h4>
1126 <div class="paragraph"><p>The <tt>from</tt> command is used to specify the commit to initialize
1127 this branch from. This revision will be the first ancestor of the
1128 new commit.</p></div>
1129 <div class="paragraph"><p>Omitting the <tt>from</tt> command in the first commit of a new branch
1130 will cause fast-import to create that commit with no ancestor. This
1131 tends to be desired only for the initial commit of a project.
1132 If the frontend creates all files from scratch when making a new
1133 branch, a <tt>merge</tt> command may be used instead of <tt>from</tt> to start
1134 the commit with an empty tree.
1135 Omitting the <tt>from</tt> command on existing branches is usually desired,
1136 as the current commit on that branch is automatically assumed to
1137 be the first ancestor of the new commit.</p></div>
1138 <div class="paragraph"><p>As <tt>LF</tt> is not valid in a Git refname or SHA-1 expression, no
1139 quoting or escaping syntax is supported within <tt>&lt;committish&gt;</tt>.</p></div>
1140 <div class="paragraph"><p>Here <tt>&lt;committish&gt;</tt> is any of the following:</p></div>
1141 <div class="ulist"><ul>
1142 <li>
1144 The name of an existing branch already in fast-import&#8217;s internal branch
1145 table. If fast-import doesn&#8217;t know the name, it&#8217;s treated as a SHA-1
1146 expression.
1147 </p>
1148 </li>
1149 <li>
1151 A mark reference, <tt>:&lt;idnum&gt;</tt>, where <tt>&lt;idnum&gt;</tt> is the mark number.
1152 </p>
1153 <div class="paragraph"><p>The reason fast-import uses <tt>:</tt> to denote a mark reference is this character
1154 is not legal in a Git branch name. The leading <tt>:</tt> makes it easy
1155 to distinguish between the mark 42 (<tt>:42</tt>) and the branch 42 (<tt>42</tt>
1156 or <tt>refs/heads/42</tt>), or an abbreviated SHA-1 which happened to
1157 consist only of base-10 digits.</p></div>
1158 <div class="paragraph"><p>Marks must be declared (via <tt>mark</tt>) before they can be used.</p></div>
1159 </li>
1160 <li>
1162 A complete 40 byte or abbreviated commit SHA-1 in hex.
1163 </p>
1164 </li>
1165 <li>
1167 Any valid Git SHA-1 expression that resolves to a commit. See
1168 &#8220;SPECIFYING REVISIONS&#8221; in <a href="gitrevisions.html">gitrevisions(7)</a> for details.
1169 </p>
1170 </li>
1171 </ul></div>
1172 <div class="paragraph"><p>The special case of restarting an incremental import from the
1173 current branch value should be written as:</p></div>
1174 <div class="listingblock">
1175 <div class="content">
1176 <pre><tt> from refs/heads/branch^0</tt></pre>
1177 </div></div>
1178 <div class="paragraph"><p>The <tt>&#94;0</tt> suffix is necessary as fast-import does not permit a branch to
1179 start from itself, and the branch is created in memory before the
1180 <tt>from</tt> command is even read from the input. Adding <tt>&#94;0</tt> will force
1181 fast-import to resolve the commit through Git&#8217;s revision parsing library,
1182 rather than its internal branch table, thereby loading in the
1183 existing value of the branch.</p></div>
1184 <h4 id="_tt_merge_tt"><tt>merge</tt></h4>
1185 <div class="paragraph"><p>Includes one additional ancestor commit. If the <tt>from</tt> command is
1186 omitted when creating a new branch, the first <tt>merge</tt> commit will be
1187 the first ancestor of the current commit, and the branch will start
1188 out with no files. An unlimited number of <tt>merge</tt> commands per
1189 commit are permitted by fast-import, thereby establishing an n-way merge.
1190 However Git&#8217;s other tools never create commits with more than 15
1191 additional ancestors (forming a 16-way merge). For this reason
1192 it is suggested that frontends do not use more than 15 <tt>merge</tt>
1193 commands per commit; 16, if starting a new, empty branch.</p></div>
1194 <div class="paragraph"><p>Here <tt>&lt;committish&gt;</tt> is any of the commit specification expressions
1195 also accepted by <tt>from</tt> (see above).</p></div>
1196 <h4 id="_tt_filemodify_tt"><tt>filemodify</tt></h4>
1197 <div class="paragraph"><p>Included in a <tt>commit</tt> command to add a new file or change the
1198 content of an existing file. This command has two different means
1199 of specifying the content of the file.</p></div>
1200 <div class="dlist"><dl>
1201 <dt class="hdlist1">
1202 External data format
1203 </dt>
1204 <dd>
1206 The data content for the file was already supplied by a prior
1207 <tt>blob</tt> command. The frontend just needs to connect it.
1208 </p>
1209 <div class="literalblock">
1210 <div class="content">
1211 <pre><tt> 'M' SP &lt;mode&gt; SP &lt;dataref&gt; SP &lt;path&gt; LF</tt></pre>
1212 </div></div>
1213 <div class="paragraph"><p>Here usually <tt>&lt;dataref&gt;</tt> must be either a mark reference (<tt>:&lt;idnum&gt;</tt>)
1214 set by a prior <tt>blob</tt> command, or a full 40-byte SHA-1 of an
1215 existing Git blob object. If <tt>&lt;mode&gt;</tt> is <tt>040000</tt>` then
1216 <tt>&lt;dataref&gt;</tt> must be the full 40-byte SHA-1 of an existing
1217 Git tree object or a mark reference set with <tt>--import-marks</tt>.</p></div>
1218 </dd>
1219 <dt class="hdlist1">
1220 Inline data format
1221 </dt>
1222 <dd>
1224 The data content for the file has not been supplied yet.
1225 The frontend wants to supply it as part of this modify
1226 command.
1227 </p>
1228 <div class="literalblock">
1229 <div class="content">
1230 <pre><tt> 'M' SP &lt;mode&gt; SP 'inline' SP &lt;path&gt; LF
1231 data</tt></pre>
1232 </div></div>
1233 <div class="paragraph"><p>See below for a detailed description of the <tt>data</tt> command.</p></div>
1234 </dd>
1235 </dl></div>
1236 <div class="paragraph"><p>In both formats <tt>&lt;mode&gt;</tt> is the type of file entry, specified
1237 in octal. Git only supports the following modes:</p></div>
1238 <div class="ulist"><ul>
1239 <li>
1241 <tt>100644</tt> or <tt>644</tt>: A normal (not-executable) file. The majority
1242 of files in most projects use this mode. If in doubt, this is
1243 what you want.
1244 </p>
1245 </li>
1246 <li>
1248 <tt>100755</tt> or <tt>755</tt>: A normal, but executable, file.
1249 </p>
1250 </li>
1251 <li>
1253 <tt>120000</tt>: A symlink, the content of the file will be the link target.
1254 </p>
1255 </li>
1256 <li>
1258 <tt>160000</tt>: A gitlink, SHA-1 of the object refers to a commit in
1259 another repository. Git links can only be specified by SHA or through
1260 a commit mark. They are used to implement submodules.
1261 </p>
1262 </li>
1263 <li>
1265 <tt>040000</tt>: A subdirectory. Subdirectories can only be specified by
1266 SHA or through a tree mark set with <tt>--import-marks</tt>.
1267 </p>
1268 </li>
1269 </ul></div>
1270 <div class="paragraph"><p>In both formats <tt>&lt;path&gt;</tt> is the complete path of the file to be added
1271 (if not already existing) or modified (if already existing).</p></div>
1272 <div class="paragraph"><p>A <tt>&lt;path&gt;</tt> string must use UNIX-style directory separators (forward
1273 slash <tt>/</tt>), may contain any byte other than <tt>LF</tt>, and must not
1274 start with double quote (<tt>"</tt>).</p></div>
1275 <div class="paragraph"><p>If an <tt>LF</tt> or double quote must be encoded into <tt>&lt;path&gt;</tt> shell-style
1276 quoting should be used, e.g. <tt>"path/with\n and \" in it"</tt>.</p></div>
1277 <div class="paragraph"><p>The value of <tt>&lt;path&gt;</tt> must be in canonical form. That is it must not:</p></div>
1278 <div class="ulist"><ul>
1279 <li>
1281 contain an empty directory component (e.g. <tt>foo//bar</tt> is invalid),
1282 </p>
1283 </li>
1284 <li>
1286 end with a directory separator (e.g. <tt>foo/</tt> is invalid),
1287 </p>
1288 </li>
1289 <li>
1291 start with a directory separator (e.g. <tt>/foo</tt> is invalid),
1292 </p>
1293 </li>
1294 <li>
1296 contain the special component <tt>.</tt> or <tt>..</tt> (e.g. <tt>foo/./bar</tt> and
1297 <tt>foo/../bar</tt> are invalid).
1298 </p>
1299 </li>
1300 </ul></div>
1301 <div class="paragraph"><p>The root of the tree can be represented by an empty string as <tt>&lt;path&gt;</tt>.</p></div>
1302 <div class="paragraph"><p>It is recommended that <tt>&lt;path&gt;</tt> always be encoded using UTF-8.</p></div>
1303 <h4 id="_tt_filedelete_tt"><tt>filedelete</tt></h4>
1304 <div class="paragraph"><p>Included in a <tt>commit</tt> command to remove a file or recursively
1305 delete an entire directory from the branch. If the file or directory
1306 removal makes its parent directory empty, the parent directory will
1307 be automatically removed too. This cascades up the tree until the
1308 first non-empty directory or the root is reached.</p></div>
1309 <div class="literalblock">
1310 <div class="content">
1311 <pre><tt> 'D' SP &lt;path&gt; LF</tt></pre>
1312 </div></div>
1313 <div class="paragraph"><p>here <tt>&lt;path&gt;</tt> is the complete path of the file or subdirectory to
1314 be removed from the branch.
1315 See <tt>filemodify</tt> above for a detailed description of <tt>&lt;path&gt;</tt>.</p></div>
1316 <h4 id="_tt_filecopy_tt"><tt>filecopy</tt></h4>
1317 <div class="paragraph"><p>Recursively copies an existing file or subdirectory to a different
1318 location within the branch. The existing file or directory must
1319 exist. If the destination exists it will be completely replaced
1320 by the content copied from the source.</p></div>
1321 <div class="literalblock">
1322 <div class="content">
1323 <pre><tt> 'C' SP &lt;path&gt; SP &lt;path&gt; LF</tt></pre>
1324 </div></div>
1325 <div class="paragraph"><p>here the first <tt>&lt;path&gt;</tt> is the source location and the second
1326 <tt>&lt;path&gt;</tt> is the destination. See <tt>filemodify</tt> above for a detailed
1327 description of what <tt>&lt;path&gt;</tt> may look like. To use a source path
1328 that contains SP the path must be quoted.</p></div>
1329 <div class="paragraph"><p>A <tt>filecopy</tt> command takes effect immediately. Once the source
1330 location has been copied to the destination any future commands
1331 applied to the source location will not impact the destination of
1332 the copy.</p></div>
1333 <h4 id="_tt_filerename_tt"><tt>filerename</tt></h4>
1334 <div class="paragraph"><p>Renames an existing file or subdirectory to a different location
1335 within the branch. The existing file or directory must exist. If
1336 the destination exists it will be replaced by the source directory.</p></div>
1337 <div class="literalblock">
1338 <div class="content">
1339 <pre><tt> 'R' SP &lt;path&gt; SP &lt;path&gt; LF</tt></pre>
1340 </div></div>
1341 <div class="paragraph"><p>here the first <tt>&lt;path&gt;</tt> is the source location and the second
1342 <tt>&lt;path&gt;</tt> is the destination. See <tt>filemodify</tt> above for a detailed
1343 description of what <tt>&lt;path&gt;</tt> may look like. To use a source path
1344 that contains SP the path must be quoted.</p></div>
1345 <div class="paragraph"><p>A <tt>filerename</tt> command takes effect immediately. Once the source
1346 location has been renamed to the destination any future commands
1347 applied to the source location will create new files there and not
1348 impact the destination of the rename.</p></div>
1349 <div class="paragraph"><p>Note that a <tt>filerename</tt> is the same as a <tt>filecopy</tt> followed by a
1350 <tt>filedelete</tt> of the source location. There is a slight performance
1351 advantage to using <tt>filerename</tt>, but the advantage is so small
1352 that it is never worth trying to convert a delete/add pair in
1353 source material into a rename for fast-import. This <tt>filerename</tt>
1354 command is provided just to simplify frontends that already have
1355 rename information and don&#8217;t want bother with decomposing it into a
1356 <tt>filecopy</tt> followed by a <tt>filedelete</tt>.</p></div>
1357 <h4 id="_tt_filedeleteall_tt"><tt>filedeleteall</tt></h4>
1358 <div class="paragraph"><p>Included in a <tt>commit</tt> command to remove all files (and also all
1359 directories) from the branch. This command resets the internal
1360 branch structure to have no files in it, allowing the frontend
1361 to subsequently add all interesting files from scratch.</p></div>
1362 <div class="literalblock">
1363 <div class="content">
1364 <pre><tt> 'deleteall' LF</tt></pre>
1365 </div></div>
1366 <div class="paragraph"><p>This command is extremely useful if the frontend does not know
1367 (or does not care to know) what files are currently on the branch,
1368 and therefore cannot generate the proper <tt>filedelete</tt> commands to
1369 update the content.</p></div>
1370 <div class="paragraph"><p>Issuing a <tt>filedeleteall</tt> followed by the needed <tt>filemodify</tt>
1371 commands to set the correct content will produce the same results
1372 as sending only the needed <tt>filemodify</tt> and <tt>filedelete</tt> commands.
1373 The <tt>filedeleteall</tt> approach may however require fast-import to use slightly
1374 more memory per active branch (less than 1 MiB for even most large
1375 projects); so frontends that can easily obtain only the affected
1376 paths for a commit are encouraged to do so.</p></div>
1377 <h4 id="_tt_notemodify_tt"><tt>notemodify</tt></h4>
1378 <div class="paragraph"><p>Included in a <tt>commit</tt> <tt>&lt;notes_ref&gt;</tt> command to add a new note
1379 annotating a <tt>&lt;committish&gt;</tt> or change this annotation contents.
1380 Internally it is similar to filemodify 100644 on <tt>&lt;committish&gt;</tt>
1381 path (maybe split into subdirectories). It&#8217;s not advised to
1382 use any other commands to write to the <tt>&lt;notes_ref&gt;</tt> tree except
1383 <tt>filedeleteall</tt> to delete all existing notes in this tree.
1384 This command has two different means of specifying the content
1385 of the note.</p></div>
1386 <div class="dlist"><dl>
1387 <dt class="hdlist1">
1388 External data format
1389 </dt>
1390 <dd>
1392 The data content for the note was already supplied by a prior
1393 <tt>blob</tt> command. The frontend just needs to connect it to the
1394 commit that is to be annotated.
1395 </p>
1396 <div class="literalblock">
1397 <div class="content">
1398 <pre><tt> 'N' SP &lt;dataref&gt; SP &lt;committish&gt; LF</tt></pre>
1399 </div></div>
1400 <div class="paragraph"><p>Here <tt>&lt;dataref&gt;</tt> can be either a mark reference (<tt>:&lt;idnum&gt;</tt>)
1401 set by a prior <tt>blob</tt> command, or a full 40-byte SHA-1 of an
1402 existing Git blob object.</p></div>
1403 </dd>
1404 <dt class="hdlist1">
1405 Inline data format
1406 </dt>
1407 <dd>
1409 The data content for the note has not been supplied yet.
1410 The frontend wants to supply it as part of this modify
1411 command.
1412 </p>
1413 <div class="literalblock">
1414 <div class="content">
1415 <pre><tt> 'N' SP 'inline' SP &lt;committish&gt; LF
1416 data</tt></pre>
1417 </div></div>
1418 <div class="paragraph"><p>See below for a detailed description of the <tt>data</tt> command.</p></div>
1419 </dd>
1420 </dl></div>
1421 <div class="paragraph"><p>In both formats <tt>&lt;committish&gt;</tt> is any of the commit specification
1422 expressions also accepted by <tt>from</tt> (see above).</p></div>
1423 <h3 id="_tt_mark_tt"><tt>mark</tt></h3><div style="clear:left"></div>
1424 <div class="paragraph"><p>Arranges for fast-import to save a reference to the current object, allowing
1425 the frontend to recall this object at a future point in time, without
1426 knowing its SHA-1. Here the current object is the object creation
1427 command the <tt>mark</tt> command appears within. This can be <tt>commit</tt>,
1428 <tt>tag</tt>, and <tt>blob</tt>, but <tt>commit</tt> is the most common usage.</p></div>
1429 <div class="literalblock">
1430 <div class="content">
1431 <pre><tt> 'mark' SP ':' &lt;idnum&gt; LF</tt></pre>
1432 </div></div>
1433 <div class="paragraph"><p>where <tt>&lt;idnum&gt;</tt> is the number assigned by the frontend to this mark.
1434 The value of <tt>&lt;idnum&gt;</tt> is expressed as an ASCII decimal integer.
1435 The value 0 is reserved and cannot be used as
1436 a mark. Only values greater than or equal to 1 may be used as marks.</p></div>
1437 <div class="paragraph"><p>New marks are created automatically. Existing marks can be moved
1438 to another object simply by reusing the same <tt>&lt;idnum&gt;</tt> in another
1439 <tt>mark</tt> command.</p></div>
1440 <h3 id="_tt_tag_tt"><tt>tag</tt></h3><div style="clear:left"></div>
1441 <div class="paragraph"><p>Creates an annotated tag referring to a specific commit. To create
1442 lightweight (non-annotated) tags see the <tt>reset</tt> command below.</p></div>
1443 <div class="literalblock">
1444 <div class="content">
1445 <pre><tt> 'tag' SP &lt;name&gt; LF
1446 'from' SP &lt;committish&gt; LF
1447 'tagger' (SP &lt;name&gt;)? SP LT &lt;email&gt; GT SP &lt;when&gt; LF
1448 data</tt></pre>
1449 </div></div>
1450 <div class="paragraph"><p>where <tt>&lt;name&gt;</tt> is the name of the tag to create.</p></div>
1451 <div class="paragraph"><p>Tag names are automatically prefixed with <tt>refs/tags/</tt> when stored
1452 in Git, so importing the CVS branch symbol <tt>RELENG-1_0-FINAL</tt> would
1453 use just <tt>RELENG-1_0-FINAL</tt> for <tt>&lt;name&gt;</tt>, and fast-import will write the
1454 corresponding ref as <tt>refs/tags/RELENG-1_0-FINAL</tt>.</p></div>
1455 <div class="paragraph"><p>The value of <tt>&lt;name&gt;</tt> must be a valid refname in Git and therefore
1456 may contain forward slashes. As <tt>LF</tt> is not valid in a Git refname,
1457 no quoting or escaping syntax is supported here.</p></div>
1458 <div class="paragraph"><p>The <tt>from</tt> command is the same as in the <tt>commit</tt> command; see
1459 above for details.</p></div>
1460 <div class="paragraph"><p>The <tt>tagger</tt> command uses the same format as <tt>committer</tt> within
1461 <tt>commit</tt>; again see above for details.</p></div>
1462 <div class="paragraph"><p>The <tt>data</tt> command following <tt>tagger</tt> must supply the annotated tag
1463 message (see below for <tt>data</tt> command syntax). To import an empty
1464 tag message use a 0 length data. Tag messages are free-form and are
1465 not interpreted by Git. Currently they must be encoded in UTF-8,
1466 as fast-import does not permit other encodings to be specified.</p></div>
1467 <div class="paragraph"><p>Signing annotated tags during import from within fast-import is not
1468 supported. Trying to include your own PGP/GPG signature is not
1469 recommended, as the frontend does not (easily) have access to the
1470 complete set of bytes which normally goes into such a signature.
1471 If signing is required, create lightweight tags from within fast-import with
1472 <tt>reset</tt>, then create the annotated versions of those tags offline
1473 with the standard <em>git tag</em> process.</p></div>
1474 <h3 id="_tt_reset_tt"><tt>reset</tt></h3><div style="clear:left"></div>
1475 <div class="paragraph"><p>Creates (or recreates) the named branch, optionally starting from
1476 a specific revision. The reset command allows a frontend to issue
1477 a new <tt>from</tt> command for an existing branch, or to create a new
1478 branch from an existing commit without creating a new commit.</p></div>
1479 <div class="literalblock">
1480 <div class="content">
1481 <pre><tt> 'reset' SP &lt;ref&gt; LF
1482 ('from' SP &lt;committish&gt; LF)?
1483 LF?</tt></pre>
1484 </div></div>
1485 <div class="paragraph"><p>For a detailed description of <tt>&lt;ref&gt;</tt> and <tt>&lt;committish&gt;</tt> see above
1486 under <tt>commit</tt> and <tt>from</tt>.</p></div>
1487 <div class="paragraph"><p>The <tt>LF</tt> after the command is optional (it used to be required).</p></div>
1488 <div class="paragraph"><p>The <tt>reset</tt> command can also be used to create lightweight
1489 (non-annotated) tags. For example:</p></div>
1490 <div class="exampleblock">
1491 <div class="exampleblock-content">
1492 <div class="literalblock">
1493 <div class="content">
1494 <pre><tt>reset refs/tags/938
1495 from :938</tt></pre>
1496 </div></div>
1497 </div></div>
1498 <div class="paragraph"><p>would create the lightweight tag <tt>refs/tags/938</tt> referring to
1499 whatever commit mark <tt>:938</tt> references.</p></div>
1500 <h3 id="_tt_blob_tt"><tt>blob</tt></h3><div style="clear:left"></div>
1501 <div class="paragraph"><p>Requests writing one file revision to the packfile. The revision
1502 is not connected to any commit; this connection must be formed in
1503 a subsequent <tt>commit</tt> command by referencing the blob through an
1504 assigned mark.</p></div>
1505 <div class="literalblock">
1506 <div class="content">
1507 <pre><tt> 'blob' LF
1508 mark?
1509 data</tt></pre>
1510 </div></div>
1511 <div class="paragraph"><p>The mark command is optional here as some frontends have chosen
1512 to generate the Git SHA-1 for the blob on their own, and feed that
1513 directly to <tt>commit</tt>. This is typically more work than it&#8217;s worth
1514 however, as marks are inexpensive to store and easy to use.</p></div>
1515 <h3 id="_tt_data_tt"><tt>data</tt></h3><div style="clear:left"></div>
1516 <div class="paragraph"><p>Supplies raw data (for use as blob/file content, commit messages, or
1517 annotated tag messages) to fast-import. Data can be supplied using an exact
1518 byte count or delimited with a terminating line. Real frontends
1519 intended for production-quality conversions should always use the
1520 exact byte count format, as it is more robust and performs better.
1521 The delimited format is intended primarily for testing fast-import.</p></div>
1522 <div class="paragraph"><p>Comment lines appearing within the <tt>&lt;raw&gt;</tt> part of <tt>data</tt> commands
1523 are always taken to be part of the body of the data and are therefore
1524 never ignored by fast-import. This makes it safe to import any
1525 file/message content whose lines might start with <tt>#</tt>.</p></div>
1526 <div class="dlist"><dl>
1527 <dt class="hdlist1">
1528 Exact byte count format
1529 </dt>
1530 <dd>
1532 The frontend must specify the number of bytes of data.
1533 </p>
1534 <div class="literalblock">
1535 <div class="content">
1536 <pre><tt> 'data' SP &lt;count&gt; LF
1537 &lt;raw&gt; LF?</tt></pre>
1538 </div></div>
1539 <div class="paragraph"><p>where <tt>&lt;count&gt;</tt> is the exact number of bytes appearing within
1540 <tt>&lt;raw&gt;</tt>. The value of <tt>&lt;count&gt;</tt> is expressed as an ASCII decimal
1541 integer. The <tt>LF</tt> on either side of <tt>&lt;raw&gt;</tt> is not
1542 included in <tt>&lt;count&gt;</tt> and will not be included in the imported data.</p></div>
1543 <div class="paragraph"><p>The <tt>LF</tt> after <tt>&lt;raw&gt;</tt> is optional (it used to be required) but
1544 recommended. Always including it makes debugging a fast-import
1545 stream easier as the next command always starts in column 0
1546 of the next line, even if <tt>&lt;raw&gt;</tt> did not end with an <tt>LF</tt>.</p></div>
1547 </dd>
1548 <dt class="hdlist1">
1549 Delimited format
1550 </dt>
1551 <dd>
1553 A delimiter string is used to mark the end of the data.
1554 fast-import will compute the length by searching for the delimiter.
1555 This format is primarily useful for testing and is not
1556 recommended for real data.
1557 </p>
1558 <div class="literalblock">
1559 <div class="content">
1560 <pre><tt> 'data' SP '&lt;&lt;' &lt;delim&gt; LF
1561 &lt;raw&gt; LF
1562 &lt;delim&gt; LF
1563 LF?</tt></pre>
1564 </div></div>
1565 <div class="paragraph"><p>where <tt>&lt;delim&gt;</tt> is the chosen delimiter string. The string <tt>&lt;delim&gt;</tt>
1566 must not appear on a line by itself within <tt>&lt;raw&gt;</tt>, as otherwise
1567 fast-import will think the data ends earlier than it really does. The <tt>LF</tt>
1568 immediately trailing <tt>&lt;raw&gt;</tt> is part of <tt>&lt;raw&gt;</tt>. This is one of
1569 the limitations of the delimited format, it is impossible to supply
1570 a data chunk which does not have an LF as its last byte.</p></div>
1571 <div class="paragraph"><p>The <tt>LF</tt> after <tt>&lt;delim&gt; LF</tt> is optional (it used to be required).</p></div>
1572 </dd>
1573 </dl></div>
1574 <h3 id="_tt_checkpoint_tt"><tt>checkpoint</tt></h3><div style="clear:left"></div>
1575 <div class="paragraph"><p>Forces fast-import to close the current packfile, start a new one, and to
1576 save out all current branch refs, tags and marks.</p></div>
1577 <div class="literalblock">
1578 <div class="content">
1579 <pre><tt> 'checkpoint' LF
1580 LF?</tt></pre>
1581 </div></div>
1582 <div class="paragraph"><p>Note that fast-import automatically switches packfiles when the current
1583 packfile reaches --max-pack-size, or 4 GiB, whichever limit is
1584 smaller. During an automatic packfile switch fast-import does not update
1585 the branch refs, tags or marks.</p></div>
1586 <div class="paragraph"><p>As a <tt>checkpoint</tt> can require a significant amount of CPU time and
1587 disk IO (to compute the overall pack SHA-1 checksum, generate the
1588 corresponding index file, and update the refs) it can easily take
1589 several minutes for a single <tt>checkpoint</tt> command to complete.</p></div>
1590 <div class="paragraph"><p>Frontends may choose to issue checkpoints during extremely large
1591 and long running imports, or when they need to allow another Git
1592 process access to a branch. However given that a 30 GiB Subversion
1593 repository can be loaded into Git through fast-import in about 3 hours,
1594 explicit checkpointing may not be necessary.</p></div>
1595 <div class="paragraph"><p>The <tt>LF</tt> after the command is optional (it used to be required).</p></div>
1596 <h3 id="_tt_progress_tt"><tt>progress</tt></h3><div style="clear:left"></div>
1597 <div class="paragraph"><p>Causes fast-import to print the entire <tt>progress</tt> line unmodified to
1598 its standard output channel (file descriptor 1) when the command is
1599 processed from the input stream. The command otherwise has no impact
1600 on the current import, or on any of fast-import&#8217;s internal state.</p></div>
1601 <div class="literalblock">
1602 <div class="content">
1603 <pre><tt> 'progress' SP &lt;any&gt; LF
1604 LF?</tt></pre>
1605 </div></div>
1606 <div class="paragraph"><p>The <tt>&lt;any&gt;</tt> part of the command may contain any sequence of bytes
1607 that does not contain <tt>LF</tt>. The <tt>LF</tt> after the command is optional.
1608 Callers may wish to process the output through a tool such as sed to
1609 remove the leading part of the line, for example:</p></div>
1610 <div class="exampleblock">
1611 <div class="exampleblock-content">
1612 <div class="literalblock">
1613 <div class="content">
1614 <pre><tt>frontend | git fast-import | sed 's/^progress //'</tt></pre>
1615 </div></div>
1616 </div></div>
1617 <div class="paragraph"><p>Placing a <tt>progress</tt> command immediately after a <tt>checkpoint</tt> will
1618 inform the reader when the <tt>checkpoint</tt> has been completed and it
1619 can safely access the refs that fast-import updated.</p></div>
1620 <h3 id="_tt_cat_blob_tt"><tt>cat-blob</tt></h3><div style="clear:left"></div>
1621 <div class="paragraph"><p>Causes fast-import to print a blob to a file descriptor previously
1622 arranged with the <tt>--cat-blob-fd</tt> argument. The command otherwise
1623 has no impact on the current import; its main purpose is to
1624 retrieve blobs that may be in fast-import&#8217;s memory but not
1625 accessible from the target repository.</p></div>
1626 <div class="literalblock">
1627 <div class="content">
1628 <pre><tt> 'cat-blob' SP &lt;dataref&gt; LF</tt></pre>
1629 </div></div>
1630 <div class="paragraph"><p>The <tt>&lt;dataref&gt;</tt> can be either a mark reference (<tt>:&lt;idnum&gt;</tt>)
1631 set previously or a full 40-byte SHA-1 of a Git blob, preexisting or
1632 ready to be written.</p></div>
1633 <div class="paragraph"><p>Output uses the same format as <tt>git cat-file --batch</tt>:</p></div>
1634 <div class="exampleblock">
1635 <div class="exampleblock-content">
1636 <div class="literalblock">
1637 <div class="content">
1638 <pre><tt>&lt;sha1&gt; SP 'blob' SP &lt;size&gt; LF
1639 &lt;contents&gt; LF</tt></pre>
1640 </div></div>
1641 </div></div>
1642 <div class="paragraph"><p>This command can be used anywhere in the stream that comments are
1643 accepted. In particular, the <tt>cat-blob</tt> command can be used in the
1644 middle of a commit but not in the middle of a <tt>data</tt> command.</p></div>
1645 <h3 id="_tt_ls_tt"><tt>ls</tt></h3><div style="clear:left"></div>
1646 <div class="paragraph"><p>Prints information about the object at a path to a file descriptor
1647 previously arranged with the <tt>--cat-blob-fd</tt> argument. This allows
1648 printing a blob from the active commit (with <tt>cat-blob</tt>) or copying a
1649 blob or tree from a previous commit for use in the current one (with
1650 <tt>filemodify</tt>).</p></div>
1651 <div class="paragraph"><p>The <tt>ls</tt> command can be used anywhere in the stream that comments are
1652 accepted, including the middle of a commit.</p></div>
1653 <div class="dlist"><dl>
1654 <dt class="hdlist1">
1655 Reading from the active commit
1656 </dt>
1657 <dd>
1659 This form can only be used in the middle of a <tt>commit</tt>.
1660 The path names a directory entry within fast-import&#8217;s
1661 active commit. The path must be quoted in this case.
1662 </p>
1663 <div class="literalblock">
1664 <div class="content">
1665 <pre><tt> 'ls' SP &lt;path&gt; LF</tt></pre>
1666 </div></div>
1667 </dd>
1668 <dt class="hdlist1">
1669 Reading from a named tree
1670 </dt>
1671 <dd>
1673 The <tt>&lt;dataref&gt;</tt> can be a mark reference (<tt>:&lt;idnum&gt;</tt>) or the
1674 full 40-byte SHA-1 of a Git tag, commit, or tree object,
1675 preexisting or waiting to be written.
1676 The path is relative to the top level of the tree
1677 named by <tt>&lt;dataref&gt;</tt>.
1678 </p>
1679 <div class="literalblock">
1680 <div class="content">
1681 <pre><tt> 'ls' SP &lt;dataref&gt; SP &lt;path&gt; LF</tt></pre>
1682 </div></div>
1683 </dd>
1684 </dl></div>
1685 <div class="paragraph"><p>See <tt>filemodify</tt> above for a detailed description of <tt>&lt;path&gt;</tt>.</p></div>
1686 <div class="paragraph"><p>Output uses the same format as <tt>git ls-tree &lt;tree&gt; &#45;&#45; &lt;path&gt;</tt>:</p></div>
1687 <div class="exampleblock">
1688 <div class="exampleblock-content">
1689 <div class="literalblock">
1690 <div class="content">
1691 <pre><tt>&lt;mode&gt; SP ('blob' | 'tree' | 'commit') SP &lt;dataref&gt; HT &lt;path&gt; LF</tt></pre>
1692 </div></div>
1693 </div></div>
1694 <div class="paragraph"><p>The &lt;dataref&gt; represents the blob, tree, or commit object at &lt;path&gt;
1695 and can be used in later <em>cat-blob</em>, <em>filemodify</em>, or <em>ls</em> commands.</p></div>
1696 <div class="paragraph"><p>If there is no file or subtree at that path, <em>git fast-import</em> will
1697 instead report</p></div>
1698 <div class="exampleblock">
1699 <div class="exampleblock-content">
1700 <div class="literalblock">
1701 <div class="content">
1702 <pre><tt>missing SP &lt;path&gt; LF</tt></pre>
1703 </div></div>
1704 </div></div>
1705 <h3 id="_tt_feature_tt"><tt>feature</tt></h3><div style="clear:left"></div>
1706 <div class="paragraph"><p>Require that fast-import supports the specified feature, or abort if
1707 it does not.</p></div>
1708 <div class="literalblock">
1709 <div class="content">
1710 <pre><tt> 'feature' SP &lt;feature&gt; ('=' &lt;argument&gt;)? LF</tt></pre>
1711 </div></div>
1712 <div class="paragraph"><p>The &lt;feature&gt; part of the command may be any one of the following:</p></div>
1713 <div class="dlist"><dl>
1714 <dt class="hdlist1">
1715 date-format
1716 </dt>
1717 <dt class="hdlist1">
1718 export-marks
1719 </dt>
1720 <dt class="hdlist1">
1721 relative-marks
1722 </dt>
1723 <dt class="hdlist1">
1724 no-relative-marks
1725 </dt>
1726 <dt class="hdlist1">
1727 force
1728 </dt>
1729 <dd>
1731 Act as though the corresponding command-line option with
1732 a leading <em>--</em> was passed on the command line
1733 (see OPTIONS, above).
1734 </p>
1735 </dd>
1736 <dt class="hdlist1">
1737 import-marks
1738 </dt>
1739 <dt class="hdlist1">
1740 import-marks-if-exists
1741 </dt>
1742 <dd>
1744 Like --import-marks except in two respects: first, only one
1745 "feature import-marks" or "feature import-marks-if-exists"
1746 command is allowed per stream; second, an --import-marks=
1747 or --import-marks-if-exists command-line option overrides
1748 any of these "feature" commands in the stream; third,
1749 "feature import-marks-if-exists" like a corresponding
1750 command-line option silently skips a nonexistent file.
1751 </p>
1752 </dd>
1753 <dt class="hdlist1">
1754 cat-blob
1755 </dt>
1756 <dt class="hdlist1">
1758 </dt>
1759 <dd>
1761 Require that the backend support the <em>cat-blob</em> or <em>ls</em> command.
1762 Versions of fast-import not supporting the specified command
1763 will exit with a message indicating so.
1764 This lets the import error out early with a clear message,
1765 rather than wasting time on the early part of an import
1766 before the unsupported command is detected.
1767 </p>
1768 </dd>
1769 <dt class="hdlist1">
1770 notes
1771 </dt>
1772 <dd>
1774 Require that the backend support the <em>notemodify</em> (N)
1775 subcommand to the <em>commit</em> command.
1776 Versions of fast-import not supporting notes will exit
1777 with a message indicating so.
1778 </p>
1779 </dd>
1780 <dt class="hdlist1">
1781 done
1782 </dt>
1783 <dd>
1785 Error out if the stream ends without a <em>done</em> command.
1786 Without this feature, errors causing the frontend to end
1787 abruptly at a convenient point in the stream can go
1788 undetected.
1789 </p>
1790 </dd>
1791 </dl></div>
1792 <h3 id="_tt_option_tt"><tt>option</tt></h3><div style="clear:left"></div>
1793 <div class="paragraph"><p>Processes the specified option so that git fast-import behaves in a
1794 way that suits the frontend&#8217;s needs.
1795 Note that options specified by the frontend are overridden by any
1796 options the user may specify to git fast-import itself.</p></div>
1797 <div class="literalblock">
1798 <div class="content">
1799 <pre><tt> 'option' SP &lt;option&gt; LF</tt></pre>
1800 </div></div>
1801 <div class="paragraph"><p>The <tt>&lt;option&gt;</tt> part of the command may contain any of the options
1802 listed in the OPTIONS section that do not change import semantics,
1803 without the leading <em>--</em> and is treated in the same way.</p></div>
1804 <div class="paragraph"><p>Option commands must be the first commands on the input (not counting
1805 feature commands), to give an option command after any non-option
1806 command is an error.</p></div>
1807 <div class="paragraph"><p>The following commandline options change import semantics and may therefore
1808 not be passed as option:</p></div>
1809 <div class="ulist"><ul>
1810 <li>
1812 date-format
1813 </p>
1814 </li>
1815 <li>
1817 import-marks
1818 </p>
1819 </li>
1820 <li>
1822 export-marks
1823 </p>
1824 </li>
1825 <li>
1827 cat-blob-fd
1828 </p>
1829 </li>
1830 <li>
1832 force
1833 </p>
1834 </li>
1835 </ul></div>
1836 <h3 id="_tt_done_tt"><tt>done</tt></h3><div style="clear:left"></div>
1837 <div class="paragraph"><p>If the <tt>done</tt> feature is not in use, treated as if EOF was read.
1838 This can be used to tell fast-import to finish early.</p></div>
1839 <div class="paragraph"><p>If the <tt>--done</tt> command line option or <tt>feature done</tt> command is
1840 in use, the <tt>done</tt> command is mandatory and marks the end of the
1841 stream.</p></div>
1842 </div>
1843 <h2 id="_crash_reports">Crash Reports</h2>
1844 <div class="sectionbody">
1845 <div class="paragraph"><p>If fast-import is supplied invalid input it will terminate with a
1846 non-zero exit status and create a crash report in the top level of
1847 the Git repository it was importing into. Crash reports contain
1848 a snapshot of the internal fast-import state as well as the most
1849 recent commands that lead up to the crash.</p></div>
1850 <div class="paragraph"><p>All recent commands (including stream comments, file changes and
1851 progress commands) are shown in the command history within the crash
1852 report, but raw file data and commit messages are excluded from the
1853 crash report. This exclusion saves space within the report file
1854 and reduces the amount of buffering that fast-import must perform
1855 during execution.</p></div>
1856 <div class="paragraph"><p>After writing a crash report fast-import will close the current
1857 packfile and export the marks table. This allows the frontend
1858 developer to inspect the repository state and resume the import from
1859 the point where it crashed. The modified branches and tags are not
1860 updated during a crash, as the import did not complete successfully.
1861 Branch and tag information can be found in the crash report and
1862 must be applied manually if the update is needed.</p></div>
1863 <div class="paragraph"><p>An example crash:</p></div>
1864 <div class="exampleblock">
1865 <div class="exampleblock-content">
1866 <div class="literalblock">
1867 <div class="content">
1868 <pre><tt>$ cat &gt;in &lt;&lt;END_OF_INPUT
1869 # my very first test commit
1870 commit refs/heads/master
1871 committer Shawn O. Pearce &lt;spearce&gt; 19283 -0400
1872 # who is that guy anyway?
1873 data &lt;&lt;EOF
1874 this is my commit
1876 M 644 inline .gitignore
1877 data &lt;&lt;EOF
1878 .gitignore
1880 M 777 inline bob
1881 END_OF_INPUT</tt></pre>
1882 </div></div>
1883 <div class="literalblock">
1884 <div class="content">
1885 <pre><tt>$ git fast-import &lt;in
1886 fatal: Corrupt mode: M 777 inline bob
1887 fast-import: dumping crash report to .git/fast_import_crash_8434</tt></pre>
1888 </div></div>
1889 <div class="literalblock">
1890 <div class="content">
1891 <pre><tt>$ cat .git/fast_import_crash_8434
1892 fast-import crash report:
1893 fast-import process: 8434
1894 parent process : 1391
1895 at Sat Sep 1 00:58:12 2007</tt></pre>
1896 </div></div>
1897 <div class="literalblock">
1898 <div class="content">
1899 <pre><tt>fatal: Corrupt mode: M 777 inline bob</tt></pre>
1900 </div></div>
1901 <div class="literalblock">
1902 <div class="content">
1903 <pre><tt>Most Recent Commands Before Crash
1904 ---------------------------------
1905 # my very first test commit
1906 commit refs/heads/master
1907 committer Shawn O. Pearce &lt;spearce&gt; 19283 -0400
1908 # who is that guy anyway?
1909 data &lt;&lt;EOF
1910 M 644 inline .gitignore
1911 data &lt;&lt;EOF
1912 * M 777 inline bob</tt></pre>
1913 </div></div>
1914 <div class="literalblock">
1915 <div class="content">
1916 <pre><tt>Active Branch LRU
1917 -----------------
1918 active_branches = 1 cur, 5 max</tt></pre>
1919 </div></div>
1920 <div class="literalblock">
1921 <div class="content">
1922 <pre><tt>pos clock name
1923 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1924 1) 0 refs/heads/master</tt></pre>
1925 </div></div>
1926 <div class="literalblock">
1927 <div class="content">
1928 <pre><tt>Inactive Branches
1929 -----------------
1930 refs/heads/master:
1931 status : active loaded dirty
1932 tip commit : 0000000000000000000000000000000000000000
1933 old tree : 0000000000000000000000000000000000000000
1934 cur tree : 0000000000000000000000000000000000000000
1935 commit clock: 0
1936 last pack :</tt></pre>
1937 </div></div>
1938 <div class="literalblock">
1939 <div class="content">
1940 <pre><tt>-------------------
1941 END OF CRASH REPORT</tt></pre>
1942 </div></div>
1943 </div></div>
1944 </div>
1945 <h2 id="_tips_and_tricks">Tips and Tricks</h2>
1946 <div class="sectionbody">
1947 <div class="paragraph"><p>The following tips and tricks have been collected from various
1948 users of fast-import, and are offered here as suggestions.</p></div>
1949 <h3 id="_use_one_mark_per_commit">Use One Mark Per Commit</h3><div style="clear:left"></div>
1950 <div class="paragraph"><p>When doing a repository conversion, use a unique mark per commit
1951 (<tt>mark :&lt;n&gt;</tt>) and supply the --export-marks option on the command
1952 line. fast-import will dump a file which lists every mark and the Git
1953 object SHA-1 that corresponds to it. If the frontend can tie
1954 the marks back to the source repository, it is easy to verify the
1955 accuracy and completeness of the import by comparing each Git
1956 commit to the corresponding source revision.</p></div>
1957 <div class="paragraph"><p>Coming from a system such as Perforce or Subversion this should be
1958 quite simple, as the fast-import mark can also be the Perforce changeset
1959 number or the Subversion revision number.</p></div>
1960 <h3 id="_freely_skip_around_branches">Freely Skip Around Branches</h3><div style="clear:left"></div>
1961 <div class="paragraph"><p>Don&#8217;t bother trying to optimize the frontend to stick to one branch
1962 at a time during an import. Although doing so might be slightly
1963 faster for fast-import, it tends to increase the complexity of the frontend
1964 code considerably.</p></div>
1965 <div class="paragraph"><p>The branch LRU builtin to fast-import tends to behave very well, and the
1966 cost of activating an inactive branch is so low that bouncing around
1967 between branches has virtually no impact on import performance.</p></div>
1968 <h3 id="_handling_renames">Handling Renames</h3><div style="clear:left"></div>
1969 <div class="paragraph"><p>When importing a renamed file or directory, simply delete the old
1970 name(s) and modify the new name(s) during the corresponding commit.
1971 Git performs rename detection after-the-fact, rather than explicitly
1972 during a commit.</p></div>
1973 <h3 id="_use_tag_fixup_branches">Use Tag Fixup Branches</h3><div style="clear:left"></div>
1974 <div class="paragraph"><p>Some other SCM systems let the user create a tag from multiple
1975 files which are not from the same commit/changeset. Or to create
1976 tags which are a subset of the files available in the repository.</p></div>
1977 <div class="paragraph"><p>Importing these tags as-is in Git is impossible without making at
1978 least one commit which &#8220;fixes up&#8221; the files to match the content
1979 of the tag. Use fast-import&#8217;s <tt>reset</tt> command to reset a dummy branch
1980 outside of your normal branch space to the base commit for the tag,
1981 then commit one or more file fixup commits, and finally tag the
1982 dummy branch.</p></div>
1983 <div class="paragraph"><p>For example since all normal branches are stored under <tt>refs/heads/</tt>
1984 name the tag fixup branch <tt>TAG_FIXUP</tt>. This way it is impossible for
1985 the fixup branch used by the importer to have namespace conflicts
1986 with real branches imported from the source (the name <tt>TAG_FIXUP</tt>
1987 is not <tt>refs/heads/TAG_FIXUP</tt>).</p></div>
1988 <div class="paragraph"><p>When committing fixups, consider using <tt>merge</tt> to connect the
1989 commit(s) which are supplying file revisions to the fixup branch.
1990 Doing so will allow tools such as <em>git blame</em> to track
1991 through the real commit history and properly annotate the source
1992 files.</p></div>
1993 <div class="paragraph"><p>After fast-import terminates the frontend will need to do <tt>rm .git/TAG_FIXUP</tt>
1994 to remove the dummy branch.</p></div>
1995 <h3 id="_import_now_repack_later">Import Now, Repack Later</h3><div style="clear:left"></div>
1996 <div class="paragraph"><p>As soon as fast-import completes the Git repository is completely valid
1997 and ready for use. Typically this takes only a very short time,
1998 even for considerably large projects (100,000+ commits).</p></div>
1999 <div class="paragraph"><p>However repacking the repository is necessary to improve data
2000 locality and access performance. It can also take hours on extremely
2001 large projects (especially if -f and a large --window parameter is
2002 used). Since repacking is safe to run alongside readers and writers,
2003 run the repack in the background and let it finish when it finishes.
2004 There is no reason to wait to explore your new Git project!</p></div>
2005 <div class="paragraph"><p>If you choose to wait for the repack, don&#8217;t try to run benchmarks
2006 or performance tests until repacking is completed. fast-import outputs
2007 suboptimal packfiles that are simply never seen in real use
2008 situations.</p></div>
2009 <h3 id="_repacking_historical_data">Repacking Historical Data</h3><div style="clear:left"></div>
2010 <div class="paragraph"><p>If you are repacking very old imported data (e.g. older than the
2011 last year), consider expending some extra CPU time and supplying
2012 --window=50 (or higher) when you run <em>git repack</em>.
2013 This will take longer, but will also produce a smaller packfile.
2014 You only need to expend the effort once, and everyone using your
2015 project will benefit from the smaller repository.</p></div>
2016 <h3 id="_include_some_progress_messages">Include Some Progress Messages</h3><div style="clear:left"></div>
2017 <div class="paragraph"><p>Every once in a while have your frontend emit a <tt>progress</tt> message
2018 to fast-import. The contents of the messages are entirely free-form,
2019 so one suggestion would be to output the current month and year
2020 each time the current commit date moves into the next month.
2021 Your users will feel better knowing how much of the data stream
2022 has been processed.</p></div>
2023 </div>
2024 <h2 id="_packfile_optimization">Packfile Optimization</h2>
2025 <div class="sectionbody">
2026 <div class="paragraph"><p>When packing a blob fast-import always attempts to deltify against the last
2027 blob written. Unless specifically arranged for by the frontend,
2028 this will probably not be a prior version of the same file, so the
2029 generated delta will not be the smallest possible. The resulting
2030 packfile will be compressed, but will not be optimal.</p></div>
2031 <div class="paragraph"><p>Frontends which have efficient access to all revisions of a
2032 single file (for example reading an RCS/CVS ,v file) can choose
2033 to supply all revisions of that file as a sequence of consecutive
2034 <tt>blob</tt> commands. This allows fast-import to deltify the different file
2035 revisions against each other, saving space in the final packfile.
2036 Marks can be used to later identify individual file revisions during
2037 a sequence of <tt>commit</tt> commands.</p></div>
2038 <div class="paragraph"><p>The packfile(s) created by fast-import do not encourage good disk access
2039 patterns. This is caused by fast-import writing the data in the order
2040 it is received on standard input, while Git typically organizes
2041 data within packfiles to make the most recent (current tip) data
2042 appear before historical data. Git also clusters commits together,
2043 speeding up revision traversal through better cache locality.</p></div>
2044 <div class="paragraph"><p>For this reason it is strongly recommended that users repack the
2045 repository with <tt>git repack -a -d</tt> after fast-import completes, allowing
2046 Git to reorganize the packfiles for faster data access. If blob
2047 deltas are suboptimal (see above) then also adding the <tt>-f</tt> option
2048 to force recomputation of all deltas can significantly reduce the
2049 final packfile size (30-50% smaller can be quite typical).</p></div>
2050 </div>
2051 <h2 id="_memory_utilization">Memory Utilization</h2>
2052 <div class="sectionbody">
2053 <div class="paragraph"><p>There are a number of factors which affect how much memory fast-import
2054 requires to perform an import. Like critical sections of core
2055 Git, fast-import uses its own memory allocators to amortize any overheads
2056 associated with malloc. In practice fast-import tends to amortize any
2057 malloc overheads to 0, due to its use of large block allocations.</p></div>
2058 <h3 id="_per_object">per object</h3><div style="clear:left"></div>
2059 <div class="paragraph"><p>fast-import maintains an in-memory structure for every object written in
2060 this execution. On a 32 bit system the structure is 32 bytes,
2061 on a 64 bit system the structure is 40 bytes (due to the larger
2062 pointer sizes). Objects in the table are not deallocated until
2063 fast-import terminates. Importing 2 million objects on a 32 bit system
2064 will require approximately 64 MiB of memory.</p></div>
2065 <div class="paragraph"><p>The object table is actually a hashtable keyed on the object name
2066 (the unique SHA-1). This storage configuration allows fast-import to reuse
2067 an existing or already written object and avoid writing duplicates
2068 to the output packfile. Duplicate blobs are surprisingly common
2069 in an import, typically due to branch merges in the source.</p></div>
2070 <h3 id="_per_mark">per mark</h3><div style="clear:left"></div>
2071 <div class="paragraph"><p>Marks are stored in a sparse array, using 1 pointer (4 bytes or 8
2072 bytes, depending on pointer size) per mark. Although the array
2073 is sparse, frontends are still strongly encouraged to use marks
2074 between 1 and n, where n is the total number of marks required for
2075 this import.</p></div>
2076 <h3 id="_per_branch">per branch</h3><div style="clear:left"></div>
2077 <div class="paragraph"><p>Branches are classified as active and inactive. The memory usage
2078 of the two classes is significantly different.</p></div>
2079 <div class="paragraph"><p>Inactive branches are stored in a structure which uses 96 or 120
2080 bytes (32 bit or 64 bit systems, respectively), plus the length of
2081 the branch name (typically under 200 bytes), per branch. fast-import will
2082 easily handle as many as 10,000 inactive branches in under 2 MiB
2083 of memory.</p></div>
2084 <div class="paragraph"><p>Active branches have the same overhead as inactive branches, but
2085 also contain copies of every tree that has been recently modified on
2086 that branch. If subtree <tt>include</tt> has not been modified since the
2087 branch became active, its contents will not be loaded into memory,
2088 but if subtree <tt>src</tt> has been modified by a commit since the branch
2089 became active, then its contents will be loaded in memory.</p></div>
2090 <div class="paragraph"><p>As active branches store metadata about the files contained on that
2091 branch, their in-memory storage size can grow to a considerable size
2092 (see below).</p></div>
2093 <div class="paragraph"><p>fast-import automatically moves active branches to inactive status based on
2094 a simple least-recently-used algorithm. The LRU chain is updated on
2095 each <tt>commit</tt> command. The maximum number of active branches can be
2096 increased or decreased on the command line with --active-branches=.</p></div>
2097 <h3 id="_per_active_tree">per active tree</h3><div style="clear:left"></div>
2098 <div class="paragraph"><p>Trees (aka directories) use just 12 bytes of memory on top of the
2099 memory required for their entries (see &#8220;per active file&#8221; below).
2100 The cost of a tree is virtually 0, as its overhead amortizes out
2101 over the individual file entries.</p></div>
2102 <h3 id="_per_active_file_entry">per active file entry</h3><div style="clear:left"></div>
2103 <div class="paragraph"><p>Files (and pointers to subtrees) within active trees require 52 or 64
2104 bytes (32/64 bit platforms) per entry. To conserve space, file and
2105 tree names are pooled in a common string table, allowing the filename
2106 &#8220;Makefile&#8221; to use just 16 bytes (after including the string header
2107 overhead) no matter how many times it occurs within the project.</p></div>
2108 <div class="paragraph"><p>The active branch LRU, when coupled with the filename string pool
2109 and lazy loading of subtrees, allows fast-import to efficiently import
2110 projects with 2,000+ branches and 45,114+ files in a very limited
2111 memory footprint (less than 2.7 MiB per active branch).</p></div>
2112 </div>
2113 <h2 id="_signals">Signals</h2>
2114 <div class="sectionbody">
2115 <div class="paragraph"><p>Sending <strong>SIGUSR1</strong> to the <em>git fast-import</em> process ends the current
2116 packfile early, simulating a <tt>checkpoint</tt> command. The impatient
2117 operator can use this facility to peek at the objects and refs from an
2118 import in progress, at the cost of some added running time and worse
2119 compression.</p></div>
2120 </div>
2121 <h2 id="_git">GIT</h2>
2122 <div class="sectionbody">
2123 <div class="paragraph"><p>Part of the <a href="git.html">git(1)</a> suite</p></div>
2124 </div>
2125 </div>
2126 <div id="footnotes"><hr /></div>
2127 <div id="footer">
2128 <div id="footer-text">
2129 Last updated 2011-09-21 23:01:14 PDT
2130 </div>
2131 </div>
2132 </body>
2133 </html>