OSDN Git Service

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