Autogenerated HTML docs for v1.6.4-rc1
[git/jnareb-git.git] / git-fast-import.html
blob491f2eb1e81fb0d1e08d300119ae58c7e31cda27
1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
2 "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
3 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
4 <head>
5 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
6 <meta name="generator" content="AsciiDoc 8.2.5" />
7 <style type="text/css">
8 /* Debug borders */
9 p, li, dt, dd, div, pre, h1, h2, h3, h4, h5, h6 {
11 border: 1px solid red;
15 body {
16 margin: 1em 5% 1em 5%;
19 a {
20 color: blue;
21 text-decoration: underline;
23 a:visited {
24 color: fuchsia;
27 em {
28 font-style: italic;
31 strong {
32 font-weight: bold;
35 tt {
36 color: navy;
39 h1, h2, h3, h4, h5, h6 {
40 color: #527bbd;
41 font-family: sans-serif;
42 margin-top: 1.2em;
43 margin-bottom: 0.5em;
44 line-height: 1.3;
47 h1, h2, h3 {
48 border-bottom: 2px solid silver;
50 h2 {
51 padding-top: 0.5em;
53 h3 {
54 float: left;
56 h3 + * {
57 clear: left;
60 div.sectionbody {
61 font-family: serif;
62 margin-left: 0;
65 hr {
66 border: 1px solid silver;
69 p {
70 margin-top: 0.5em;
71 margin-bottom: 0.5em;
74 pre {
75 padding: 0;
76 margin: 0;
79 span#author {
80 color: #527bbd;
81 font-family: sans-serif;
82 font-weight: bold;
83 font-size: 1.1em;
85 span#email {
87 span#revision {
88 font-family: sans-serif;
91 div#footer {
92 font-family: sans-serif;
93 font-size: small;
94 border-top: 2px solid silver;
95 padding-top: 0.5em;
96 margin-top: 4.0em;
98 div#footer-text {
99 float: left;
100 padding-bottom: 0.5em;
102 div#footer-badges {
103 float: right;
104 padding-bottom: 0.5em;
107 div#preamble,
108 div.tableblock, div.imageblock, div.exampleblock, div.verseblock,
109 div.quoteblock, div.literalblock, div.listingblock, div.sidebarblock,
110 div.admonitionblock {
111 margin-right: 10%;
112 margin-top: 1.5em;
113 margin-bottom: 1.5em;
115 div.admonitionblock {
116 margin-top: 2.5em;
117 margin-bottom: 2.5em;
120 div.content { /* Block element content. */
121 padding: 0;
124 /* Block element titles. */
125 div.title, caption.title {
126 font-family: sans-serif;
127 font-weight: bold;
128 text-align: left;
129 margin-top: 1.0em;
130 margin-bottom: 0.5em;
132 div.title + * {
133 margin-top: 0;
136 td div.title:first-child {
137 margin-top: 0.0em;
139 div.content div.title:first-child {
140 margin-top: 0.0em;
142 div.content + div.title {
143 margin-top: 0.0em;
146 div.sidebarblock > div.content {
147 background: #ffffee;
148 border: 1px solid silver;
149 padding: 0.5em;
152 div.listingblock {
153 margin-right: 0%;
155 div.listingblock > div.content {
156 border: 1px solid silver;
157 background: #f4f4f4;
158 padding: 0.5em;
161 div.quoteblock > div.content {
162 padding-left: 2.0em;
165 div.attribution {
166 text-align: right;
168 div.verseblock + div.attribution {
169 text-align: left;
172 div.admonitionblock .icon {
173 vertical-align: top;
174 font-size: 1.1em;
175 font-weight: bold;
176 text-decoration: underline;
177 color: #527bbd;
178 padding-right: 0.5em;
180 div.admonitionblock td.content {
181 padding-left: 0.5em;
182 border-left: 2px solid silver;
185 div.exampleblock > div.content {
186 border-left: 2px solid silver;
187 padding: 0.5em;
190 div.verseblock div.content {
191 white-space: pre;
194 div.imageblock div.content { padding-left: 0; }
195 div.imageblock img { border: 1px solid silver; }
196 span.image img { border-style: none; }
198 dl {
199 margin-top: 0.8em;
200 margin-bottom: 0.8em;
202 dt {
203 margin-top: 0.5em;
204 margin-bottom: 0;
205 font-style: italic;
207 dd > *:first-child {
208 margin-top: 0;
211 ul, ol {
212 list-style-position: outside;
214 div.olist2 ol {
215 list-style-type: lower-alpha;
218 div.tableblock > table {
219 border: 3px solid #527bbd;
221 thead {
222 font-family: sans-serif;
223 font-weight: bold;
225 tfoot {
226 font-weight: bold;
229 div.hlist {
230 margin-top: 0.8em;
231 margin-bottom: 0.8em;
233 div.hlist td {
234 padding-bottom: 5px;
236 td.hlist1 {
237 vertical-align: top;
238 font-style: italic;
239 padding-right: 0.8em;
241 td.hlist2 {
242 vertical-align: top;
245 @media print {
246 div#footer-badges { display: none; }
249 div#toctitle {
250 color: #527bbd;
251 font-family: sans-serif;
252 font-size: 1.1em;
253 font-weight: bold;
254 margin-top: 1.0em;
255 margin-bottom: 0.1em;
258 div.toclevel1, div.toclevel2, div.toclevel3, div.toclevel4 {
259 margin-top: 0;
260 margin-bottom: 0;
262 div.toclevel2 {
263 margin-left: 2em;
264 font-size: 0.9em;
266 div.toclevel3 {
267 margin-left: 4em;
268 font-size: 0.9em;
270 div.toclevel4 {
271 margin-left: 6em;
272 font-size: 0.9em;
274 include1::./stylesheets/xhtml11-manpage.css[]
275 /* Workarounds for IE6's broken and incomplete CSS2. */
277 div.sidebar-content {
278 background: #ffffee;
279 border: 1px solid silver;
280 padding: 0.5em;
282 div.sidebar-title, div.image-title {
283 font-family: sans-serif;
284 font-weight: bold;
285 margin-top: 0.0em;
286 margin-bottom: 0.5em;
289 div.listingblock div.content {
290 border: 1px solid silver;
291 background: #f4f4f4;
292 padding: 0.5em;
295 div.quoteblock-content {
296 padding-left: 2.0em;
299 div.exampleblock-content {
300 border-left: 2px solid silver;
301 padding-left: 0.5em;
304 /* IE6 sets dynamically generated links as visited. */
305 div#toc a:visited { color: blue; }
306 </style>
307 <title>git-fast-import(1)</title>
308 </head>
309 <body>
310 <div id="header">
311 <h1>
312 git-fast-import(1) Manual Page
313 </h1>
314 <h2>NAME</h2>
315 <div class="sectionbody">
316 <p>git-fast-import -
317 Backend for fast Git data importers
318 </p>
319 </div>
320 </div>
321 <h2>SYNOPSIS</h2>
322 <div class="sectionbody">
323 <div class="para"><p>frontend | <em>git fast-import</em> [options]</p></div>
324 </div>
325 <h2 id="_description">DESCRIPTION</h2>
326 <div class="sectionbody">
327 <div class="para"><p>This program is usually not what the end user wants to run directly.
328 Most end users want to use one of the existing frontend programs,
329 which parses a specific type of foreign source and feeds the contents
330 stored there to <em>git-fast-import</em>.</p></div>
331 <div class="para"><p>fast-import reads a mixed command/data stream from standard input and
332 writes one or more packfiles directly into the current repository.
333 When EOF is received on standard input, fast import writes out
334 updated branch and tag refs, fully updating the current repository
335 with the newly imported data.</p></div>
336 <div class="para"><p>The fast-import backend itself can import into an empty repository (one that
337 has already been initialized by <em>git-init</em>) or incrementally
338 update an existing populated repository. Whether or not incremental
339 imports are supported from a particular foreign source depends on
340 the frontend program in use.</p></div>
341 </div>
342 <h2 id="_options">OPTIONS</h2>
343 <div class="sectionbody">
344 <div class="vlist"><dl>
345 <dt>
346 --date-format=&lt;fmt&gt;
347 </dt>
348 <dd>
350 Specify the type of dates the frontend will supply to
351 fast-import within <tt>author</tt>, <tt>committer</tt> and <tt>tagger</tt> commands.
352 See &#8220;Date Formats&#8221; below for details about which formats
353 are supported, and their syntax.
354 </p>
355 </dd>
356 <dt>
357 --force
358 </dt>
359 <dd>
361 Force updating modified existing branches, even if doing
362 so would cause commits to be lost (as the new commit does
363 not contain the old commit).
364 </p>
365 </dd>
366 <dt>
367 --max-pack-size=&lt;n&gt;
368 </dt>
369 <dd>
371 Maximum size of each output packfile, expressed in MiB.
372 The default is 4096 (4 GiB) as that is the maximum allowed
373 packfile size (due to file format limitations). Some
374 importers may wish to lower this, such as to ensure the
375 resulting packfiles fit on CDs.
376 </p>
377 </dd>
378 <dt>
379 --depth=&lt;n&gt;
380 </dt>
381 <dd>
383 Maximum delta depth, for blob and tree deltification.
384 Default is 10.
385 </p>
386 </dd>
387 <dt>
388 --active-branches=&lt;n&gt;
389 </dt>
390 <dd>
392 Maximum number of branches to maintain active at once.
393 See &#8220;Memory Utilization&#8221; below for details. Default is 5.
394 </p>
395 </dd>
396 <dt>
397 --export-marks=&lt;file&gt;
398 </dt>
399 <dd>
401 Dumps the internal marks table to &lt;file&gt; when complete.
402 Marks are written one per line as <tt>:markid SHA-1</tt>.
403 Frontends can use this file to validate imports after they
404 have been completed, or to save the marks table across
405 incremental runs. As &lt;file&gt; is only opened and truncated
406 at checkpoint (or completion) the same path can also be
407 safely given to --import-marks.
408 </p>
409 </dd>
410 <dt>
411 --import-marks=&lt;file&gt;
412 </dt>
413 <dd>
415 Before processing any input, load the marks specified in
416 &lt;file&gt;. The input file must exist, must be readable, and
417 must use the same format as produced by --export-marks.
418 Multiple options may be supplied to import more than one
419 set of marks. If a mark is defined to different values,
420 the last file wins.
421 </p>
422 </dd>
423 <dt>
424 --export-pack-edges=&lt;file&gt;
425 </dt>
426 <dd>
428 After creating a packfile, print a line of data to
429 &lt;file&gt; listing the filename of the packfile and the last
430 commit on each branch that was written to that packfile.
431 This information may be useful after importing projects
432 whose total object set exceeds the 4 GiB packfile limit,
433 as these commits can be used as edge points during calls
434 to <em>git-pack-objects</em>.
435 </p>
436 </dd>
437 <dt>
438 --quiet
439 </dt>
440 <dd>
442 Disable all non-fatal output, making fast-import silent when it
443 is successful. This option disables the output shown by
444 --stats.
445 </p>
446 </dd>
447 <dt>
448 --stats
449 </dt>
450 <dd>
452 Display some basic statistics about the objects fast-import has
453 created, the packfiles they were stored into, and the
454 memory used by fast-import during this run. Showing this output
455 is currently the default, but can be disabled with --quiet.
456 </p>
457 </dd>
458 </dl></div>
459 </div>
460 <h2 id="_performance">Performance</h2>
461 <div class="sectionbody">
462 <div class="para"><p>The design of fast-import allows it to import large projects in a minimum
463 amount of memory usage and processing time. Assuming the frontend
464 is able to keep up with fast-import and feed it a constant stream of data,
465 import times for projects holding 10+ years of history and containing
466 100,000+ individual commits are generally completed in just 1-2
467 hours on quite modest (~$2,000 USD) hardware.</p></div>
468 <div class="para"><p>Most bottlenecks appear to be in foreign source data access (the
469 source just cannot extract revisions fast enough) or disk IO (fast-import
470 writes as fast as the disk will take the data). Imports will run
471 faster if the source data is stored on a different drive than the
472 destination Git repository (due to less IO contention).</p></div>
473 </div>
474 <h2 id="_development_cost">Development Cost</h2>
475 <div class="sectionbody">
476 <div class="para"><p>A typical frontend for fast-import tends to weigh in at approximately 200
477 lines of Perl/Python/Ruby code. Most developers have been able to
478 create working importers in just a couple of hours, even though it
479 is their first exposure to fast-import, and sometimes even to Git. This is
480 an ideal situation, given that most conversion tools are throw-away
481 (use once, and never look back).</p></div>
482 </div>
483 <h2 id="_parallel_operation">Parallel Operation</h2>
484 <div class="sectionbody">
485 <div class="para"><p>Like <em>git-push</em> or <em>git-fetch</em>, imports handled by fast-import are safe to
486 run alongside parallel <tt>git repack -a -d</tt> or <tt>git gc</tt> invocations,
487 or any other Git operation (including <em>git-prune</em>, as loose objects
488 are never used by fast-import).</p></div>
489 <div class="para"><p>fast-import does not lock the branch or tag refs it is actively importing.
490 After the import, during its ref update phase, fast-import tests each
491 existing branch ref to verify the update will be a fast-forward
492 update (the commit stored in the ref is contained in the new
493 history of the commit to be written). If the update is not a
494 fast-forward update, fast-import will skip updating that ref and instead
495 prints a warning message. fast-import will always attempt to update all
496 branch refs, and does not stop on the first failure.</p></div>
497 <div class="para"><p>Branch updates can be forced with --force, but its recommended that
498 this only be used on an otherwise quiet repository. Using --force
499 is not necessary for an initial import into an empty repository.</p></div>
500 </div>
501 <h2 id="_technical_discussion">Technical Discussion</h2>
502 <div class="sectionbody">
503 <div class="para"><p>fast-import tracks a set of branches in memory. Any branch can be created
504 or modified at any point during the import process by sending a
505 <tt>commit</tt> command on the input stream. This design allows a frontend
506 program to process an unlimited number of branches simultaneously,
507 generating commits in the order they are available from the source
508 data. It also simplifies the frontend programs considerably.</p></div>
509 <div class="para"><p>fast-import does not use or alter the current working directory, or any
510 file within it. (It does however update the current Git repository,
511 as referenced by <tt>GIT_DIR</tt>.) Therefore an import frontend may use
512 the working directory for its own purposes, such as extracting file
513 revisions from the foreign source. This ignorance of the working
514 directory also allows fast-import to run very quickly, as it does not
515 need to perform any costly file update operations when switching
516 between branches.</p></div>
517 </div>
518 <h2 id="_input_format">Input Format</h2>
519 <div class="sectionbody">
520 <div class="para"><p>With the exception of raw file data (which Git does not interpret)
521 the fast-import input format is text (ASCII) based. This text based
522 format simplifies development and debugging of frontend programs,
523 especially when a higher level language such as Perl, Python or
524 Ruby is being used.</p></div>
525 <div class="para"><p>fast-import is very strict about its input. Where we say SP below we mean
526 <strong>exactly</strong> one space. Likewise LF means one (and only one) linefeed.
527 Supplying additional whitespace characters will cause unexpected
528 results, such as branch names or file names with leading or trailing
529 spaces in their name, or early termination of fast-import when it encounters
530 unexpected input.</p></div>
531 <h3 id="_stream_comments">Stream Comments</h3><div style="clear:left"></div>
532 <div class="para"><p>To aid in debugging frontends fast-import ignores any line that
533 begins with <tt>#</tt> (ASCII pound/hash) up to and including the line
534 ending <tt>LF</tt>. A comment line may contain any sequence of bytes
535 that does not contain an LF and therefore may be used to include
536 any detailed debugging information that might be specific to the
537 frontend and useful when inspecting a fast-import data stream.</p></div>
538 <h3 id="_date_formats">Date Formats</h3><div style="clear:left"></div>
539 <div class="para"><p>The following date formats are supported. A frontend should select
540 the format it will use for this import by passing the format name
541 in the --date-format=&lt;fmt&gt; command line option.</p></div>
542 <div class="vlist"><dl>
543 <dt>
544 <tt>raw</tt>
545 </dt>
546 <dd>
548 This is the Git native format and is <tt>&lt;time&gt; SP &lt;offutc&gt;</tt>.
549 It is also fast-import's default format, if --date-format was
550 not specified.
551 </p>
552 <div class="para"><p>The time of the event is specified by <tt>&lt;time&gt;</tt> as the number of
553 seconds since the UNIX epoch (midnight, Jan 1, 1970, UTC) and is
554 written as an ASCII decimal integer.</p></div>
555 <div class="para"><p>The local offset is specified by <tt>&lt;offutc&gt;</tt> as a positive or negative
556 offset from UTC. For example EST (which is 5 hours behind UTC)
557 would be expressed in <tt>&lt;tz&gt;</tt> by &#8220;-0500&#8221; while UTC is &#8220;+0000&#8221;.
558 The local offset does not affect <tt>&lt;time&gt;</tt>; it is used only as an
559 advisement to help formatting routines display the timestamp.</p></div>
560 <div class="para"><p>If the local offset is not available in the source material, use
561 &#8220;+0000&#8221;, or the most common local offset. For example many
562 organizations have a CVS repository which has only ever been accessed
563 by users who are located in the same location and timezone. In this
564 case a reasonable offset from UTC could be assumed.</p></div>
565 <div class="para"><p>Unlike the <tt>rfc2822</tt> format, this format is very strict. Any
566 variation in formatting will cause fast-import to reject the value.</p></div>
567 </dd>
568 <dt>
569 <tt>rfc2822</tt>
570 </dt>
571 <dd>
573 This is the standard email format as described by RFC 2822.
574 </p>
575 <div class="para"><p>An example value is &#8220;Tue Feb 6 11:22:18 2007 -0500&#8221;. The Git
576 parser is accurate, but a little on the lenient side. It is the
577 same parser used by <em>git-am</em> when applying patches
578 received from email.</p></div>
579 <div class="para"><p>Some malformed strings may be accepted as valid dates. In some of
580 these cases Git will still be able to obtain the correct date from
581 the malformed string. There are also some types of malformed
582 strings which Git will parse wrong, and yet consider valid.
583 Seriously malformed strings will be rejected.</p></div>
584 <div class="para"><p>Unlike the <tt>raw</tt> format above, the timezone/UTC offset information
585 contained in an RFC 2822 date string is used to adjust the date
586 value to UTC prior to storage. Therefore it is important that
587 this information be as accurate as possible.</p></div>
588 <div class="para"><p>If the source material uses RFC 2822 style dates,
589 the frontend should let fast-import handle the parsing and conversion
590 (rather than attempting to do it itself) as the Git parser has
591 been well tested in the wild.</p></div>
592 <div class="para"><p>Frontends should prefer the <tt>raw</tt> format if the source material
593 already uses UNIX-epoch format, can be coaxed to give dates in that
594 format, or its format is easily convertible to it, as there is no
595 ambiguity in parsing.</p></div>
596 </dd>
597 <dt>
598 <tt>now</tt>
599 </dt>
600 <dd>
602 Always use the current time and timezone. The literal
603 <tt>now</tt> must always be supplied for <tt>&lt;when&gt;</tt>.
604 </p>
605 <div class="para"><p>This is a toy format. The current time and timezone of this system
606 is always copied into the identity string at the time it is being
607 created by fast-import. There is no way to specify a different time or
608 timezone.</p></div>
609 <div class="para"><p>This particular format is supplied as its short to implement and
610 may be useful to a process that wants to create a new commit
611 right now, without needing to use a working directory or
612 <em>git-update-index</em>.</p></div>
613 <div class="para"><p>If separate <tt>author</tt> and <tt>committer</tt> commands are used in a <tt>commit</tt>
614 the timestamps may not match, as the system clock will be polled
615 twice (once for each command). The only way to ensure that both
616 author and committer identity information has the same timestamp
617 is to omit <tt>author</tt> (thus copying from <tt>committer</tt>) or to use a
618 date format other than <tt>now</tt>.</p></div>
619 </dd>
620 </dl></div>
621 <h3 id="_commands">Commands</h3><div style="clear:left"></div>
622 <div class="para"><p>fast-import accepts several commands to update the current repository
623 and control the current import process. More detailed discussion
624 (with examples) of each command follows later.</p></div>
625 <div class="vlist"><dl>
626 <dt>
627 <tt>commit</tt>
628 </dt>
629 <dd>
631 Creates a new branch or updates an existing branch by
632 creating a new commit and updating the branch to point at
633 the newly created commit.
634 </p>
635 </dd>
636 <dt>
637 <tt>tag</tt>
638 </dt>
639 <dd>
641 Creates an annotated tag object from an existing commit or
642 branch. Lightweight tags are not supported by this command,
643 as they are not recommended for recording meaningful points
644 in time.
645 </p>
646 </dd>
647 <dt>
648 <tt>reset</tt>
649 </dt>
650 <dd>
652 Reset an existing branch (or a new branch) to a specific
653 revision. This command must be used to change a branch to
654 a specific revision without making a commit on it.
655 </p>
656 </dd>
657 <dt>
658 <tt>blob</tt>
659 </dt>
660 <dd>
662 Convert raw file data into a blob, for future use in a
663 <tt>commit</tt> command. This command is optional and is not
664 needed to perform an import.
665 </p>
666 </dd>
667 <dt>
668 <tt>checkpoint</tt>
669 </dt>
670 <dd>
672 Forces fast-import to close the current packfile, generate its
673 unique SHA-1 checksum and index, and start a new packfile.
674 This command is optional and is not needed to perform
675 an import.
676 </p>
677 </dd>
678 <dt>
679 <tt>progress</tt>
680 </dt>
681 <dd>
683 Causes fast-import to echo the entire line to its own
684 standard output. This command is optional and is not needed
685 to perform an import.
686 </p>
687 </dd>
688 </dl></div>
689 <h3 id="_tt_commit_tt"><tt>commit</tt></h3><div style="clear:left"></div>
690 <div class="para"><p>Create or update a branch with a new commit, recording one logical
691 change to the project.</p></div>
692 <div class="literalblock">
693 <div class="content">
694 <pre><tt> 'commit' SP &lt;ref&gt; LF
695 mark?
696 ('author' SP &lt;name&gt; SP LT &lt;email&gt; GT SP &lt;when&gt; LF)?
697 'committer' SP &lt;name&gt; SP LT &lt;email&gt; GT SP &lt;when&gt; LF
698 data
699 ('from' SP &lt;committish&gt; LF)?
700 ('merge' SP &lt;committish&gt; LF)?
701 (filemodify | filedelete | filecopy | filerename | filedeleteall)*
702 LF?</tt></pre>
703 </div></div>
704 <div class="para"><p>where <tt>&lt;ref&gt;</tt> is the name of the branch to make the commit on.
705 Typically branch names are prefixed with <tt>refs/heads/</tt> in
706 Git, so importing the CVS branch symbol <tt>RELENG-1_0</tt> would use
707 <tt>refs/heads/RELENG-1_0</tt> for the value of <tt>&lt;ref&gt;</tt>. The value of
708 <tt>&lt;ref&gt;</tt> must be a valid refname in Git. As <tt>LF</tt> is not valid in
709 a Git refname, no quoting or escaping syntax is supported here.</p></div>
710 <div class="para"><p>A <tt>mark</tt> command may optionally appear, requesting fast-import to save a
711 reference to the newly created commit for future use by the frontend
712 (see below for format). It is very common for frontends to mark
713 every commit they create, thereby allowing future branch creation
714 from any imported commit.</p></div>
715 <div class="para"><p>The <tt>data</tt> command following <tt>committer</tt> must supply the commit
716 message (see below for <tt>data</tt> command syntax). To import an empty
717 commit message use a 0 length data. Commit messages are free-form
718 and are not interpreted by Git. Currently they must be encoded in
719 UTF-8, as fast-import does not permit other encodings to be specified.</p></div>
720 <div class="para"><p>Zero or more <tt>filemodify</tt>, <tt>filedelete</tt>, <tt>filecopy</tt>, <tt>filerename</tt>
721 and <tt>filedeleteall</tt> commands
722 may be included to update the contents of the branch prior to
723 creating the commit. These commands may be supplied in any order.
724 However it is recommended that a <tt>filedeleteall</tt> command precede
725 all <tt>filemodify</tt>, <tt>filecopy</tt> and <tt>filerename</tt> commands in the same
726 commit, as <tt>filedeleteall</tt>
727 wipes the branch clean (see below).</p></div>
728 <div class="para"><p>The <tt>LF</tt> after the command is optional (it used to be required).</p></div>
729 <h4 id="_tt_author_tt"><tt>author</tt></h4>
730 <div class="para"><p>An <tt>author</tt> command may optionally appear, if the author information
731 might differ from the committer information. If <tt>author</tt> is omitted
732 then fast-import will automatically use the committer's information for
733 the author portion of the commit. See below for a description of
734 the fields in <tt>author</tt>, as they are identical to <tt>committer</tt>.</p></div>
735 <h4 id="_tt_committer_tt"><tt>committer</tt></h4>
736 <div class="para"><p>The <tt>committer</tt> command indicates who made this commit, and when
737 they made it.</p></div>
738 <div class="para"><p>Here <tt>&lt;name&gt;</tt> is the person's display name (for example
739 &#8220;Com M Itter&#8221;) and <tt>&lt;email&gt;</tt> is the person's email address
740 (&#8220;cm@example.com&#8221;). <tt>LT</tt> and <tt>GT</tt> are the literal less-than (\x3c)
741 and greater-than (\x3e) symbols. These are required to delimit
742 the email address from the other fields in the line. Note that
743 <tt>&lt;name&gt;</tt> is free-form and may contain any sequence of bytes, except
744 <tt>LT</tt> and <tt>LF</tt>. It is typically UTF-8 encoded.</p></div>
745 <div class="para"><p>The time of the change is specified by <tt>&lt;when&gt;</tt> using the date format
746 that was selected by the --date-format=&lt;fmt&gt; command line option.
747 See &#8220;Date Formats&#8221; above for the set of supported formats, and
748 their syntax.</p></div>
749 <h4 id="_tt_from_tt"><tt>from</tt></h4>
750 <div class="para"><p>The <tt>from</tt> command is used to specify the commit to initialize
751 this branch from. This revision will be the first ancestor of the
752 new commit.</p></div>
753 <div class="para"><p>Omitting the <tt>from</tt> command in the first commit of a new branch
754 will cause fast-import to create that commit with no ancestor. This
755 tends to be desired only for the initial commit of a project.
756 If the frontend creates all files from scratch when making a new
757 branch, a <tt>merge</tt> command may be used instead of <tt>from</tt> to start
758 the commit with an empty tree.
759 Omitting the <tt>from</tt> command on existing branches is usually desired,
760 as the current commit on that branch is automatically assumed to
761 be the first ancestor of the new commit.</p></div>
762 <div class="para"><p>As <tt>LF</tt> is not valid in a Git refname or SHA-1 expression, no
763 quoting or escaping syntax is supported within <tt>&lt;committish&gt;</tt>.</p></div>
764 <div class="para"><p>Here <tt>&lt;committish&gt;</tt> is any of the following:</p></div>
765 <div class="ilist"><ul>
766 <li>
768 The name of an existing branch already in fast-import's internal branch
769 table. If fast-import doesn't know the name, its treated as a SHA-1
770 expression.
771 </p>
772 </li>
773 <li>
775 A mark reference, <tt>:&lt;idnum&gt;</tt>, where <tt>&lt;idnum&gt;</tt> is the mark number.
776 </p>
777 <div class="para"><p>The reason fast-import uses <tt>:</tt> to denote a mark reference is this character
778 is not legal in a Git branch name. The leading <tt>:</tt> makes it easy
779 to distinguish between the mark 42 (<tt>:42</tt>) and the branch 42 (<tt>42</tt>
780 or <tt>refs/heads/42</tt>), or an abbreviated SHA-1 which happened to
781 consist only of base-10 digits.</p></div>
782 <div class="para"><p>Marks must be declared (via <tt>mark</tt>) before they can be used.</p></div>
783 </li>
784 <li>
786 A complete 40 byte or abbreviated commit SHA-1 in hex.
787 </p>
788 </li>
789 <li>
791 Any valid Git SHA-1 expression that resolves to a commit. See
792 &#8220;SPECIFYING REVISIONS&#8221; in <a href="git-rev-parse.html">git-rev-parse(1)</a> for details.
793 </p>
794 </li>
795 </ul></div>
796 <div class="para"><p>The special case of restarting an incremental import from the
797 current branch value should be written as:</p></div>
798 <div class="listingblock">
799 <div class="content">
800 <pre><tt> from refs/heads/branch^0</tt></pre>
801 </div></div>
802 <div class="para"><p>The <tt>&#94;0</tt> suffix is necessary as fast-import does not permit a branch to
803 start from itself, and the branch is created in memory before the
804 <tt>from</tt> command is even read from the input. Adding <tt>&#94;0</tt> will force
805 fast-import to resolve the commit through Git's revision parsing library,
806 rather than its internal branch table, thereby loading in the
807 existing value of the branch.</p></div>
808 <h4 id="_tt_merge_tt"><tt>merge</tt></h4>
809 <div class="para"><p>Includes one additional ancestor commit. If the <tt>from</tt> command is
810 omitted when creating a new branch, the first <tt>merge</tt> commit will be
811 the first ancestor of the current commit, and the branch will start
812 out with no files. An unlimited number of <tt>merge</tt> commands per
813 commit are permitted by fast-import, thereby establishing an n-way merge.
814 However Git's other tools never create commits with more than 15
815 additional ancestors (forming a 16-way merge). For this reason
816 it is suggested that frontends do not use more than 15 <tt>merge</tt>
817 commands per commit; 16, if starting a new, empty branch.</p></div>
818 <div class="para"><p>Here <tt>&lt;committish&gt;</tt> is any of the commit specification expressions
819 also accepted by <tt>from</tt> (see above).</p></div>
820 <h4 id="_tt_filemodify_tt"><tt>filemodify</tt></h4>
821 <div class="para"><p>Included in a <tt>commit</tt> command to add a new file or change the
822 content of an existing file. This command has two different means
823 of specifying the content of the file.</p></div>
824 <div class="vlist"><dl>
825 <dt>
826 External data format
827 </dt>
828 <dd>
830 The data content for the file was already supplied by a prior
831 <tt>blob</tt> command. The frontend just needs to connect it.
832 </p>
833 <div class="literalblock">
834 <div class="content">
835 <pre><tt> 'M' SP &lt;mode&gt; SP &lt;dataref&gt; SP &lt;path&gt; LF</tt></pre>
836 </div></div>
837 <div class="para"><p>Here <tt>&lt;dataref&gt;</tt> can be either a mark reference (<tt>:&lt;idnum&gt;</tt>)
838 set by a prior <tt>blob</tt> command, or a full 40-byte SHA-1 of an
839 existing Git blob object.</p></div>
840 </dd>
841 <dt>
842 Inline data format
843 </dt>
844 <dd>
846 The data content for the file has not been supplied yet.
847 The frontend wants to supply it as part of this modify
848 command.
849 </p>
850 <div class="literalblock">
851 <div class="content">
852 <pre><tt> 'M' SP &lt;mode&gt; SP 'inline' SP &lt;path&gt; LF
853 data</tt></pre>
854 </div></div>
855 <div class="para"><p>See below for a detailed description of the <tt>data</tt> command.</p></div>
856 </dd>
857 </dl></div>
858 <div class="para"><p>In both formats <tt>&lt;mode&gt;</tt> is the type of file entry, specified
859 in octal. Git only supports the following modes:</p></div>
860 <div class="ilist"><ul>
861 <li>
863 <tt>100644</tt> or <tt>644</tt>: A normal (not-executable) file. The majority
864 of files in most projects use this mode. If in doubt, this is
865 what you want.
866 </p>
867 </li>
868 <li>
870 <tt>100755</tt> or <tt>755</tt>: A normal, but executable, file.
871 </p>
872 </li>
873 <li>
875 <tt>120000</tt>: A symlink, the content of the file will be the link target.
876 </p>
877 </li>
878 <li>
880 <tt>160000</tt>: A gitlink, SHA-1 of the object refers to a commit in
881 another repository. Git links can only be specified by SHA or through
882 a commit mark. They are used to implement submodules.
883 </p>
884 </li>
885 </ul></div>
886 <div class="para"><p>In both formats <tt>&lt;path&gt;</tt> is the complete path of the file to be added
887 (if not already existing) or modified (if already existing).</p></div>
888 <div class="para"><p>A <tt>&lt;path&gt;</tt> string must use UNIX-style directory separators (forward
889 slash <tt>/</tt>), may contain any byte other than <tt>LF</tt>, and must not
890 start with double quote (<tt>"</tt>).</p></div>
891 <div class="para"><p>If an <tt>LF</tt> or double quote must be encoded into <tt>&lt;path&gt;</tt> shell-style
892 quoting should be used, e.g. <tt>"path/with\n and \" in it"</tt>.</p></div>
893 <div class="para"><p>The value of <tt>&lt;path&gt;</tt> must be in canonical form. That is it must not:</p></div>
894 <div class="ilist"><ul>
895 <li>
897 contain an empty directory component (e.g. <tt>foo//bar</tt> is invalid),
898 </p>
899 </li>
900 <li>
902 end with a directory separator (e.g. <tt>foo/</tt> is invalid),
903 </p>
904 </li>
905 <li>
907 start with a directory separator (e.g. <tt>/foo</tt> is invalid),
908 </p>
909 </li>
910 <li>
912 contain the special component <tt>.</tt> or <tt>..</tt> (e.g. <tt>foo/./bar</tt> and
913 <tt>foo/../bar</tt> are invalid).
914 </p>
915 </li>
916 </ul></div>
917 <div class="para"><p>It is recommended that <tt>&lt;path&gt;</tt> always be encoded using UTF-8.</p></div>
918 <h4 id="_tt_filedelete_tt"><tt>filedelete</tt></h4>
919 <div class="para"><p>Included in a <tt>commit</tt> command to remove a file or recursively
920 delete an entire directory from the branch. If the file or directory
921 removal makes its parent directory empty, the parent directory will
922 be automatically removed too. This cascades up the tree until the
923 first non-empty directory or the root is reached.</p></div>
924 <div class="literalblock">
925 <div class="content">
926 <pre><tt> 'D' SP &lt;path&gt; LF</tt></pre>
927 </div></div>
928 <div class="para"><p>here <tt>&lt;path&gt;</tt> is the complete path of the file or subdirectory to
929 be removed from the branch.
930 See <tt>filemodify</tt> above for a detailed description of <tt>&lt;path&gt;</tt>.</p></div>
931 <h4 id="_tt_filecopy_tt"><tt>filecopy</tt></h4>
932 <div class="para"><p>Recursively copies an existing file or subdirectory to a different
933 location within the branch. The existing file or directory must
934 exist. If the destination exists it will be completely replaced
935 by the content copied from the source.</p></div>
936 <div class="literalblock">
937 <div class="content">
938 <pre><tt> 'C' SP &lt;path&gt; SP &lt;path&gt; LF</tt></pre>
939 </div></div>
940 <div class="para"><p>here the first <tt>&lt;path&gt;</tt> is the source location and the second
941 <tt>&lt;path&gt;</tt> is the destination. See <tt>filemodify</tt> above for a detailed
942 description of what <tt>&lt;path&gt;</tt> may look like. To use a source path
943 that contains SP the path must be quoted.</p></div>
944 <div class="para"><p>A <tt>filecopy</tt> command takes effect immediately. Once the source
945 location has been copied to the destination any future commands
946 applied to the source location will not impact the destination of
947 the copy.</p></div>
948 <h4 id="_tt_filerename_tt"><tt>filerename</tt></h4>
949 <div class="para"><p>Renames an existing file or subdirectory to a different location
950 within the branch. The existing file or directory must exist. If
951 the destination exists it will be replaced by the source directory.</p></div>
952 <div class="literalblock">
953 <div class="content">
954 <pre><tt> 'R' SP &lt;path&gt; SP &lt;path&gt; LF</tt></pre>
955 </div></div>
956 <div class="para"><p>here the first <tt>&lt;path&gt;</tt> is the source location and the second
957 <tt>&lt;path&gt;</tt> is the destination. See <tt>filemodify</tt> above for a detailed
958 description of what <tt>&lt;path&gt;</tt> may look like. To use a source path
959 that contains SP the path must be quoted.</p></div>
960 <div class="para"><p>A <tt>filerename</tt> command takes effect immediately. Once the source
961 location has been renamed to the destination any future commands
962 applied to the source location will create new files there and not
963 impact the destination of the rename.</p></div>
964 <div class="para"><p>Note that a <tt>filerename</tt> is the same as a <tt>filecopy</tt> followed by a
965 <tt>filedelete</tt> of the source location. There is a slight performance
966 advantage to using <tt>filerename</tt>, but the advantage is so small
967 that it is never worth trying to convert a delete/add pair in
968 source material into a rename for fast-import. This <tt>filerename</tt>
969 command is provided just to simplify frontends that already have
970 rename information and don't want bother with decomposing it into a
971 <tt>filecopy</tt> followed by a <tt>filedelete</tt>.</p></div>
972 <h4 id="_tt_filedeleteall_tt"><tt>filedeleteall</tt></h4>
973 <div class="para"><p>Included in a <tt>commit</tt> command to remove all files (and also all
974 directories) from the branch. This command resets the internal
975 branch structure to have no files in it, allowing the frontend
976 to subsequently add all interesting files from scratch.</p></div>
977 <div class="literalblock">
978 <div class="content">
979 <pre><tt> 'deleteall' LF</tt></pre>
980 </div></div>
981 <div class="para"><p>This command is extremely useful if the frontend does not know
982 (or does not care to know) what files are currently on the branch,
983 and therefore cannot generate the proper <tt>filedelete</tt> commands to
984 update the content.</p></div>
985 <div class="para"><p>Issuing a <tt>filedeleteall</tt> followed by the needed <tt>filemodify</tt>
986 commands to set the correct content will produce the same results
987 as sending only the needed <tt>filemodify</tt> and <tt>filedelete</tt> commands.
988 The <tt>filedeleteall</tt> approach may however require fast-import to use slightly
989 more memory per active branch (less than 1 MiB for even most large
990 projects); so frontends that can easily obtain only the affected
991 paths for a commit are encouraged to do so.</p></div>
992 <h3 id="_tt_mark_tt"><tt>mark</tt></h3><div style="clear:left"></div>
993 <div class="para"><p>Arranges for fast-import to save a reference to the current object, allowing
994 the frontend to recall this object at a future point in time, without
995 knowing its SHA-1. Here the current object is the object creation
996 command the <tt>mark</tt> command appears within. This can be <tt>commit</tt>,
997 <tt>tag</tt>, and <tt>blob</tt>, but <tt>commit</tt> is the most common usage.</p></div>
998 <div class="literalblock">
999 <div class="content">
1000 <pre><tt> 'mark' SP ':' &lt;idnum&gt; LF</tt></pre>
1001 </div></div>
1002 <div class="para"><p>where <tt>&lt;idnum&gt;</tt> is the number assigned by the frontend to this mark.
1003 The value of <tt>&lt;idnum&gt;</tt> is expressed as an ASCII decimal integer.
1004 The value 0 is reserved and cannot be used as
1005 a mark. Only values greater than or equal to 1 may be used as marks.</p></div>
1006 <div class="para"><p>New marks are created automatically. Existing marks can be moved
1007 to another object simply by reusing the same <tt>&lt;idnum&gt;</tt> in another
1008 <tt>mark</tt> command.</p></div>
1009 <h3 id="_tt_tag_tt"><tt>tag</tt></h3><div style="clear:left"></div>
1010 <div class="para"><p>Creates an annotated tag referring to a specific commit. To create
1011 lightweight (non-annotated) tags see the <tt>reset</tt> command below.</p></div>
1012 <div class="literalblock">
1013 <div class="content">
1014 <pre><tt> 'tag' SP &lt;name&gt; LF
1015 'from' SP &lt;committish&gt; LF
1016 'tagger' SP &lt;name&gt; SP LT &lt;email&gt; GT SP &lt;when&gt; LF
1017 data</tt></pre>
1018 </div></div>
1019 <div class="para"><p>where <tt>&lt;name&gt;</tt> is the name of the tag to create.</p></div>
1020 <div class="para"><p>Tag names are automatically prefixed with <tt>refs/tags/</tt> when stored
1021 in Git, so importing the CVS branch symbol <tt>RELENG-1_0-FINAL</tt> would
1022 use just <tt>RELENG-1_0-FINAL</tt> for <tt>&lt;name&gt;</tt>, and fast-import will write the
1023 corresponding ref as <tt>refs/tags/RELENG-1_0-FINAL</tt>.</p></div>
1024 <div class="para"><p>The value of <tt>&lt;name&gt;</tt> must be a valid refname in Git and therefore
1025 may contain forward slashes. As <tt>LF</tt> is not valid in a Git refname,
1026 no quoting or escaping syntax is supported here.</p></div>
1027 <div class="para"><p>The <tt>from</tt> command is the same as in the <tt>commit</tt> command; see
1028 above for details.</p></div>
1029 <div class="para"><p>The <tt>tagger</tt> command uses the same format as <tt>committer</tt> within
1030 <tt>commit</tt>; again see above for details.</p></div>
1031 <div class="para"><p>The <tt>data</tt> command following <tt>tagger</tt> must supply the annotated tag
1032 message (see below for <tt>data</tt> command syntax). To import an empty
1033 tag message use a 0 length data. Tag messages are free-form and are
1034 not interpreted by Git. Currently they must be encoded in UTF-8,
1035 as fast-import does not permit other encodings to be specified.</p></div>
1036 <div class="para"><p>Signing annotated tags during import from within fast-import is not
1037 supported. Trying to include your own PGP/GPG signature is not
1038 recommended, as the frontend does not (easily) have access to the
1039 complete set of bytes which normally goes into such a signature.
1040 If signing is required, create lightweight tags from within fast-import with
1041 <tt>reset</tt>, then create the annotated versions of those tags offline
1042 with the standard <em>git-tag</em> process.</p></div>
1043 <h3 id="_tt_reset_tt"><tt>reset</tt></h3><div style="clear:left"></div>
1044 <div class="para"><p>Creates (or recreates) the named branch, optionally starting from
1045 a specific revision. The reset command allows a frontend to issue
1046 a new <tt>from</tt> command for an existing branch, or to create a new
1047 branch from an existing commit without creating a new commit.</p></div>
1048 <div class="literalblock">
1049 <div class="content">
1050 <pre><tt> 'reset' SP &lt;ref&gt; LF
1051 ('from' SP &lt;committish&gt; LF)?
1052 LF?</tt></pre>
1053 </div></div>
1054 <div class="para"><p>For a detailed description of <tt>&lt;ref&gt;</tt> and <tt>&lt;committish&gt;</tt> see above
1055 under <tt>commit</tt> and <tt>from</tt>.</p></div>
1056 <div class="para"><p>The <tt>LF</tt> after the command is optional (it used to be required).</p></div>
1057 <div class="para"><p>The <tt>reset</tt> command can also be used to create lightweight
1058 (non-annotated) tags. For example:</p></div>
1059 <div class="exampleblock">
1060 <div class="exampleblock-content">
1061 <div class="literalblock">
1062 <div class="content">
1063 <pre><tt>reset refs/tags/938
1064 from :938</tt></pre>
1065 </div></div>
1066 </div></div>
1067 <div class="para"><p>would create the lightweight tag <tt>refs/tags/938</tt> referring to
1068 whatever commit mark <tt>:938</tt> references.</p></div>
1069 <h3 id="_tt_blob_tt"><tt>blob</tt></h3><div style="clear:left"></div>
1070 <div class="para"><p>Requests writing one file revision to the packfile. The revision
1071 is not connected to any commit; this connection must be formed in
1072 a subsequent <tt>commit</tt> command by referencing the blob through an
1073 assigned mark.</p></div>
1074 <div class="literalblock">
1075 <div class="content">
1076 <pre><tt> 'blob' LF
1077 mark?
1078 data</tt></pre>
1079 </div></div>
1080 <div class="para"><p>The mark command is optional here as some frontends have chosen
1081 to generate the Git SHA-1 for the blob on their own, and feed that
1082 directly to <tt>commit</tt>. This is typically more work than its worth
1083 however, as marks are inexpensive to store and easy to use.</p></div>
1084 <h3 id="_tt_data_tt"><tt>data</tt></h3><div style="clear:left"></div>
1085 <div class="para"><p>Supplies raw data (for use as blob/file content, commit messages, or
1086 annotated tag messages) to fast-import. Data can be supplied using an exact
1087 byte count or delimited with a terminating line. Real frontends
1088 intended for production-quality conversions should always use the
1089 exact byte count format, as it is more robust and performs better.
1090 The delimited format is intended primarily for testing fast-import.</p></div>
1091 <div class="para"><p>Comment lines appearing within the <tt>&lt;raw&gt;</tt> part of <tt>data</tt> commands
1092 are always taken to be part of the body of the data and are therefore
1093 never ignored by fast-import. This makes it safe to import any
1094 file/message content whose lines might start with <tt>#</tt>.</p></div>
1095 <div class="vlist"><dl>
1096 <dt>
1097 Exact byte count format
1098 </dt>
1099 <dd>
1101 The frontend must specify the number of bytes of data.
1102 </p>
1103 <div class="literalblock">
1104 <div class="content">
1105 <pre><tt> 'data' SP &lt;count&gt; LF
1106 &lt;raw&gt; LF?</tt></pre>
1107 </div></div>
1108 <div class="para"><p>where <tt>&lt;count&gt;</tt> is the exact number of bytes appearing within
1109 <tt>&lt;raw&gt;</tt>. The value of <tt>&lt;count&gt;</tt> is expressed as an ASCII decimal
1110 integer. The <tt>LF</tt> on either side of <tt>&lt;raw&gt;</tt> is not
1111 included in <tt>&lt;count&gt;</tt> and will not be included in the imported data.</p></div>
1112 <div class="para"><p>The <tt>LF</tt> after <tt>&lt;raw&gt;</tt> is optional (it used to be required) but
1113 recommended. Always including it makes debugging a fast-import
1114 stream easier as the next command always starts in column 0
1115 of the next line, even if <tt>&lt;raw&gt;</tt> did not end with an <tt>LF</tt>.</p></div>
1116 </dd>
1117 <dt>
1118 Delimited format
1119 </dt>
1120 <dd>
1122 A delimiter string is used to mark the end of the data.
1123 fast-import will compute the length by searching for the delimiter.
1124 This format is primarily useful for testing and is not
1125 recommended for real data.
1126 </p>
1127 <div class="literalblock">
1128 <div class="content">
1129 <pre><tt> 'data' SP '&lt;&lt;' &lt;delim&gt; LF
1130 &lt;raw&gt; LF
1131 &lt;delim&gt; LF
1132 LF?</tt></pre>
1133 </div></div>
1134 <div class="para"><p>where <tt>&lt;delim&gt;</tt> is the chosen delimiter string. The string <tt>&lt;delim&gt;</tt>
1135 must not appear on a line by itself within <tt>&lt;raw&gt;</tt>, as otherwise
1136 fast-import will think the data ends earlier than it really does. The <tt>LF</tt>
1137 immediately trailing <tt>&lt;raw&gt;</tt> is part of <tt>&lt;raw&gt;</tt>. This is one of
1138 the limitations of the delimited format, it is impossible to supply
1139 a data chunk which does not have an LF as its last byte.</p></div>
1140 <div class="para"><p>The <tt>LF</tt> after <tt>&lt;delim&gt; LF</tt> is optional (it used to be required).</p></div>
1141 </dd>
1142 </dl></div>
1143 <h3 id="_tt_checkpoint_tt"><tt>checkpoint</tt></h3><div style="clear:left"></div>
1144 <div class="para"><p>Forces fast-import to close the current packfile, start a new one, and to
1145 save out all current branch refs, tags and marks.</p></div>
1146 <div class="literalblock">
1147 <div class="content">
1148 <pre><tt> 'checkpoint' LF
1149 LF?</tt></pre>
1150 </div></div>
1151 <div class="para"><p>Note that fast-import automatically switches packfiles when the current
1152 packfile reaches --max-pack-size, or 4 GiB, whichever limit is
1153 smaller. During an automatic packfile switch fast-import does not update
1154 the branch refs, tags or marks.</p></div>
1155 <div class="para"><p>As a <tt>checkpoint</tt> can require a significant amount of CPU time and
1156 disk IO (to compute the overall pack SHA-1 checksum, generate the
1157 corresponding index file, and update the refs) it can easily take
1158 several minutes for a single <tt>checkpoint</tt> command to complete.</p></div>
1159 <div class="para"><p>Frontends may choose to issue checkpoints during extremely large
1160 and long running imports, or when they need to allow another Git
1161 process access to a branch. However given that a 30 GiB Subversion
1162 repository can be loaded into Git through fast-import in about 3 hours,
1163 explicit checkpointing may not be necessary.</p></div>
1164 <div class="para"><p>The <tt>LF</tt> after the command is optional (it used to be required).</p></div>
1165 <h3 id="_tt_progress_tt"><tt>progress</tt></h3><div style="clear:left"></div>
1166 <div class="para"><p>Causes fast-import to print the entire <tt>progress</tt> line unmodified to
1167 its standard output channel (file descriptor 1) when the command is
1168 processed from the input stream. The command otherwise has no impact
1169 on the current import, or on any of fast-import's internal state.</p></div>
1170 <div class="literalblock">
1171 <div class="content">
1172 <pre><tt> 'progress' SP &lt;any&gt; LF
1173 LF?</tt></pre>
1174 </div></div>
1175 <div class="para"><p>The <tt>&lt;any&gt;</tt> part of the command may contain any sequence of bytes
1176 that does not contain <tt>LF</tt>. The <tt>LF</tt> after the command is optional.
1177 Callers may wish to process the output through a tool such as sed to
1178 remove the leading part of the line, for example:</p></div>
1179 <div class="exampleblock">
1180 <div class="exampleblock-content">
1181 <div class="literalblock">
1182 <div class="content">
1183 <pre><tt>frontend | git fast-import | sed 's/^progress //'</tt></pre>
1184 </div></div>
1185 </div></div>
1186 <div class="para"><p>Placing a <tt>progress</tt> command immediately after a <tt>checkpoint</tt> will
1187 inform the reader when the <tt>checkpoint</tt> has been completed and it
1188 can safely access the refs that fast-import updated.</p></div>
1189 </div>
1190 <h2 id="_crash_reports">Crash Reports</h2>
1191 <div class="sectionbody">
1192 <div class="para"><p>If fast-import is supplied invalid input it will terminate with a
1193 non-zero exit status and create a crash report in the top level of
1194 the Git repository it was importing into. Crash reports contain
1195 a snapshot of the internal fast-import state as well as the most
1196 recent commands that lead up to the crash.</p></div>
1197 <div class="para"><p>All recent commands (including stream comments, file changes and
1198 progress commands) are shown in the command history within the crash
1199 report, but raw file data and commit messages are excluded from the
1200 crash report. This exclusion saves space within the report file
1201 and reduces the amount of buffering that fast-import must perform
1202 during execution.</p></div>
1203 <div class="para"><p>After writing a crash report fast-import will close the current
1204 packfile and export the marks table. This allows the frontend
1205 developer to inspect the repository state and resume the import from
1206 the point where it crashed. The modified branches and tags are not
1207 updated during a crash, as the import did not complete successfully.
1208 Branch and tag information can be found in the crash report and
1209 must be applied manually if the update is needed.</p></div>
1210 <div class="para"><p>An example crash:</p></div>
1211 <div class="exampleblock">
1212 <div class="exampleblock-content">
1213 <div class="literalblock">
1214 <div class="content">
1215 <pre><tt>$ cat &gt;in &lt;&lt;END_OF_INPUT
1216 # my very first test commit
1217 commit refs/heads/master
1218 committer Shawn O. Pearce &lt;spearce&gt; 19283 -0400
1219 # who is that guy anyway?
1220 data &lt;&lt;EOF
1221 this is my commit
1223 M 644 inline .gitignore
1224 data &lt;&lt;EOF
1225 .gitignore
1227 M 777 inline bob
1228 END_OF_INPUT</tt></pre>
1229 </div></div>
1230 <div class="literalblock">
1231 <div class="content">
1232 <pre><tt>$ git fast-import &lt;in
1233 fatal: Corrupt mode: M 777 inline bob
1234 fast-import: dumping crash report to .git/fast_import_crash_8434</tt></pre>
1235 </div></div>
1236 <div class="literalblock">
1237 <div class="content">
1238 <pre><tt>$ cat .git/fast_import_crash_8434
1239 fast-import crash report:
1240 fast-import process: 8434
1241 parent process : 1391
1242 at Sat Sep 1 00:58:12 2007</tt></pre>
1243 </div></div>
1244 <div class="literalblock">
1245 <div class="content">
1246 <pre><tt>fatal: Corrupt mode: M 777 inline bob</tt></pre>
1247 </div></div>
1248 <div class="literalblock">
1249 <div class="content">
1250 <pre><tt>Most Recent Commands Before Crash
1251 ---------------------------------
1252 # my very first test commit
1253 commit refs/heads/master
1254 committer Shawn O. Pearce &lt;spearce&gt; 19283 -0400
1255 # who is that guy anyway?
1256 data &lt;&lt;EOF
1257 M 644 inline .gitignore
1258 data &lt;&lt;EOF
1259 * M 777 inline bob</tt></pre>
1260 </div></div>
1261 <div class="literalblock">
1262 <div class="content">
1263 <pre><tt>Active Branch LRU
1264 -----------------
1265 active_branches = 1 cur, 5 max</tt></pre>
1266 </div></div>
1267 <div class="literalblock">
1268 <div class="content">
1269 <pre><tt>pos clock name
1270 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1271 1) 0 refs/heads/master</tt></pre>
1272 </div></div>
1273 <div class="literalblock">
1274 <div class="content">
1275 <pre><tt>Inactive Branches
1276 -----------------
1277 refs/heads/master:
1278 status : active loaded dirty
1279 tip commit : 0000000000000000000000000000000000000000
1280 old tree : 0000000000000000000000000000000000000000
1281 cur tree : 0000000000000000000000000000000000000000
1282 commit clock: 0
1283 last pack :</tt></pre>
1284 </div></div>
1285 <div class="literalblock">
1286 <div class="content">
1287 <pre><tt>-------------------
1288 END OF CRASH REPORT</tt></pre>
1289 </div></div>
1290 </div></div>
1291 </div>
1292 <h2 id="_tips_and_tricks">Tips and Tricks</h2>
1293 <div class="sectionbody">
1294 <div class="para"><p>The following tips and tricks have been collected from various
1295 users of fast-import, and are offered here as suggestions.</p></div>
1296 <h3 id="_use_one_mark_per_commit">Use One Mark Per Commit</h3><div style="clear:left"></div>
1297 <div class="para"><p>When doing a repository conversion, use a unique mark per commit
1298 (<tt>mark :&lt;n&gt;</tt>) and supply the --export-marks option on the command
1299 line. fast-import will dump a file which lists every mark and the Git
1300 object SHA-1 that corresponds to it. If the frontend can tie
1301 the marks back to the source repository, it is easy to verify the
1302 accuracy and completeness of the import by comparing each Git
1303 commit to the corresponding source revision.</p></div>
1304 <div class="para"><p>Coming from a system such as Perforce or Subversion this should be
1305 quite simple, as the fast-import mark can also be the Perforce changeset
1306 number or the Subversion revision number.</p></div>
1307 <h3 id="_freely_skip_around_branches">Freely Skip Around Branches</h3><div style="clear:left"></div>
1308 <div class="para"><p>Don't bother trying to optimize the frontend to stick to one branch
1309 at a time during an import. Although doing so might be slightly
1310 faster for fast-import, it tends to increase the complexity of the frontend
1311 code considerably.</p></div>
1312 <div class="para"><p>The branch LRU builtin to fast-import tends to behave very well, and the
1313 cost of activating an inactive branch is so low that bouncing around
1314 between branches has virtually no impact on import performance.</p></div>
1315 <h3 id="_handling_renames">Handling Renames</h3><div style="clear:left"></div>
1316 <div class="para"><p>When importing a renamed file or directory, simply delete the old
1317 name(s) and modify the new name(s) during the corresponding commit.
1318 Git performs rename detection after-the-fact, rather than explicitly
1319 during a commit.</p></div>
1320 <h3 id="_use_tag_fixup_branches">Use Tag Fixup Branches</h3><div style="clear:left"></div>
1321 <div class="para"><p>Some other SCM systems let the user create a tag from multiple
1322 files which are not from the same commit/changeset. Or to create
1323 tags which are a subset of the files available in the repository.</p></div>
1324 <div class="para"><p>Importing these tags as-is in Git is impossible without making at
1325 least one commit which &#8220;fixes up&#8221; the files to match the content
1326 of the tag. Use fast-import's <tt>reset</tt> command to reset a dummy branch
1327 outside of your normal branch space to the base commit for the tag,
1328 then commit one or more file fixup commits, and finally tag the
1329 dummy branch.</p></div>
1330 <div class="para"><p>For example since all normal branches are stored under <tt>refs/heads/</tt>
1331 name the tag fixup branch <tt>TAG_FIXUP</tt>. This way it is impossible for
1332 the fixup branch used by the importer to have namespace conflicts
1333 with real branches imported from the source (the name <tt>TAG_FIXUP</tt>
1334 is not <tt>refs/heads/TAG_FIXUP</tt>).</p></div>
1335 <div class="para"><p>When committing fixups, consider using <tt>merge</tt> to connect the
1336 commit(s) which are supplying file revisions to the fixup branch.
1337 Doing so will allow tools such as <em>git-blame</em> to track
1338 through the real commit history and properly annotate the source
1339 files.</p></div>
1340 <div class="para"><p>After fast-import terminates the frontend will need to do <tt>rm .git/TAG_FIXUP</tt>
1341 to remove the dummy branch.</p></div>
1342 <h3 id="_import_now_repack_later">Import Now, Repack Later</h3><div style="clear:left"></div>
1343 <div class="para"><p>As soon as fast-import completes the Git repository is completely valid
1344 and ready for use. Typically this takes only a very short time,
1345 even for considerably large projects (100,000+ commits).</p></div>
1346 <div class="para"><p>However repacking the repository is necessary to improve data
1347 locality and access performance. It can also take hours on extremely
1348 large projects (especially if -f and a large --window parameter is
1349 used). Since repacking is safe to run alongside readers and writers,
1350 run the repack in the background and let it finish when it finishes.
1351 There is no reason to wait to explore your new Git project!</p></div>
1352 <div class="para"><p>If you choose to wait for the repack, don't try to run benchmarks
1353 or performance tests until repacking is completed. fast-import outputs
1354 suboptimal packfiles that are simply never seen in real use
1355 situations.</p></div>
1356 <h3 id="_repacking_historical_data">Repacking Historical Data</h3><div style="clear:left"></div>
1357 <div class="para"><p>If you are repacking very old imported data (e.g. older than the
1358 last year), consider expending some extra CPU time and supplying
1359 --window=50 (or higher) when you run <em>git-repack</em>.
1360 This will take longer, but will also produce a smaller packfile.
1361 You only need to expend the effort once, and everyone using your
1362 project will benefit from the smaller repository.</p></div>
1363 <h3 id="_include_some_progress_messages">Include Some Progress Messages</h3><div style="clear:left"></div>
1364 <div class="para"><p>Every once in a while have your frontend emit a <tt>progress</tt> message
1365 to fast-import. The contents of the messages are entirely free-form,
1366 so one suggestion would be to output the current month and year
1367 each time the current commit date moves into the next month.
1368 Your users will feel better knowing how much of the data stream
1369 has been processed.</p></div>
1370 </div>
1371 <h2 id="_packfile_optimization">Packfile Optimization</h2>
1372 <div class="sectionbody">
1373 <div class="para"><p>When packing a blob fast-import always attempts to deltify against the last
1374 blob written. Unless specifically arranged for by the frontend,
1375 this will probably not be a prior version of the same file, so the
1376 generated delta will not be the smallest possible. The resulting
1377 packfile will be compressed, but will not be optimal.</p></div>
1378 <div class="para"><p>Frontends which have efficient access to all revisions of a
1379 single file (for example reading an RCS/CVS ,v file) can choose
1380 to supply all revisions of that file as a sequence of consecutive
1381 <tt>blob</tt> commands. This allows fast-import to deltify the different file
1382 revisions against each other, saving space in the final packfile.
1383 Marks can be used to later identify individual file revisions during
1384 a sequence of <tt>commit</tt> commands.</p></div>
1385 <div class="para"><p>The packfile(s) created by fast-import do not encourage good disk access
1386 patterns. This is caused by fast-import writing the data in the order
1387 it is received on standard input, while Git typically organizes
1388 data within packfiles to make the most recent (current tip) data
1389 appear before historical data. Git also clusters commits together,
1390 speeding up revision traversal through better cache locality.</p></div>
1391 <div class="para"><p>For this reason it is strongly recommended that users repack the
1392 repository with <tt>git repack -a -d</tt> after fast-import completes, allowing
1393 Git to reorganize the packfiles for faster data access. If blob
1394 deltas are suboptimal (see above) then also adding the <tt>-f</tt> option
1395 to force recomputation of all deltas can significantly reduce the
1396 final packfile size (30-50% smaller can be quite typical).</p></div>
1397 </div>
1398 <h2 id="_memory_utilization">Memory Utilization</h2>
1399 <div class="sectionbody">
1400 <div class="para"><p>There are a number of factors which affect how much memory fast-import
1401 requires to perform an import. Like critical sections of core
1402 Git, fast-import uses its own memory allocators to amortize any overheads
1403 associated with malloc. In practice fast-import tends to amortize any
1404 malloc overheads to 0, due to its use of large block allocations.</p></div>
1405 <h3 id="_per_object">per object</h3><div style="clear:left"></div>
1406 <div class="para"><p>fast-import maintains an in-memory structure for every object written in
1407 this execution. On a 32 bit system the structure is 32 bytes,
1408 on a 64 bit system the structure is 40 bytes (due to the larger
1409 pointer sizes). Objects in the table are not deallocated until
1410 fast-import terminates. Importing 2 million objects on a 32 bit system
1411 will require approximately 64 MiB of memory.</p></div>
1412 <div class="para"><p>The object table is actually a hashtable keyed on the object name
1413 (the unique SHA-1). This storage configuration allows fast-import to reuse
1414 an existing or already written object and avoid writing duplicates
1415 to the output packfile. Duplicate blobs are surprisingly common
1416 in an import, typically due to branch merges in the source.</p></div>
1417 <h3 id="_per_mark">per mark</h3><div style="clear:left"></div>
1418 <div class="para"><p>Marks are stored in a sparse array, using 1 pointer (4 bytes or 8
1419 bytes, depending on pointer size) per mark. Although the array
1420 is sparse, frontends are still strongly encouraged to use marks
1421 between 1 and n, where n is the total number of marks required for
1422 this import.</p></div>
1423 <h3 id="_per_branch">per branch</h3><div style="clear:left"></div>
1424 <div class="para"><p>Branches are classified as active and inactive. The memory usage
1425 of the two classes is significantly different.</p></div>
1426 <div class="para"><p>Inactive branches are stored in a structure which uses 96 or 120
1427 bytes (32 bit or 64 bit systems, respectively), plus the length of
1428 the branch name (typically under 200 bytes), per branch. fast-import will
1429 easily handle as many as 10,000 inactive branches in under 2 MiB
1430 of memory.</p></div>
1431 <div class="para"><p>Active branches have the same overhead as inactive branches, but
1432 also contain copies of every tree that has been recently modified on
1433 that branch. If subtree <tt>include</tt> has not been modified since the
1434 branch became active, its contents will not be loaded into memory,
1435 but if subtree <tt>src</tt> has been modified by a commit since the branch
1436 became active, then its contents will be loaded in memory.</p></div>
1437 <div class="para"><p>As active branches store metadata about the files contained on that
1438 branch, their in-memory storage size can grow to a considerable size
1439 (see below).</p></div>
1440 <div class="para"><p>fast-import automatically moves active branches to inactive status based on
1441 a simple least-recently-used algorithm. The LRU chain is updated on
1442 each <tt>commit</tt> command. The maximum number of active branches can be
1443 increased or decreased on the command line with --active-branches=.</p></div>
1444 <h3 id="_per_active_tree">per active tree</h3><div style="clear:left"></div>
1445 <div class="para"><p>Trees (aka directories) use just 12 bytes of memory on top of the
1446 memory required for their entries (see &#8220;per active file&#8221; below).
1447 The cost of a tree is virtually 0, as its overhead amortizes out
1448 over the individual file entries.</p></div>
1449 <h3 id="_per_active_file_entry">per active file entry</h3><div style="clear:left"></div>
1450 <div class="para"><p>Files (and pointers to subtrees) within active trees require 52 or 64
1451 bytes (32/64 bit platforms) per entry. To conserve space, file and
1452 tree names are pooled in a common string table, allowing the filename
1453 &#8220;Makefile&#8221; to use just 16 bytes (after including the string header
1454 overhead) no matter how many times it occurs within the project.</p></div>
1455 <div class="para"><p>The active branch LRU, when coupled with the filename string pool
1456 and lazy loading of subtrees, allows fast-import to efficiently import
1457 projects with 2,000+ branches and 45,114+ files in a very limited
1458 memory footprint (less than 2.7 MiB per active branch).</p></div>
1459 </div>
1460 <h2 id="_author">Author</h2>
1461 <div class="sectionbody">
1462 <div class="para"><p>Written by Shawn O. Pearce &lt;spearce@spearce.org&gt;.</p></div>
1463 </div>
1464 <h2 id="_documentation">Documentation</h2>
1465 <div class="sectionbody">
1466 <div class="para"><p>Documentation by Shawn O. Pearce &lt;spearce@spearce.org&gt;.</p></div>
1467 </div>
1468 <h2 id="_git">GIT</h2>
1469 <div class="sectionbody">
1470 <div class="para"><p>Part of the <a href="git.html">git(1)</a> suite</p></div>
1471 </div>
1472 <div id="footer">
1473 <div id="footer-text">
1474 Last updated 2009-07-01 02:30:49 UTC
1475 </div>
1476 </div>
1477 </body>
1478 </html>