1 <?xml version=
"1.0" encoding=
"UTF-8"?>
2 <!DOCTYPE html PUBLIC
"-//W3C//DTD XHTML 1.1//EN"
3 "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
4 <html xmlns=
"http://www.w3.org/1999/xhtml" xml:
lang=
"en">
6 <meta http-equiv=
"Content-Type" content=
"application/xhtml+xml; charset=UTF-8" />
7 <meta name=
"generator" content=
"AsciiDoc 10.2.0" />
8 <title>git-fast-import(
1)
</title>
9 <style type=
"text/css">
10 /* Shared CSS for AsciiDoc xhtml11 and html5 backends */
14 font-family: Georgia,serif;
18 h1, h2, h3, h4, h5, h6,
19 div.title, caption.title,
20 thead, p.table.header,
22 #author, #revnumber, #revdate, #revremark,
24 font-family: Arial,Helvetica,sans-serif;
28 margin:
1em
5%
1em
5%;
33 text-decoration: underline;
49 h1, h2, h3, h4, h5, h6 {
57 border-bottom:
2px solid silver;
77 border:
1px solid silver;
88 ul
> li { color: #aaa; }
89 ul
> li
> * { color: black; }
91 .monospaced, code, pre {
92 font-family:
"Courier New", Courier, monospace;
99 white-space: pre-wrap;
109 #revnumber, #revdate, #revremark {
114 border-top:
2px solid silver;
120 padding-bottom:
0.5em;
124 padding-bottom:
0.5em;
129 margin-bottom:
1.5em;
131 div.imageblock, div.exampleblock, div.verseblock,
132 div.quoteblock, div.literalblock, div.listingblock, div.sidebarblock,
133 div.admonitionblock {
135 margin-bottom:
1.5em;
137 div.admonitionblock {
139 margin-bottom:
2.0em;
144 div.content { /* Block element content. */
148 /* Block element titles. */
149 div.title, caption.title {
154 margin-bottom:
0.5em;
160 td div.title:first-child {
163 div.content div.title:first-child {
166 div.content + div.title {
170 div.sidebarblock
> div.content {
172 border:
1px solid #dddddd;
173 border-left:
4px solid #f0f0f0;
177 div.listingblock
> div.content {
178 border:
1px solid #dddddd;
179 border-left:
5px solid #f0f0f0;
184 div.quoteblock, div.verseblock {
188 border-left:
5px solid #f0f0f0;
192 div.quoteblock
> div.attribution {
197 div.verseblock
> pre.content {
198 font-family: inherit;
201 div.verseblock
> div.attribution {
205 /* DEPRECATED: Pre version
8.2.7 verse style literal block. */
206 div.verseblock + div.attribution {
210 div.admonitionblock .icon {
214 text-decoration: underline;
216 padding-right:
0.5em;
218 div.admonitionblock td.content {
220 border-left:
3px solid #dddddd;
223 div.exampleblock
> div.content {
224 border-left:
3px solid #dddddd;
228 div.imageblock div.content { padding-left:
0; }
229 span.image img { border-style: none; vertical-align: text-bottom; }
230 a.image:visited { color: white; }
234 margin-bottom:
0.8em;
247 list-style-position: outside;
250 list-style-type: decimal;
253 list-style-type: lower-alpha;
256 list-style-type: upper-alpha;
259 list-style-type: lower-roman;
262 list-style-type: upper-roman;
265 div.compact ul, div.compact ol,
266 div.compact p, div.compact p,
267 div.compact div, div.compact div {
269 margin-bottom:
0.1em;
281 margin-bottom:
0.8em;
284 padding-bottom:
15px;
286 dt.hdlist1.strong, td.hdlist1.strong {
292 padding-right:
0.8em;
298 div.hdlist.compact tr {
307 .footnote, .footnoteref {
311 span.footnote, span.footnoteref {
312 vertical-align: super;
316 margin:
20px
0 20px
0;
320 #footnotes div.footnote {
326 border-top:
1px solid silver;
335 padding-right:
0.5em;
336 padding-bottom:
0.3em;
344 #footer-badges { display: none; }
348 margin-bottom:
2.5em;
356 margin-bottom:
0.1em;
359 div.toclevel0, div.toclevel1, div.toclevel2, div.toclevel3, div.toclevel4 {
376 span.aqua { color: aqua; }
377 span.black { color: black; }
378 span.blue { color: blue; }
379 span.fuchsia { color: fuchsia; }
380 span.gray { color: gray; }
381 span.green { color: green; }
382 span.lime { color: lime; }
383 span.maroon { color: maroon; }
384 span.navy { color: navy; }
385 span.olive { color: olive; }
386 span.purple { color: purple; }
387 span.red { color: red; }
388 span.silver { color: silver; }
389 span.teal { color: teal; }
390 span.white { color: white; }
391 span.yellow { color: yellow; }
393 span.aqua-background { background: aqua; }
394 span.black-background { background: black; }
395 span.blue-background { background: blue; }
396 span.fuchsia-background { background: fuchsia; }
397 span.gray-background { background: gray; }
398 span.green-background { background: green; }
399 span.lime-background { background: lime; }
400 span.maroon-background { background: maroon; }
401 span.navy-background { background: navy; }
402 span.olive-background { background: olive; }
403 span.purple-background { background: purple; }
404 span.red-background { background: red; }
405 span.silver-background { background: silver; }
406 span.teal-background { background: teal; }
407 span.white-background { background: white; }
408 span.yellow-background { background: yellow; }
410 span.big { font-size:
2em; }
411 span.small { font-size:
0.6em; }
413 span.underline { text-decoration: underline; }
414 span.overline { text-decoration: overline; }
415 span.line-through { text-decoration: line-through; }
417 div.unbreakable { page-break-inside: avoid; }
427 margin-bottom:
1.5em;
429 div.tableblock
> table {
430 border:
3px solid #
527bbd;
432 thead, p.table.header {
439 /* Because the table frame attribute is overridden by CSS in most browsers. */
440 div.tableblock
> table[
frame=
"void"] {
443 div.tableblock
> table[
frame=
"hsides"] {
444 border-left-style: none;
445 border-right-style: none;
447 div.tableblock
> table[
frame=
"vsides"] {
448 border-top-style: none;
449 border-bottom-style: none;
460 margin-bottom:
1.5em;
462 thead, p.tableblock.header {
473 border-color: #
527bbd;
474 border-collapse: collapse;
476 th.tableblock, td.tableblock {
480 border-color: #
527bbd;
483 table.tableblock.frame-topbot {
484 border-left-style: hidden;
485 border-right-style: hidden;
487 table.tableblock.frame-sides {
488 border-top-style: hidden;
489 border-bottom-style: hidden;
491 table.tableblock.frame-none {
492 border-style: hidden;
495 th.tableblock.halign-left, td.tableblock.halign-left {
498 th.tableblock.halign-center, td.tableblock.halign-center {
501 th.tableblock.halign-right, td.tableblock.halign-right {
505 th.tableblock.valign-top, td.tableblock.valign-top {
508 th.tableblock.valign-middle, td.tableblock.valign-middle {
509 vertical-align: middle;
511 th.tableblock.valign-bottom, td.tableblock.valign-bottom {
512 vertical-align: bottom;
523 padding-bottom:
0.5em;
524 border-top:
2px solid silver;
525 border-bottom:
2px solid silver;
530 body.manpage div.sectionbody {
535 body.manpage div#toc { display: none; }
540 <script type=
"text/javascript">
542 var asciidoc = { // Namespace.
544 /////////////////////////////////////////////////////////////////////
545 // Table Of Contents generator
546 /////////////////////////////////////////////////////////////////////
548 /* Author: Mihai Bazon, September
2002
549 * http://students.infoiasi.ro/~mishoo
551 * Table Of Content generator
554 * Feel free to use this script under the terms of the GNU General Public
555 * License, as long as you do not remove or alter this notice.
558 /* modified by Troy D. Hanson, September
2006. License: GPL */
559 /* modified by Stuart Rackham,
2006,
2009. License: GPL */
562 toc: function (toclevels) {
564 function getText(el) {
566 for (var i = el.firstChild; i != null; i = i.nextSibling) {
567 if (i.nodeType ==
3 /* Node.TEXT_NODE */) // IE doesn't speak constants.
569 else if (i.firstChild != null)
575 function TocEntry(el, text, toclevel) {
578 this.toclevel = toclevel;
581 function tocEntries(el, toclevels) {
582 var result = new Array;
583 var re = new RegExp('[hH]([
1-'+(toclevels+
1)+'])');
584 // Function that scans the DOM tree for header elements (the DOM2
585 // nodeIterator API would be a better technique but not supported by all
587 var iterate = function (el) {
588 for (var i = el.firstChild; i != null; i = i.nextSibling) {
589 if (i.nodeType ==
1 /* Node.ELEMENT_NODE */) {
590 var mo = re.exec(i.tagName);
591 if (mo && (i.getAttribute(
"class") || i.getAttribute(
"className")) !=
"float") {
592 result[result.length] = new TocEntry(i, getText(i), mo[
1]-
1);
602 var toc = document.getElementById(
"toc");
607 // Delete existing TOC entries in case we're reloading the TOC.
608 var tocEntriesToRemove = [];
610 for (i =
0; i < toc.childNodes.length; i++) {
611 var entry = toc.childNodes[i];
612 if (entry.nodeName.toLowerCase() == 'div'
613 && entry.getAttribute(
"class")
614 && entry.getAttribute(
"class").match(/^toclevel/))
615 tocEntriesToRemove.push(entry);
617 for (i =
0; i < tocEntriesToRemove.length; i++) {
618 toc.removeChild(tocEntriesToRemove[i]);
621 // Rebuild TOC entries.
622 var entries = tocEntries(document.getElementById(
"content"), toclevels);
623 for (var i =
0; i < entries.length; ++i) {
624 var entry = entries[i];
625 if (entry.element.id ==
"")
626 entry.element.id =
"_toc_" + i;
627 var a = document.createElement(
"a");
628 a.href =
"#" + entry.element.id;
629 a.appendChild(document.createTextNode(entry.text));
630 var div = document.createElement(
"div");
632 div.className =
"toclevel" + entry.toclevel;
633 toc.appendChild(div);
635 if (entries.length ==
0)
636 toc.parentNode.removeChild(toc);
640 /////////////////////////////////////////////////////////////////////
641 // Footnotes generator
642 /////////////////////////////////////////////////////////////////////
644 /* Based on footnote generation code from:
645 * http://www.brandspankingnew.net/archive/
2005/
07/format_footnote.html
648 footnotes: function () {
649 // Delete existing footnote entries in case we're reloading the footnodes.
651 var noteholder = document.getElementById(
"footnotes");
655 var entriesToRemove = [];
656 for (i =
0; i < noteholder.childNodes.length; i++) {
657 var entry = noteholder.childNodes[i];
658 if (entry.nodeName.toLowerCase() == 'div' && entry.getAttribute(
"class") ==
"footnote")
659 entriesToRemove.push(entry);
661 for (i =
0; i < entriesToRemove.length; i++) {
662 noteholder.removeChild(entriesToRemove[i]);
665 // Rebuild footnote entries.
666 var cont = document.getElementById(
"content");
667 var spans = cont.getElementsByTagName(
"span");
670 for (i=
0; i
<spans.length; i++) {
671 if (spans[i].className ==
"footnote") {
673 var note = spans[i].getAttribute(
"data-note");
675 // Use [\s\S] in place of . so multi-line matches work.
676 // Because JavaScript has no s (dotall) regex flag.
677 note = spans[i].innerHTML.match(/\s*\[([\s\S]*)]\s*/)[
1];
679 "[<a id='_footnoteref_" + n +
"' href='#_footnote_" + n +
680 "' title='View footnote' class='footnote'>" + n +
"</a>]";
681 spans[i].setAttribute(
"data-note", note);
683 noteholder.innerHTML +=
684 "<div class='footnote' id='_footnote_" + n +
"'>" +
685 "<a href='#_footnoteref_" + n +
"' title='Return to text'>" +
686 n +
"</a>. " + note +
"</div>";
687 var id =spans[i].getAttribute(
"id");
688 if (id != null) refs[
"#"+id] = n;
692 noteholder.parentNode.removeChild(noteholder);
694 // Process footnoterefs.
695 for (i=
0; i
<spans.length; i++) {
696 if (spans[i].className ==
"footnoteref") {
697 var href = spans[i].getElementsByTagName(
"a")[
0].getAttribute(
"href");
698 href = href.match(/#.*/)[
0]; // Because IE return full URL.
701 "[<a href='#_footnote_" + n +
702 "' title='View footnote' class='footnote'>" + n +
"</a>]";
708 install: function(toclevels) {
711 function reinstall() {
712 asciidoc.footnotes();
714 asciidoc.toc(toclevels);
718 function reinstallAndRemoveTimer() {
719 clearInterval(timerId);
723 timerId = setInterval(reinstall,
500);
724 if (document.addEventListener)
725 document.addEventListener(
"DOMContentLoaded", reinstallAndRemoveTimer, false);
727 window.onload = reinstallAndRemoveTimer;
735 <body class=
"manpage">
738 git-fast-import(
1) Manual Page
741 <div class=
"sectionbody">
743 Backend for fast Git data importers
749 <h2 id=
"_synopsis">SYNOPSIS
</h2>
750 <div class=
"sectionbody">
751 <div class=
"verseblock">
752 <pre class=
"content">frontend |
<em>git fast-import
</em> [
<options
>]
</pre>
753 <div class=
"attribution">
758 <h2 id=
"_description">DESCRIPTION
</h2>
759 <div class=
"sectionbody">
760 <div class=
"paragraph"><p>This program is usually not what the end user wants to run directly.
761 Most end users want to use one of the existing frontend programs,
762 which parses a specific type of foreign source and feeds the contents
763 stored there to
<em>git fast-import
</em>.
</p></div>
764 <div class=
"paragraph"><p>fast-import reads a mixed command/data stream from standard input and
765 writes one or more packfiles directly into the current repository.
766 When EOF is received on standard input, fast import writes out
767 updated branch and tag refs, fully updating the current repository
768 with the newly imported data.
</p></div>
769 <div class=
"paragraph"><p>The fast-import backend itself can import into an empty repository (one that
770 has already been initialized by
<em>git init
</em>) or incrementally
771 update an existing populated repository. Whether or not incremental
772 imports are supported from a particular foreign source depends on
773 the frontend program in use.
</p></div>
777 <h2 id=
"_options">OPTIONS
</h2>
778 <div class=
"sectionbody">
779 <div class=
"dlist"><dl>
785 Force updating modified existing branches, even if doing
786 so would cause commits to be lost (as the new commit does
787 not contain the old commit).
795 Disable the output shown by --stats, making fast-import usually
796 be silent when it is successful. However, if the import stream
797 has directives intended to show user output (e.g.
<code>progress
</code>
798 directives), the corresponding messages will still be shown.
806 Display some basic statistics about the objects fast-import has
807 created, the packfiles they were stored into, and the
808 memory used by fast-import during this run. Showing this output
809 is currently the default, but can be disabled with --quiet.
813 --allow-unsafe-features
817 Many command-line options can be provided as part of the
818 fast-import stream itself by using the
<code>feature
</code> or
<code>option
</code>
819 commands. However, some of these options are unsafe (e.g.,
820 allowing fast-import to access the filesystem outside of the
821 repository). These options are disabled by default, but can be
822 allowed by providing this option on the command line. This
823 currently impacts only the
<code>export-marks
</code>,
<code>import-marks
</code>, and
824 <code>import-marks-if-exists
</code> feature commands.
826 <div class=
"literalblock">
827 <div class=
"content">
828 <pre><code>Only enable this option if you trust the program generating the
829 fast-import stream! This option is enabled automatically for
830 remote-helpers that use the `import` capability, as they are
831 already trusted to run their own code.
</code></pre>
836 <h3 id=
"_options_for_frontends">Options for Frontends
</h3>
837 <div class=
"dlist"><dl>
839 --cat-blob-fd=
<fd
>
843 Write responses to
<code>get-mark
</code>,
<code>cat-blob
</code>, and
<code>ls
</code> queries to the
844 file descriptor
<fd
> instead of
<code>stdout
</code>. Allows
<code>progress
</code>
845 output intended for the end-user to be separated from other
850 --date-format=
<fmt
>
854 Specify the type of dates the frontend will supply to
855 fast-import within
<code>author
</code>,
<code>committer
</code> and
<code>tagger
</code> commands.
856 See
“Date Formats
” below for details about which formats
857 are supported, and their syntax.
865 Terminate with error if there is no
<code>done
</code> command at the end of
866 the stream. This option might be useful for detecting errors
867 that cause the frontend to terminate before it has started to
874 <h3 id=
"_locations_of_marks_files">Locations of Marks Files
</h3>
875 <div class=
"dlist"><dl>
877 --export-marks=
<file
>
881 Dumps the internal marks table to
<file
> when complete.
882 Marks are written one per line as
<code>:markid SHA-
1</code>.
883 Frontends can use this file to validate imports after they
884 have been completed, or to save the marks table across
885 incremental runs. As
<file
> is only opened and truncated
886 at checkpoint (or completion) the same path can also be
887 safely given to --import-marks.
891 --import-marks=
<file
>
895 Before processing any input, load the marks specified in
896 <file
>. The input file must exist, must be readable, and
897 must use the same format as produced by --export-marks.
898 Multiple options may be supplied to import more than one
899 set of marks. If a mark is defined to different values,
904 --import-marks-if-exists=
<file
>
908 Like --import-marks but instead of erroring out, silently
909 skips the file if it does not exist.
913 --[no-]relative-marks
917 After specifying --relative-marks the paths specified
918 with --import-marks= and --export-marks= are relative
919 to an internal directory in the current repository.
920 In git-fast-import this means that the paths are relative
921 to the .git/info/fast-import directory. However, other
922 importers may use a different location.
924 <div class=
"paragraph"><p>Relative and non-relative marks may be combined by interweaving
925 --(no-)-relative-marks with the --(import|export)-marks= options.
</p></div>
930 <h3 id=
"_submodule_rewriting">Submodule Rewriting
</h3>
931 <div class=
"dlist"><dl>
933 --rewrite-submodules-from=
<name
>:
<file
>
936 --rewrite-submodules-to=
<name
>:
<file
>
940 Rewrite the object IDs for the submodule specified by
<name
> from the values
941 used in the from
<file
> to those used in the to
<file
>. The from marks should
942 have been created by
<code>git fast-export
</code>, and the to marks should have been
943 created by
<code>git fast-import
</code> when importing that same submodule.
945 <div class=
"paragraph"><p><name
> may be any arbitrary string not containing a colon character, but the
946 same value must be used with both options when specifying corresponding marks.
947 Multiple submodules may be specified with different values for
<name
>. It is an
948 error not to use these options in corresponding pairs.
</p></div>
949 <div class=
"paragraph"><p>These options are primarily useful when converting a repository from one hash
950 algorithm to another; without them, fast-import will fail if it encounters a
951 submodule because it has no way of writing the object ID into the new hash
957 <h3 id=
"_performance_and_compression_tuning">Performance and Compression Tuning
</h3>
958 <div class=
"dlist"><dl>
960 --active-branches=
<n
>
964 Maximum number of branches to maintain active at once.
965 See
“Memory Utilization
” below for details. Default is
5.
969 --big-file-threshold=
<n
>
973 Maximum size of a blob that fast-import will attempt to
974 create a delta for, expressed in bytes. The default is
512m
975 (
512 MiB). Some importers may wish to lower this on systems
976 with constrained memory.
984 Maximum delta depth, for blob and tree deltification.
989 --export-pack-edges=
<file
>
993 After creating a packfile, print a line of data to
994 <file
> listing the filename of the packfile and the last
995 commit on each branch that was written to that packfile.
996 This information may be useful after importing projects
997 whose total object set exceeds the
4 GiB packfile limit,
998 as these commits can be used as edge points during calls
999 to
<em>git pack-objects
</em>.
1002 <dt class=
"hdlist1">
1003 --max-pack-size=
<n
>
1007 Maximum size of each output packfile.
1008 The default is unlimited.
1011 <dt class=
"hdlist1">
1012 fastimport.unpackLimit
1016 See
<a href=
"git-config.html">git-config(
1)
</a>
1024 <h2 id=
"_performance">PERFORMANCE
</h2>
1025 <div class=
"sectionbody">
1026 <div class=
"paragraph"><p>The design of fast-import allows it to import large projects in a minimum
1027 amount of memory usage and processing time. Assuming the frontend
1028 is able to keep up with fast-import and feed it a constant stream of data,
1029 import times for projects holding
10+ years of history and containing
1030 100,
000+ individual commits are generally completed in just
1-
2
1031 hours on quite modest (~$
2,
000 USD) hardware.
</p></div>
1032 <div class=
"paragraph"><p>Most bottlenecks appear to be in foreign source data access (the
1033 source just cannot extract revisions fast enough) or disk IO (fast-import
1034 writes as fast as the disk will take the data). Imports will run
1035 faster if the source data is stored on a different drive than the
1036 destination Git repository (due to less IO contention).
</p></div>
1040 <h2 id=
"_development_cost">DEVELOPMENT COST
</h2>
1041 <div class=
"sectionbody">
1042 <div class=
"paragraph"><p>A typical frontend for fast-import tends to weigh in at approximately
200
1043 lines of Perl/Python/Ruby code. Most developers have been able to
1044 create working importers in just a couple of hours, even though it
1045 is their first exposure to fast-import, and sometimes even to Git. This is
1046 an ideal situation, given that most conversion tools are throw-away
1047 (use once, and never look back).
</p></div>
1051 <h2 id=
"_parallel_operation">PARALLEL OPERATION
</h2>
1052 <div class=
"sectionbody">
1053 <div class=
"paragraph"><p>Like
<em>git push
</em> or
<em>git fetch
</em>, imports handled by fast-import are safe to
1054 run alongside parallel
<code>git repack -a -d
</code> or
<code>git gc
</code> invocations,
1055 or any other Git operation (including
<em>git prune
</em>, as loose objects
1056 are never used by fast-import).
</p></div>
1057 <div class=
"paragraph"><p>fast-import does not lock the branch or tag refs it is actively importing.
1058 After the import, during its ref update phase, fast-import tests each
1059 existing branch ref to verify the update will be a fast-forward
1060 update (the commit stored in the ref is contained in the new
1061 history of the commit to be written). If the update is not a
1062 fast-forward update, fast-import will skip updating that ref and instead
1063 prints a warning message. fast-import will always attempt to update all
1064 branch refs, and does not stop on the first failure.
</p></div>
1065 <div class=
"paragraph"><p>Branch updates can be forced with --force, but it
’s recommended that
1066 this only be used on an otherwise quiet repository. Using --force
1067 is not necessary for an initial import into an empty repository.
</p></div>
1071 <h2 id=
"_technical_discussion">TECHNICAL DISCUSSION
</h2>
1072 <div class=
"sectionbody">
1073 <div class=
"paragraph"><p>fast-import tracks a set of branches in memory. Any branch can be created
1074 or modified at any point during the import process by sending a
1075 <code>commit
</code> command on the input stream. This design allows a frontend
1076 program to process an unlimited number of branches simultaneously,
1077 generating commits in the order they are available from the source
1078 data. It also simplifies the frontend programs considerably.
</p></div>
1079 <div class=
"paragraph"><p>fast-import does not use or alter the current working directory, or any
1080 file within it. (It does however update the current Git repository,
1081 as referenced by
<code>GIT_DIR
</code>.) Therefore an import frontend may use
1082 the working directory for its own purposes, such as extracting file
1083 revisions from the foreign source. This ignorance of the working
1084 directory also allows fast-import to run very quickly, as it does not
1085 need to perform any costly file update operations when switching
1086 between branches.
</p></div>
1090 <h2 id=
"_input_format">INPUT FORMAT
</h2>
1091 <div class=
"sectionbody">
1092 <div class=
"paragraph"><p>With the exception of raw file data (which Git does not interpret)
1093 the fast-import input format is text (ASCII) based. This text based
1094 format simplifies development and debugging of frontend programs,
1095 especially when a higher level language such as Perl, Python or
1096 Ruby is being used.
</p></div>
1097 <div class=
"paragraph"><p>fast-import is very strict about its input. Where we say SP below we mean
1098 <strong>exactly
</strong> one space. Likewise LF means one (and only one) linefeed
1099 and HT one (and only one) horizontal tab.
1100 Supplying additional whitespace characters will cause unexpected
1101 results, such as branch names or file names with leading or trailing
1102 spaces in their name, or early termination of fast-import when it encounters
1103 unexpected input.
</p></div>
1105 <h3 id=
"_stream_comments">Stream Comments
</h3>
1106 <div class=
"paragraph"><p>To aid in debugging frontends fast-import ignores any line that
1107 begins with
<code>#
</code> (ASCII pound/hash) up to and including the line
1108 ending
<code>LF
</code>. A comment line may contain any sequence of bytes
1109 that does not contain an LF and therefore may be used to include
1110 any detailed debugging information that might be specific to the
1111 frontend and useful when inspecting a fast-import data stream.
</p></div>
1114 <h3 id=
"_date_formats">Date Formats
</h3>
1115 <div class=
"paragraph"><p>The following date formats are supported. A frontend should select
1116 the format it will use for this import by passing the format name
1117 in the --date-format=
<fmt
> command-line option.
</p></div>
1118 <div class=
"dlist"><dl>
1119 <dt class=
"hdlist1">
1124 This is the Git native format and is
<code><time
> SP
<offutc
></code>.
1125 It is also fast-import
’s default format, if --date-format was
1128 <div class=
"paragraph"><p>The time of the event is specified by
<code><time
></code> as the number of
1129 seconds since the UNIX epoch (midnight, Jan
1,
1970, UTC) and is
1130 written as an ASCII decimal integer.
</p></div>
1131 <div class=
"paragraph"><p>The local offset is specified by
<code><offutc
></code> as a positive or negative
1132 offset from UTC. For example EST (which is
5 hours behind UTC)
1133 would be expressed in
<code><tz
></code> by
“-
0500” while UTC is
“+
0000”.
1134 The local offset does not affect
<code><time
></code>; it is used only as an
1135 advisement to help formatting routines display the timestamp.
</p></div>
1136 <div class=
"paragraph"><p>If the local offset is not available in the source material, use
1137 “+
0000”, or the most common local offset. For example many
1138 organizations have a CVS repository which has only ever been accessed
1139 by users who are located in the same location and time zone. In this
1140 case a reasonable offset from UTC could be assumed.
</p></div>
1141 <div class=
"paragraph"><p>Unlike the
<code>rfc2822
</code> format, this format is very strict. Any
1142 variation in formatting will cause fast-import to reject the value,
1143 and some sanity checks on the numeric values may also be performed.
</p></div>
1145 <dt class=
"hdlist1">
1146 <code>raw-permissive
</code>
1150 This is the same as
<code>raw
</code> except that no sanity checks on
1151 the numeric epoch and local offset are performed. This can
1152 be useful when trying to filter or import an existing history
1153 with e.g. bogus timezone values.
1156 <dt class=
"hdlist1">
1157 <code>rfc2822
</code>
1161 This is the standard email format as described by RFC
2822.
1163 <div class=
"paragraph"><p>An example value is
“Tue Feb
6 11:
22:
18 2007 -
0500”. The Git
1164 parser is accurate, but a little on the lenient side. It is the
1165 same parser used by
<em>git am
</em> when applying patches
1166 received from email.
</p></div>
1167 <div class=
"paragraph"><p>Some malformed strings may be accepted as valid dates. In some of
1168 these cases Git will still be able to obtain the correct date from
1169 the malformed string. There are also some types of malformed
1170 strings which Git will parse wrong, and yet consider valid.
1171 Seriously malformed strings will be rejected.
</p></div>
1172 <div class=
"paragraph"><p>Unlike the
<code>raw
</code> format above, the time zone/UTC offset information
1173 contained in an RFC
2822 date string is used to adjust the date
1174 value to UTC prior to storage. Therefore it is important that
1175 this information be as accurate as possible.
</p></div>
1176 <div class=
"paragraph"><p>If the source material uses RFC
2822 style dates,
1177 the frontend should let fast-import handle the parsing and conversion
1178 (rather than attempting to do it itself) as the Git parser has
1179 been well tested in the wild.
</p></div>
1180 <div class=
"paragraph"><p>Frontends should prefer the
<code>raw
</code> format if the source material
1181 already uses UNIX-epoch format, can be coaxed to give dates in that
1182 format, or its format is easily convertible to it, as there is no
1183 ambiguity in parsing.
</p></div>
1185 <dt class=
"hdlist1">
1190 Always use the current time and time zone. The literal
1191 <code>now
</code> must always be supplied for
<code><when
></code>.
1193 <div class=
"paragraph"><p>This is a toy format. The current time and time zone of this system
1194 is always copied into the identity string at the time it is being
1195 created by fast-import. There is no way to specify a different time or
1196 time zone.
</p></div>
1197 <div class=
"paragraph"><p>This particular format is supplied as it
’s short to implement and
1198 may be useful to a process that wants to create a new commit
1199 right now, without needing to use a working directory or
1200 <em>git update-index
</em>.
</p></div>
1201 <div class=
"paragraph"><p>If separate
<code>author
</code> and
<code>committer
</code> commands are used in a
<code>commit
</code>
1202 the timestamps may not match, as the system clock will be polled
1203 twice (once for each command). The only way to ensure that both
1204 author and committer identity information has the same timestamp
1205 is to omit
<code>author
</code> (thus copying from
<code>committer
</code>) or to use a
1206 date format other than
<code>now
</code>.
</p></div>
1211 <h3 id=
"_commands">Commands
</h3>
1212 <div class=
"paragraph"><p>fast-import accepts several commands to update the current repository
1213 and control the current import process. More detailed discussion
1214 (with examples) of each command follows later.
</p></div>
1215 <div class=
"dlist"><dl>
1216 <dt class=
"hdlist1">
1221 Creates a new branch or updates an existing branch by
1222 creating a new commit and updating the branch to point at
1223 the newly created commit.
1226 <dt class=
"hdlist1">
1231 Creates an annotated tag object from an existing commit or
1232 branch. Lightweight tags are not supported by this command,
1233 as they are not recommended for recording meaningful points
1237 <dt class=
"hdlist1">
1242 Reset an existing branch (or a new branch) to a specific
1243 revision. This command must be used to change a branch to
1244 a specific revision without making a commit on it.
1247 <dt class=
"hdlist1">
1252 Convert raw file data into a blob, for future use in a
1253 <code>commit
</code> command. This command is optional and is not
1254 needed to perform an import.
1257 <dt class=
"hdlist1">
1262 Record that a mark refers to a given object without first
1263 creating any new object. Using --import-marks and referring
1264 to missing marks will cause fast-import to fail, so aliases
1265 can provide a way to set otherwise pruned commits to a valid
1266 value (e.g. the nearest non-pruned ancestor).
1269 <dt class=
"hdlist1">
1270 <code>checkpoint
</code>
1274 Forces fast-import to close the current packfile, generate its
1275 unique SHA-
1 checksum and index, and start a new packfile.
1276 This command is optional and is not needed to perform
1280 <dt class=
"hdlist1">
1281 <code>progress
</code>
1285 Causes fast-import to echo the entire line to its own
1286 standard output. This command is optional and is not needed
1287 to perform an import.
1290 <dt class=
"hdlist1">
1295 Marks the end of the stream. This command is optional
1296 unless the
<code>done
</code> feature was requested using the
1297 <code>--done
</code> command-line option or
<code>feature done
</code> command.
1300 <dt class=
"hdlist1">
1301 <code>get-mark
</code>
1305 Causes fast-import to print the SHA-
1 corresponding to a mark
1306 to the file descriptor set with
<code>--cat-blob-fd
</code>, or
<code>stdout
</code> if
1310 <dt class=
"hdlist1">
1311 <code>cat-blob
</code>
1315 Causes fast-import to print a blob in
<em>cat-file --batch
</em>
1316 format to the file descriptor set with
<code>--cat-blob-fd
</code> or
1317 <code>stdout
</code> if unspecified.
1320 <dt class=
"hdlist1">
1325 Causes fast-import to print a line describing a directory
1326 entry in
<em>ls-tree
</em> format to the file descriptor set with
1327 <code>--cat-blob-fd
</code> or
<code>stdout
</code> if unspecified.
1330 <dt class=
"hdlist1">
1331 <code>feature
</code>
1335 Enable the specified feature. This requires that fast-import
1336 supports the specified feature, and aborts if it does not.
1339 <dt class=
"hdlist1">
1344 Specify any of the options listed under OPTIONS that do not
1345 change stream semantic to suit the frontend
’s needs. This
1346 command is optional and is not needed to perform an import.
1352 <h3 id=
"_code_commit_code"><code>commit
</code></h3>
1353 <div class=
"paragraph"><p>Create or update a branch with a new commit, recording one logical
1354 change to the project.
</p></div>
1355 <div class=
"literalblock">
1356 <div class=
"content">
1357 <pre><code> 'commit' SP
<ref
> LF
1360 ('author' (SP
<name
>)? SP LT
<email
> GT SP
<when
> LF)?
1361 'committer' (SP
<name
>)? SP LT
<email
> GT SP
<when
> LF
1362 ('encoding' SP
<encoding
>)?
1364 ('from' SP
<commit-ish
> LF)?
1365 ('merge' SP
<commit-ish
> LF)*
1366 (filemodify | filedelete | filecopy | filerename | filedeleteall | notemodify)*
1369 <div class=
"paragraph"><p>where
<code><ref
></code> is the name of the branch to make the commit on.
1370 Typically branch names are prefixed with
<code>refs/heads/
</code> in
1371 Git, so importing the CVS branch symbol
<code>RELENG-
1_0
</code> would use
1372 <code>refs/heads/RELENG-
1_0
</code> for the value of
<code><ref
></code>. The value of
1373 <code><ref
></code> must be a valid refname in Git. As
<code>LF
</code> is not valid in
1374 a Git refname, no quoting or escaping syntax is supported here.
</p></div>
1375 <div class=
"paragraph"><p>A
<code>mark
</code> command may optionally appear, requesting fast-import to save a
1376 reference to the newly created commit for future use by the frontend
1377 (see below for format). It is very common for frontends to mark
1378 every commit they create, thereby allowing future branch creation
1379 from any imported commit.
</p></div>
1380 <div class=
"paragraph"><p>The
<code>data
</code> command following
<code>committer
</code> must supply the commit
1381 message (see below for
<code>data
</code> command syntax). To import an empty
1382 commit message use a
0 length data. Commit messages are free-form
1383 and are not interpreted by Git. Currently they must be encoded in
1384 UTF-
8, as fast-import does not permit other encodings to be specified.
</p></div>
1385 <div class=
"paragraph"><p>Zero or more
<code>filemodify
</code>,
<code>filedelete
</code>,
<code>filecopy
</code>,
<code>filerename
</code>,
1386 <code>filedeleteall
</code> and
<code>notemodify
</code> commands
1387 may be included to update the contents of the branch prior to
1388 creating the commit. These commands may be supplied in any order.
1389 However it is recommended that a
<code>filedeleteall
</code> command precede
1390 all
<code>filemodify
</code>,
<code>filecopy
</code>,
<code>filerename
</code> and
<code>notemodify
</code> commands in
1391 the same commit, as
<code>filedeleteall
</code> wipes the branch clean (see below).
</p></div>
1392 <div class=
"paragraph"><p>The
<code>LF
</code> after the command is optional (it used to be required). Note
1393 that for reasons of backward compatibility, if the commit ends with a
1394 <code>data
</code> command (i.e. it has no
<code>from
</code>,
<code>merge
</code>,
<code>filemodify
</code>,
1395 <code>filedelete
</code>,
<code>filecopy
</code>,
<code>filerename
</code>,
<code>filedeleteall
</code> or
1396 <code>notemodify
</code> commands) then two
<code>LF
</code> commands may appear at the end of
1397 the command instead of just one.
</p></div>
1399 <h4 id=
"_code_author_code"><code>author
</code></h4>
1400 <div class=
"paragraph"><p>An
<code>author
</code> command may optionally appear, if the author information
1401 might differ from the committer information. If
<code>author
</code> is omitted
1402 then fast-import will automatically use the committer
’s information for
1403 the author portion of the commit. See below for a description of
1404 the fields in
<code>author
</code>, as they are identical to
<code>committer
</code>.
</p></div>
1407 <h4 id=
"_code_committer_code"><code>committer
</code></h4>
1408 <div class=
"paragraph"><p>The
<code>committer
</code> command indicates who made this commit, and when
1409 they made it.
</p></div>
1410 <div class=
"paragraph"><p>Here
<code><name
></code> is the person
’s display name (for example
1411 “Com M Itter
”) and
<code><email
></code> is the person
’s email address
1412 (
“cm@example.com
”).
<code>LT
</code> and
<code>GT
</code> are the literal less-than (\x3c)
1413 and greater-than (\x3e) symbols. These are required to delimit
1414 the email address from the other fields in the line. Note that
1415 <code><name
></code> and
<code><email
></code> are free-form and may contain any sequence
1416 of bytes, except
<code>LT
</code>,
<code>GT
</code> and
<code>LF
</code>.
<code><name
></code> is typically UTF-
8 encoded.
</p></div>
1417 <div class=
"paragraph"><p>The time of the change is specified by
<code><when
></code> using the date format
1418 that was selected by the --date-format=
<fmt
> command-line option.
1419 See
“Date Formats
” above for the set of supported formats, and
1420 their syntax.
</p></div>
1423 <h4 id=
"_code_encoding_code"><code>encoding
</code></h4>
1424 <div class=
"paragraph"><p>The optional
<code>encoding
</code> command indicates the encoding of the commit
1425 message. Most commits are UTF-
8 and the encoding is omitted, but this
1426 allows importing commit messages into git without first reencoding them.
</p></div>
1429 <h4 id=
"_code_from_code"><code>from
</code></h4>
1430 <div class=
"paragraph"><p>The
<code>from
</code> command is used to specify the commit to initialize
1431 this branch from. This revision will be the first ancestor of the
1432 new commit. The state of the tree built at this commit will begin
1433 with the state at the
<code>from
</code> commit, and be altered by the content
1434 modifications in this commit.
</p></div>
1435 <div class=
"paragraph"><p>Omitting the
<code>from
</code> command in the first commit of a new branch
1436 will cause fast-import to create that commit with no ancestor. This
1437 tends to be desired only for the initial commit of a project.
1438 If the frontend creates all files from scratch when making a new
1439 branch, a
<code>merge
</code> command may be used instead of
<code>from
</code> to start
1440 the commit with an empty tree.
1441 Omitting the
<code>from
</code> command on existing branches is usually desired,
1442 as the current commit on that branch is automatically assumed to
1443 be the first ancestor of the new commit.
</p></div>
1444 <div class=
"paragraph"><p>As
<code>LF
</code> is not valid in a Git refname or SHA-
1 expression, no
1445 quoting or escaping syntax is supported within
<code><commit-ish
></code>.
</p></div>
1446 <div class=
"paragraph"><p>Here
<code><commit-ish
></code> is any of the following:
</p></div>
1447 <div class=
"ulist"><ul>
1450 The name of an existing branch already in fast-import
’s internal branch
1451 table. If fast-import doesn
’t know the name, it
’s treated as a SHA-
1
1457 A mark reference,
<code>:
<idnum
></code>, where
<code><idnum
></code> is the mark number.
1459 <div class=
"paragraph"><p>The reason fast-import uses
<code>:
</code> to denote a mark reference is this character
1460 is not legal in a Git branch name. The leading
<code>:
</code> makes it easy
1461 to distinguish between the mark
42 (
<code>:
42</code>) and the branch
42 (
<code>42</code>
1462 or
<code>refs/heads/
42</code>), or an abbreviated SHA-
1 which happened to
1463 consist only of base-
10 digits.
</p></div>
1464 <div class=
"paragraph"><p>Marks must be declared (via
<code>mark
</code>) before they can be used.
</p></div>
1468 A complete
40 byte or abbreviated commit SHA-
1 in hex.
1473 Any valid Git SHA-
1 expression that resolves to a commit. See
1474 “SPECIFYING REVISIONS
” in
<a href=
"gitrevisions.html">gitrevisions(
7)
</a> for details.
1479 The special null SHA-
1 (
40 zeros) specifies that the branch is to be
1484 <div class=
"paragraph"><p>The special case of restarting an incremental import from the
1485 current branch value should be written as:
</p></div>
1486 <div class=
"listingblock">
1487 <div class=
"content">
1488 <pre><code> from refs/heads/branch^
0</code></pre>
1490 <div class=
"paragraph"><p>The
<code>^
0</code> suffix is necessary as fast-import does not permit a branch to
1491 start from itself, and the branch is created in memory before the
1492 <code>from
</code> command is even read from the input. Adding
<code>^
0</code> will force
1493 fast-import to resolve the commit through Git
’s revision parsing library,
1494 rather than its internal branch table, thereby loading in the
1495 existing value of the branch.
</p></div>
1498 <h4 id=
"_code_merge_code"><code>merge
</code></h4>
1499 <div class=
"paragraph"><p>Includes one additional ancestor commit. The additional ancestry
1500 link does not change the way the tree state is built at this commit.
1501 If the
<code>from
</code> command is
1502 omitted when creating a new branch, the first
<code>merge
</code> commit will be
1503 the first ancestor of the current commit, and the branch will start
1504 out with no files. An unlimited number of
<code>merge
</code> commands per
1505 commit are permitted by fast-import, thereby establishing an n-way merge.
</p></div>
1506 <div class=
"paragraph"><p>Here
<code><commit-ish
></code> is any of the commit specification expressions
1507 also accepted by
<code>from
</code> (see above).
</p></div>
1510 <h4 id=
"_code_filemodify_code"><code>filemodify
</code></h4>
1511 <div class=
"paragraph"><p>Included in a
<code>commit
</code> command to add a new file or change the
1512 content of an existing file. This command has two different means
1513 of specifying the content of the file.
</p></div>
1514 <div class=
"dlist"><dl>
1515 <dt class=
"hdlist1">
1516 External data format
1520 The data content for the file was already supplied by a prior
1521 <code>blob
</code> command. The frontend just needs to connect it.
1523 <div class=
"literalblock">
1524 <div class=
"content">
1525 <pre><code> 'M' SP
<mode
> SP
<dataref
> SP
<path
> LF
</code></pre>
1527 <div class=
"paragraph"><p>Here usually
<code><dataref
></code> must be either a mark reference (
<code>:
<idnum
></code>)
1528 set by a prior
<code>blob
</code> command, or a full
40-byte SHA-
1 of an
1529 existing Git blob object. If
<code><mode
></code> is
<code>040000`
</code> then
1530 <code><dataref
></code> must be the full
40-byte SHA-
1 of an existing
1531 Git tree object or a mark reference set with
<code>--import-marks
</code>.
</p></div>
1533 <dt class=
"hdlist1">
1538 The data content for the file has not been supplied yet.
1539 The frontend wants to supply it as part of this modify
1542 <div class=
"literalblock">
1543 <div class=
"content">
1544 <pre><code> 'M' SP
<mode
> SP 'inline' SP
<path
> LF
1547 <div class=
"paragraph"><p>See below for a detailed description of the
<code>data
</code> command.
</p></div>
1550 <div class=
"paragraph"><p>In both formats
<code><mode
></code> is the type of file entry, specified
1551 in octal. Git only supports the following modes:
</p></div>
1552 <div class=
"ulist"><ul>
1555 <code>100644</code> or
<code>644</code>: A normal (not-executable) file. The majority
1556 of files in most projects use this mode. If in doubt, this is
1562 <code>100755</code> or
<code>755</code>: A normal, but executable, file.
1567 <code>120000</code>: A symlink, the content of the file will be the link target.
1572 <code>160000</code>: A gitlink, SHA-
1 of the object refers to a commit in
1573 another repository. Git links can only be specified by SHA or through
1574 a commit mark. They are used to implement submodules.
1579 <code>040000</code>: A subdirectory. Subdirectories can only be specified by
1580 SHA or through a tree mark set with
<code>--import-marks
</code>.
1584 <div class=
"paragraph"><p>In both formats
<code><path
></code> is the complete path of the file to be added
1585 (if not already existing) or modified (if already existing).
</p></div>
1586 <div class=
"paragraph"><p>A
<code><path
></code> string must use UNIX-style directory separators (forward
1587 slash
<code>/
</code>), may contain any byte other than
<code>LF
</code>, and must not
1588 start with double quote (
<code>"</code>).</p></div>
1589 <div class="paragraph
"><p>A path can use C-style string quoting; this is accepted in all cases
1590 and mandatory if the filename starts with double quote or contains
1591 <code>LF</code>. In C-style quoting, the complete name should be surrounded with
1592 double quotes, and any <code>LF</code>, backslash, or double quote characters
1593 must be escaped by preceding them with a backslash (e.g.,
1594 <code>"path/with\n, \\ and \
" in it"</code>).
</p></div>
1595 <div class=
"paragraph"><p>The value of
<code><path
></code> must be in canonical form. That is it must not:
</p></div>
1596 <div class=
"ulist"><ul>
1599 contain an empty directory component (e.g.
<code>foo//bar
</code> is invalid),
1604 end with a directory separator (e.g.
<code>foo/
</code> is invalid),
1609 start with a directory separator (e.g.
<code>/foo
</code> is invalid),
1614 contain the special component
<code>.
</code> or
<code>..
</code> (e.g.
<code>foo/./bar
</code> and
1615 <code>foo/../bar
</code> are invalid).
1619 <div class=
"paragraph"><p>The root of the tree can be represented by an empty string as
<code><path
></code>.
</p></div>
1620 <div class=
"paragraph"><p>It is recommended that
<code><path
></code> always be encoded using UTF-
8.
</p></div>
1623 <h4 id=
"_code_filedelete_code"><code>filedelete
</code></h4>
1624 <div class=
"paragraph"><p>Included in a
<code>commit
</code> command to remove a file or recursively
1625 delete an entire directory from the branch. If the file or directory
1626 removal makes its parent directory empty, the parent directory will
1627 be automatically removed too. This cascades up the tree until the
1628 first non-empty directory or the root is reached.
</p></div>
1629 <div class=
"literalblock">
1630 <div class=
"content">
1631 <pre><code> 'D' SP
<path
> LF
</code></pre>
1633 <div class=
"paragraph"><p>here
<code><path
></code> is the complete path of the file or subdirectory to
1634 be removed from the branch.
1635 See
<code>filemodify
</code> above for a detailed description of
<code><path
></code>.
</p></div>
1638 <h4 id=
"_code_filecopy_code"><code>filecopy
</code></h4>
1639 <div class=
"paragraph"><p>Recursively copies an existing file or subdirectory to a different
1640 location within the branch. The existing file or directory must
1641 exist. If the destination exists it will be completely replaced
1642 by the content copied from the source.
</p></div>
1643 <div class=
"literalblock">
1644 <div class=
"content">
1645 <pre><code> 'C' SP
<path
> SP
<path
> LF
</code></pre>
1647 <div class=
"paragraph"><p>here the first
<code><path
></code> is the source location and the second
1648 <code><path
></code> is the destination. See
<code>filemodify
</code> above for a detailed
1649 description of what
<code><path
></code> may look like. To use a source path
1650 that contains SP the path must be quoted.
</p></div>
1651 <div class=
"paragraph"><p>A
<code>filecopy
</code> command takes effect immediately. Once the source
1652 location has been copied to the destination any future commands
1653 applied to the source location will not impact the destination of
1657 <h4 id=
"_code_filerename_code"><code>filerename
</code></h4>
1658 <div class=
"paragraph"><p>Renames an existing file or subdirectory to a different location
1659 within the branch. The existing file or directory must exist. If
1660 the destination exists it will be replaced by the source directory.
</p></div>
1661 <div class=
"literalblock">
1662 <div class=
"content">
1663 <pre><code> 'R' SP
<path
> SP
<path
> LF
</code></pre>
1665 <div class=
"paragraph"><p>here the first
<code><path
></code> is the source location and the second
1666 <code><path
></code> is the destination. See
<code>filemodify
</code> above for a detailed
1667 description of what
<code><path
></code> may look like. To use a source path
1668 that contains SP the path must be quoted.
</p></div>
1669 <div class=
"paragraph"><p>A
<code>filerename
</code> command takes effect immediately. Once the source
1670 location has been renamed to the destination any future commands
1671 applied to the source location will create new files there and not
1672 impact the destination of the rename.
</p></div>
1673 <div class=
"paragraph"><p>Note that a
<code>filerename
</code> is the same as a
<code>filecopy
</code> followed by a
1674 <code>filedelete
</code> of the source location. There is a slight performance
1675 advantage to using
<code>filerename
</code>, but the advantage is so small
1676 that it is never worth trying to convert a delete/add pair in
1677 source material into a rename for fast-import. This
<code>filerename
</code>
1678 command is provided just to simplify frontends that already have
1679 rename information and don
’t want bother with decomposing it into a
1680 <code>filecopy
</code> followed by a
<code>filedelete
</code>.
</p></div>
1683 <h4 id=
"_code_filedeleteall_code"><code>filedeleteall
</code></h4>
1684 <div class=
"paragraph"><p>Included in a
<code>commit
</code> command to remove all files (and also all
1685 directories) from the branch. This command resets the internal
1686 branch structure to have no files in it, allowing the frontend
1687 to subsequently add all interesting files from scratch.
</p></div>
1688 <div class=
"literalblock">
1689 <div class=
"content">
1690 <pre><code> 'deleteall' LF
</code></pre>
1692 <div class=
"paragraph"><p>This command is extremely useful if the frontend does not know
1693 (or does not care to know) what files are currently on the branch,
1694 and therefore cannot generate the proper
<code>filedelete
</code> commands to
1695 update the content.
</p></div>
1696 <div class=
"paragraph"><p>Issuing a
<code>filedeleteall
</code> followed by the needed
<code>filemodify
</code>
1697 commands to set the correct content will produce the same results
1698 as sending only the needed
<code>filemodify
</code> and
<code>filedelete
</code> commands.
1699 The
<code>filedeleteall
</code> approach may however require fast-import to use slightly
1700 more memory per active branch (less than
1 MiB for even most large
1701 projects); so frontends that can easily obtain only the affected
1702 paths for a commit are encouraged to do so.
</p></div>
1705 <h4 id=
"_code_notemodify_code"><code>notemodify
</code></h4>
1706 <div class=
"paragraph"><p>Included in a
<code>commit
</code> <code><notes_ref
></code> command to add a new note
1707 annotating a
<code><commit-ish
></code> or change this annotation contents.
1708 Internally it is similar to filemodify
100644 on
<code><commit-ish
></code>
1709 path (maybe split into subdirectories). It
’s not advised to
1710 use any other commands to write to the
<code><notes_ref
></code> tree except
1711 <code>filedeleteall
</code> to delete all existing notes in this tree.
1712 This command has two different means of specifying the content
1713 of the note.
</p></div>
1714 <div class=
"dlist"><dl>
1715 <dt class=
"hdlist1">
1716 External data format
1720 The data content for the note was already supplied by a prior
1721 <code>blob
</code> command. The frontend just needs to connect it to the
1722 commit that is to be annotated.
1724 <div class=
"literalblock">
1725 <div class=
"content">
1726 <pre><code> 'N' SP
<dataref
> SP
<commit-ish
> LF
</code></pre>
1728 <div class=
"paragraph"><p>Here
<code><dataref
></code> can be either a mark reference (
<code>:
<idnum
></code>)
1729 set by a prior
<code>blob
</code> command, or a full
40-byte SHA-
1 of an
1730 existing Git blob object.
</p></div>
1732 <dt class=
"hdlist1">
1737 The data content for the note has not been supplied yet.
1738 The frontend wants to supply it as part of this modify
1741 <div class=
"literalblock">
1742 <div class=
"content">
1743 <pre><code> 'N' SP 'inline' SP
<commit-ish
> LF
1746 <div class=
"paragraph"><p>See below for a detailed description of the
<code>data
</code> command.
</p></div>
1749 <div class=
"paragraph"><p>In both formats
<code><commit-ish
></code> is any of the commit specification
1750 expressions also accepted by
<code>from
</code> (see above).
</p></div>
1754 <h3 id=
"_code_mark_code"><code>mark
</code></h3>
1755 <div class=
"paragraph"><p>Arranges for fast-import to save a reference to the current object, allowing
1756 the frontend to recall this object at a future point in time, without
1757 knowing its SHA-
1. Here the current object is the object creation
1758 command the
<code>mark
</code> command appears within. This can be
<code>commit
</code>,
1759 <code>tag
</code>, and
<code>blob
</code>, but
<code>commit
</code> is the most common usage.
</p></div>
1760 <div class=
"literalblock">
1761 <div class=
"content">
1762 <pre><code> 'mark' SP ':'
<idnum
> LF
</code></pre>
1764 <div class=
"paragraph"><p>where
<code><idnum
></code> is the number assigned by the frontend to this mark.
1765 The value of
<code><idnum
></code> is expressed as an ASCII decimal integer.
1766 The value
0 is reserved and cannot be used as
1767 a mark. Only values greater than or equal to
1 may be used as marks.
</p></div>
1768 <div class=
"paragraph"><p>New marks are created automatically. Existing marks can be moved
1769 to another object simply by reusing the same
<code><idnum
></code> in another
1770 <code>mark
</code> command.
</p></div>
1773 <h3 id=
"_code_original_oid_code"><code>original-oid
</code></h3>
1774 <div class=
"paragraph"><p>Provides the name of the object in the original source control system.
1775 fast-import will simply ignore this directive, but filter processes
1776 which operate on and modify the stream before feeding to fast-import
1777 may have uses for this information
</p></div>
1778 <div class=
"literalblock">
1779 <div class=
"content">
1780 <pre><code> 'original-oid' SP
<object-identifier
> LF
</code></pre>
1782 <div class=
"paragraph"><p>where
<code><object-identifier
></code> is any string not containing LF.
</p></div>
1785 <h3 id=
"_code_tag_code"><code>tag
</code></h3>
1786 <div class=
"paragraph"><p>Creates an annotated tag referring to a specific commit. To create
1787 lightweight (non-annotated) tags see the
<code>reset
</code> command below.
</p></div>
1788 <div class=
"literalblock">
1789 <div class=
"content">
1790 <pre><code> 'tag' SP
<name
> LF
1792 'from' SP
<commit-ish
> LF
1794 'tagger' (SP
<name
>)? SP LT
<email
> GT SP
<when
> LF
1797 <div class=
"paragraph"><p>where
<code><name
></code> is the name of the tag to create.
</p></div>
1798 <div class=
"paragraph"><p>Tag names are automatically prefixed with
<code>refs/tags/
</code> when stored
1799 in Git, so importing the CVS branch symbol
<code>RELENG-
1_0-FINAL
</code> would
1800 use just
<code>RELENG-
1_0-FINAL
</code> for
<code><name
></code>, and fast-import will write the
1801 corresponding ref as
<code>refs/tags/RELENG-
1_0-FINAL
</code>.
</p></div>
1802 <div class=
"paragraph"><p>The value of
<code><name
></code> must be a valid refname in Git and therefore
1803 may contain forward slashes. As
<code>LF
</code> is not valid in a Git refname,
1804 no quoting or escaping syntax is supported here.
</p></div>
1805 <div class=
"paragraph"><p>The
<code>from
</code> command is the same as in the
<code>commit
</code> command; see
1806 above for details.
</p></div>
1807 <div class=
"paragraph"><p>The
<code>tagger
</code> command uses the same format as
<code>committer
</code> within
1808 <code>commit
</code>; again see above for details.
</p></div>
1809 <div class=
"paragraph"><p>The
<code>data
</code> command following
<code>tagger
</code> must supply the annotated tag
1810 message (see below for
<code>data
</code> command syntax). To import an empty
1811 tag message use a
0 length data. Tag messages are free-form and are
1812 not interpreted by Git. Currently they must be encoded in UTF-
8,
1813 as fast-import does not permit other encodings to be specified.
</p></div>
1814 <div class=
"paragraph"><p>Signing annotated tags during import from within fast-import is not
1815 supported. Trying to include your own PGP/GPG signature is not
1816 recommended, as the frontend does not (easily) have access to the
1817 complete set of bytes which normally goes into such a signature.
1818 If signing is required, create lightweight tags from within fast-import with
1819 <code>reset
</code>, then create the annotated versions of those tags offline
1820 with the standard
<em>git tag
</em> process.
</p></div>
1823 <h3 id=
"_code_reset_code"><code>reset
</code></h3>
1824 <div class=
"paragraph"><p>Creates (or recreates) the named branch, optionally starting from
1825 a specific revision. The reset command allows a frontend to issue
1826 a new
<code>from
</code> command for an existing branch, or to create a new
1827 branch from an existing commit without creating a new commit.
</p></div>
1828 <div class=
"literalblock">
1829 <div class=
"content">
1830 <pre><code> 'reset' SP
<ref
> LF
1831 ('from' SP
<commit-ish
> LF)?
1834 <div class=
"paragraph"><p>For a detailed description of
<code><ref
></code> and
<code><commit-ish
></code> see above
1835 under
<code>commit
</code> and
<code>from
</code>.
</p></div>
1836 <div class=
"paragraph"><p>The
<code>LF
</code> after the command is optional (it used to be required).
</p></div>
1837 <div class=
"paragraph"><p>The
<code>reset
</code> command can also be used to create lightweight
1838 (non-annotated) tags. For example:
</p></div>
1839 <div class=
"exampleblock">
1840 <div class=
"content">
1841 <div class=
"literalblock">
1842 <div class=
"content">
1843 <pre><code>reset refs/tags/
938
1844 from :
938</code></pre>
1847 <div class=
"paragraph"><p>would create the lightweight tag
<code>refs/tags/
938</code> referring to
1848 whatever commit mark
<code>:
938</code> references.
</p></div>
1851 <h3 id=
"_code_blob_code"><code>blob
</code></h3>
1852 <div class=
"paragraph"><p>Requests writing one file revision to the packfile. The revision
1853 is not connected to any commit; this connection must be formed in
1854 a subsequent
<code>commit
</code> command by referencing the blob through an
1855 assigned mark.
</p></div>
1856 <div class=
"literalblock">
1857 <div class=
"content">
1858 <pre><code> 'blob' LF
1863 <div class=
"paragraph"><p>The mark command is optional here as some frontends have chosen
1864 to generate the Git SHA-
1 for the blob on their own, and feed that
1865 directly to
<code>commit
</code>. This is typically more work than it
’s worth
1866 however, as marks are inexpensive to store and easy to use.
</p></div>
1869 <h3 id=
"_code_data_code"><code>data
</code></h3>
1870 <div class=
"paragraph"><p>Supplies raw data (for use as blob/file content, commit messages, or
1871 annotated tag messages) to fast-import. Data can be supplied using an exact
1872 byte count or delimited with a terminating line. Real frontends
1873 intended for production-quality conversions should always use the
1874 exact byte count format, as it is more robust and performs better.
1875 The delimited format is intended primarily for testing fast-import.
</p></div>
1876 <div class=
"paragraph"><p>Comment lines appearing within the
<code><raw
></code> part of
<code>data
</code> commands
1877 are always taken to be part of the body of the data and are therefore
1878 never ignored by fast-import. This makes it safe to import any
1879 file/message content whose lines might start with
<code>#
</code>.
</p></div>
1880 <div class=
"dlist"><dl>
1881 <dt class=
"hdlist1">
1882 Exact byte count format
1886 The frontend must specify the number of bytes of data.
1888 <div class=
"literalblock">
1889 <div class=
"content">
1890 <pre><code> 'data' SP
<count
> LF
1891 <raw
> LF?
</code></pre>
1893 <div class=
"paragraph"><p>where
<code><count
></code> is the exact number of bytes appearing within
1894 <code><raw
></code>. The value of
<code><count
></code> is expressed as an ASCII decimal
1895 integer. The
<code>LF
</code> on either side of
<code><raw
></code> is not
1896 included in
<code><count
></code> and will not be included in the imported data.
</p></div>
1897 <div class=
"paragraph"><p>The
<code>LF
</code> after
<code><raw
></code> is optional (it used to be required) but
1898 recommended. Always including it makes debugging a fast-import
1899 stream easier as the next command always starts in column
0
1900 of the next line, even if
<code><raw
></code> did not end with an
<code>LF
</code>.
</p></div>
1902 <dt class=
"hdlist1">
1907 A delimiter string is used to mark the end of the data.
1908 fast-import will compute the length by searching for the delimiter.
1909 This format is primarily useful for testing and is not
1910 recommended for real data.
1912 <div class=
"literalblock">
1913 <div class=
"content">
1914 <pre><code> 'data' SP '
<<'
<delim
> LF
1919 <div class=
"paragraph"><p>where
<code><delim
></code> is the chosen delimiter string. The string
<code><delim
></code>
1920 must not appear on a line by itself within
<code><raw
></code>, as otherwise
1921 fast-import will think the data ends earlier than it really does. The
<code>LF
</code>
1922 immediately trailing
<code><raw
></code> is part of
<code><raw
></code>. This is one of
1923 the limitations of the delimited format, it is impossible to supply
1924 a data chunk which does not have an LF as its last byte.
</p></div>
1925 <div class=
"paragraph"><p>The
<code>LF
</code> after
<code><delim
> LF
</code> is optional (it used to be required).
</p></div>
1930 <h3 id=
"_code_alias_code"><code>alias
</code></h3>
1931 <div class=
"paragraph"><p>Record that a mark refers to a given object without first creating any
1932 new object.
</p></div>
1933 <div class=
"literalblock">
1934 <div class=
"content">
1935 <pre><code> 'alias' LF
1937 'to' SP
<commit-ish
> LF
1940 <div class=
"paragraph"><p>For a detailed description of
<code><commit-ish
></code> see above under
<code>from
</code>.
</p></div>
1943 <h3 id=
"_code_checkpoint_code"><code>checkpoint
</code></h3>
1944 <div class=
"paragraph"><p>Forces fast-import to close the current packfile, start a new one, and to
1945 save out all current branch refs, tags and marks.
</p></div>
1946 <div class=
"literalblock">
1947 <div class=
"content">
1948 <pre><code> 'checkpoint' LF
1951 <div class=
"paragraph"><p>Note that fast-import automatically switches packfiles when the current
1952 packfile reaches --max-pack-size, or
4 GiB, whichever limit is
1953 smaller. During an automatic packfile switch fast-import does not update
1954 the branch refs, tags or marks.
</p></div>
1955 <div class=
"paragraph"><p>As a
<code>checkpoint
</code> can require a significant amount of CPU time and
1956 disk IO (to compute the overall pack SHA-
1 checksum, generate the
1957 corresponding index file, and update the refs) it can easily take
1958 several minutes for a single
<code>checkpoint
</code> command to complete.
</p></div>
1959 <div class=
"paragraph"><p>Frontends may choose to issue checkpoints during extremely large
1960 and long running imports, or when they need to allow another Git
1961 process access to a branch. However given that a
30 GiB Subversion
1962 repository can be loaded into Git through fast-import in about
3 hours,
1963 explicit checkpointing may not be necessary.
</p></div>
1964 <div class=
"paragraph"><p>The
<code>LF
</code> after the command is optional (it used to be required).
</p></div>
1967 <h3 id=
"_code_progress_code"><code>progress
</code></h3>
1968 <div class=
"paragraph"><p>Causes fast-import to print the entire
<code>progress
</code> line unmodified to
1969 its standard output channel (file descriptor
1) when the command is
1970 processed from the input stream. The command otherwise has no impact
1971 on the current import, or on any of fast-import
’s internal state.
</p></div>
1972 <div class=
"literalblock">
1973 <div class=
"content">
1974 <pre><code> 'progress' SP
<any
> LF
1977 <div class=
"paragraph"><p>The
<code><any
></code> part of the command may contain any sequence of bytes
1978 that does not contain
<code>LF
</code>. The
<code>LF
</code> after the command is optional.
1979 Callers may wish to process the output through a tool such as sed to
1980 remove the leading part of the line, for example:
</p></div>
1981 <div class=
"exampleblock">
1982 <div class=
"content">
1983 <div class=
"literalblock">
1984 <div class=
"content">
1985 <pre><code>frontend | git fast-import | sed 's/^progress //'
</code></pre>
1988 <div class=
"paragraph"><p>Placing a
<code>progress
</code> command immediately after a
<code>checkpoint
</code> will
1989 inform the reader when the
<code>checkpoint
</code> has been completed and it
1990 can safely access the refs that fast-import updated.
</p></div>
1993 <h3 id=
"_code_get_mark_code"><code>get-mark
</code></h3>
1994 <div class=
"paragraph"><p>Causes fast-import to print the SHA-
1 corresponding to a mark to
1995 stdout or to the file descriptor previously arranged with the
1996 <code>--cat-blob-fd
</code> argument. The command otherwise has no impact on the
1997 current import; its purpose is to retrieve SHA-
1s that later commits
1998 might want to refer to in their commit messages.
</p></div>
1999 <div class=
"literalblock">
2000 <div class=
"content">
2001 <pre><code> 'get-mark' SP ':'
<idnum
> LF
</code></pre>
2003 <div class=
"paragraph"><p>See
“Responses To Commands
” below for details about how to read
2004 this output safely.
</p></div>
2007 <h3 id=
"_code_cat_blob_code"><code>cat-blob
</code></h3>
2008 <div class=
"paragraph"><p>Causes fast-import to print a blob to a file descriptor previously
2009 arranged with the
<code>--cat-blob-fd
</code> argument. The command otherwise
2010 has no impact on the current import; its main purpose is to
2011 retrieve blobs that may be in fast-import
’s memory but not
2012 accessible from the target repository.
</p></div>
2013 <div class=
"literalblock">
2014 <div class=
"content">
2015 <pre><code> 'cat-blob' SP
<dataref
> LF
</code></pre>
2017 <div class=
"paragraph"><p>The
<code><dataref
></code> can be either a mark reference (
<code>:
<idnum
></code>)
2018 set previously or a full
40-byte SHA-
1 of a Git blob, preexisting or
2019 ready to be written.
</p></div>
2020 <div class=
"paragraph"><p>Output uses the same format as
<code>git cat-file --batch
</code>:
</p></div>
2021 <div class=
"exampleblock">
2022 <div class=
"content">
2023 <div class=
"literalblock">
2024 <div class=
"content">
2025 <pre><code><sha1
> SP 'blob' SP
<size
> LF
2026 <contents
> LF
</code></pre>
2029 <div class=
"paragraph"><p>This command can be used where a
<code>filemodify
</code> directive can appear,
2030 allowing it to be used in the middle of a commit. For a
<code>filemodify
</code>
2031 using an inline directive, it can also appear right before the
<code>data
</code>
2032 directive.
</p></div>
2033 <div class=
"paragraph"><p>See
“Responses To Commands
” below for details about how to read
2034 this output safely.
</p></div>
2037 <h3 id=
"_code_ls_code"><code>ls
</code></h3>
2038 <div class=
"paragraph"><p>Prints information about the object at a path to a file descriptor
2039 previously arranged with the
<code>--cat-blob-fd
</code> argument. This allows
2040 printing a blob from the active commit (with
<code>cat-blob
</code>) or copying a
2041 blob or tree from a previous commit for use in the current one (with
2042 <code>filemodify
</code>).
</p></div>
2043 <div class=
"paragraph"><p>The
<code>ls
</code> command can also be used where a
<code>filemodify
</code> directive can
2044 appear, allowing it to be used in the middle of a commit.
</p></div>
2045 <div class=
"dlist"><dl>
2046 <dt class=
"hdlist1">
2047 Reading from the active commit
2051 This form can only be used in the middle of a
<code>commit
</code>.
2052 The path names a directory entry within fast-import
’s
2053 active commit. The path must be quoted in this case.
2055 <div class=
"literalblock">
2056 <div class=
"content">
2057 <pre><code> 'ls' SP
<path
> LF
</code></pre>
2060 <dt class=
"hdlist1">
2061 Reading from a named tree
2065 The
<code><dataref
></code> can be a mark reference (
<code>:
<idnum
></code>) or the
2066 full
40-byte SHA-
1 of a Git tag, commit, or tree object,
2067 preexisting or waiting to be written.
2068 The path is relative to the top level of the tree
2069 named by
<code><dataref
></code>.
2071 <div class=
"literalblock">
2072 <div class=
"content">
2073 <pre><code> 'ls' SP
<dataref
> SP
<path
> LF
</code></pre>
2077 <div class=
"paragraph"><p>See
<code>filemodify
</code> above for a detailed description of
<code><path
></code>.
</p></div>
2078 <div class=
"paragraph"><p>Output uses the same format as
<code>git ls-tree
<tree
> --
<path
></code>:
</p></div>
2079 <div class=
"exampleblock">
2080 <div class=
"content">
2081 <div class=
"literalblock">
2082 <div class=
"content">
2083 <pre><code><mode
> SP ('blob' | 'tree' | 'commit') SP
<dataref
> HT
<path
> LF
</code></pre>
2086 <div class=
"paragraph"><p>The
<dataref
> represents the blob, tree, or commit object at
<path
>
2087 and can be used in later
<em>get-mark
</em>,
<em>cat-blob
</em>,
<em>filemodify
</em>, or
2088 <em>ls
</em> commands.
</p></div>
2089 <div class=
"paragraph"><p>If there is no file or subtree at that path,
<em>git fast-import
</em> will
2090 instead report
</p></div>
2091 <div class=
"exampleblock">
2092 <div class=
"content">
2093 <div class=
"literalblock">
2094 <div class=
"content">
2095 <pre><code>missing SP
<path
> LF
</code></pre>
2098 <div class=
"paragraph"><p>See
“Responses To Commands
” below for details about how to read
2099 this output safely.
</p></div>
2102 <h3 id=
"_code_feature_code"><code>feature
</code></h3>
2103 <div class=
"paragraph"><p>Require that fast-import supports the specified feature, or abort if
2104 it does not.
</p></div>
2105 <div class=
"literalblock">
2106 <div class=
"content">
2107 <pre><code> 'feature' SP
<feature
> ('='
<argument
>)? LF
</code></pre>
2109 <div class=
"paragraph"><p>The
<feature
> part of the command may be any one of the following:
</p></div>
2110 <div class=
"dlist"><dl>
2111 <dt class=
"hdlist1">
2114 <dt class=
"hdlist1">
2117 <dt class=
"hdlist1">
2120 <dt class=
"hdlist1">
2123 <dt class=
"hdlist1">
2128 Act as though the corresponding command-line option with
2129 a leading
<code>--
</code> was passed on the command line
2130 (see OPTIONS, above).
2133 <dt class=
"hdlist1">
2136 <dt class=
"hdlist1">
2137 import-marks-if-exists
2141 Like --import-marks except in two respects: first, only one
2142 "feature import-marks" or
"feature import-marks-if-exists"
2143 command is allowed per stream; second, an --import-marks=
2144 or --import-marks-if-exists command-line option overrides
2145 any of these
"feature" commands in the stream; third,
2146 "feature import-marks-if-exists" like a corresponding
2147 command-line option silently skips a nonexistent file.
2150 <dt class=
"hdlist1">
2153 <dt class=
"hdlist1">
2156 <dt class=
"hdlist1">
2161 Require that the backend support the
<em>get-mark
</em>,
<em>cat-blob
</em>,
2162 or
<em>ls
</em> command respectively.
2163 Versions of fast-import not supporting the specified command
2164 will exit with a message indicating so.
2165 This lets the import error out early with a clear message,
2166 rather than wasting time on the early part of an import
2167 before the unsupported command is detected.
2170 <dt class=
"hdlist1">
2175 Require that the backend support the
<em>notemodify
</em> (N)
2176 subcommand to the
<em>commit
</em> command.
2177 Versions of fast-import not supporting notes will exit
2178 with a message indicating so.
2181 <dt class=
"hdlist1">
2186 Error out if the stream ends without a
<em>done
</em> command.
2187 Without this feature, errors causing the frontend to end
2188 abruptly at a convenient point in the stream can go
2189 undetected. This may occur, for example, if an import
2190 front end dies in mid-operation without emitting SIGTERM
2191 or SIGKILL at its subordinate git fast-import instance.
2197 <h3 id=
"_code_option_code"><code>option
</code></h3>
2198 <div class=
"paragraph"><p>Processes the specified option so that git fast-import behaves in a
2199 way that suits the frontend
’s needs.
2200 Note that options specified by the frontend are overridden by any
2201 options the user may specify to git fast-import itself.
</p></div>
2202 <div class=
"literalblock">
2203 <div class=
"content">
2204 <pre><code> 'option' SP
<option
> LF
</code></pre>
2206 <div class=
"paragraph"><p>The
<code><option
></code> part of the command may contain any of the options
2207 listed in the OPTIONS section that do not change import semantics,
2208 without the leading
<code>--
</code> and is treated in the same way.
</p></div>
2209 <div class=
"paragraph"><p>Option commands must be the first commands on the input (not counting
2210 feature commands), to give an option command after any non-option
2211 command is an error.
</p></div>
2212 <div class=
"paragraph"><p>The following command-line options change import semantics and may therefore
2213 not be passed as option:
</p></div>
2214 <div class=
"ulist"><ul>
2243 <h3 id=
"_code_done_code"><code>done
</code></h3>
2244 <div class=
"paragraph"><p>If the
<code>done
</code> feature is not in use, treated as if EOF was read.
2245 This can be used to tell fast-import to finish early.
</p></div>
2246 <div class=
"paragraph"><p>If the
<code>--done
</code> command-line option or
<code>feature done
</code> command is
2247 in use, the
<code>done
</code> command is mandatory and marks the end of the
2253 <h2 id=
"_responses_to_commands">RESPONSES TO COMMANDS
</h2>
2254 <div class=
"sectionbody">
2255 <div class=
"paragraph"><p>New objects written by fast-import are not available immediately.
2256 Most fast-import commands have no visible effect until the next
2257 checkpoint (or completion). The frontend can send commands to
2258 fill fast-import
’s input pipe without worrying about how quickly
2259 they will take effect, which improves performance by simplifying
2260 scheduling.
</p></div>
2261 <div class=
"paragraph"><p>For some frontends, though, it is useful to be able to read back
2262 data from the current repository as it is being updated (for
2263 example when the source material describes objects in terms of
2264 patches to be applied to previously imported objects). This can
2265 be accomplished by connecting the frontend and fast-import via
2266 bidirectional pipes:
</p></div>
2267 <div class=
"exampleblock">
2268 <div class=
"content">
2269 <div class=
"literalblock">
2270 <div class=
"content">
2271 <pre><code>mkfifo fast-import-output
2272 frontend
<fast-import-output |
2273 git fast-import
>fast-import-output
</code></pre>
2276 <div class=
"paragraph"><p>A frontend set up this way can use
<code>progress
</code>,
<code>get-mark
</code>,
<code>ls
</code>, and
2277 <code>cat-blob
</code> commands to read information from the import in progress.
</p></div>
2278 <div class=
"paragraph"><p>To avoid deadlock, such frontends must completely consume any
2279 pending output from
<code>progress
</code>,
<code>ls
</code>,
<code>get-mark
</code>, and
<code>cat-blob
</code> before
2280 performing writes to fast-import that might block.
</p></div>
2284 <h2 id=
"_crash_reports">CRASH REPORTS
</h2>
2285 <div class=
"sectionbody">
2286 <div class=
"paragraph"><p>If fast-import is supplied invalid input it will terminate with a
2287 non-zero exit status and create a crash report in the top level of
2288 the Git repository it was importing into. Crash reports contain
2289 a snapshot of the internal fast-import state as well as the most
2290 recent commands that lead up to the crash.
</p></div>
2291 <div class=
"paragraph"><p>All recent commands (including stream comments, file changes and
2292 progress commands) are shown in the command history within the crash
2293 report, but raw file data and commit messages are excluded from the
2294 crash report. This exclusion saves space within the report file
2295 and reduces the amount of buffering that fast-import must perform
2296 during execution.
</p></div>
2297 <div class=
"paragraph"><p>After writing a crash report fast-import will close the current
2298 packfile and export the marks table. This allows the frontend
2299 developer to inspect the repository state and resume the import from
2300 the point where it crashed. The modified branches and tags are not
2301 updated during a crash, as the import did not complete successfully.
2302 Branch and tag information can be found in the crash report and
2303 must be applied manually if the update is needed.
</p></div>
2304 <div class=
"paragraph"><p>An example crash:
</p></div>
2305 <div class=
"exampleblock">
2306 <div class=
"content">
2307 <div class=
"literalblock">
2308 <div class=
"content">
2309 <pre><code>$ cat
>in
<<END_OF_INPUT
2310 # my very first test commit
2311 commit refs/heads/master
2312 committer Shawn O. Pearce
<spearce
> 19283 -
0400
2313 # who is that guy anyway?
2317 M
644 inline .gitignore
2322 END_OF_INPUT
</code></pre>
2324 <div class=
"literalblock">
2325 <div class=
"content">
2326 <pre><code>$ git fast-import
<in
2327 fatal: Corrupt mode: M
777 inline bob
2328 fast-import: dumping crash report to .git/fast_import_crash_8434
</code></pre>
2330 <div class=
"literalblock">
2331 <div class=
"content">
2332 <pre><code>$ cat .git/fast_import_crash_8434
2333 fast-import crash report:
2334 fast-import process:
8434
2335 parent process :
1391
2336 at Sat Sep
1 00:
58:
12 2007</code></pre>
2338 <div class=
"literalblock">
2339 <div class=
"content">
2340 <pre><code>fatal: Corrupt mode: M
777 inline bob
</code></pre>
2342 <div class=
"literalblock">
2343 <div class=
"content">
2344 <pre><code>Most Recent Commands Before Crash
2345 ---------------------------------
2346 # my very first test commit
2347 commit refs/heads/master
2348 committer Shawn O. Pearce
<spearce
> 19283 -
0400
2349 # who is that guy anyway?
2351 M
644 inline .gitignore
2353 * M
777 inline bob
</code></pre>
2355 <div class=
"literalblock">
2356 <div class=
"content">
2357 <pre><code>Active Branch LRU
2359 active_branches =
1 cur,
5 max
</code></pre>
2361 <div class=
"literalblock">
2362 <div class=
"content">
2363 <pre><code>pos clock name
2364 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2365 1)
0 refs/heads/master
</code></pre>
2367 <div class=
"literalblock">
2368 <div class=
"content">
2369 <pre><code>Inactive Branches
2372 status : active loaded dirty
2373 tip commit :
0000000000000000000000000000000000000000
2374 old tree :
0000000000000000000000000000000000000000
2375 cur tree :
0000000000000000000000000000000000000000
2377 last pack :
</code></pre>
2379 <div class=
"literalblock">
2380 <div class=
"content">
2381 <pre><code>-------------------
2382 END OF CRASH REPORT
</code></pre>
2388 <h2 id=
"_tips_and_tricks">TIPS AND TRICKS
</h2>
2389 <div class=
"sectionbody">
2390 <div class=
"paragraph"><p>The following tips and tricks have been collected from various
2391 users of fast-import, and are offered here as suggestions.
</p></div>
2393 <h3 id=
"_use_one_mark_per_commit">Use One Mark Per Commit
</h3>
2394 <div class=
"paragraph"><p>When doing a repository conversion, use a unique mark per commit
2395 (
<code>mark :
<n
></code>) and supply the --export-marks option on the command
2396 line. fast-import will dump a file which lists every mark and the Git
2397 object SHA-
1 that corresponds to it. If the frontend can tie
2398 the marks back to the source repository, it is easy to verify the
2399 accuracy and completeness of the import by comparing each Git
2400 commit to the corresponding source revision.
</p></div>
2401 <div class=
"paragraph"><p>Coming from a system such as Perforce or Subversion this should be
2402 quite simple, as the fast-import mark can also be the Perforce changeset
2403 number or the Subversion revision number.
</p></div>
2406 <h3 id=
"_freely_skip_around_branches">Freely Skip Around Branches
</h3>
2407 <div class=
"paragraph"><p>Don
’t bother trying to optimize the frontend to stick to one branch
2408 at a time during an import. Although doing so might be slightly
2409 faster for fast-import, it tends to increase the complexity of the frontend
2410 code considerably.
</p></div>
2411 <div class=
"paragraph"><p>The branch LRU builtin to fast-import tends to behave very well, and the
2412 cost of activating an inactive branch is so low that bouncing around
2413 between branches has virtually no impact on import performance.
</p></div>
2416 <h3 id=
"_handling_renames">Handling Renames
</h3>
2417 <div class=
"paragraph"><p>When importing a renamed file or directory, simply delete the old
2418 name(s) and modify the new name(s) during the corresponding commit.
2419 Git performs rename detection after-the-fact, rather than explicitly
2420 during a commit.
</p></div>
2423 <h3 id=
"_use_tag_fixup_branches">Use Tag Fixup Branches
</h3>
2424 <div class=
"paragraph"><p>Some other SCM systems let the user create a tag from multiple
2425 files which are not from the same commit/changeset. Or to create
2426 tags which are a subset of the files available in the repository.
</p></div>
2427 <div class=
"paragraph"><p>Importing these tags as-is in Git is impossible without making at
2428 least one commit which
“fixes up
” the files to match the content
2429 of the tag. Use fast-import
’s
<code>reset
</code> command to reset a dummy branch
2430 outside of your normal branch space to the base commit for the tag,
2431 then commit one or more file fixup commits, and finally tag the
2432 dummy branch.
</p></div>
2433 <div class=
"paragraph"><p>For example since all normal branches are stored under
<code>refs/heads/
</code>
2434 name the tag fixup branch
<code>TAG_FIXUP
</code>. This way it is impossible for
2435 the fixup branch used by the importer to have namespace conflicts
2436 with real branches imported from the source (the name
<code>TAG_FIXUP
</code>
2437 is not
<code>refs/heads/TAG_FIXUP
</code>).
</p></div>
2438 <div class=
"paragraph"><p>When committing fixups, consider using
<code>merge
</code> to connect the
2439 commit(s) which are supplying file revisions to the fixup branch.
2440 Doing so will allow tools such as
<em>git blame
</em> to track
2441 through the real commit history and properly annotate the source
2443 <div class=
"paragraph"><p>After fast-import terminates the frontend will need to do
<code>rm .git/TAG_FIXUP
</code>
2444 to remove the dummy branch.
</p></div>
2447 <h3 id=
"_import_now_repack_later">Import Now, Repack Later
</h3>
2448 <div class=
"paragraph"><p>As soon as fast-import completes the Git repository is completely valid
2449 and ready for use. Typically this takes only a very short time,
2450 even for considerably large projects (
100,
000+ commits).
</p></div>
2451 <div class=
"paragraph"><p>However repacking the repository is necessary to improve data
2452 locality and access performance. It can also take hours on extremely
2453 large projects (especially if -f and a large --window parameter is
2454 used). Since repacking is safe to run alongside readers and writers,
2455 run the repack in the background and let it finish when it finishes.
2456 There is no reason to wait to explore your new Git project!
</p></div>
2457 <div class=
"paragraph"><p>If you choose to wait for the repack, don
’t try to run benchmarks
2458 or performance tests until repacking is completed. fast-import outputs
2459 suboptimal packfiles that are simply never seen in real use
2460 situations.
</p></div>
2463 <h3 id=
"_repacking_historical_data">Repacking Historical Data
</h3>
2464 <div class=
"paragraph"><p>If you are repacking very old imported data (e.g. older than the
2465 last year), consider expending some extra CPU time and supplying
2466 --window=
50 (or higher) when you run
<em>git repack
</em>.
2467 This will take longer, but will also produce a smaller packfile.
2468 You only need to expend the effort once, and everyone using your
2469 project will benefit from the smaller repository.
</p></div>
2472 <h3 id=
"_include_some_progress_messages">Include Some Progress Messages
</h3>
2473 <div class=
"paragraph"><p>Every once in a while have your frontend emit a
<code>progress
</code> message
2474 to fast-import. The contents of the messages are entirely free-form,
2475 so one suggestion would be to output the current month and year
2476 each time the current commit date moves into the next month.
2477 Your users will feel better knowing how much of the data stream
2478 has been processed.
</p></div>
2483 <h2 id=
"_packfile_optimization">PACKFILE OPTIMIZATION
</h2>
2484 <div class=
"sectionbody">
2485 <div class=
"paragraph"><p>When packing a blob fast-import always attempts to deltify against the last
2486 blob written. Unless specifically arranged for by the frontend,
2487 this will probably not be a prior version of the same file, so the
2488 generated delta will not be the smallest possible. The resulting
2489 packfile will be compressed, but will not be optimal.
</p></div>
2490 <div class=
"paragraph"><p>Frontends which have efficient access to all revisions of a
2491 single file (for example reading an RCS/CVS ,v file) can choose
2492 to supply all revisions of that file as a sequence of consecutive
2493 <code>blob
</code> commands. This allows fast-import to deltify the different file
2494 revisions against each other, saving space in the final packfile.
2495 Marks can be used to later identify individual file revisions during
2496 a sequence of
<code>commit
</code> commands.
</p></div>
2497 <div class=
"paragraph"><p>The packfile(s) created by fast-import do not encourage good disk access
2498 patterns. This is caused by fast-import writing the data in the order
2499 it is received on standard input, while Git typically organizes
2500 data within packfiles to make the most recent (current tip) data
2501 appear before historical data. Git also clusters commits together,
2502 speeding up revision traversal through better cache locality.
</p></div>
2503 <div class=
"paragraph"><p>For this reason it is strongly recommended that users repack the
2504 repository with
<code>git repack -a -d
</code> after fast-import completes, allowing
2505 Git to reorganize the packfiles for faster data access. If blob
2506 deltas are suboptimal (see above) then also adding the
<code>-f
</code> option
2507 to force recomputation of all deltas can significantly reduce the
2508 final packfile size (
30-
50% smaller can be quite typical).
</p></div>
2509 <div class=
"paragraph"><p>Instead of running
<code>git repack
</code> you can also run
<code>git gc
2510 --aggressive
</code>, which will also optimize other things after an import
2511 (e.g. pack loose refs). As noted in the
"AGGRESSIVE" section in
2512 <a href=
"git-gc.html">git-gc(
1)
</a> the
<code>--aggressive
</code> option will find new deltas with
2513 the
<code>-f
</code> option to
<a href=
"git-repack.html">git-repack(
1)
</a>. For the reasons elaborated
2514 on above using
<code>--aggressive
</code> after a fast-import is one of the few
2515 cases where it
’s known to be worthwhile.
</p></div>
2519 <h2 id=
"_memory_utilization">MEMORY UTILIZATION
</h2>
2520 <div class=
"sectionbody">
2521 <div class=
"paragraph"><p>There are a number of factors which affect how much memory fast-import
2522 requires to perform an import. Like critical sections of core
2523 Git, fast-import uses its own memory allocators to amortize any overheads
2524 associated with malloc. In practice fast-import tends to amortize any
2525 malloc overheads to
0, due to its use of large block allocations.
</p></div>
2527 <h3 id=
"_per_object">per object
</h3>
2528 <div class=
"paragraph"><p>fast-import maintains an in-memory structure for every object written in
2529 this execution. On a
32 bit system the structure is
32 bytes,
2530 on a
64 bit system the structure is
40 bytes (due to the larger
2531 pointer sizes). Objects in the table are not deallocated until
2532 fast-import terminates. Importing
2 million objects on a
32 bit system
2533 will require approximately
64 MiB of memory.
</p></div>
2534 <div class=
"paragraph"><p>The object table is actually a hashtable keyed on the object name
2535 (the unique SHA-
1). This storage configuration allows fast-import to reuse
2536 an existing or already written object and avoid writing duplicates
2537 to the output packfile. Duplicate blobs are surprisingly common
2538 in an import, typically due to branch merges in the source.
</p></div>
2541 <h3 id=
"_per_mark">per mark
</h3>
2542 <div class=
"paragraph"><p>Marks are stored in a sparse array, using
1 pointer (
4 bytes or
8
2543 bytes, depending on pointer size) per mark. Although the array
2544 is sparse, frontends are still strongly encouraged to use marks
2545 between
1 and n, where n is the total number of marks required for
2546 this import.
</p></div>
2549 <h3 id=
"_per_branch">per branch
</h3>
2550 <div class=
"paragraph"><p>Branches are classified as active and inactive. The memory usage
2551 of the two classes is significantly different.
</p></div>
2552 <div class=
"paragraph"><p>Inactive branches are stored in a structure which uses
96 or
120
2553 bytes (
32 bit or
64 bit systems, respectively), plus the length of
2554 the branch name (typically under
200 bytes), per branch. fast-import will
2555 easily handle as many as
10,
000 inactive branches in under
2 MiB
2556 of memory.
</p></div>
2557 <div class=
"paragraph"><p>Active branches have the same overhead as inactive branches, but
2558 also contain copies of every tree that has been recently modified on
2559 that branch. If subtree
<code>include
</code> has not been modified since the
2560 branch became active, its contents will not be loaded into memory,
2561 but if subtree
<code>src
</code> has been modified by a commit since the branch
2562 became active, then its contents will be loaded in memory.
</p></div>
2563 <div class=
"paragraph"><p>As active branches store metadata about the files contained on that
2564 branch, their in-memory storage size can grow to a considerable size
2565 (see below).
</p></div>
2566 <div class=
"paragraph"><p>fast-import automatically moves active branches to inactive status based on
2567 a simple least-recently-used algorithm. The LRU chain is updated on
2568 each
<code>commit
</code> command. The maximum number of active branches can be
2569 increased or decreased on the command line with --active-branches=.
</p></div>
2572 <h3 id=
"_per_active_tree">per active tree
</h3>
2573 <div class=
"paragraph"><p>Trees (aka directories) use just
12 bytes of memory on top of the
2574 memory required for their entries (see
“per active file
” below).
2575 The cost of a tree is virtually
0, as its overhead amortizes out
2576 over the individual file entries.
</p></div>
2579 <h3 id=
"_per_active_file_entry">per active file entry
</h3>
2580 <div class=
"paragraph"><p>Files (and pointers to subtrees) within active trees require
52 or
64
2581 bytes (
32/
64 bit platforms) per entry. To conserve space, file and
2582 tree names are pooled in a common string table, allowing the filename
2583 “Makefile
” to use just
16 bytes (after including the string header
2584 overhead) no matter how many times it occurs within the project.
</p></div>
2585 <div class=
"paragraph"><p>The active branch LRU, when coupled with the filename string pool
2586 and lazy loading of subtrees, allows fast-import to efficiently import
2587 projects with
2,
000+ branches and
45,
114+ files in a very limited
2588 memory footprint (less than
2.7 MiB per active branch).
</p></div>
2593 <h2 id=
"_signals">SIGNALS
</h2>
2594 <div class=
"sectionbody">
2595 <div class=
"paragraph"><p>Sending
<strong>SIGUSR1
</strong> to the
<em>git fast-import
</em> process ends the current
2596 packfile early, simulating a
<code>checkpoint
</code> command. The impatient
2597 operator can use this facility to peek at the objects and refs from an
2598 import in progress, at the cost of some added running time and worse
2599 compression.
</p></div>
2603 <h2 id=
"_configuration">CONFIGURATION
</h2>
2604 <div class=
"sectionbody">
2605 <div class=
"paragraph"><p>Everything below this line in this section is selectively included
2606 from the
<a href=
"git-config.html">git-config(
1)
</a> documentation. The content is the same
2607 as what
’s found there:
</p></div>
2608 <div class=
"dlist"><dl>
2609 <dt class=
"hdlist1">
2610 fastimport.unpackLimit
2614 If the number of objects imported by
<a href=
"git-fast-import.html">git-fast-import(
1)
</a>
2615 is below this limit, then the objects will be unpacked into
2616 loose object files. However if the number of imported objects
2617 equals or exceeds this limit then the pack will be stored as a
2618 pack. Storing the pack from a fast-import can make the import
2619 operation complete faster, especially on slow filesystems. If
2620 not set, the value of
<code>transfer.unpackLimit
</code> is used instead.
2627 <h2 id=
"_see_also">SEE ALSO
</h2>
2628 <div class=
"sectionbody">
2629 <div class=
"paragraph"><p><a href=
"git-fast-export.html">git-fast-export(
1)
</a></p></div>
2633 <h2 id=
"_git">GIT
</h2>
2634 <div class=
"sectionbody">
2635 <div class=
"paragraph"><p>Part of the
<a href=
"git.html">git(
1)
</a> suite
</p></div>
2639 <div id=
"footnotes"><hr /></div>
2641 <div id=
"footer-text">
2643 2022-
09-
14 13:
23:
11 PDT