]> git.ipfire.org Git - thirdparty/git.git/blame - builtin/fast-export.c
Merge branch 'jn/gitweb-no-logo' into maint
[thirdparty/git.git] / builtin / fast-export.c
CommitLineData
f2dc849e
JS
1/*
2 * "git fast-export" builtin command
3 *
4 * Copyright (C) 2007 Johannes E. Schindelin
5 */
6#include "builtin.h"
7#include "cache.h"
8#include "commit.h"
9#include "object.h"
10#include "tag.h"
11#include "diff.h"
12#include "diffcore.h"
13#include "log-tree.h"
14#include "revision.h"
15#include "decorate.h"
c455c87c 16#include "string-list.h"
f2dc849e
JS
17#include "utf8.h"
18#include "parse-options.h"
19
20static const char *fast_export_usage[] = {
1b1dd23f 21 "git fast-export [rev-list-opts]",
f2dc849e
JS
22 NULL
23};
24
25static int progress;
2d8ad469
EN
26static enum { ABORT, VERBATIM, WARN, STRIP } signed_tag_mode = ABORT;
27static enum { ERROR, DROP, REWRITE } tag_of_filtered_mode = ABORT;
4e46a8d6 28static int fake_missing_tagger;
79559f27 29static int no_data;
7f40ab09 30static int full_tree;
f2dc849e
JS
31
32static int parse_opt_signed_tag_mode(const struct option *opt,
33 const char *arg, int unset)
34{
35 if (unset || !strcmp(arg, "abort"))
36 signed_tag_mode = ABORT;
ee4bc371
JS
37 else if (!strcmp(arg, "verbatim") || !strcmp(arg, "ignore"))
38 signed_tag_mode = VERBATIM;
f2dc849e
JS
39 else if (!strcmp(arg, "warn"))
40 signed_tag_mode = WARN;
41 else if (!strcmp(arg, "strip"))
42 signed_tag_mode = STRIP;
43 else
44 return error("Unknown signed-tag mode: %s", arg);
45 return 0;
46}
47
2d8ad469
EN
48static int parse_opt_tag_of_filtered_mode(const struct option *opt,
49 const char *arg, int unset)
50{
51 if (unset || !strcmp(arg, "abort"))
52 tag_of_filtered_mode = ABORT;
53 else if (!strcmp(arg, "drop"))
54 tag_of_filtered_mode = DROP;
55 else if (!strcmp(arg, "rewrite"))
56 tag_of_filtered_mode = REWRITE;
57 else
58 return error("Unknown tag-of-filtered mode: %s", arg);
59 return 0;
60}
61
f2dc849e
JS
62static struct decoration idnums;
63static uint32_t last_idnum;
64
65static int has_unshown_parent(struct commit *commit)
66{
67 struct commit_list *parent;
68
69 for (parent = commit->parents; parent; parent = parent->next)
70 if (!(parent->item->object.flags & SHOWN) &&
71 !(parent->item->object.flags & UNINTERESTING))
72 return 1;
73 return 0;
74}
75
76/* Since intptr_t is C99, we do not use it here */
df6a7ff7 77static inline uint32_t *mark_to_ptr(uint32_t mark)
f2dc849e 78{
df6a7ff7
PB
79 return ((uint32_t *)NULL) + mark;
80}
81
82static inline uint32_t ptr_to_mark(void * mark)
83{
84 return (uint32_t *)mark - (uint32_t *)NULL;
85}
86
87static inline void mark_object(struct object *object, uint32_t mark)
88{
89 add_decoration(&idnums, object, mark_to_ptr(mark));
90}
91
92static inline void mark_next_object(struct object *object)
93{
94 mark_object(object, ++last_idnum);
f2dc849e
JS
95}
96
97static int get_object_mark(struct object *object)
98{
99 void *decoration = lookup_decoration(&idnums, object);
100 if (!decoration)
101 return 0;
df6a7ff7 102 return ptr_to_mark(decoration);
f2dc849e
JS
103}
104
105static void show_progress(void)
106{
107 static int counter = 0;
108 if (!progress)
109 return;
110 if ((++counter % progress) == 0)
111 printf("progress %d objects\n", counter);
112}
113
114static void handle_object(const unsigned char *sha1)
115{
116 unsigned long size;
117 enum object_type type;
118 char *buf;
119 struct object *object;
120
79559f27
GI
121 if (no_data)
122 return;
123
f2dc849e
JS
124 if (is_null_sha1(sha1))
125 return;
126
127 object = parse_object(sha1);
128 if (!object)
129 die ("Could not read blob %s", sha1_to_hex(sha1));
130
131 if (object->flags & SHOWN)
132 return;
133
134 buf = read_sha1_file(sha1, &type, &size);
135 if (!buf)
136 die ("Could not read blob %s", sha1_to_hex(sha1));
137
df6a7ff7 138 mark_next_object(object);
f2dc849e 139
6e1c2344 140 printf("blob\nmark :%"PRIu32"\ndata %lu\n", last_idnum, size);
b0fe0d72 141 if (size && fwrite(buf, size, 1, stdout) != 1)
0721c314 142 die_errno ("Could not write blob '%s'", sha1_to_hex(sha1));
f2dc849e
JS
143 printf("\n");
144
145 show_progress();
146
147 object->flags |= SHOWN;
148 free(buf);
149}
150
060df624
EN
151static int depth_first(const void *a_, const void *b_)
152{
153 const struct diff_filepair *a = *((const struct diff_filepair **)a_);
154 const struct diff_filepair *b = *((const struct diff_filepair **)b_);
155 const char *name_a, *name_b;
156 int len_a, len_b, len;
157 int cmp;
158
159 name_a = a->one ? a->one->path : a->two->path;
160 name_b = b->one ? b->one->path : b->two->path;
161
162 len_a = strlen(name_a);
163 len_b = strlen(name_b);
164 len = (len_a < len_b) ? len_a : len_b;
165
166 /* strcmp will sort 'd' before 'd/e', we want 'd/e' before 'd' */
167 cmp = memcmp(name_a, name_b, len);
168 if (cmp)
169 return cmp;
4ce6fb80
JS
170 cmp = len_b - len_a;
171 if (cmp)
172 return cmp;
173 /*
174 * Move 'R'ename entries last so that all references of the file
175 * appear in the output before it is renamed (e.g., when a file
176 * was copied and renamed in the same commit).
177 */
178 return (a->status == 'R') - (b->status == 'R');
060df624
EN
179}
180
f2dc849e
JS
181static void show_filemodify(struct diff_queue_struct *q,
182 struct diff_options *options, void *data)
183{
184 int i;
060df624
EN
185
186 /*
187 * Handle files below a directory first, in case they are all deleted
188 * and the directory changes to a file or symlink.
189 */
190 qsort(q->queue, q->nr, sizeof(q->queue[0]), depth_first);
191
f2dc849e 192 for (i = 0; i < q->nr; i++) {
ae7c5dce 193 struct diff_filespec *ospec = q->queue[i]->one;
f2dc849e 194 struct diff_filespec *spec = q->queue[i]->two;
ae7c5dce
AG
195
196 switch (q->queue[i]->status) {
197 case DIFF_STATUS_DELETED:
f2dc849e 198 printf("D %s\n", spec->path);
ae7c5dce
AG
199 break;
200
201 case DIFF_STATUS_COPIED:
202 case DIFF_STATUS_RENAMED:
203 printf("%c \"%s\" \"%s\"\n", q->queue[i]->status,
204 ospec->path, spec->path);
205
206 if (!hashcmp(ospec->sha1, spec->sha1) &&
207 ospec->mode == spec->mode)
208 break;
209 /* fallthrough */
210
211 case DIFF_STATUS_TYPE_CHANGED:
212 case DIFF_STATUS_MODIFIED:
213 case DIFF_STATUS_ADDED:
03db4525
AG
214 /*
215 * Links refer to objects in another repositories;
216 * output the SHA-1 verbatim.
217 */
79559f27 218 if (no_data || S_ISGITLINK(spec->mode))
03db4525
AG
219 printf("M %06o %s %s\n", spec->mode,
220 sha1_to_hex(spec->sha1), spec->path);
221 else {
222 struct object *object = lookup_object(spec->sha1);
223 printf("M %06o :%d %s\n", spec->mode,
224 get_object_mark(object), spec->path);
225 }
ae7c5dce
AG
226 break;
227
228 default:
229 die("Unexpected comparison status '%c' for %s, %s",
230 q->queue[i]->status,
231 ospec->path ? ospec->path : "none",
232 spec->path ? spec->path : "none");
f2dc849e
JS
233 }
234 }
235}
236
237static const char *find_encoding(const char *begin, const char *end)
238{
239 const char *needle = "\nencoding ";
240 char *bol, *eol;
241
242 bol = memmem(begin, end ? end - begin : strlen(begin),
243 needle, strlen(needle));
244 if (!bol)
245 return git_commit_encoding;
246 bol += strlen(needle);
247 eol = strchrnul(bol, '\n');
248 *eol = '\0';
249 return bol;
250}
251
252static void handle_commit(struct commit *commit, struct rev_info *rev)
253{
254 int saved_output_format = rev->diffopt.output_format;
255 const char *author, *author_end, *committer, *committer_end;
256 const char *encoding, *message;
257 char *reencoded = NULL;
258 struct commit_list *p;
259 int i;
260
261 rev->diffopt.output_format = DIFF_FORMAT_CALLBACK;
262
263 parse_commit(commit);
264 author = strstr(commit->buffer, "\nauthor ");
265 if (!author)
266 die ("Could not find author in commit %s",
267 sha1_to_hex(commit->object.sha1));
268 author++;
269 author_end = strchrnul(author, '\n');
270 committer = strstr(author_end, "\ncommitter ");
271 if (!committer)
272 die ("Could not find committer in commit %s",
273 sha1_to_hex(commit->object.sha1));
274 committer++;
275 committer_end = strchrnul(committer, '\n');
276 message = strstr(committer_end, "\n\n");
277 encoding = find_encoding(committer_end, message);
278 if (message)
279 message += 2;
280
ebeec7db 281 if (commit->parents &&
4087a02e
EN
282 get_object_mark(&commit->parents->item->object) != 0 &&
283 !full_tree) {
f2dc849e
JS
284 parse_commit(commit->parents->item);
285 diff_tree_sha1(commit->parents->item->tree->object.sha1,
286 commit->tree->object.sha1, "", &rev->diffopt);
287 }
288 else
289 diff_root_tree_sha1(commit->tree->object.sha1,
290 "", &rev->diffopt);
291
03db4525 292 /* Export the referenced blobs, and remember the marks. */
f2dc849e 293 for (i = 0; i < diff_queued_diff.nr; i++)
03db4525
AG
294 if (!S_ISGITLINK(diff_queued_diff.queue[i]->two->mode))
295 handle_object(diff_queued_diff.queue[i]->two->sha1);
f2dc849e 296
df6a7ff7 297 mark_next_object(&commit->object);
f2dc849e
JS
298 if (!is_encoding_utf8(encoding))
299 reencoded = reencode_string(message, "UTF-8", encoding);
d8933f01
SP
300 if (!commit->parents)
301 printf("reset %s\n", (const char*)commit->util);
6e1c2344 302 printf("commit %s\nmark :%"PRIu32"\n%.*s\n%.*s\ndata %u\n%s",
f2dc849e
JS
303 (const char *)commit->util, last_idnum,
304 (int)(author_end - author), author,
305 (int)(committer_end - committer), committer,
306 (unsigned)(reencoded
307 ? strlen(reencoded) : message
308 ? strlen(message) : 0),
309 reencoded ? reencoded : message ? message : "");
8e0f7003 310 free(reencoded);
f2dc849e
JS
311
312 for (i = 0, p = commit->parents; p; p = p->next) {
313 int mark = get_object_mark(&p->item->object);
314 if (!mark)
315 continue;
316 if (i == 0)
317 printf("from :%d\n", mark);
f2dc849e 318 else
5070b49e 319 printf("merge :%d\n", mark);
f2dc849e
JS
320 i++;
321 }
f2dc849e 322
4087a02e
EN
323 if (full_tree)
324 printf("deleteall\n");
f2dc849e
JS
325 log_tree_diff_flush(rev);
326 rev->diffopt.output_format = saved_output_format;
327
328 printf("\n");
329
330 show_progress();
331}
332
333static void handle_tail(struct object_array *commits, struct rev_info *revs)
334{
335 struct commit *commit;
336 while (commits->nr) {
337 commit = (struct commit *)commits->objects[commits->nr - 1].item;
338 if (has_unshown_parent(commit))
339 return;
340 handle_commit(commit, revs);
341 commits->nr--;
342 }
343}
344
345static void handle_tag(const char *name, struct tag *tag)
346{
347 unsigned long size;
348 enum object_type type;
349 char *buf;
350 const char *tagger, *tagger_end, *message;
351 size_t message_size = 0;
02c48cd6 352 struct object *tagged;
2d8ad469
EN
353 int tagged_mark;
354 struct commit *p;
02c48cd6
EN
355
356 /* Trees have no identifer in fast-export output, thus we have no way
357 * to output tags of trees, tags of tags of trees, etc. Simply omit
358 * such tags.
359 */
360 tagged = tag->tagged;
361 while (tagged->type == OBJ_TAG) {
362 tagged = ((struct tag *)tagged)->tagged;
363 }
364 if (tagged->type == OBJ_TREE) {
365 warning("Omitting tag %s,\nsince tags of trees (or tags of tags of trees, etc.) are not supported.",
366 sha1_to_hex(tag->object.sha1));
367 return;
368 }
f2dc849e
JS
369
370 buf = read_sha1_file(tag->object.sha1, &type, &size);
371 if (!buf)
372 die ("Could not read tag %s", sha1_to_hex(tag->object.sha1));
373 message = memmem(buf, size, "\n\n", 2);
374 if (message) {
375 message += 2;
376 message_size = strlen(message);
377 }
378 tagger = memmem(buf, message ? message - buf : size, "\ntagger ", 8);
4e46a8d6
JS
379 if (!tagger) {
380 if (fake_missing_tagger)
381 tagger = "tagger Unspecified Tagger "
382 "<unspecified-tagger> 0 +0000";
383 else
384 tagger = "";
385 tagger_end = tagger + strlen(tagger);
386 } else {
387 tagger++;
388 tagger_end = strchrnul(tagger, '\n');
389 }
f2dc849e
JS
390
391 /* handle signed tags */
392 if (message) {
393 const char *signature = strstr(message,
394 "\n-----BEGIN PGP SIGNATURE-----\n");
395 if (signature)
396 switch(signed_tag_mode) {
397 case ABORT:
398 die ("Encountered signed tag %s; use "
399 "--signed-tag=<mode> to handle it.",
400 sha1_to_hex(tag->object.sha1));
401 case WARN:
402 warning ("Exporting signed tag %s",
403 sha1_to_hex(tag->object.sha1));
404 /* fallthru */
ee4bc371 405 case VERBATIM:
f2dc849e
JS
406 break;
407 case STRIP:
408 message_size = signature + 1 - message;
409 break;
410 }
411 }
412
2d8ad469
EN
413 /* handle tag->tagged having been filtered out due to paths specified */
414 tagged = tag->tagged;
415 tagged_mark = get_object_mark(tagged);
416 if (!tagged_mark) {
417 switch(tag_of_filtered_mode) {
418 case ABORT:
419 die ("Tag %s tags unexported object; use "
420 "--tag-of-filtered-object=<mode> to handle it.",
421 sha1_to_hex(tag->object.sha1));
422 case DROP:
423 /* Ignore this tag altogether */
424 return;
425 case REWRITE:
426 if (tagged->type != OBJ_COMMIT) {
427 die ("Tag %s tags unexported %s!",
428 sha1_to_hex(tag->object.sha1),
429 typename(tagged->type));
430 }
431 p = (struct commit *)tagged;
432 for (;;) {
433 if (p->parents && p->parents->next)
434 break;
435 if (p->object.flags & UNINTERESTING)
436 break;
437 if (!(p->object.flags & TREESAME))
438 break;
439 if (!p->parents)
440 die ("Can't find replacement commit for tag %s\n",
441 sha1_to_hex(tag->object.sha1));
442 p = p->parents->item;
443 }
444 tagged_mark = get_object_mark(&p->object);
445 }
446 }
447
f2dc849e
JS
448 if (!prefixcmp(name, "refs/tags/"))
449 name += 10;
4e46a8d6 450 printf("tag %s\nfrom :%d\n%.*s%sdata %d\n%.*s\n",
2d8ad469 451 name, tagged_mark,
f2dc849e 452 (int)(tagger_end - tagger), tagger,
4e46a8d6 453 tagger == tagger_end ? "" : "\n",
f2dc849e
JS
454 (int)message_size, (int)message_size, message ? message : "");
455}
456
457static void get_tags_and_duplicates(struct object_array *pending,
c455c87c 458 struct string_list *extra_refs)
f2dc849e
JS
459{
460 struct tag *tag;
461 int i;
462
463 for (i = 0; i < pending->nr; i++) {
464 struct object_array_entry *e = pending->objects + i;
465 unsigned char sha1[20];
466 struct commit *commit = commit;
467 char *full_name;
468
469 if (dwim_ref(e->name, strlen(e->name), sha1, &full_name) != 1)
470 continue;
471
472 switch (e->item->type) {
473 case OBJ_COMMIT:
474 commit = (struct commit *)e->item;
475 break;
476 case OBJ_TAG:
477 tag = (struct tag *)e->item;
1982467d
EFL
478
479 /* handle nested tags */
f2dc849e 480 while (tag && tag->object.type == OBJ_TAG) {
1982467d 481 parse_object(tag->object.sha1);
1d2f80fa 482 string_list_append(extra_refs, full_name)->util = tag;
f2dc849e
JS
483 tag = (struct tag *)tag->tagged;
484 }
485 if (!tag)
486 die ("Tag %s points nowhere?", e->name);
487 switch(tag->object.type) {
488 case OBJ_COMMIT:
489 commit = (struct commit *)tag;
490 break;
491 case OBJ_BLOB:
492 handle_object(tag->object.sha1);
493 continue;
1982467d 494 default: /* OBJ_TAG (nested tags) is already handled */
c0582c53
EFL
495 warning("Tag points to object of unexpected type %s, skipping.",
496 typename(tag->object.type));
497 continue;
f2dc849e
JS
498 }
499 break;
500 default:
2d07f6d4
EFL
501 warning("%s: Unexpected object of type %s, skipping.",
502 e->name,
503 typename(e->item->type));
504 continue;
f2dc849e
JS
505 }
506 if (commit->util)
507 /* more than one name for the same object */
1d2f80fa 508 string_list_append(extra_refs, full_name)->util = commit;
f2dc849e
JS
509 else
510 commit->util = full_name;
511 }
512}
513
c455c87c 514static void handle_tags_and_duplicates(struct string_list *extra_refs)
f2dc849e
JS
515{
516 struct commit *commit;
517 int i;
518
519 for (i = extra_refs->nr - 1; i >= 0; i--) {
c455c87c 520 const char *name = extra_refs->items[i].string;
f2dc849e
JS
521 struct object *object = extra_refs->items[i].util;
522 switch (object->type) {
523 case OBJ_TAG:
524 handle_tag(name, (struct tag *)object);
525 break;
526 case OBJ_COMMIT:
527 /* create refs pointing to already seen commits */
528 commit = (struct commit *)object;
529 printf("reset %s\nfrom :%d\n\n", name,
530 get_object_mark(&commit->object));
531 show_progress();
532 break;
533 }
534 }
535}
536
df6a7ff7
PB
537static void export_marks(char *file)
538{
539 unsigned int i;
540 uint32_t mark;
541 struct object_decoration *deco = idnums.hash;
542 FILE *f;
96d69b55 543 int e = 0;
df6a7ff7
PB
544
545 f = fopen(file, "w");
546 if (!f)
bb6ad28c 547 die_errno("Unable to open marks file %s for writing.", file);
df6a7ff7 548
69913575
JH
549 for (i = 0; i < idnums.size; i++) {
550 if (deco->base && deco->base->type == 1) {
df6a7ff7 551 mark = ptr_to_mark(deco->decoration);
96d69b55
MA
552 if (fprintf(f, ":%"PRIu32" %s\n", mark,
553 sha1_to_hex(deco->base->sha1)) < 0) {
554 e = 1;
555 break;
556 }
df6a7ff7 557 }
69913575 558 deco++;
df6a7ff7
PB
559 }
560
96d69b55
MA
561 e |= ferror(f);
562 e |= fclose(f);
563 if (e)
df6a7ff7
PB
564 error("Unable to write marks file %s.", file);
565}
566
69913575 567static void import_marks(char *input_file)
df6a7ff7
PB
568{
569 char line[512];
570 FILE *f = fopen(input_file, "r");
571 if (!f)
d824cbba 572 die_errno("cannot read '%s'", input_file);
df6a7ff7
PB
573
574 while (fgets(line, sizeof(line), f)) {
575 uint32_t mark;
576 char *line_end, *mark_end;
577 unsigned char sha1[20];
578 struct object *object;
579
580 line_end = strchr(line, '\n');
581 if (line[0] != ':' || !line_end)
582 die("corrupt mark line: %s", line);
69913575 583 *line_end = '\0';
df6a7ff7
PB
584
585 mark = strtoumax(line + 1, &mark_end, 10);
586 if (!mark || mark_end == line + 1
587 || *mark_end != ' ' || get_sha1(mark_end + 1, sha1))
588 die("corrupt mark line: %s", line);
589
590 object = parse_object(sha1);
591 if (!object)
592 die ("Could not read blob %s", sha1_to_hex(sha1));
593
594 if (object->flags & SHOWN)
595 error("Object %s already has a mark", sha1);
596
597 mark_object(object, mark);
598 if (last_idnum < mark)
599 last_idnum = mark;
600
601 object->flags |= SHOWN;
602 }
603 fclose(f);
604}
605
f2dc849e
JS
606int cmd_fast_export(int argc, const char **argv, const char *prefix)
607{
608 struct rev_info revs;
3cd47459 609 struct object_array commits = OBJECT_ARRAY_INIT;
183113a5 610 struct string_list extra_refs = STRING_LIST_INIT_NODUP;
f2dc849e 611 struct commit *commit;
df6a7ff7 612 char *export_filename = NULL, *import_filename = NULL;
f2dc849e
JS
613 struct option options[] = {
614 OPT_INTEGER(0, "progress", &progress,
615 "show progress after <n> objects"),
616 OPT_CALLBACK(0, "signed-tags", &signed_tag_mode, "mode",
617 "select handling of signed tags",
618 parse_opt_signed_tag_mode),
2d8ad469
EN
619 OPT_CALLBACK(0, "tag-of-filtered-object", &tag_of_filtered_mode, "mode",
620 "select handling of tags that tag filtered objects",
621 parse_opt_tag_of_filtered_mode),
df6a7ff7
PB
622 OPT_STRING(0, "export-marks", &export_filename, "FILE",
623 "Dump marks to this file"),
624 OPT_STRING(0, "import-marks", &import_filename, "FILE",
625 "Import marks from this file"),
4e46a8d6
JS
626 OPT_BOOLEAN(0, "fake-missing-tagger", &fake_missing_tagger,
627 "Fake a tagger when tags lack one"),
7f40ab09
EN
628 OPT_BOOLEAN(0, "full-tree", &full_tree,
629 "Output full tree for each commit"),
79559f27
GI
630 { OPTION_NEGBIT, 0, "data", &no_data, NULL,
631 "Skip output of blob data",
632 PARSE_OPT_NOARG | PARSE_OPT_NEGHELP, NULL, 1 },
f2dc849e
JS
633 OPT_END()
634 };
635
dcfdbdf0
MV
636 if (argc == 1)
637 usage_with_options (fast_export_usage, options);
638
f2dc849e 639 /* we handle encodings */
ef90d6d4 640 git_config(git_default_config, NULL);
f2dc849e
JS
641
642 init_revisions(&revs, prefix);
668f3aa7 643 revs.topo_order = 1;
2374502c 644 revs.show_source = 1;
32164131 645 revs.rewrite_parents = 1;
f2dc849e 646 argc = setup_revisions(argc, argv, &revs, NULL);
37782920 647 argc = parse_options(argc, argv, prefix, options, fast_export_usage, 0);
f2dc849e
JS
648 if (argc > 1)
649 usage_with_options (fast_export_usage, options);
650
df6a7ff7
PB
651 if (import_filename)
652 import_marks(import_filename);
653
4087a02e
EN
654 if (import_filename && revs.prune_data)
655 full_tree = 1;
656
f2dc849e
JS
657 get_tags_and_duplicates(&revs.pending, &extra_refs);
658
3d51e1b5
MK
659 if (prepare_revision_walk(&revs))
660 die("revision walk setup failed");
f2dc849e
JS
661 revs.diffopt.format_callback = show_filemodify;
662 DIFF_OPT_SET(&revs.diffopt, RECURSIVE);
663 while ((commit = get_revision(&revs))) {
664 if (has_unshown_parent(commit)) {
f2dc849e 665 add_object_array(&commit->object, NULL, &commits);
f2dc849e
JS
666 }
667 else {
668 handle_commit(commit, &revs);
669 handle_tail(&commits, &revs);
670 }
671 }
672
673 handle_tags_and_duplicates(&extra_refs);
674
df6a7ff7
PB
675 if (export_filename)
676 export_marks(export_filename);
677
f2dc849e
JS
678 return 0;
679}