blob: 0fb105083f9ce3b0f64fc423ce5fbc0acff18165 [file] [log] [blame]
Junio C Hamanodf60f442007-02-07 05:52:371<!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 7.0.2" />
7<style type="text/css">
8/* Debug borders */
9p, li, dt, dd, div, pre, h1, h2, h3, h4, h5, h6 {
10/*
11 border: 1px solid red;
12*/
13}
14
15body {
16 margin: 1em 5% 1em 5%;
17}
18
19a { color: blue; }
20a:visited { color: fuchsia; }
21
22em {
23 font-style: italic;
24}
25
26strong {
27 font-weight: bold;
28}
29
30tt {
31 color: navy;
32}
33
34h1, h2, h3, h4, h5, h6 {
35 color: #527bbd;
36 font-family: sans-serif;
37 margin-top: 1.2em;
38 margin-bottom: 0.5em;
39 line-height: 1.3;
40}
41
42h1 {
43 border-bottom: 2px solid silver;
44}
45h2 {
46 border-bottom: 2px solid silver;
47 padding-top: 0.5em;
48}
49
50div.sectionbody {
51 font-family: serif;
52 margin-left: 0;
53}
54
55hr {
56 border: 1px solid silver;
57}
58
59p {
60 margin-top: 0.5em;
61 margin-bottom: 0.5em;
62}
63
64pre {
65 padding: 0;
66 margin: 0;
67}
68
69span#author {
70 color: #527bbd;
71 font-family: sans-serif;
72 font-weight: bold;
73 font-size: 1.2em;
74}
75span#email {
76}
77span#revision {
78 font-family: sans-serif;
79}
80
81div#footer {
82 font-family: sans-serif;
83 font-size: small;
84 border-top: 2px solid silver;
85 padding-top: 0.5em;
86 margin-top: 4.0em;
87}
88div#footer-text {
89 float: left;
90 padding-bottom: 0.5em;
91}
92div#footer-badges {
93 float: right;
94 padding-bottom: 0.5em;
95}
96
97div#preamble,
98div.tableblock, div.imageblock, div.exampleblock, div.verseblock,
99div.quoteblock, div.literalblock, div.listingblock, div.sidebarblock,
100div.admonitionblock {
101 margin-right: 10%;
102 margin-top: 1.5em;
103 margin-bottom: 1.5em;
104}
105div.admonitionblock {
106 margin-top: 2.5em;
107 margin-bottom: 2.5em;
108}
109
110div.content { /* Block element content. */
111 padding: 0;
112}
113
114/* Block element titles. */
115div.title, caption.title {
116 font-family: sans-serif;
117 font-weight: bold;
118 text-align: left;
119 margin-top: 1.0em;
120 margin-bottom: 0.5em;
121}
122div.title + * {
123 margin-top: 0;
124}
125
126td div.title:first-child {
127 margin-top: 0.0em;
128}
129div.content div.title:first-child {
130 margin-top: 0.0em;
131}
132div.content + div.title {
133 margin-top: 0.0em;
134}
135
136div.sidebarblock > div.content {
137 background: #ffffee;
138 border: 1px solid silver;
139 padding: 0.5em;
140}
141
142div.listingblock > div.content {
143 border: 1px solid silver;
144 background: #f4f4f4;
145 padding: 0.5em;
146}
147
148div.quoteblock > div.content {
149 padding-left: 2.0em;
150}
151div.quoteblock .attribution {
152 text-align: right;
153}
154
155div.admonitionblock .icon {
156 vertical-align: top;
157 font-size: 1.1em;
158 font-weight: bold;
159 text-decoration: underline;
160 color: #527bbd;
161 padding-right: 0.5em;
162}
163div.admonitionblock td.content {
164 padding-left: 0.5em;
165 border-left: 2px solid silver;
166}
167
168div.exampleblock > div.content {
169 border-left: 2px solid silver;
170 padding: 0.5em;
171}
172
173div.verseblock div.content {
174 white-space: pre;
175}
176
177div.imageblock div.content { padding-left: 0; }
178div.imageblock img { border: 1px solid silver; }
179span.image img { border-style: none; }
180
181dl {
182 margin-top: 0.8em;
183 margin-bottom: 0.8em;
184}
185dt {
186 margin-top: 0.5em;
187 margin-bottom: 0;
188 font-style: italic;
189}
190dd > *:first-child {
191 margin-top: 0;
192}
193
194ul, ol {
195 list-style-position: outside;
196}
197ol.olist2 {
198 list-style-type: lower-alpha;
199}
200
201div.tableblock > table {
202 border-color: #527bbd;
203 border-width: 3px;
204}
205thead {
206 font-family: sans-serif;
207 font-weight: bold;
208}
209tfoot {
210 font-weight: bold;
211}
212
213div.hlist {
214 margin-top: 0.8em;
215 margin-bottom: 0.8em;
216}
217td.hlist1 {
218 vertical-align: top;
219 font-style: italic;
220 padding-right: 0.8em;
221}
222td.hlist2 {
223 vertical-align: top;
224}
225
226@media print {
227 div#footer-badges { display: none; }
228}
229include::./stylesheets/xhtml11-manpage.css[]
230/* Workarounds for IE6's broken and incomplete CSS2. */
231
232div.sidebar-content {
233 background: #ffffee;
234 border: 1px solid silver;
235 padding: 0.5em;
236}
237div.sidebar-title, div.image-title {
238 font-family: sans-serif;
239 font-weight: bold;
240 margin-top: 0.0em;
241 margin-bottom: 0.5em;
242}
243
244div.listingblock div.content {
245 border: 1px solid silver;
246 background: #f4f4f4;
247 padding: 0.5em;
248}
249
250div.quoteblock-content {
251 padding-left: 2.0em;
252}
253
254div.exampleblock-content {
255 border-left: 2px solid silver;
256 padding-left: 0.5em;
257}
258</style>
259<title>git-fast-import(1)</title>
260</head>
261<body>
262<div id="header">
263<h1>
264git-fast-import(1) Manual Page
265</h1>
266<h2>NAME</h2>
267<div class="sectionbody">
268<p>git-fast-import -
Junio C Hamano053827f2007-02-14 07:23:58269 Backend for fast Git data importers
Junio C Hamanodf60f442007-02-07 05:52:37270</p>
271</div>
272</div>
273<h2>SYNOPSIS</h2>
274<div class="sectionbody">
275<p>frontend | <em>git-fast-import</em> [options]</p>
276</div>
277<h2>DESCRIPTION</h2>
278<div class="sectionbody">
279<p>This program is usually not what the end user wants to run directly.
280Most end users want to use one of the existing frontend programs,
281which parses a specific type of foreign source and feeds the contents
Junio C Hamanod3339982007-02-09 08:38:48282stored there to git-fast-import.</p>
283<p>fast-import reads a mixed command/data stream from standard input and
Junio C Hamanodf60f442007-02-07 05:52:37284writes one or more packfiles directly into the current repository.
285When EOF is received on standard input, fast import writes out
286updated branch and tag refs, fully updating the current repository
287with the newly imported data.</p>
Junio C Hamanod3339982007-02-09 08:38:48288<p>The fast-import backend itself can import into an empty repository (one that
Junio C Hamanodf60f442007-02-07 05:52:37289has already been initialized by <a href="git-init.html">git-init(1)</a>) or incrementally
290update an existing populated repository. Whether or not incremental
291imports are supported from a particular foreign source depends on
292the frontend program in use.</p>
293</div>
294<h2>OPTIONS</h2>
295<div class="sectionbody">
296<dl>
297<dt>
298--date-format=&lt;fmt&gt;
299</dt>
300<dd>
301<p>
302 Specify the type of dates the frontend will supply to
Junio C Hamanod3339982007-02-09 08:38:48303 fast-import within <tt>author</tt>, <tt>committer</tt> and <tt>tagger</tt> commands.
Junio C Hamanodf60f442007-02-07 05:52:37304 See &#8220;Date Formats&#8221; below for details about which formats
305 are supported, and their syntax.
306</p>
307</dd>
308<dt>
309--force
310</dt>
311<dd>
312<p>
313 Force updating modified existing branches, even if doing
314 so would cause commits to be lost (as the new commit does
315 not contain the old commit).
316</p>
317</dd>
318<dt>
319--max-pack-size=&lt;n&gt;
320</dt>
321<dd>
322<p>
323 Maximum size of each output packfile, expressed in MiB.
324 The default is 4096 (4 GiB) as that is the maximum allowed
325 packfile size (due to file format limitations). Some
326 importers may wish to lower this, such as to ensure the
327 resulting packfiles fit on CDs.
328</p>
329</dd>
330<dt>
331--depth=&lt;n&gt;
332</dt>
333<dd>
334<p>
335 Maximum delta depth, for blob and tree deltification.
336 Default is 10.
337</p>
338</dd>
339<dt>
340--active-branches=&lt;n&gt;
341</dt>
342<dd>
343<p>
344 Maximum number of branches to maintain active at once.
345 See &#8220;Memory Utilization&#8221; below for details. Default is 5.
346</p>
347</dd>
348<dt>
349--export-marks=&lt;file&gt;
350</dt>
351<dd>
352<p>
353 Dumps the internal marks table to &lt;file&gt; when complete.
354 Marks are written one per line as <tt>:markid SHA-1</tt>.
355 Frontends can use this file to validate imports after they
Junio C Hamanod15328a2007-03-09 09:06:40356 have been completed, or to save the marks table across
357 incremental runs. As &lt;file&gt; is only opened and truncated
358 at checkpoint (or completion) the same path can also be
359 safely given to --import-marks.
360</p>
361</dd>
362<dt>
363--import-marks=&lt;file&gt;
364</dt>
365<dd>
366<p>
367 Before processing any input, load the marks specified in
368 &lt;file&gt;. The input file must exist, must be readable, and
369 must use the same format as produced by --export-marks.
370 Multiple options may be supplied to import more than one
371 set of marks. If a mark is defined to different values,
372 the last file wins.
Junio C Hamanodf60f442007-02-07 05:52:37373</p>
374</dd>
Junio C Hamanodfc4ce72007-02-07 23:17:29375<dt>
Junio C Hamano9dd8bb02007-02-12 07:15:35376--export-pack-edges=&lt;file&gt;
377</dt>
378<dd>
379<p>
380 After creating a packfile, print a line of data to
381 &lt;file&gt; listing the filename of the packfile and the last
382 commit on each branch that was written to that packfile.
383 This information may be useful after importing projects
384 whose total object set exceeds the 4 GiB packfile limit,
385 as these commits can be used as edge points during calls
386 to <a href="git-pack-objects.html">git-pack-objects(1)</a>.
387</p>
388</dd>
389<dt>
Junio C Hamanodfc4ce72007-02-07 23:17:29390--quiet
391</dt>
392<dd>
393<p>
Junio C Hamanod3339982007-02-09 08:38:48394 Disable all non-fatal output, making fast-import silent when it
Junio C Hamanodfc4ce72007-02-07 23:17:29395 is successful. This option disables the output shown by
396 --stats.
397</p>
398</dd>
399<dt>
400--stats
401</dt>
402<dd>
403<p>
Junio C Hamanod3339982007-02-09 08:38:48404 Display some basic statistics about the objects fast-import has
Junio C Hamanodfc4ce72007-02-07 23:17:29405 created, the packfiles they were stored into, and the
Junio C Hamanod3339982007-02-09 08:38:48406 memory used by fast-import during this run. Showing this output
Junio C Hamanodfc4ce72007-02-07 23:17:29407 is currently the default, but can be disabled with --quiet.
408</p>
409</dd>
Junio C Hamanodf60f442007-02-07 05:52:37410</dl>
411</div>
412<h2>Performance</h2>
413<div class="sectionbody">
Junio C Hamanod3339982007-02-09 08:38:48414<p>The design of fast-import allows it to import large projects in a minimum
Junio C Hamanodf60f442007-02-07 05:52:37415amount of memory usage and processing time. Assuming the frontend
Junio C Hamanod3339982007-02-09 08:38:48416is able to keep up with fast-import and feed it a constant stream of data,
Junio C Hamanodf60f442007-02-07 05:52:37417import times for projects holding 10+ years of history and containing
418100,000+ individual commits are generally completed in just 1-2
419hours on quite modest (~$2,000 USD) hardware.</p>
420<p>Most bottlenecks appear to be in foreign source data access (the
Junio C Hamanod3339982007-02-09 08:38:48421source just cannot extract revisions fast enough) or disk IO (fast-import
Junio C Hamanodf60f442007-02-07 05:52:37422writes as fast as the disk will take the data). Imports will run
423faster if the source data is stored on a different drive than the
424destination Git repository (due to less IO contention).</p>
425</div>
426<h2>Development Cost</h2>
427<div class="sectionbody">
Junio C Hamanod3339982007-02-09 08:38:48428<p>A typical frontend for fast-import tends to weigh in at approximately 200
Junio C Hamanodf60f442007-02-07 05:52:37429lines of Perl/Python/Ruby code. Most developers have been able to
430create working importers in just a couple of hours, even though it
Junio C Hamanod3339982007-02-09 08:38:48431is their first exposure to fast-import, and sometimes even to Git. This is
Junio C Hamanodf60f442007-02-07 05:52:37432an ideal situation, given that most conversion tools are throw-away
433(use once, and never look back).</p>
434</div>
435<h2>Parallel Operation</h2>
436<div class="sectionbody">
Junio C Hamanod3339982007-02-09 08:38:48437<p>Like <tt>git-push</tt> or <tt>git-fetch</tt>, imports handled by fast-import are safe to
Junio C Hamanodf60f442007-02-07 05:52:37438run alongside parallel <tt>git repack -a -d</tt> or <tt>git gc</tt> invocations,
439or any other Git operation (including <tt>git prune</tt>, as loose objects
Junio C Hamanod3339982007-02-09 08:38:48440are never used by fast-import).</p>
441<p>fast-import does not lock the branch or tag refs it is actively importing.
442After the import, during its ref update phase, fast-import tests each
Junio C Hamanodf60f442007-02-07 05:52:37443existing branch ref to verify the update will be a fast-forward
444update (the commit stored in the ref is contained in the new
445history of the commit to be written). If the update is not a
Junio C Hamanod3339982007-02-09 08:38:48446fast-forward update, fast-import will skip updating that ref and instead
447prints a warning message. fast-import will always attempt to update all
Junio C Hamanodf60f442007-02-07 05:52:37448branch refs, and does not stop on the first failure.</p>
Junio C Hamanodfc4ce72007-02-07 23:17:29449<p>Branch updates can be forced with --force, but its recommended that
450this only be used on an otherwise quiet repository. Using --force
Junio C Hamanodf60f442007-02-07 05:52:37451is not necessary for an initial import into an empty repository.</p>
452</div>
453<h2>Technical Discussion</h2>
454<div class="sectionbody">
Junio C Hamanod3339982007-02-09 08:38:48455<p>fast-import tracks a set of branches in memory. Any branch can be created
Junio C Hamanodf60f442007-02-07 05:52:37456or modified at any point during the import process by sending a
457<tt>commit</tt> command on the input stream. This design allows a frontend
458program to process an unlimited number of branches simultaneously,
459generating commits in the order they are available from the source
460data. It also simplifies the frontend programs considerably.</p>
Junio C Hamanod3339982007-02-09 08:38:48461<p>fast-import does not use or alter the current working directory, or any
Junio C Hamanodf60f442007-02-07 05:52:37462file within it. (It does however update the current Git repository,
463as referenced by <tt>GIT_DIR</tt>.) Therefore an import frontend may use
464the working directory for its own purposes, such as extracting file
465revisions from the foreign source. This ignorance of the working
Junio C Hamanod3339982007-02-09 08:38:48466directory also allows fast-import to run very quickly, as it does not
Junio C Hamanodf60f442007-02-07 05:52:37467need to perform any costly file update operations when switching
468between branches.</p>
469</div>
470<h2>Input Format</h2>
471<div class="sectionbody">
472<p>With the exception of raw file data (which Git does not interpret)
Junio C Hamanod3339982007-02-09 08:38:48473the fast-import input format is text (ASCII) based. This text based
Junio C Hamanodf60f442007-02-07 05:52:37474format simplifies development and debugging of frontend programs,
475especially when a higher level language such as Perl, Python or
476Ruby is being used.</p>
Junio C Hamanod3339982007-02-09 08:38:48477<p>fast-import is very strict about its input. Where we say SP below we mean
Junio C Hamanodf60f442007-02-07 05:52:37478<strong>exactly</strong> one space. Likewise LF means one (and only one) linefeed.
479Supplying additional whitespace characters will cause unexpected
480results, such as branch names or file names with leading or trailing
Junio C Hamanod3339982007-02-09 08:38:48481spaces in their name, or early termination of fast-import when it encounters
Junio C Hamanodf60f442007-02-07 05:52:37482unexpected input.</p>
483<h3>Date Formats</h3>
484<p>The following date formats are supported. A frontend should select
485the format it will use for this import by passing the format name
Junio C Hamanodfc4ce72007-02-07 23:17:29486in the --date-format=&lt;fmt&gt; command line option.</p>
Junio C Hamanodf60f442007-02-07 05:52:37487<dl>
488<dt>
489<tt>raw</tt>
490</dt>
491<dd>
492<p>
Junio C Hamanodfc4ce72007-02-07 23:17:29493 This is the Git native format and is <tt>&lt;time&gt; SP &lt;offutc&gt;</tt>.
Junio C Hamanod3339982007-02-09 08:38:48494 It is also fast-import's default format, if --date-format was
Junio C Hamanodf60f442007-02-07 05:52:37495 not specified.
496</p>
497<p>The time of the event is specified by <tt>&lt;time&gt;</tt> as the number of
498seconds since the UNIX epoch (midnight, Jan 1, 1970, UTC) and is
499written as an ASCII decimal integer.</p>
Junio C Hamanodfc4ce72007-02-07 23:17:29500<p>The local offset is specified by <tt>&lt;offutc&gt;</tt> as a positive or negative
501offset from UTC. For example EST (which is 5 hours behind UTC)
502would be expressed in <tt>&lt;tz&gt;</tt> by &#8220;-0500&#8221; while UTC is &#8220;+0000&#8221;.
503The local offset does not affect <tt>&lt;time&gt;</tt>; it is used only as an
504advisement to help formatting routines display the timestamp.</p>
505<p>If the local offset is not available in the source material, use
506&#8220;+0000&#8221;, or the most common local offset. For example many
Junio C Hamanodf60f442007-02-07 05:52:37507organizations have a CVS repository which has only ever been accessed
508by users who are located in the same location and timezone. In this
Junio C Hamanod3339982007-02-09 08:38:48509case a reasonable offset from UTC could be assumed.</p>
Junio C Hamanodf60f442007-02-07 05:52:37510<p>Unlike the <tt>rfc2822</tt> format, this format is very strict. Any
Junio C Hamanod3339982007-02-09 08:38:48511variation in formatting will cause fast-import to reject the value.</p>
Junio C Hamanodf60f442007-02-07 05:52:37512</dd>
513<dt>
514<tt>rfc2822</tt>
515</dt>
516<dd>
517<p>
518 This is the standard email format as described by RFC 2822.
519</p>
520<p>An example value is &#8220;Tue Feb 6 11:22:18 2007 -0500&#8221;. The Git
Junio C Hamanod3339982007-02-09 08:38:48521parser is accurate, but a little on the lenient side. It is the
Junio C Hamanodf60f442007-02-07 05:52:37522same parser used by <a href="git-am.html">git-am(1)</a> when applying patches
523received from email.</p>
524<p>Some malformed strings may be accepted as valid dates. In some of
525these cases Git will still be able to obtain the correct date from
526the malformed string. There are also some types of malformed
527strings which Git will parse wrong, and yet consider valid.
528Seriously malformed strings will be rejected.</p>
Junio C Hamanodfc4ce72007-02-07 23:17:29529<p>Unlike the <tt>raw</tt> format above, the timezone/UTC offset information
530contained in an RFC 2822 date string is used to adjust the date
531value to UTC prior to storage. Therefore it is important that
532this information be as accurate as possible.</p>
Junio C Hamanod3339982007-02-09 08:38:48533<p>If the source material uses RFC 2822 style dates,
534the frontend should let fast-import handle the parsing and conversion
Junio C Hamanodf60f442007-02-07 05:52:37535(rather than attempting to do it itself) as the Git parser has
536been well tested in the wild.</p>
537<p>Frontends should prefer the <tt>raw</tt> format if the source material
Junio C Hamanod3339982007-02-09 08:38:48538already uses UNIX-epoch format, can be coaxed to give dates in that
539format, or its format is easiliy convertible to it, as there is no
540ambiguity in parsing.</p>
Junio C Hamanodf60f442007-02-07 05:52:37541</dd>
542<dt>
543<tt>now</tt>
544</dt>
545<dd>
546<p>
547 Always use the current time and timezone. The literal
548 <tt>now</tt> must always be supplied for <tt>&lt;when&gt;</tt>.
549</p>
550<p>This is a toy format. The current time and timezone of this system
551is always copied into the identity string at the time it is being
Junio C Hamanod3339982007-02-09 08:38:48552created by fast-import. There is no way to specify a different time or
Junio C Hamanodf60f442007-02-07 05:52:37553timezone.</p>
554<p>This particular format is supplied as its short to implement and
555may be useful to a process that wants to create a new commit
556right now, without needing to use a working directory or
557<a href="git-update-index.html">git-update-index(1)</a>.</p>
558<p>If separate <tt>author</tt> and <tt>committer</tt> commands are used in a <tt>commit</tt>
559the timestamps may not match, as the system clock will be polled
560twice (once for each command). The only way to ensure that both
561author and committer identity information has the same timestamp
562is to omit <tt>author</tt> (thus copying from <tt>committer</tt>) or to use a
563date format other than <tt>now</tt>.</p>
564</dd>
565</dl>
566<h3>Commands</h3>
Junio C Hamanod3339982007-02-09 08:38:48567<p>fast-import accepts several commands to update the current repository
Junio C Hamanodf60f442007-02-07 05:52:37568and control the current import process. More detailed discussion
569(with examples) of each command follows later.</p>
570<dl>
571<dt>
572<tt>commit</tt>
573</dt>
574<dd>
575<p>
576 Creates a new branch or updates an existing branch by
577 creating a new commit and updating the branch to point at
578 the newly created commit.
579</p>
580</dd>
581<dt>
582<tt>tag</tt>
583</dt>
584<dd>
585<p>
586 Creates an annotated tag object from an existing commit or
587 branch. Lightweight tags are not supported by this command,
588 as they are not recommended for recording meaningful points
589 in time.
590</p>
591</dd>
592<dt>
593<tt>reset</tt>
594</dt>
595<dd>
596<p>
597 Reset an existing branch (or a new branch) to a specific
598 revision. This command must be used to change a branch to
599 a specific revision without making a commit on it.
600</p>
601</dd>
602<dt>
603<tt>blob</tt>
604</dt>
605<dd>
606<p>
607 Convert raw file data into a blob, for future use in a
608 <tt>commit</tt> command. This command is optional and is not
609 needed to perform an import.
610</p>
611</dd>
612<dt>
613<tt>checkpoint</tt>
614</dt>
615<dd>
616<p>
Junio C Hamanod3339982007-02-09 08:38:48617 Forces fast-import to close the current packfile, generate its
Junio C Hamanodf60f442007-02-07 05:52:37618 unique SHA-1 checksum and index, and start a new packfile.
619 This command is optional and is not needed to perform
620 an import.
621</p>
622</dd>
623</dl>
624<h3><tt>commit</tt></h3>
625<p>Create or update a branch with a new commit, recording one logical
626change to the project.</p>
627<div class="literalblock">
628<div class="content">
629<pre><tt> 'commit' SP &lt;ref&gt; LF
630 mark?
631 ('author' SP &lt;name&gt; SP LT &lt;email&gt; GT SP &lt;when&gt; LF)?
632 'committer' SP &lt;name&gt; SP LT &lt;email&gt; GT SP &lt;when&gt; LF
633 data
634 ('from' SP &lt;committish&gt; LF)?
635 ('merge' SP &lt;committish&gt; LF)?
Junio C Hamanodfc4ce72007-02-07 23:17:29636 (filemodify | filedelete | filedeleteall)*
Junio C Hamanodf60f442007-02-07 05:52:37637 LF</tt></pre>
638</div></div>
639<p>where <tt>&lt;ref&gt;</tt> is the name of the branch to make the commit on.
640Typically branch names are prefixed with <tt>refs/heads/</tt> in
641Git, so importing the CVS branch symbol <tt>RELENG-1_0</tt> would use
642<tt>refs/heads/RELENG-1_0</tt> for the value of <tt>&lt;ref&gt;</tt>. The value of
643<tt>&lt;ref&gt;</tt> must be a valid refname in Git. As <tt>LF</tt> is not valid in
644a Git refname, no quoting or escaping syntax is supported here.</p>
Junio C Hamanod3339982007-02-09 08:38:48645<p>A <tt>mark</tt> command may optionally appear, requesting fast-import to save a
Junio C Hamanodf60f442007-02-07 05:52:37646reference to the newly created commit for future use by the frontend
647(see below for format). It is very common for frontends to mark
648every commit they create, thereby allowing future branch creation
649from any imported commit.</p>
650<p>The <tt>data</tt> command following <tt>committer</tt> must supply the commit
651message (see below for <tt>data</tt> command syntax). To import an empty
652commit message use a 0 length data. Commit messages are free-form
653and are not interpreted by Git. Currently they must be encoded in
Junio C Hamanod3339982007-02-09 08:38:48654UTF-8, as fast-import does not permit other encodings to be specified.</p>
Junio C Hamanodfc4ce72007-02-07 23:17:29655<p>Zero or more <tt>filemodify</tt>, <tt>filedelete</tt> and <tt>filedeleteall</tt> commands
656may be included to update the contents of the branch prior to
657creating the commit. These commands may be supplied in any order.
658However it is recommended that a <tt>filedeleteall</tt> command preceed
659all <tt>filemodify</tt> commands in the same commit, as <tt>filedeleteall</tt>
660wipes the branch clean (see below).</p>
Junio C Hamanodf60f442007-02-07 05:52:37661<h4><tt>author</tt></h4>
662<p>An <tt>author</tt> command may optionally appear, if the author information
663might differ from the committer information. If <tt>author</tt> is omitted
Junio C Hamanod3339982007-02-09 08:38:48664then fast-import will automatically use the committer's information for
Junio C Hamanodf60f442007-02-07 05:52:37665the author portion of the commit. See below for a description of
666the fields in <tt>author</tt>, as they are identical to <tt>committer</tt>.</p>
667<h4><tt>committer</tt></h4>
668<p>The <tt>committer</tt> command indicates who made this commit, and when
669they made it.</p>
670<p>Here <tt>&lt;name&gt;</tt> is the person's display name (for example
671&#8220;Com M Itter&#8221;) and <tt>&lt;email&gt;</tt> is the person's email address
672(&#8220;cm@example.com&#8221;). <tt>LT</tt> and <tt>GT</tt> are the literal less-than (\x3c)
673and greater-than (\x3e) symbols. These are required to delimit
674the email address from the other fields in the line. Note that
675<tt>&lt;name&gt;</tt> is free-form and may contain any sequence of bytes, except
676<tt>LT</tt> and <tt>LF</tt>. It is typically UTF-8 encoded.</p>
677<p>The time of the change is specified by <tt>&lt;when&gt;</tt> using the date format
Junio C Hamanodfc4ce72007-02-07 23:17:29678that was selected by the --date-format=&lt;fmt&gt; command line option.
Junio C Hamanodf60f442007-02-07 05:52:37679See &#8220;Date Formats&#8221; above for the set of supported formats, and
680their syntax.</p>
681<h4><tt>from</tt></h4>
Junio C Hamano5dad0832007-02-13 05:16:23682<p>The <tt>from</tt> command is used to specify the commit to initialize
683this branch from. This revision will be the first ancestor of the
684new commit.</p>
685<p>Omitting the <tt>from</tt> command in the first commit of a new branch
686will cause fast-import to create that commit with no ancestor. This
687tends to be desired only for the initial commit of a project.
688Omitting the <tt>from</tt> command on existing branches is usually desired,
689as the current commit on that branch is automatically assumed to
690be the first ancestor of the new commit.</p>
Junio C Hamanodf60f442007-02-07 05:52:37691<p>As <tt>LF</tt> is not valid in a Git refname or SHA-1 expression, no
692quoting or escaping syntax is supported within <tt>&lt;committish&gt;</tt>.</p>
693<p>Here <tt>&lt;committish&gt;</tt> is any of the following:</p>
694<ul>
695<li>
696<p>
Junio C Hamanod3339982007-02-09 08:38:48697The name of an existing branch already in fast-import's internal branch
698 table. If fast-import doesn't know the name, its treated as a SHA-1
Junio C Hamanodf60f442007-02-07 05:52:37699 expression.
700</p>
701</li>
702<li>
703<p>
704A mark reference, <tt>:&lt;idnum&gt;</tt>, where <tt>&lt;idnum&gt;</tt> is the mark number.
705</p>
Junio C Hamanod3339982007-02-09 08:38:48706<p>The reason fast-import uses <tt>:</tt> to denote a mark reference is this character
Junio C Hamanodf60f442007-02-07 05:52:37707is not legal in a Git branch name. The leading <tt>:</tt> makes it easy
708to distingush between the mark 42 (<tt>:42</tt>) and the branch 42 (<tt>42</tt>
709or <tt>refs/heads/42</tt>), or an abbreviated SHA-1 which happened to
710consist only of base-10 digits.</p>
711<p>Marks must be declared (via <tt>mark</tt>) before they can be used.</p>
712</li>
713<li>
714<p>
715A complete 40 byte or abbreviated commit SHA-1 in hex.
716</p>
717</li>
718<li>
719<p>
720Any valid Git SHA-1 expression that resolves to a commit. See
721 &#8220;SPECIFYING REVISIONS&#8221; in <a href="git-rev-parse.html">git-rev-parse(1)</a> for details.
722</p>
723</li>
724</ul>
725<p>The special case of restarting an incremental import from the
726current branch value should be written as:</p>
727<div class="listingblock">
728<div class="content">
729<pre><tt> from refs/heads/branch^0</tt></pre>
730</div></div>
Junio C Hamanod3339982007-02-09 08:38:48731<p>The <tt>^0</tt> suffix is necessary as fast-import does not permit a branch to
Junio C Hamanodf60f442007-02-07 05:52:37732start from itself, and the branch is created in memory before the
733<tt>from</tt> command is even read from the input. Adding <tt>^0</tt> will force
Junio C Hamanod3339982007-02-09 08:38:48734fast-import to resolve the commit through Git's revision parsing library,
Junio C Hamanodf60f442007-02-07 05:52:37735rather than its internal branch table, thereby loading in the
736existing value of the branch.</p>
737<h4><tt>merge</tt></h4>
738<p>Includes one additional ancestor commit, and makes the current
739commit a merge commit. An unlimited number of <tt>merge</tt> commands per
Junio C Hamanod3339982007-02-09 08:38:48740commit are permitted by fast-import, thereby establishing an n-way merge.
Junio C Hamanodf60f442007-02-07 05:52:37741However Git's other tools never create commits with more than 15
742additional ancestors (forming a 16-way merge). For this reason
743it is suggested that frontends do not use more than 15 <tt>merge</tt>
744commands per commit.</p>
745<p>Here <tt>&lt;committish&gt;</tt> is any of the commit specification expressions
746also accepted by <tt>from</tt> (see above).</p>
747<h4><tt>filemodify</tt></h4>
748<p>Included in a <tt>commit</tt> command to add a new file or change the
749content of an existing file. This command has two different means
750of specifying the content of the file.</p>
751<dl>
752<dt>
753External data format
754</dt>
755<dd>
756<p>
757 The data content for the file was already supplied by a prior
758 <tt>blob</tt> command. The frontend just needs to connect it.
759</p>
760<div class="literalblock">
761<div class="content">
762<pre><tt> 'M' SP &lt;mode&gt; SP &lt;dataref&gt; SP &lt;path&gt; LF</tt></pre>
763</div></div>
764<p>Here <tt>&lt;dataref&gt;</tt> can be either a mark reference (<tt>:&lt;idnum&gt;</tt>)
765set by a prior <tt>blob</tt> command, or a full 40-byte SHA-1 of an
766existing Git blob object.</p>
767</dd>
768<dt>
769Inline data format
770</dt>
771<dd>
772<p>
773 The data content for the file has not been supplied yet.
774 The frontend wants to supply it as part of this modify
775 command.
776</p>
777<div class="literalblock">
778<div class="content">
779<pre><tt> 'M' SP &lt;mode&gt; SP 'inline' SP &lt;path&gt; LF
780 data</tt></pre>
781</div></div>
782<p>See below for a detailed description of the <tt>data</tt> command.</p>
783</dd>
784</dl>
785<p>In both formats <tt>&lt;mode&gt;</tt> is the type of file entry, specified
786in octal. Git only supports the following modes:</p>
787<ul>
788<li>
789<p>
790<tt>100644</tt> or <tt>644</tt>: A normal (not-executable) file. The majority
791 of files in most projects use this mode. If in doubt, this is
792 what you want.
793</p>
794</li>
795<li>
796<p>
797<tt>100755</tt> or <tt>755</tt>: A normal, but executable, file.
798</p>
799</li>
800<li>
801<p>
802<tt>120000</tt>: A symlink, the content of the file will be the link target.
803</p>
804</li>
805</ul>
806<p>In both formats <tt>&lt;path&gt;</tt> is the complete path of the file to be added
807(if not already existing) or modified (if already existing).</p>
Junio C Hamanoc51fede2007-03-12 07:29:20808<p>A <tt>&lt;path&gt;</tt> string must use UNIX-style directory separators (forward
Junio C Hamanodf60f442007-02-07 05:52:37809slash <tt>/</tt>), may contain any byte other than <tt>LF</tt>, and must not
810start with double quote (<tt>"</tt>).</p>
811<p>If an <tt>LF</tt> or double quote must be encoded into <tt>&lt;path&gt;</tt> shell-style
812quoting should be used, e.g. <tt>"path/with\n and \" in it"</tt>.</p>
813<p>The value of <tt>&lt;path&gt;</tt> must be in canoncial form. That is it must not:</p>
814<ul>
815<li>
816<p>
817contain an empty directory component (e.g. <tt>foo//bar</tt> is invalid),
818</p>
819</li>
820<li>
821<p>
Junio C Hamanoc51fede2007-03-12 07:29:20822end with a directory separator (e.g. <tt>foo/</tt> is invalid),
Junio C Hamanodf60f442007-02-07 05:52:37823</p>
824</li>
825<li>
826<p>
Junio C Hamanoc51fede2007-03-12 07:29:20827start with a directory separator (e.g. <tt>/foo</tt> is invalid),
Junio C Hamanodf60f442007-02-07 05:52:37828</p>
829</li>
830<li>
831<p>
832contain the special component <tt>.</tt> or <tt>..</tt> (e.g. <tt>foo/./bar</tt> and
833 <tt>foo/../bar</tt> are invalid).
834</p>
835</li>
836</ul>
837<p>It is recommended that <tt>&lt;path&gt;</tt> always be encoded using UTF-8.</p>
838<h4><tt>filedelete</tt></h4>
839<p>Included in a <tt>commit</tt> command to remove a file from the branch.
840If the file removal makes its directory empty, the directory will
841be automatically removed too. This cascades up the tree until the
842first non-empty directory or the root is reached.</p>
843<div class="literalblock">
844<div class="content">
845<pre><tt> 'D' SP &lt;path&gt; LF</tt></pre>
846</div></div>
847<p>here <tt>&lt;path&gt;</tt> is the complete path of the file to be removed.
848See <tt>filemodify</tt> above for a detailed description of <tt>&lt;path&gt;</tt>.</p>
Junio C Hamanodfc4ce72007-02-07 23:17:29849<h4><tt>filedeleteall</tt></h4>
850<p>Included in a <tt>commit</tt> command to remove all files (and also all
851directories) from the branch. This command resets the internal
852branch structure to have no files in it, allowing the frontend
853to subsequently add all interesting files from scratch.</p>
854<div class="literalblock">
855<div class="content">
856<pre><tt> 'deleteall' LF</tt></pre>
857</div></div>
858<p>This command is extremely useful if the frontend does not know
859(or does not care to know) what files are currently on the branch,
860and therefore cannot generate the proper <tt>filedelete</tt> commands to
861update the content.</p>
862<p>Issuing a <tt>filedeleteall</tt> followed by the needed <tt>filemodify</tt>
863commands to set the correct content will produce the same results
864as sending only the needed <tt>filemodify</tt> and <tt>filedelete</tt> commands.
Junio C Hamanod3339982007-02-09 08:38:48865The <tt>filedeleteall</tt> approach may however require fast-import to use slightly
Junio C Hamanodfc4ce72007-02-07 23:17:29866more memory per active branch (less than 1 MiB for even most large
867projects); so frontends that can easily obtain only the affected
868paths for a commit are encouraged to do so.</p>
Junio C Hamanodf60f442007-02-07 05:52:37869<h3><tt>mark</tt></h3>
Junio C Hamanod3339982007-02-09 08:38:48870<p>Arranges for fast-import to save a reference to the current object, allowing
Junio C Hamanodf60f442007-02-07 05:52:37871the frontend to recall this object at a future point in time, without
872knowing its SHA-1. Here the current object is the object creation
873command the <tt>mark</tt> command appears within. This can be <tt>commit</tt>,
874<tt>tag</tt>, and <tt>blob</tt>, but <tt>commit</tt> is the most common usage.</p>
875<div class="literalblock">
876<div class="content">
877<pre><tt> 'mark' SP ':' &lt;idnum&gt; LF</tt></pre>
878</div></div>
879<p>where <tt>&lt;idnum&gt;</tt> is the number assigned by the frontend to this mark.
880The value of <tt>&lt;idnum&gt;</tt> is expressed as an ASCII decimal integer.
881The value 0 is reserved and cannot be used as
882a mark. Only values greater than or equal to 1 may be used as marks.</p>
883<p>New marks are created automatically. Existing marks can be moved
884to another object simply by reusing the same <tt>&lt;idnum&gt;</tt> in another
885<tt>mark</tt> command.</p>
886<h3><tt>tag</tt></h3>
887<p>Creates an annotated tag referring to a specific commit. To create
888lightweight (non-annotated) tags see the <tt>reset</tt> command below.</p>
889<div class="literalblock">
890<div class="content">
891<pre><tt> 'tag' SP &lt;name&gt; LF
892 'from' SP &lt;committish&gt; LF
893 'tagger' SP &lt;name&gt; SP LT &lt;email&gt; GT SP &lt;when&gt; LF
894 data
895 LF</tt></pre>
896</div></div>
897<p>where <tt>&lt;name&gt;</tt> is the name of the tag to create.</p>
898<p>Tag names are automatically prefixed with <tt>refs/tags/</tt> when stored
899in Git, so importing the CVS branch symbol <tt>RELENG-1_0-FINAL</tt> would
Junio C Hamanod3339982007-02-09 08:38:48900use just <tt>RELENG-1_0-FINAL</tt> for <tt>&lt;name&gt;</tt>, and fast-import will write the
Junio C Hamanodf60f442007-02-07 05:52:37901corresponding ref as <tt>refs/tags/RELENG-1_0-FINAL</tt>.</p>
902<p>The value of <tt>&lt;name&gt;</tt> must be a valid refname in Git and therefore
903may contain forward slashes. As <tt>LF</tt> is not valid in a Git refname,
904no quoting or escaping syntax is supported here.</p>
905<p>The <tt>from</tt> command is the same as in the <tt>commit</tt> command; see
906above for details.</p>
907<p>The <tt>tagger</tt> command uses the same format as <tt>committer</tt> within
908<tt>commit</tt>; again see above for details.</p>
909<p>The <tt>data</tt> command following <tt>tagger</tt> must supply the annotated tag
910message (see below for <tt>data</tt> command syntax). To import an empty
911tag message use a 0 length data. Tag messages are free-form and are
912not interpreted by Git. Currently they must be encoded in UTF-8,
Junio C Hamanod3339982007-02-09 08:38:48913as fast-import does not permit other encodings to be specified.</p>
914<p>Signing annotated tags during import from within fast-import is not
Junio C Hamanodf60f442007-02-07 05:52:37915supported. Trying to include your own PGP/GPG signature is not
916recommended, as the frontend does not (easily) have access to the
917complete set of bytes which normally goes into such a signature.
Junio C Hamanod3339982007-02-09 08:38:48918If signing is required, create lightweight tags from within fast-import with
Junio C Hamanodf60f442007-02-07 05:52:37919<tt>reset</tt>, then create the annotated versions of those tags offline
920with the standard <a href="git-tag.html">git-tag(1)</a> process.</p>
921<h3><tt>reset</tt></h3>
922<p>Creates (or recreates) the named branch, optionally starting from
923a specific revision. The reset command allows a frontend to issue
924a new <tt>from</tt> command for an existing branch, or to create a new
925branch from an existing commit without creating a new commit.</p>
926<div class="literalblock">
927<div class="content">
928<pre><tt> 'reset' SP &lt;ref&gt; LF
929 ('from' SP &lt;committish&gt; LF)?
930 LF</tt></pre>
931</div></div>
932<p>For a detailed description of <tt>&lt;ref&gt;</tt> and <tt>&lt;committish&gt;</tt> see above
933under <tt>commit</tt> and <tt>from</tt>.</p>
934<p>The <tt>reset</tt> command can also be used to create lightweight
935(non-annotated) tags. For example:</p>
936<div class="exampleblock">
937<div class="exampleblock-content">
938<div class="literalblock">
939<div class="content">
940<pre><tt>reset refs/tags/938
941from :938</tt></pre>
942</div></div>
943</div></div>
944<p>would create the lightweight tag <tt>refs/tags/938</tt> referring to
945whatever commit mark <tt>:938</tt> references.</p>
946<h3><tt>blob</tt></h3>
947<p>Requests writing one file revision to the packfile. The revision
948is not connected to any commit; this connection must be formed in
949a subsequent <tt>commit</tt> command by referencing the blob through an
950assigned mark.</p>
951<div class="literalblock">
952<div class="content">
953<pre><tt> 'blob' LF
954 mark?
955 data</tt></pre>
956</div></div>
957<p>The mark command is optional here as some frontends have chosen
958to generate the Git SHA-1 for the blob on their own, and feed that
959directly to <tt>commit</tt>. This is typically more work than its worth
960however, as marks are inexpensive to store and easy to use.</p>
961<h3><tt>data</tt></h3>
962<p>Supplies raw data (for use as blob/file content, commit messages, or
Junio C Hamanod3339982007-02-09 08:38:48963annotated tag messages) to fast-import. Data can be supplied using an exact
Junio C Hamanodf60f442007-02-07 05:52:37964byte count or delimited with a terminating line. Real frontends
965intended for production-quality conversions should always use the
966exact byte count format, as it is more robust and performs better.
Junio C Hamanod3339982007-02-09 08:38:48967The delimited format is intended primarily for testing fast-import.</p>
Junio C Hamanodf60f442007-02-07 05:52:37968<dl>
969<dt>
970Exact byte count format
971</dt>
972<dd>
973<p>
974 The frontend must specify the number of bytes of data.
975</p>
976<div class="literalblock">
977<div class="content">
978<pre><tt> 'data' SP &lt;count&gt; LF
979 &lt;raw&gt; LF</tt></pre>
980</div></div>
981<p>where <tt>&lt;count&gt;</tt> is the exact number of bytes appearing within
982<tt>&lt;raw&gt;</tt>. The value of <tt>&lt;count&gt;</tt> is expressed as an ASCII decimal
983integer. The <tt>LF</tt> on either side of <tt>&lt;raw&gt;</tt> is not
984included in <tt>&lt;count&gt;</tt> and will not be included in the imported data.</p>
985</dd>
986<dt>
987Delimited format
988</dt>
989<dd>
990<p>
991 A delimiter string is used to mark the end of the data.
Junio C Hamanod3339982007-02-09 08:38:48992 fast-import will compute the length by searching for the delimiter.
Junio C Hamanodf60f442007-02-07 05:52:37993 This format is primarly useful for testing and is not
994 recommended for real data.
995</p>
996<div class="literalblock">
997<div class="content">
998<pre><tt> 'data' SP '&lt;&lt;' &lt;delim&gt; LF
999 &lt;raw&gt; LF
1000 &lt;delim&gt; LF</tt></pre>
1001</div></div>
1002<p>where <tt>&lt;delim&gt;</tt> is the chosen delimiter string. The string <tt>&lt;delim&gt;</tt>
1003must not appear on a line by itself within <tt>&lt;raw&gt;</tt>, as otherwise
Junio C Hamanod3339982007-02-09 08:38:481004fast-import will think the data ends earlier than it really does. The <tt>LF</tt>
Junio C Hamanodf60f442007-02-07 05:52:371005immediately trailing <tt>&lt;raw&gt;</tt> is part of <tt>&lt;raw&gt;</tt>. This is one of
1006the limitations of the delimited format, it is impossible to supply
1007a data chunk which does not have an LF as its last byte.</p>
1008</dd>
1009</dl>
1010<h3><tt>checkpoint</tt></h3>
Junio C Hamanod3339982007-02-09 08:38:481011<p>Forces fast-import to close the current packfile, start a new one, and to
Junio C Hamanodfc4ce72007-02-07 23:17:291012save out all current branch refs, tags and marks.</p>
Junio C Hamanodf60f442007-02-07 05:52:371013<div class="literalblock">
1014<div class="content">
1015<pre><tt> 'checkpoint' LF
1016 LF</tt></pre>
1017</div></div>
Junio C Hamanod3339982007-02-09 08:38:481018<p>Note that fast-import automatically switches packfiles when the current
Junio C Hamanodfc4ce72007-02-07 23:17:291019packfile reaches --max-pack-size, or 4 GiB, whichever limit is
Junio C Hamanod3339982007-02-09 08:38:481020smaller. During an automatic packfile switch fast-import does not update
Junio C Hamanodfc4ce72007-02-07 23:17:291021the branch refs, tags or marks.</p>
1022<p>As a <tt>checkpoint</tt> can require a significant amount of CPU time and
1023disk IO (to compute the overall pack SHA-1 checksum, generate the
1024corresponding index file, and update the refs) it can easily take
1025several minutes for a single <tt>checkpoint</tt> command to complete.</p>
1026<p>Frontends may choose to issue checkpoints during extremely large
1027and long running imports, or when they need to allow another Git
1028process access to a branch. However given that a 30 GiB Subversion
Junio C Hamanod3339982007-02-09 08:38:481029repository can be loaded into Git through fast-import in about 3 hours,
Junio C Hamanodfc4ce72007-02-07 23:17:291030explicit checkpointing may not be necessary.</p>
1031</div>
1032<h2>Tips and Tricks</h2>
1033<div class="sectionbody">
1034<p>The following tips and tricks have been collected from various
Junio C Hamanod3339982007-02-09 08:38:481035users of fast-import, and are offered here as suggestions.</p>
Junio C Hamanodfc4ce72007-02-07 23:17:291036<h3>Use One Mark Per Commit</h3>
1037<p>When doing a repository conversion, use a unique mark per commit
1038(<tt>mark :&lt;n&gt;</tt>) and supply the --export-marks option on the command
Junio C Hamanod3339982007-02-09 08:38:481039line. fast-import will dump a file which lists every mark and the Git
Junio C Hamanodfc4ce72007-02-07 23:17:291040object SHA-1 that corresponds to it. If the frontend can tie
1041the marks back to the source repository, it is easy to verify the
1042accuracy and completeness of the import by comparing each Git
1043commit to the corresponding source revision.</p>
1044<p>Coming from a system such as Perforce or Subversion this should be
Junio C Hamanod3339982007-02-09 08:38:481045quite simple, as the fast-import mark can also be the Perforce changeset
Junio C Hamanodfc4ce72007-02-07 23:17:291046number or the Subversion revision number.</p>
1047<h3>Freely Skip Around Branches</h3>
1048<p>Don't bother trying to optimize the frontend to stick to one branch
1049at a time during an import. Although doing so might be slightly
Junio C Hamanod3339982007-02-09 08:38:481050faster for fast-import, it tends to increase the complexity of the frontend
Junio C Hamanodfc4ce72007-02-07 23:17:291051code considerably.</p>
Junio C Hamanod3339982007-02-09 08:38:481052<p>The branch LRU builtin to fast-import tends to behave very well, and the
Junio C Hamanodfc4ce72007-02-07 23:17:291053cost of activating an inactive branch is so low that bouncing around
1054between branches has virtually no impact on import performance.</p>
Junio C Hamano9dd8bb02007-02-12 07:15:351055<h3>Handling Renames</h3>
1056<p>When importing a renamed file or directory, simply delete the old
1057name(s) and modify the new name(s) during the corresponding commit.
1058Git performs rename detection after-the-fact, rather than explicitly
1059during a commit.</p>
Junio C Hamanodfc4ce72007-02-07 23:17:291060<h3>Use Tag Fixup Branches</h3>
1061<p>Some other SCM systems let the user create a tag from multiple
1062files which are not from the same commit/changeset. Or to create
1063tags which are a subset of the files available in the repository.</p>
1064<p>Importing these tags as-is in Git is impossible without making at
1065least one commit which &#8220;fixes up&#8221; the files to match the content
Junio C Hamanod3339982007-02-09 08:38:481066of the tag. Use fast-import's <tt>reset</tt> command to reset a dummy branch
Junio C Hamanodfc4ce72007-02-07 23:17:291067outside of your normal branch space to the base commit for the tag,
1068then commit one or more file fixup commits, and finally tag the
1069dummy branch.</p>
1070<p>For example since all normal branches are stored under <tt>refs/heads/</tt>
1071name the tag fixup branch <tt>TAG_FIXUP</tt>. This way it is impossible for
1072the fixup branch used by the importer to have namespace conflicts
1073with real branches imported from the source (the name <tt>TAG_FIXUP</tt>
1074is not <tt>refs/heads/TAG_FIXUP</tt>).</p>
1075<p>When committing fixups, consider using <tt>merge</tt> to connect the
1076commit(s) which are supplying file revisions to the fixup branch.
1077Doing so will allow tools such as <a href="git-blame.html">git-blame(1)</a> to track
1078through the real commit history and properly annotate the source
1079files.</p>
Junio C Hamanod3339982007-02-09 08:38:481080<p>After fast-import terminates the frontend will need to do <tt>rm .git/TAG_FIXUP</tt>
Junio C Hamanodfc4ce72007-02-07 23:17:291081to remove the dummy branch.</p>
1082<h3>Import Now, Repack Later</h3>
Junio C Hamanod3339982007-02-09 08:38:481083<p>As soon as fast-import completes the Git repository is completely valid
Junio C Hamanodfc4ce72007-02-07 23:17:291084and ready for use. Typicallly this takes only a very short time,
1085even for considerably large projects (100,000+ commits).</p>
1086<p>However repacking the repository is necessary to improve data
1087locality and access performance. It can also take hours on extremely
1088large projects (especially if -f and a large --window parameter is
1089used). Since repacking is safe to run alongside readers and writers,
1090run the repack in the background and let it finish when it finishes.
1091There is no reason to wait to explore your new Git project!</p>
1092<p>If you choose to wait for the repack, don't try to run benchmarks
Junio C Hamanod3339982007-02-09 08:38:481093or performance tests until repacking is completed. fast-import outputs
Junio C Hamanodfc4ce72007-02-07 23:17:291094suboptimal packfiles that are simply never seen in real use
1095situations.</p>
1096<h3>Repacking Historical Data</h3>
1097<p>If you are repacking very old imported data (e.g. older than the
1098last year), consider expending some extra CPU time and supplying
1099--window=50 (or higher) when you run <a href="git-repack.html">git-repack(1)</a>.
1100This will take longer, but will also produce a smaller packfile.
1101You only need to expend the effort once, and everyone using your
1102project will benefit from the smaller repository.</p>
Junio C Hamanodf60f442007-02-07 05:52:371103</div>
1104<h2>Packfile Optimization</h2>
1105<div class="sectionbody">
Junio C Hamanod3339982007-02-09 08:38:481106<p>When packing a blob fast-import always attempts to deltify against the last
Junio C Hamanodf60f442007-02-07 05:52:371107blob written. Unless specifically arranged for by the frontend,
1108this will probably not be a prior version of the same file, so the
1109generated delta will not be the smallest possible. The resulting
1110packfile will be compressed, but will not be optimal.</p>
1111<p>Frontends which have efficient access to all revisions of a
1112single file (for example reading an RCS/CVS ,v file) can choose
1113to supply all revisions of that file as a sequence of consecutive
Junio C Hamanod3339982007-02-09 08:38:481114<tt>blob</tt> commands. This allows fast-import to deltify the different file
Junio C Hamanodf60f442007-02-07 05:52:371115revisions against each other, saving space in the final packfile.
1116Marks can be used to later identify individual file revisions during
1117a sequence of <tt>commit</tt> commands.</p>
Junio C Hamanod3339982007-02-09 08:38:481118<p>The packfile(s) created by fast-import do not encourage good disk access
1119patterns. This is caused by fast-import writing the data in the order
Junio C Hamanodf60f442007-02-07 05:52:371120it is received on standard input, while Git typically organizes
1121data within packfiles to make the most recent (current tip) data
1122appear before historical data. Git also clusters commits together,
1123speeding up revision traversal through better cache locality.</p>
1124<p>For this reason it is strongly recommended that users repack the
Junio C Hamanod3339982007-02-09 08:38:481125repository with <tt>git repack -a -d</tt> after fast-import completes, allowing
Junio C Hamanodf60f442007-02-07 05:52:371126Git to reorganize the packfiles for faster data access. If blob
1127deltas are suboptimal (see above) then also adding the <tt>-f</tt> option
1128to force recomputation of all deltas can significantly reduce the
1129final packfile size (30-50% smaller can be quite typical).</p>
1130</div>
1131<h2>Memory Utilization</h2>
1132<div class="sectionbody">
Junio C Hamanod3339982007-02-09 08:38:481133<p>There are a number of factors which affect how much memory fast-import
Junio C Hamanodf60f442007-02-07 05:52:371134requires to perform an import. Like critical sections of core
Junio C Hamanod3339982007-02-09 08:38:481135Git, fast-import uses its own memory allocators to ammortize any overheads
1136associated with malloc. In practice fast-import tends to ammoritize any
Junio C Hamanodf60f442007-02-07 05:52:371137malloc overheads to 0, due to its use of large block allocations.</p>
1138<h3>per object</h3>
Junio C Hamanod3339982007-02-09 08:38:481139<p>fast-import maintains an in-memory structure for every object written in
Junio C Hamanodf60f442007-02-07 05:52:371140this execution. On a 32 bit system the structure is 32 bytes,
1141on a 64 bit system the structure is 40 bytes (due to the larger
1142pointer sizes). Objects in the table are not deallocated until
Junio C Hamanod3339982007-02-09 08:38:481143fast-import terminates. Importing 2 million objects on a 32 bit system
Junio C Hamanodf60f442007-02-07 05:52:371144will require approximately 64 MiB of memory.</p>
1145<p>The object table is actually a hashtable keyed on the object name
Junio C Hamanod3339982007-02-09 08:38:481146(the unique SHA-1). This storage configuration allows fast-import to reuse
Junio C Hamanodf60f442007-02-07 05:52:371147an existing or already written object and avoid writing duplicates
1148to the output packfile. Duplicate blobs are surprisingly common
1149in an import, typically due to branch merges in the source.</p>
1150<h3>per mark</h3>
1151<p>Marks are stored in a sparse array, using 1 pointer (4 bytes or 8
1152bytes, depending on pointer size) per mark. Although the array
1153is sparse, frontends are still strongly encouraged to use marks
1154between 1 and n, where n is the total number of marks required for
1155this import.</p>
1156<h3>per branch</h3>
1157<p>Branches are classified as active and inactive. The memory usage
1158of the two classes is significantly different.</p>
1159<p>Inactive branches are stored in a structure which uses 96 or 120
1160bytes (32 bit or 64 bit systems, respectively), plus the length of
Junio C Hamanod3339982007-02-09 08:38:481161the branch name (typically under 200 bytes), per branch. fast-import will
Junio C Hamanodf60f442007-02-07 05:52:371162easily handle as many as 10,000 inactive branches in under 2 MiB
1163of memory.</p>
1164<p>Active branches have the same overhead as inactive branches, but
1165also contain copies of every tree that has been recently modified on
1166that branch. If subtree <tt>include</tt> has not been modified since the
1167branch became active, its contents will not be loaded into memory,
1168but if subtree <tt>src</tt> has been modified by a commit since the branch
1169became active, then its contents will be loaded in memory.</p>
1170<p>As active branches store metadata about the files contained on that
1171branch, their in-memory storage size can grow to a considerable size
1172(see below).</p>
Junio C Hamanod3339982007-02-09 08:38:481173<p>fast-import automatically moves active branches to inactive status based on
Junio C Hamanodf60f442007-02-07 05:52:371174a simple least-recently-used algorithm. The LRU chain is updated on
1175each <tt>commit</tt> command. The maximum number of active branches can be
Junio C Hamanodfc4ce72007-02-07 23:17:291176increased or decreased on the command line with --active-branches=.</p>
Junio C Hamanodf60f442007-02-07 05:52:371177<h3>per active tree</h3>
1178<p>Trees (aka directories) use just 12 bytes of memory on top of the
1179memory required for their entries (see &#8220;per active file&#8221; below).
1180The cost of a tree is virtually 0, as its overhead ammortizes out
1181over the individual file entries.</p>
1182<h3>per active file entry</h3>
1183<p>Files (and pointers to subtrees) within active trees require 52 or 64
1184bytes (32/64 bit platforms) per entry. To conserve space, file and
1185tree names are pooled in a common string table, allowing the filename
1186&#8220;Makefile&#8221; to use just 16 bytes (after including the string header
1187overhead) no matter how many times it occurs within the project.</p>
1188<p>The active branch LRU, when coupled with the filename string pool
Junio C Hamanod3339982007-02-09 08:38:481189and lazy loading of subtrees, allows fast-import to efficiently import
Junio C Hamanodf60f442007-02-07 05:52:371190projects with 2,000+ branches and 45,114+ files in a very limited
1191memory footprint (less than 2.7 MiB per active branch).</p>
1192</div>
1193<h2>Author</h2>
1194<div class="sectionbody">
1195<p>Written by Shawn O. Pearce &lt;spearce@spearce.org&gt;.</p>
1196</div>
1197<h2>Documentation</h2>
1198<div class="sectionbody">
1199<p>Documentation by Shawn O. Pearce &lt;spearce@spearce.org&gt;.</p>
1200</div>
1201<h2>GIT</h2>
1202<div class="sectionbody">
1203<p>Part of the <a href="git.html">git(7)</a> suite</p>
1204</div>
1205<div id="footer">
1206<div id="footer-text">
Junio C Hamanoc51fede2007-03-12 07:29:201207Last updated 12-Mar-2007 07:28:53 UTC
Junio C Hamanodf60f442007-02-07 05:52:371208</div>
1209</div>
1210</body>
1211</html>