From: Dmitry Ivankov Date: Mon, 22 Aug 2011 12:10:18 GMT Subject: [PATCH 1/2] fast-import: add tests for tagging blobs Message-ID: <1314015019-6636-2-git-send-email-divanorama@gmail.com> In-Reply-To: <1314015019-6636-1-git-send-email-divanorama@gmail.com> fast-import allows to create an annotated tag that annotates a blob, via mark or direct sha1 specification. For mark it works, for sha1 it tries to read the object. It tries to do so via read_sha1_file, and then checks the size to be at least 46. That's weird, let's just allow to (annotated) tag any object referenced by sha1. If the object originates from our packfile, we still fail though. Signed-off-by: Dmitry Ivankov --- fast-import.c | 10 +++------- t/t9300-fast-import.sh | 41 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+), 7 deletions(-) diff --git a/fast-import.c b/fast-import.c index 7cc2262..0b0f598 100644 --- a/fast-import.c +++ b/fast-import.c @@ -2690,13 +2690,9 @@ 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); + type = sha1_object_info(sha1, NULL); + if (type < 0) + die("Not a valid object: %s", from); } 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 f256475..41f0d02 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 <expect <actual && + test_cmp expect actual' + +test_tick +cat >input < $GIT_COMMITTER_DATE data <