blob: 22f72bd5cc51da9d4870b1ea74af2de992c34578 [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>
Junio C Hamanoe52cf782007-08-19 19:15:52483<h3>Stream Comments</h3>
484<p>To aid in debugging frontends fast-import ignores any line that
485begins with <tt>#</tt> (ASCII pound/hash) up to and including the line
486ending <tt>LF</tt>. A comment line may contain any sequence of bytes
487that does not contain an LF and therefore may be used to include
488any detailed debugging information that might be specific to the
489frontend and useful when inspecting a fast-import data stream.</p>
Junio C Hamanodf60f442007-02-07 05:52:37490<h3>Date Formats</h3>
491<p>The following date formats are supported. A frontend should select
492the format it will use for this import by passing the format name
Junio C Hamanodfc4ce72007-02-07 23:17:29493in the --date-format=&lt;fmt&gt; command line option.</p>
Junio C Hamanodf60f442007-02-07 05:52:37494<dl>
495<dt>
496<tt>raw</tt>
497</dt>
498<dd>
499<p>
Junio C Hamanodfc4ce72007-02-07 23:17:29500 This is the Git native format and is <tt>&lt;time&gt; SP &lt;offutc&gt;</tt>.
Junio C Hamanod3339982007-02-09 08:38:48501 It is also fast-import's default format, if --date-format was
Junio C Hamanodf60f442007-02-07 05:52:37502 not specified.
503</p>
504<p>The time of the event is specified by <tt>&lt;time&gt;</tt> as the number of
505seconds since the UNIX epoch (midnight, Jan 1, 1970, UTC) and is
506written as an ASCII decimal integer.</p>
Junio C Hamanodfc4ce72007-02-07 23:17:29507<p>The local offset is specified by <tt>&lt;offutc&gt;</tt> as a positive or negative
508offset from UTC. For example EST (which is 5 hours behind UTC)
509would be expressed in <tt>&lt;tz&gt;</tt> by &#8220;-0500&#8221; while UTC is &#8220;+0000&#8221;.
510The local offset does not affect <tt>&lt;time&gt;</tt>; it is used only as an
511advisement to help formatting routines display the timestamp.</p>
512<p>If the local offset is not available in the source material, use
513&#8220;+0000&#8221;, or the most common local offset. For example many
Junio C Hamanodf60f442007-02-07 05:52:37514organizations have a CVS repository which has only ever been accessed
515by users who are located in the same location and timezone. In this
Junio C Hamanod3339982007-02-09 08:38:48516case a reasonable offset from UTC could be assumed.</p>
Junio C Hamanodf60f442007-02-07 05:52:37517<p>Unlike the <tt>rfc2822</tt> format, this format is very strict. Any
Junio C Hamanod3339982007-02-09 08:38:48518variation in formatting will cause fast-import to reject the value.</p>
Junio C Hamanodf60f442007-02-07 05:52:37519</dd>
520<dt>
521<tt>rfc2822</tt>
522</dt>
523<dd>
524<p>
525 This is the standard email format as described by RFC 2822.
526</p>
527<p>An example value is &#8220;Tue Feb 6 11:22:18 2007 -0500&#8221;. The Git
Junio C Hamanod3339982007-02-09 08:38:48528parser is accurate, but a little on the lenient side. It is the
Junio C Hamanodf60f442007-02-07 05:52:37529same parser used by <a href="git-am.html">git-am(1)</a> when applying patches
530received from email.</p>
531<p>Some malformed strings may be accepted as valid dates. In some of
532these cases Git will still be able to obtain the correct date from
533the malformed string. There are also some types of malformed
534strings which Git will parse wrong, and yet consider valid.
535Seriously malformed strings will be rejected.</p>
Junio C Hamanodfc4ce72007-02-07 23:17:29536<p>Unlike the <tt>raw</tt> format above, the timezone/UTC offset information
537contained in an RFC 2822 date string is used to adjust the date
538value to UTC prior to storage. Therefore it is important that
539this information be as accurate as possible.</p>
Junio C Hamanod3339982007-02-09 08:38:48540<p>If the source material uses RFC 2822 style dates,
541the frontend should let fast-import handle the parsing and conversion
Junio C Hamanodf60f442007-02-07 05:52:37542(rather than attempting to do it itself) as the Git parser has
543been well tested in the wild.</p>
544<p>Frontends should prefer the <tt>raw</tt> format if the source material
Junio C Hamanod3339982007-02-09 08:38:48545already uses UNIX-epoch format, can be coaxed to give dates in that
Junio C Hamanoa6387422007-08-25 03:54:27546format, or its format is easily convertible to it, as there is no
Junio C Hamanod3339982007-02-09 08:38:48547ambiguity in parsing.</p>
Junio C Hamanodf60f442007-02-07 05:52:37548</dd>
549<dt>
550<tt>now</tt>
551</dt>
552<dd>
553<p>
554 Always use the current time and timezone. The literal
555 <tt>now</tt> must always be supplied for <tt>&lt;when&gt;</tt>.
556</p>
557<p>This is a toy format. The current time and timezone of this system
558is always copied into the identity string at the time it is being
Junio C Hamanod3339982007-02-09 08:38:48559created by fast-import. There is no way to specify a different time or
Junio C Hamanodf60f442007-02-07 05:52:37560timezone.</p>
561<p>This particular format is supplied as its short to implement and
562may be useful to a process that wants to create a new commit
563right now, without needing to use a working directory or
564<a href="git-update-index.html">git-update-index(1)</a>.</p>
565<p>If separate <tt>author</tt> and <tt>committer</tt> commands are used in a <tt>commit</tt>
566the timestamps may not match, as the system clock will be polled
567twice (once for each command). The only way to ensure that both
568author and committer identity information has the same timestamp
569is to omit <tt>author</tt> (thus copying from <tt>committer</tt>) or to use a
570date format other than <tt>now</tt>.</p>
571</dd>
572</dl>
573<h3>Commands</h3>
Junio C Hamanod3339982007-02-09 08:38:48574<p>fast-import accepts several commands to update the current repository
Junio C Hamanodf60f442007-02-07 05:52:37575and control the current import process. More detailed discussion
576(with examples) of each command follows later.</p>
577<dl>
578<dt>
579<tt>commit</tt>
580</dt>
581<dd>
582<p>
583 Creates a new branch or updates an existing branch by
584 creating a new commit and updating the branch to point at
585 the newly created commit.
586</p>
587</dd>
588<dt>
589<tt>tag</tt>
590</dt>
591<dd>
592<p>
593 Creates an annotated tag object from an existing commit or
594 branch. Lightweight tags are not supported by this command,
595 as they are not recommended for recording meaningful points
596 in time.
597</p>
598</dd>
599<dt>
600<tt>reset</tt>
601</dt>
602<dd>
603<p>
604 Reset an existing branch (or a new branch) to a specific
605 revision. This command must be used to change a branch to
606 a specific revision without making a commit on it.
607</p>
608</dd>
609<dt>
610<tt>blob</tt>
611</dt>
612<dd>
613<p>
614 Convert raw file data into a blob, for future use in a
615 <tt>commit</tt> command. This command is optional and is not
616 needed to perform an import.
617</p>
618</dd>
619<dt>
620<tt>checkpoint</tt>
621</dt>
622<dd>
623<p>
Junio C Hamanod3339982007-02-09 08:38:48624 Forces fast-import to close the current packfile, generate its
Junio C Hamanodf60f442007-02-07 05:52:37625 unique SHA-1 checksum and index, and start a new packfile.
626 This command is optional and is not needed to perform
627 an import.
628</p>
629</dd>
Junio C Hamanoe52cf782007-08-19 19:15:52630<dt>
631<tt>progress</tt>
632</dt>
633<dd>
634<p>
635 Causes fast-import to echo the entire line to its own
636 standard output. This command is optional and is not needed
637 to perform an import.
638</p>
639</dd>
Junio C Hamanodf60f442007-02-07 05:52:37640</dl>
641<h3><tt>commit</tt></h3>
642<p>Create or update a branch with a new commit, recording one logical
643change to the project.</p>
644<div class="literalblock">
645<div class="content">
646<pre><tt> 'commit' SP &lt;ref&gt; LF
647 mark?
648 ('author' SP &lt;name&gt; SP LT &lt;email&gt; GT SP &lt;when&gt; LF)?
649 'committer' SP &lt;name&gt; SP LT &lt;email&gt; GT SP &lt;when&gt; LF
650 data
651 ('from' SP &lt;committish&gt; LF)?
652 ('merge' SP &lt;committish&gt; LF)?
Junio C Hamanoc0ea7c62007-07-15 07:19:06653 (filemodify | filedelete | filecopy | filerename | filedeleteall)*
Junio C Hamanoe52cf782007-08-19 19:15:52654 LF?</tt></pre>
Junio C Hamanodf60f442007-02-07 05:52:37655</div></div>
656<p>where <tt>&lt;ref&gt;</tt> is the name of the branch to make the commit on.
657Typically branch names are prefixed with <tt>refs/heads/</tt> in
658Git, so importing the CVS branch symbol <tt>RELENG-1_0</tt> would use
659<tt>refs/heads/RELENG-1_0</tt> for the value of <tt>&lt;ref&gt;</tt>. The value of
660<tt>&lt;ref&gt;</tt> must be a valid refname in Git. As <tt>LF</tt> is not valid in
661a Git refname, no quoting or escaping syntax is supported here.</p>
Junio C Hamanod3339982007-02-09 08:38:48662<p>A <tt>mark</tt> command may optionally appear, requesting fast-import to save a
Junio C Hamanodf60f442007-02-07 05:52:37663reference to the newly created commit for future use by the frontend
664(see below for format). It is very common for frontends to mark
665every commit they create, thereby allowing future branch creation
666from any imported commit.</p>
667<p>The <tt>data</tt> command following <tt>committer</tt> must supply the commit
668message (see below for <tt>data</tt> command syntax). To import an empty
669commit message use a 0 length data. Commit messages are free-form
670and are not interpreted by Git. Currently they must be encoded in
Junio C Hamanod3339982007-02-09 08:38:48671UTF-8, as fast-import does not permit other encodings to be specified.</p>
Junio C Hamanoc0ea7c62007-07-15 07:19:06672<p>Zero or more <tt>filemodify</tt>, <tt>filedelete</tt>, <tt>filecopy</tt>, <tt>filerename</tt>
673and <tt>filedeleteall</tt> commands
Junio C Hamanodfc4ce72007-02-07 23:17:29674may be included to update the contents of the branch prior to
675creating the commit. These commands may be supplied in any order.
Junio C Hamanoa6387422007-08-25 03:54:27676However it is recommended that a <tt>filedeleteall</tt> command precede
Junio C Hamanoc0ea7c62007-07-15 07:19:06677all <tt>filemodify</tt>, <tt>filecopy</tt> and <tt>filerename</tt> commands in the same
678commit, as <tt>filedeleteall</tt>
Junio C Hamanodfc4ce72007-02-07 23:17:29679wipes the branch clean (see below).</p>
Junio C Hamanoe52cf782007-08-19 19:15:52680<p>The <tt>LF</tt> after the command is optional (it used to be required).</p>
Junio C Hamanodf60f442007-02-07 05:52:37681<h4><tt>author</tt></h4>
682<p>An <tt>author</tt> command may optionally appear, if the author information
683might differ from the committer information. If <tt>author</tt> is omitted
Junio C Hamanod3339982007-02-09 08:38:48684then fast-import will automatically use the committer's information for
Junio C Hamanodf60f442007-02-07 05:52:37685the author portion of the commit. See below for a description of
686the fields in <tt>author</tt>, as they are identical to <tt>committer</tt>.</p>
687<h4><tt>committer</tt></h4>
688<p>The <tt>committer</tt> command indicates who made this commit, and when
689they made it.</p>
690<p>Here <tt>&lt;name&gt;</tt> is the person's display name (for example
691&#8220;Com M Itter&#8221;) and <tt>&lt;email&gt;</tt> is the person's email address
692(&#8220;cm@example.com&#8221;). <tt>LT</tt> and <tt>GT</tt> are the literal less-than (\x3c)
693and greater-than (\x3e) symbols. These are required to delimit
694the email address from the other fields in the line. Note that
695<tt>&lt;name&gt;</tt> is free-form and may contain any sequence of bytes, except
696<tt>LT</tt> and <tt>LF</tt>. It is typically UTF-8 encoded.</p>
697<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:29698that was selected by the --date-format=&lt;fmt&gt; command line option.
Junio C Hamanodf60f442007-02-07 05:52:37699See &#8220;Date Formats&#8221; above for the set of supported formats, and
700their syntax.</p>
701<h4><tt>from</tt></h4>
Junio C Hamano5dad0832007-02-13 05:16:23702<p>The <tt>from</tt> command is used to specify the commit to initialize
703this branch from. This revision will be the first ancestor of the
704new commit.</p>
705<p>Omitting the <tt>from</tt> command in the first commit of a new branch
706will cause fast-import to create that commit with no ancestor. This
707tends to be desired only for the initial commit of a project.
708Omitting the <tt>from</tt> command on existing branches is usually desired,
709as the current commit on that branch is automatically assumed to
710be the first ancestor of the new commit.</p>
Junio C Hamanodf60f442007-02-07 05:52:37711<p>As <tt>LF</tt> is not valid in a Git refname or SHA-1 expression, no
712quoting or escaping syntax is supported within <tt>&lt;committish&gt;</tt>.</p>
713<p>Here <tt>&lt;committish&gt;</tt> is any of the following:</p>
714<ul>
715<li>
716<p>
Junio C Hamanod3339982007-02-09 08:38:48717The 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
Junio C Hamanodf60f442007-02-07 05:52:37719 expression.
720</p>
721</li>
722<li>
723<p>
724A mark reference, <tt>:&lt;idnum&gt;</tt>, where <tt>&lt;idnum&gt;</tt> is the mark number.
725</p>
Junio C Hamanod3339982007-02-09 08:38:48726<p>The reason fast-import uses <tt>:</tt> to denote a mark reference is this character
Junio C Hamanodf60f442007-02-07 05:52:37727is not legal in a Git branch name. The leading <tt>:</tt> makes it easy
Junio C Hamanoa6387422007-08-25 03:54:27728to distinguish between the mark 42 (<tt>:42</tt>) and the branch 42 (<tt>42</tt>
Junio C Hamanodf60f442007-02-07 05:52:37729or <tt>refs/heads/42</tt>), or an abbreviated SHA-1 which happened to
730consist 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>
734<p>
735A complete 40 byte or abbreviated commit SHA-1 in hex.
736</p>
737</li>
738<li>
739<p>
740Any valid Git SHA-1 expression that resolves to a commit. See
741 &#8220;SPECIFYING REVISIONS&#8221; 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
746current 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>
Junio C Hamano6926bef2007-06-16 09:54:05751<p>The <tt>&#94;0</tt> suffix is necessary as fast-import does not permit a branch to
Junio C Hamanodf60f442007-02-07 05:52:37752start from itself, and the branch is created in memory before the
Junio C Hamano6926bef2007-06-16 09:54:05753<tt>from</tt> command is even read from the input. Adding <tt>&#94;0</tt> will force
Junio C Hamanod3339982007-02-09 08:38:48754fast-import to resolve the commit through Git's revision parsing library,
Junio C Hamanodf60f442007-02-07 05:52:37755rather than its internal branch table, thereby loading in the
756existing value of the branch.</p>
757<h4><tt>merge</tt></h4>
758<p>Includes one additional ancestor commit, and makes the current
759commit a merge commit. An unlimited number of <tt>merge</tt> commands per
Junio C Hamanod3339982007-02-09 08:38:48760commit are permitted by fast-import, thereby establishing an n-way merge.
Junio C Hamanodf60f442007-02-07 05:52:37761However Git's other tools never create commits with more than 15
762additional ancestors (forming a 16-way merge). For this reason
763it is suggested that frontends do not use more than 15 <tt>merge</tt>
764commands per commit.</p>
765<p>Here <tt>&lt;committish&gt;</tt> is any of the commit specification expressions
766also accepted by <tt>from</tt> (see above).</p>
767<h4><tt>filemodify</tt></h4>
768<p>Included in a <tt>commit</tt> command to add a new file or change the
769content of an existing file. This command has two different means
770of specifying the content of the file.</p>
771<dl>
772<dt>
773External data format
774</dt>
775<dd>
776<p>
777 The data content for the file was already supplied by a prior
778 <tt>blob</tt> command. The frontend just needs to connect it.
779</p>
780<div class="literalblock">
781<div class="content">
782<pre><tt> 'M' SP &lt;mode&gt; SP &lt;dataref&gt; SP &lt;path&gt; LF</tt></pre>
783</div></div>
784<p>Here <tt>&lt;dataref&gt;</tt> can be either a mark reference (<tt>:&lt;idnum&gt;</tt>)
785set by a prior <tt>blob</tt> command, or a full 40-byte SHA-1 of an
786existing Git blob object.</p>
787</dd>
788<dt>
789Inline data format
790</dt>
791<dd>
792<p>
793 The data content for the file has not been supplied yet.
794 The frontend wants to supply it as part of this modify
795 command.
796</p>
797<div class="literalblock">
798<div class="content">
799<pre><tt> 'M' SP &lt;mode&gt; SP 'inline' SP &lt;path&gt; LF
800 data</tt></pre>
801</div></div>
802<p>See below for a detailed description of the <tt>data</tt> command.</p>
803</dd>
804</dl>
805<p>In both formats <tt>&lt;mode&gt;</tt> is the type of file entry, specified
806in octal. Git only supports the following modes:</p>
807<ul>
808<li>
809<p>
810<tt>100644</tt> or <tt>644</tt>: A normal (not-executable) file. The majority
811 of files in most projects use this mode. If in doubt, this is
812 what you want.
813</p>
814</li>
815<li>
816<p>
817<tt>100755</tt> or <tt>755</tt>: A normal, but executable, file.
818</p>
819</li>
820<li>
821<p>
822<tt>120000</tt>: A symlink, the content of the file will be the link target.
823</p>
824</li>
825</ul>
826<p>In both formats <tt>&lt;path&gt;</tt> is the complete path of the file to be added
827(if not already existing) or modified (if already existing).</p>
Junio C Hamanoc51fede2007-03-12 07:29:20828<p>A <tt>&lt;path&gt;</tt> string must use UNIX-style directory separators (forward
Junio C Hamanodf60f442007-02-07 05:52:37829slash <tt>/</tt>), may contain any byte other than <tt>LF</tt>, and must not
830start with double quote (<tt>"</tt>).</p>
831<p>If an <tt>LF</tt> or double quote must be encoded into <tt>&lt;path&gt;</tt> shell-style
832quoting should be used, e.g. <tt>"path/with\n and \" in it"</tt>.</p>
Junio C Hamanoa6387422007-08-25 03:54:27833<p>The value of <tt>&lt;path&gt;</tt> must be in canonical form. That is it must not:</p>
Junio C Hamanodf60f442007-02-07 05:52:37834<ul>
835<li>
836<p>
837contain an empty directory component (e.g. <tt>foo//bar</tt> is invalid),
838</p>
839</li>
840<li>
841<p>
Junio C Hamanoc51fede2007-03-12 07:29:20842end with a directory separator (e.g. <tt>foo/</tt> is invalid),
Junio C Hamanodf60f442007-02-07 05:52:37843</p>
844</li>
845<li>
846<p>
Junio C Hamanoc51fede2007-03-12 07:29:20847start with a directory separator (e.g. <tt>/foo</tt> is invalid),
Junio C Hamanodf60f442007-02-07 05:52:37848</p>
849</li>
850<li>
851<p>
852contain the special component <tt>.</tt> or <tt>..</tt> (e.g. <tt>foo/./bar</tt> and
853 <tt>foo/../bar</tt> are invalid).
854</p>
855</li>
856</ul>
857<p>It is recommended that <tt>&lt;path&gt;</tt> always be encoded using UTF-8.</p>
858<h4><tt>filedelete</tt></h4>
Junio C Hamano06216df2007-07-10 07:49:37859<p>Included in a <tt>commit</tt> command to remove a file or recursively
860delete an entire directory from the branch. If the file or directory
861removal makes its parent directory empty, the parent directory will
Junio C Hamanodf60f442007-02-07 05:52:37862be automatically removed too. This cascades up the tree until the
863first non-empty directory or the root is reached.</p>
864<div class="literalblock">
865<div class="content">
866<pre><tt> 'D' SP &lt;path&gt; LF</tt></pre>
867</div></div>
Junio C Hamano06216df2007-07-10 07:49:37868<p>here <tt>&lt;path&gt;</tt> is the complete path of the file or subdirectory to
869be removed from the branch.
Junio C Hamanodf60f442007-02-07 05:52:37870See <tt>filemodify</tt> above for a detailed description of <tt>&lt;path&gt;</tt>.</p>
Junio C Hamanoc0ea7c62007-07-15 07:19:06871<h4><tt>filecopy</tt></h4>
872<p>Recursively copies an existing file or subdirectory to a different
873location within the branch. The existing file or directory must
874exist. If the destination exists it will be completely replaced
875by the content copied from the source.</p>
876<div class="literalblock">
877<div class="content">
878<pre><tt> 'C' SP &lt;path&gt; SP &lt;path&gt; LF</tt></pre>
879</div></div>
880<p>here the first <tt>&lt;path&gt;</tt> is the source location and the second
881<tt>&lt;path&gt;</tt> is the destination. See <tt>filemodify</tt> above for a detailed
882description of what <tt>&lt;path&gt;</tt> may look like. To use a source path
883that contains SP the path must be quoted.</p>
884<p>A <tt>filecopy</tt> command takes effect immediately. Once the source
885location has been copied to the destination any future commands
886applied to the source location will not impact the destination of
887the copy.</p>
Junio C Hamano06216df2007-07-10 07:49:37888<h4><tt>filerename</tt></h4>
889<p>Renames an existing file or subdirectory to a different location
890within the branch. The existing file or directory must exist. If
891the destination exists it will be replaced by the source directory.</p>
892<div class="literalblock">
893<div class="content">
894<pre><tt> 'R' SP &lt;path&gt; SP &lt;path&gt; LF</tt></pre>
895</div></div>
896<p>here the first <tt>&lt;path&gt;</tt> is the source location and the second
897<tt>&lt;path&gt;</tt> is the destination. See <tt>filemodify</tt> above for a detailed
898description of what <tt>&lt;path&gt;</tt> may look like. To use a source path
899that contains SP the path must be quoted.</p>
900<p>A <tt>filerename</tt> command takes effect immediately. Once the source
901location has been renamed to the destination any future commands
902applied to the source location will create new files there and not
903impact the destination of the rename.</p>
Junio C Hamanoc0ea7c62007-07-15 07:19:06904<p>Note that a <tt>filerename</tt> is the same as a <tt>filecopy</tt> followed by a
905<tt>filedelete</tt> of the source location. There is a slight performance
906advantage to using <tt>filerename</tt>, but the advantage is so small
907that it is never worth trying to convert a delete/add pair in
908source material into a rename for fast-import. This <tt>filerename</tt>
909command is provided just to simplify frontends that already have
910rename information and don't want bother with decomposing it into a
911<tt>filecopy</tt> followed by a <tt>filedelete</tt>.</p>
Junio C Hamanodfc4ce72007-02-07 23:17:29912<h4><tt>filedeleteall</tt></h4>
913<p>Included in a <tt>commit</tt> command to remove all files (and also all
914directories) from the branch. This command resets the internal
915branch structure to have no files in it, allowing the frontend
916to subsequently add all interesting files from scratch.</p>
917<div class="literalblock">
918<div class="content">
919<pre><tt> 'deleteall' LF</tt></pre>
920</div></div>
921<p>This command is extremely useful if the frontend does not know
922(or does not care to know) what files are currently on the branch,
923and therefore cannot generate the proper <tt>filedelete</tt> commands to
924update the content.</p>
925<p>Issuing a <tt>filedeleteall</tt> followed by the needed <tt>filemodify</tt>
926commands to set the correct content will produce the same results
927as sending only the needed <tt>filemodify</tt> and <tt>filedelete</tt> commands.
Junio C Hamanod3339982007-02-09 08:38:48928The <tt>filedeleteall</tt> approach may however require fast-import to use slightly
Junio C Hamanodfc4ce72007-02-07 23:17:29929more memory per active branch (less than 1 MiB for even most large
930projects); so frontends that can easily obtain only the affected
931paths for a commit are encouraged to do so.</p>
Junio C Hamanodf60f442007-02-07 05:52:37932<h3><tt>mark</tt></h3>
Junio C Hamanod3339982007-02-09 08:38:48933<p>Arranges for fast-import to save a reference to the current object, allowing
Junio C Hamanodf60f442007-02-07 05:52:37934the frontend to recall this object at a future point in time, without
935knowing its SHA-1. Here the current object is the object creation
936command the <tt>mark</tt> command appears within. This can be <tt>commit</tt>,
937<tt>tag</tt>, and <tt>blob</tt>, but <tt>commit</tt> is the most common usage.</p>
938<div class="literalblock">
939<div class="content">
940<pre><tt> 'mark' SP ':' &lt;idnum&gt; LF</tt></pre>
941</div></div>
942<p>where <tt>&lt;idnum&gt;</tt> is the number assigned by the frontend to this mark.
943The value of <tt>&lt;idnum&gt;</tt> is expressed as an ASCII decimal integer.
944The value 0 is reserved and cannot be used as
945a mark. Only values greater than or equal to 1 may be used as marks.</p>
946<p>New marks are created automatically. Existing marks can be moved
947to another object simply by reusing the same <tt>&lt;idnum&gt;</tt> in another
948<tt>mark</tt> command.</p>
949<h3><tt>tag</tt></h3>
950<p>Creates an annotated tag referring to a specific commit. To create
951lightweight (non-annotated) tags see the <tt>reset</tt> command below.</p>
952<div class="literalblock">
953<div class="content">
954<pre><tt> 'tag' SP &lt;name&gt; LF
955 'from' SP &lt;committish&gt; LF
956 'tagger' SP &lt;name&gt; SP LT &lt;email&gt; GT SP &lt;when&gt; LF
Junio C Hamanoea5dae62007-05-10 23:25:08957 data</tt></pre>
Junio C Hamanodf60f442007-02-07 05:52:37958</div></div>
959<p>where <tt>&lt;name&gt;</tt> is the name of the tag to create.</p>
960<p>Tag names are automatically prefixed with <tt>refs/tags/</tt> when stored
961in Git, so importing the CVS branch symbol <tt>RELENG-1_0-FINAL</tt> would
Junio C Hamanod3339982007-02-09 08:38:48962use 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:37963corresponding ref as <tt>refs/tags/RELENG-1_0-FINAL</tt>.</p>
964<p>The value of <tt>&lt;name&gt;</tt> must be a valid refname in Git and therefore
965may contain forward slashes. As <tt>LF</tt> is not valid in a Git refname,
966no quoting or escaping syntax is supported here.</p>
967<p>The <tt>from</tt> command is the same as in the <tt>commit</tt> command; see
968above for details.</p>
969<p>The <tt>tagger</tt> command uses the same format as <tt>committer</tt> within
970<tt>commit</tt>; again see above for details.</p>
971<p>The <tt>data</tt> command following <tt>tagger</tt> must supply the annotated tag
972message (see below for <tt>data</tt> command syntax). To import an empty
973tag message use a 0 length data. Tag messages are free-form and are
974not interpreted by Git. Currently they must be encoded in UTF-8,
Junio C Hamanod3339982007-02-09 08:38:48975as fast-import does not permit other encodings to be specified.</p>
976<p>Signing annotated tags during import from within fast-import is not
Junio C Hamanodf60f442007-02-07 05:52:37977supported. Trying to include your own PGP/GPG signature is not
978recommended, as the frontend does not (easily) have access to the
979complete set of bytes which normally goes into such a signature.
Junio C Hamanod3339982007-02-09 08:38:48980If signing is required, create lightweight tags from within fast-import with
Junio C Hamanodf60f442007-02-07 05:52:37981<tt>reset</tt>, then create the annotated versions of those tags offline
982with the standard <a href="git-tag.html">git-tag(1)</a> process.</p>
983<h3><tt>reset</tt></h3>
984<p>Creates (or recreates) the named branch, optionally starting from
985a specific revision. The reset command allows a frontend to issue
986a new <tt>from</tt> command for an existing branch, or to create a new
987branch from an existing commit without creating a new commit.</p>
988<div class="literalblock">
989<div class="content">
990<pre><tt> 'reset' SP &lt;ref&gt; LF
991 ('from' SP &lt;committish&gt; LF)?
Junio C Hamanoe52cf782007-08-19 19:15:52992 LF?</tt></pre>
Junio C Hamanodf60f442007-02-07 05:52:37993</div></div>
994<p>For a detailed description of <tt>&lt;ref&gt;</tt> and <tt>&lt;committish&gt;</tt> see above
995under <tt>commit</tt> and <tt>from</tt>.</p>
Junio C Hamanoe52cf782007-08-19 19:15:52996<p>The <tt>LF</tt> after the command is optional (it used to be required).</p>
Junio C Hamanodf60f442007-02-07 05:52:37997<p>The <tt>reset</tt> command can also be used to create lightweight
998(non-annotated) tags. For example:</p>
999<div class="exampleblock">
1000<div class="exampleblock-content">
1001<div class="literalblock">
1002<div class="content">
1003<pre><tt>reset refs/tags/938
1004from :938</tt></pre>
1005</div></div>
1006</div></div>
1007<p>would create the lightweight tag <tt>refs/tags/938</tt> referring to
1008whatever commit mark <tt>:938</tt> references.</p>
1009<h3><tt>blob</tt></h3>
1010<p>Requests writing one file revision to the packfile. The revision
1011is not connected to any commit; this connection must be formed in
1012a subsequent <tt>commit</tt> command by referencing the blob through an
1013assigned mark.</p>
1014<div class="literalblock">
1015<div class="content">
1016<pre><tt> 'blob' LF
1017 mark?
1018 data</tt></pre>
1019</div></div>
1020<p>The mark command is optional here as some frontends have chosen
1021to generate the Git SHA-1 for the blob on their own, and feed that
1022directly to <tt>commit</tt>. This is typically more work than its worth
1023however, as marks are inexpensive to store and easy to use.</p>
1024<h3><tt>data</tt></h3>
1025<p>Supplies raw data (for use as blob/file content, commit messages, or
Junio C Hamanod3339982007-02-09 08:38:481026annotated tag messages) to fast-import. Data can be supplied using an exact
Junio C Hamanodf60f442007-02-07 05:52:371027byte count or delimited with a terminating line. Real frontends
1028intended for production-quality conversions should always use the
1029exact byte count format, as it is more robust and performs better.
Junio C Hamanod3339982007-02-09 08:38:481030The delimited format is intended primarily for testing fast-import.</p>
Junio C Hamanoe52cf782007-08-19 19:15:521031<p>Comment lines appearing within the <tt>&lt;raw&gt;</tt> part of <tt>data</tt> commands
1032are always taken to be part of the body of the data and are therefore
1033never ignored by fast-import. This makes it safe to import any
1034file/message content whose lines might start with <tt>#</tt>.</p>
Junio C Hamanodf60f442007-02-07 05:52:371035<dl>
1036<dt>
1037Exact byte count format
1038</dt>
1039<dd>
1040<p>
1041 The frontend must specify the number of bytes of data.
1042</p>
1043<div class="literalblock">
1044<div class="content">
1045<pre><tt> 'data' SP &lt;count&gt; LF
Junio C Hamanoe52cf782007-08-19 19:15:521046 &lt;raw&gt; LF?</tt></pre>
Junio C Hamanodf60f442007-02-07 05:52:371047</div></div>
1048<p>where <tt>&lt;count&gt;</tt> is the exact number of bytes appearing within
1049<tt>&lt;raw&gt;</tt>. The value of <tt>&lt;count&gt;</tt> is expressed as an ASCII decimal
1050integer. The <tt>LF</tt> on either side of <tt>&lt;raw&gt;</tt> is not
1051included in <tt>&lt;count&gt;</tt> and will not be included in the imported data.</p>
Junio C Hamanoe52cf782007-08-19 19:15:521052<p>The <tt>LF</tt> after <tt>&lt;raw&gt;</tt> is optional (it used to be required) but
1053recommended. Always including it makes debugging a fast-import
1054stream easier as the next command always starts in column 0
1055of the next line, even if <tt>&lt;raw&gt;</tt> did not end with an <tt>LF</tt>.</p>
Junio C Hamanodf60f442007-02-07 05:52:371056</dd>
1057<dt>
1058Delimited format
1059</dt>
1060<dd>
1061<p>
1062 A delimiter string is used to mark the end of the data.
Junio C Hamanod3339982007-02-09 08:38:481063 fast-import will compute the length by searching for the delimiter.
Junio C Hamanoa6387422007-08-25 03:54:271064 This format is primarily useful for testing and is not
Junio C Hamanodf60f442007-02-07 05:52:371065 recommended for real data.
1066</p>
1067<div class="literalblock">
1068<div class="content">
1069<pre><tt> 'data' SP '&lt;&lt;' &lt;delim&gt; LF
1070 &lt;raw&gt; LF
Junio C Hamanoe52cf782007-08-19 19:15:521071 &lt;delim&gt; LF
1072 LF?</tt></pre>
Junio C Hamanodf60f442007-02-07 05:52:371073</div></div>
1074<p>where <tt>&lt;delim&gt;</tt> is the chosen delimiter string. The string <tt>&lt;delim&gt;</tt>
1075must not appear on a line by itself within <tt>&lt;raw&gt;</tt>, as otherwise
Junio C Hamanod3339982007-02-09 08:38:481076fast-import will think the data ends earlier than it really does. The <tt>LF</tt>
Junio C Hamanodf60f442007-02-07 05:52:371077immediately trailing <tt>&lt;raw&gt;</tt> is part of <tt>&lt;raw&gt;</tt>. This is one of
1078the limitations of the delimited format, it is impossible to supply
1079a data chunk which does not have an LF as its last byte.</p>
Junio C Hamanoe52cf782007-08-19 19:15:521080<p>The <tt>LF</tt> after <tt>&lt;delim&gt; LF</tt> is optional (it used to be required).</p>
Junio C Hamanodf60f442007-02-07 05:52:371081</dd>
1082</dl>
1083<h3><tt>checkpoint</tt></h3>
Junio C Hamanod3339982007-02-09 08:38:481084<p>Forces fast-import to close the current packfile, start a new one, and to
Junio C Hamanodfc4ce72007-02-07 23:17:291085save out all current branch refs, tags and marks.</p>
Junio C Hamanodf60f442007-02-07 05:52:371086<div class="literalblock">
1087<div class="content">
1088<pre><tt> 'checkpoint' LF
Junio C Hamanoe52cf782007-08-19 19:15:521089 LF?</tt></pre>
Junio C Hamanodf60f442007-02-07 05:52:371090</div></div>
Junio C Hamanod3339982007-02-09 08:38:481091<p>Note that fast-import automatically switches packfiles when the current
Junio C Hamanodfc4ce72007-02-07 23:17:291092packfile reaches --max-pack-size, or 4 GiB, whichever limit is
Junio C Hamanod3339982007-02-09 08:38:481093smaller. During an automatic packfile switch fast-import does not update
Junio C Hamanodfc4ce72007-02-07 23:17:291094the branch refs, tags or marks.</p>
1095<p>As a <tt>checkpoint</tt> can require a significant amount of CPU time and
1096disk IO (to compute the overall pack SHA-1 checksum, generate the
1097corresponding index file, and update the refs) it can easily take
1098several minutes for a single <tt>checkpoint</tt> command to complete.</p>
1099<p>Frontends may choose to issue checkpoints during extremely large
1100and long running imports, or when they need to allow another Git
1101process access to a branch. However given that a 30 GiB Subversion
Junio C Hamanod3339982007-02-09 08:38:481102repository can be loaded into Git through fast-import in about 3 hours,
Junio C Hamanodfc4ce72007-02-07 23:17:291103explicit checkpointing may not be necessary.</p>
Junio C Hamanoe52cf782007-08-19 19:15:521104<p>The <tt>LF</tt> after the command is optional (it used to be required).</p>
1105<h3><tt>progress</tt></h3>
1106<p>Causes fast-import to print the entire <tt>progress</tt> line unmodified to
1107its standard output channel (file descriptor 1) when the command is
1108processed from the input stream. The command otherwise has no impact
1109on the current import, or on any of fast-import's internal state.</p>
1110<div class="literalblock">
1111<div class="content">
1112<pre><tt> 'progress' SP &lt;any&gt; LF
1113 LF?</tt></pre>
1114</div></div>
1115<p>The <tt>&lt;any&gt;</tt> part of the command may contain any sequence of bytes
1116that does not contain <tt>LF</tt>. The <tt>LF</tt> after the command is optional.
1117Callers may wish to process the output through a tool such as sed to
1118remove the leading part of the line, for example:</p>
1119<div class="exampleblock">
1120<div class="exampleblock-content">
1121<div class="literalblock">
1122<div class="content">
1123<pre><tt>frontend | git-fast-import | sed 's/^progress //'</tt></pre>
1124</div></div>
1125</div></div>
1126<p>Placing a <tt>progress</tt> command immediately after a <tt>checkpoint</tt> will
1127inform the reader when the <tt>checkpoint</tt> has been completed and it
1128can safely access the refs that fast-import updated.</p>
Junio C Hamanodfc4ce72007-02-07 23:17:291129</div>
1130<h2>Tips and Tricks</h2>
1131<div class="sectionbody">
1132<p>The following tips and tricks have been collected from various
Junio C Hamanod3339982007-02-09 08:38:481133users of fast-import, and are offered here as suggestions.</p>
Junio C Hamanodfc4ce72007-02-07 23:17:291134<h3>Use One Mark Per Commit</h3>
1135<p>When doing a repository conversion, use a unique mark per commit
1136(<tt>mark :&lt;n&gt;</tt>) and supply the --export-marks option on the command
Junio C Hamanod3339982007-02-09 08:38:481137line. fast-import will dump a file which lists every mark and the Git
Junio C Hamanodfc4ce72007-02-07 23:17:291138object SHA-1 that corresponds to it. If the frontend can tie
1139the marks back to the source repository, it is easy to verify the
1140accuracy and completeness of the import by comparing each Git
1141commit to the corresponding source revision.</p>
1142<p>Coming from a system such as Perforce or Subversion this should be
Junio C Hamanod3339982007-02-09 08:38:481143quite simple, as the fast-import mark can also be the Perforce changeset
Junio C Hamanodfc4ce72007-02-07 23:17:291144number or the Subversion revision number.</p>
1145<h3>Freely Skip Around Branches</h3>
1146<p>Don't bother trying to optimize the frontend to stick to one branch
1147at a time during an import. Although doing so might be slightly
Junio C Hamanod3339982007-02-09 08:38:481148faster for fast-import, it tends to increase the complexity of the frontend
Junio C Hamanodfc4ce72007-02-07 23:17:291149code considerably.</p>
Junio C Hamanod3339982007-02-09 08:38:481150<p>The branch LRU builtin to fast-import tends to behave very well, and the
Junio C Hamanodfc4ce72007-02-07 23:17:291151cost of activating an inactive branch is so low that bouncing around
1152between branches has virtually no impact on import performance.</p>
Junio C Hamano9dd8bb02007-02-12 07:15:351153<h3>Handling Renames</h3>
1154<p>When importing a renamed file or directory, simply delete the old
1155name(s) and modify the new name(s) during the corresponding commit.
1156Git performs rename detection after-the-fact, rather than explicitly
1157during a commit.</p>
Junio C Hamanodfc4ce72007-02-07 23:17:291158<h3>Use Tag Fixup Branches</h3>
1159<p>Some other SCM systems let the user create a tag from multiple
1160files which are not from the same commit/changeset. Or to create
1161tags which are a subset of the files available in the repository.</p>
1162<p>Importing these tags as-is in Git is impossible without making at
1163least one commit which &#8220;fixes up&#8221; the files to match the content
Junio C Hamanod3339982007-02-09 08:38:481164of the tag. Use fast-import's <tt>reset</tt> command to reset a dummy branch
Junio C Hamanodfc4ce72007-02-07 23:17:291165outside of your normal branch space to the base commit for the tag,
1166then commit one or more file fixup commits, and finally tag the
1167dummy branch.</p>
1168<p>For example since all normal branches are stored under <tt>refs/heads/</tt>
1169name the tag fixup branch <tt>TAG_FIXUP</tt>. This way it is impossible for
1170the fixup branch used by the importer to have namespace conflicts
1171with real branches imported from the source (the name <tt>TAG_FIXUP</tt>
1172is not <tt>refs/heads/TAG_FIXUP</tt>).</p>
1173<p>When committing fixups, consider using <tt>merge</tt> to connect the
1174commit(s) which are supplying file revisions to the fixup branch.
1175Doing so will allow tools such as <a href="git-blame.html">git-blame(1)</a> to track
1176through the real commit history and properly annotate the source
1177files.</p>
Junio C Hamanod3339982007-02-09 08:38:481178<p>After fast-import terminates the frontend will need to do <tt>rm .git/TAG_FIXUP</tt>
Junio C Hamanodfc4ce72007-02-07 23:17:291179to remove the dummy branch.</p>
1180<h3>Import Now, Repack Later</h3>
Junio C Hamanod3339982007-02-09 08:38:481181<p>As soon as fast-import completes the Git repository is completely valid
Junio C Hamanoa6387422007-08-25 03:54:271182and ready for use. Typically this takes only a very short time,
Junio C Hamanodfc4ce72007-02-07 23:17:291183even for considerably large projects (100,000+ commits).</p>
1184<p>However repacking the repository is necessary to improve data
1185locality and access performance. It can also take hours on extremely
1186large projects (especially if -f and a large --window parameter is
1187used). Since repacking is safe to run alongside readers and writers,
1188run the repack in the background and let it finish when it finishes.
1189There is no reason to wait to explore your new Git project!</p>
1190<p>If you choose to wait for the repack, don't try to run benchmarks
Junio C Hamanod3339982007-02-09 08:38:481191or performance tests until repacking is completed. fast-import outputs
Junio C Hamanodfc4ce72007-02-07 23:17:291192suboptimal packfiles that are simply never seen in real use
1193situations.</p>
1194<h3>Repacking Historical Data</h3>
1195<p>If you are repacking very old imported data (e.g. older than the
1196last year), consider expending some extra CPU time and supplying
1197--window=50 (or higher) when you run <a href="git-repack.html">git-repack(1)</a>.
1198This will take longer, but will also produce a smaller packfile.
1199You only need to expend the effort once, and everyone using your
1200project will benefit from the smaller repository.</p>
Junio C Hamanoe52cf782007-08-19 19:15:521201<h3>Include Some Progress Messages</h3>
1202<p>Every once in a while have your frontend emit a <tt>progress</tt> message
1203to fast-import. The contents of the messages are entirely free-form,
1204so one suggestion would be to output the current month and year
1205each time the current commit date moves into the next month.
1206Your users will feel better knowing how much of the data stream
1207has been processed.</p>
Junio C Hamanodf60f442007-02-07 05:52:371208</div>
1209<h2>Packfile Optimization</h2>
1210<div class="sectionbody">
Junio C Hamanod3339982007-02-09 08:38:481211<p>When packing a blob fast-import always attempts to deltify against the last
Junio C Hamanodf60f442007-02-07 05:52:371212blob written. Unless specifically arranged for by the frontend,
1213this will probably not be a prior version of the same file, so the
1214generated delta will not be the smallest possible. The resulting
1215packfile will be compressed, but will not be optimal.</p>
1216<p>Frontends which have efficient access to all revisions of a
1217single file (for example reading an RCS/CVS ,v file) can choose
1218to supply all revisions of that file as a sequence of consecutive
Junio C Hamanod3339982007-02-09 08:38:481219<tt>blob</tt> commands. This allows fast-import to deltify the different file
Junio C Hamanodf60f442007-02-07 05:52:371220revisions against each other, saving space in the final packfile.
1221Marks can be used to later identify individual file revisions during
1222a sequence of <tt>commit</tt> commands.</p>
Junio C Hamanod3339982007-02-09 08:38:481223<p>The packfile(s) created by fast-import do not encourage good disk access
1224patterns. This is caused by fast-import writing the data in the order
Junio C Hamanodf60f442007-02-07 05:52:371225it is received on standard input, while Git typically organizes
1226data within packfiles to make the most recent (current tip) data
1227appear before historical data. Git also clusters commits together,
1228speeding up revision traversal through better cache locality.</p>
1229<p>For this reason it is strongly recommended that users repack the
Junio C Hamanod3339982007-02-09 08:38:481230repository with <tt>git repack -a -d</tt> after fast-import completes, allowing
Junio C Hamanodf60f442007-02-07 05:52:371231Git to reorganize the packfiles for faster data access. If blob
1232deltas are suboptimal (see above) then also adding the <tt>-f</tt> option
1233to force recomputation of all deltas can significantly reduce the
1234final packfile size (30-50% smaller can be quite typical).</p>
1235</div>
1236<h2>Memory Utilization</h2>
1237<div class="sectionbody">
Junio C Hamanod3339982007-02-09 08:38:481238<p>There are a number of factors which affect how much memory fast-import
Junio C Hamanodf60f442007-02-07 05:52:371239requires to perform an import. Like critical sections of core
Junio C Hamanoa6387422007-08-25 03:54:271240Git, fast-import uses its own memory allocators to amortize any overheads
1241associated with malloc. In practice fast-import tends to amortize any
Junio C Hamanodf60f442007-02-07 05:52:371242malloc overheads to 0, due to its use of large block allocations.</p>
1243<h3>per object</h3>
Junio C Hamanod3339982007-02-09 08:38:481244<p>fast-import maintains an in-memory structure for every object written in
Junio C Hamanodf60f442007-02-07 05:52:371245this execution. On a 32 bit system the structure is 32 bytes,
1246on a 64 bit system the structure is 40 bytes (due to the larger
1247pointer sizes). Objects in the table are not deallocated until
Junio C Hamanod3339982007-02-09 08:38:481248fast-import terminates. Importing 2 million objects on a 32 bit system
Junio C Hamanodf60f442007-02-07 05:52:371249will require approximately 64 MiB of memory.</p>
1250<p>The object table is actually a hashtable keyed on the object name
Junio C Hamanod3339982007-02-09 08:38:481251(the unique SHA-1). This storage configuration allows fast-import to reuse
Junio C Hamanodf60f442007-02-07 05:52:371252an existing or already written object and avoid writing duplicates
1253to the output packfile. Duplicate blobs are surprisingly common
1254in an import, typically due to branch merges in the source.</p>
1255<h3>per mark</h3>
1256<p>Marks are stored in a sparse array, using 1 pointer (4 bytes or 8
1257bytes, depending on pointer size) per mark. Although the array
1258is sparse, frontends are still strongly encouraged to use marks
1259between 1 and n, where n is the total number of marks required for
1260this import.</p>
1261<h3>per branch</h3>
1262<p>Branches are classified as active and inactive. The memory usage
1263of the two classes is significantly different.</p>
1264<p>Inactive branches are stored in a structure which uses 96 or 120
1265bytes (32 bit or 64 bit systems, respectively), plus the length of
Junio C Hamanod3339982007-02-09 08:38:481266the branch name (typically under 200 bytes), per branch. fast-import will
Junio C Hamanodf60f442007-02-07 05:52:371267easily handle as many as 10,000 inactive branches in under 2 MiB
1268of memory.</p>
1269<p>Active branches have the same overhead as inactive branches, but
1270also contain copies of every tree that has been recently modified on
1271that branch. If subtree <tt>include</tt> has not been modified since the
1272branch became active, its contents will not be loaded into memory,
1273but if subtree <tt>src</tt> has been modified by a commit since the branch
1274became active, then its contents will be loaded in memory.</p>
1275<p>As active branches store metadata about the files contained on that
1276branch, their in-memory storage size can grow to a considerable size
1277(see below).</p>
Junio C Hamanod3339982007-02-09 08:38:481278<p>fast-import automatically moves active branches to inactive status based on
Junio C Hamanodf60f442007-02-07 05:52:371279a simple least-recently-used algorithm. The LRU chain is updated on
1280each <tt>commit</tt> command. The maximum number of active branches can be
Junio C Hamanodfc4ce72007-02-07 23:17:291281increased or decreased on the command line with --active-branches=.</p>
Junio C Hamanodf60f442007-02-07 05:52:371282<h3>per active tree</h3>
1283<p>Trees (aka directories) use just 12 bytes of memory on top of the
1284memory required for their entries (see &#8220;per active file&#8221; below).
Junio C Hamanoa6387422007-08-25 03:54:271285The cost of a tree is virtually 0, as its overhead amortizes out
Junio C Hamanodf60f442007-02-07 05:52:371286over the individual file entries.</p>
1287<h3>per active file entry</h3>
1288<p>Files (and pointers to subtrees) within active trees require 52 or 64
1289bytes (32/64 bit platforms) per entry. To conserve space, file and
1290tree names are pooled in a common string table, allowing the filename
1291&#8220;Makefile&#8221; to use just 16 bytes (after including the string header
1292overhead) no matter how many times it occurs within the project.</p>
1293<p>The active branch LRU, when coupled with the filename string pool
Junio C Hamanod3339982007-02-09 08:38:481294and lazy loading of subtrees, allows fast-import to efficiently import
Junio C Hamanodf60f442007-02-07 05:52:371295projects with 2,000+ branches and 45,114+ files in a very limited
1296memory footprint (less than 2.7 MiB per active branch).</p>
1297</div>
1298<h2>Author</h2>
1299<div class="sectionbody">
1300<p>Written by Shawn O. Pearce &lt;spearce@spearce.org&gt;.</p>
1301</div>
1302<h2>Documentation</h2>
1303<div class="sectionbody">
1304<p>Documentation by Shawn O. Pearce &lt;spearce@spearce.org&gt;.</p>
1305</div>
1306<h2>GIT</h2>
1307<div class="sectionbody">
1308<p>Part of the <a href="git.html">git(7)</a> suite</p>
1309</div>
1310<div id="footer">
1311<div id="footer-text">
Junio C Hamanoa6387422007-08-25 03:54:271312Last updated 25-Aug-2007 03:53:08 UTC
Junio C Hamanodf60f442007-02-07 05:52:371313</div>
1314</div>
1315</body>
1316</html>