diff --git a/fast-import.c b/fast-import.c index 96ccd2aece..742e7da6b8 100644 --- a/fast-import.c +++ b/fast-import.c @@ -2726,13 +2726,13 @@ static void parse_new_tag(void) type = oe->type; hashcpy(sha1, oe->idx.sha1); } else if (!get_sha1(from, sha1)) { - unsigned long size; - char *buf; - - buf = read_sha1_file(sha1, &type, &size); - if (!buf || size < 46) - die("Not a valid commit: %s", from); - free(buf); + struct object_entry *oe = find_object(sha1); + if (!oe) { + type = sha1_object_info(sha1, NULL); + if (type < 0) + die("Not a valid object: %s", from); + } else + type = oe->type; } else die("Invalid ref name or SHA1 expression: %s", from); read_next_command(); diff --git a/t/t9300-fast-import.sh b/t/t9300-fast-import.sh index dbe109963e..1a6c06631c 100755 --- a/t/t9300-fast-import.sh +++ b/t/t9300-fast-import.sh @@ -94,6 +94,12 @@ data <expect <actual && + test_cmp expect actual +' + cat >expect <input < 0 +0000 +data 0 +M 644 :6 new_blob +#pretend we got sha1 from fast-import +ls "new_blob" + +tag series-A-blob-3 +from $new_blob +data <expect <actual && + git cat-file tag tags/series-A-blob-3 >>actual && + test_cmp expect actual' + test_tick cat >input <