23
};
24
25
static int progress;
26
-static enum { VERBATIM, WARN, STRIP, ABORT } signed_tag_mode = ABORT;
26
+static enum { ABORT, VERBATIM, WARN, STRIP } signed_tag_mode = ABORT;
27
+static enum { ERROR, DROP, REWRITE } tag_of_filtered_mode = ABORT;
28
static int fake_missing_tagger;
29
30
static int parse_opt_signed_tag_mode(const struct option *opt,
43
return 0;
44
}
45
46
+static int parse_opt_tag_of_filtered_mode(const struct option *opt,
47
+ const char *arg, int unset)
48
+{
49
+ if (unset || !strcmp(arg, "abort"))
50
+ tag_of_filtered_mode = ABORT;
51
+ else if (!strcmp(arg, "drop"))
52
+ tag_of_filtered_mode = DROP;
53
+ else if (!strcmp(arg, "rewrite"))
54
+ tag_of_filtered_mode = REWRITE;
55
+ else
56
+ return error("Unknown tag-of-filtered mode: %s", arg);
57
+ return 0;
58
+}
59
+
60
static struct decoration idnums;
61
static uint32_t last_idnum;
62
305
const char *tagger, *tagger_end, *message;
306
size_t message_size = 0;
307
struct object *tagged;
308
+ int tagged_mark;
309
+ struct commit *p;
310
311
/* Trees have no identifer in fast-export output, thus we have no way
312
* to output tags of trees, tags of tags of trees, etc. Simply omit
365
}
366
}
367
368
+ /* handle tag->tagged having been filtered out due to paths specified */
369
+ tagged = tag->tagged;
370
+ tagged_mark = get_object_mark(tagged);
371
+ if (!tagged_mark) {
372
+ switch(tag_of_filtered_mode) {
373
+ case ABORT:
374
+ die ("Tag %s tags unexported object; use "
375
+ "--tag-of-filtered-object=<mode> to handle it.",
376
+ sha1_to_hex(tag->object.sha1));
377
+ case DROP:
378
+ /* Ignore this tag altogether */
379
+ return;
380
+ case REWRITE:
381
+ if (tagged->type != OBJ_COMMIT) {
382
+ die ("Tag %s tags unexported %s!",
383
+ sha1_to_hex(tag->object.sha1),
384
+ typename(tagged->type));
385
+ }
386
+ p = (struct commit *)tagged;
387
+ for (;;) {
388
+ if (p->parents && p->parents->next)
389
+ break;
390
+ if (p->object.flags & UNINTERESTING)
391
+ break;
392
+ if (!(p->object.flags & TREESAME))
393
+ break;
394
+ if (!p->parents)
395
+ die ("Can't find replacement commit for tag %s\n",
396
+ sha1_to_hex(tag->object.sha1));
397
+ p = p->parents->item;
398
+ }
399
+ tagged_mark = get_object_mark(&p->object);
400
+ }
401
+ }
402
+
403
if (!prefixcmp(name, "refs/tags/"))
404
name += 10;
405
printf("tag %s\nfrom :%d\n%.*s%sdata %d\n%.*s\n",
354
- name, get_object_mark(tag->tagged),
406
+ name, tagged_mark,
407
(int)(tagger_end - tagger), tagger,
408
tagger == tagger_end ? "" : "\n",
409
(int)message_size, (int)message_size, message ? message : "");
565
OPT_CALLBACK(0, "signed-tags", &signed_tag_mode, "mode",
566
"select handling of signed tags",
567
parse_opt_signed_tag_mode),
568
+ OPT_CALLBACK(0, "tag-of-filtered-object", &tag_of_filtered_mode, "mode",
569
+ "select handling of tags that tag filtered objects",
570
+ parse_opt_tag_of_filtered_mode),
571
OPT_STRING(0, "export-marks", &export_filename, "FILE",
572
"Dump marks to this file"),
573
OPT_STRING(0, "import-marks", &import_filename, "FILE",