Skip to content

Commit

Permalink
fast-import: tag may point to any object type
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Dmitry Potapov authored and Junio C Hamano committed Jan 15, 2010
1 parent c8cba79 commit 8db751a
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions fast-import.c
Original file line number Diff line number Diff line change
Expand Up @@ -2225,6 +2225,7 @@ static void parse_new_tag(void)
struct tag *t;
uintmax_t from_mark = 0;
unsigned char sha1[20];
enum object_type type;

/* Obtain the new tag name from the rest of our command */
sp = strchr(command_buf.buf, ' ') + 1;
Expand All @@ -2245,19 +2246,18 @@ static void parse_new_tag(void)
s = lookup_branch(from);
if (s) {
hashcpy(sha1, s->sha1);
type = OBJ_COMMIT;
} else if (*from == ':') {
struct object_entry *oe;
from_mark = strtoumax(from + 1, NULL, 10);
oe = find_mark(from_mark);
if (oe->type != OBJ_COMMIT)
die("Mark :%" PRIuMAX " not a commit", from_mark);
type = oe->type;
hashcpy(sha1, oe->sha1);
} else if (!get_sha1(from, sha1)) {
unsigned long size;
char *buf;

buf = read_object_with_reference(sha1,
commit_type, &size, sha1);
buf = read_sha1_file(sha1, &type, &size);
if (!buf || size < 46)
die("Not a valid commit: %s", from);
free(buf);
Expand All @@ -2282,7 +2282,7 @@ static void parse_new_tag(void)
"object %s\n"
"type %s\n"
"tag %s\n",
sha1_to_hex(sha1), commit_type, t->name);
sha1_to_hex(sha1), typename(type), t->name);
if (tagger)
strbuf_addf(&new_data,
"tagger %s\n", tagger);
Expand Down

0 comments on commit 8db751a

Please sign in to comment.