fast-import: tag may point to any object type
If you tried to export the official git repository, and then to import it back then git-fast-import would die complaining that "Mark :1 not a commit". Accordingly to a generated crash file, Mark 1 is not a commit but a blob, which is pointed by junio-gpg-pub tag. Because git-tag allows to create such tags, git-fast-import should import them. Signed-off-by: Dmitry Potapov <dpotapov@gmail.com> Acked-by: Shawn O. Pearce <spearce@spearce.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Dmitry Potapov committed
Jan 14, 2010 at 07:44 UTC
8db751a8f953bf1a571e1fd825d1a4219e65b501
1 file changed
+5
-5
fast-import.c
+5
-5
@@ -2225,6 +2225,7 @@ static void parse_new_tag(void)
2225
struct tag *t;
2226
uintmax_t from_mark = 0;
2227
unsigned char sha1[20];
2228
+ enum object_type type;
2229
2230
/* Obtain the new tag name from the rest of our command */
2231
sp = strchr(command_buf.buf, ' ') + 1;
@@ -2245,19 +2246,18 @@ static void parse_new_tag(void)
2246
s = lookup_branch(from);
2247
if (s) {
2248
hashcpy(sha1, s->sha1);
2249
+ type = OBJ_COMMIT;
2250
} else if (*from == ':') {
2251
struct object_entry *oe;
2252
from_mark = strtoumax(from + 1, NULL, 10);
2253
oe = find_mark(from_mark);
2252
- if (oe->type != OBJ_COMMIT)
2253
- die("Mark :%" PRIuMAX " not a commit", from_mark);
2254
+ type = oe->type;
2255
hashcpy(sha1, oe->sha1);
2256
} else if (!get_sha1(from, sha1)) {
2257
unsigned long size;
2258
char *buf;
2259
2259
- buf = read_object_with_reference(sha1,
2260
- commit_type, &size, sha1);
2260
+ buf = read_sha1_file(sha1, &type, &size);
2261
if (!buf || size < 46)
2262
die("Not a valid commit: %s", from);
2263
free(buf);
@@ -2282,7 +2282,7 @@ static void parse_new_tag(void)
2282
"object %s\n"
2283
"type %s\n"
2284
"tag %s\n",
2285
- sha1_to_hex(sha1), commit_type, t->name);
2285
+ sha1_to_hex(sha1), typename(type), t->name);
2286
if (tagger)
2287
strbuf_addf(&new_data,
2288
"tagger %s\n", tagger);