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