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