From 2efe38e7da40fdf2b6e0261984d7adaab16ad930 Mon Sep 17 00:00:00 2001 From: Dmitry Ivankov Date: Mon, 22 Aug 2011 18:10:18 +0600 Subject: [PATCH 1/2] fast-import: add tests for tagging blobs 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 Signed-off-by: Junio C Hamano --- 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 78d978684d..ca21458612 100644 --- a/fast-import.c +++ b/fast-import.c @@ -2688,13 +2688,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 2a53640c5b..80b06f0714 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 < Date: Mon, 22 Aug 2011 18:10:19 +0600 Subject: [PATCH 2/2] fast-import: allow to tag newly created objects fast-import allows to tag objects by sha1 and to query sha1 of objects being imported. So it should allow to tag these objects, make it do so. Signed-off-by: Dmitry Ivankov Signed-off-by: Junio C Hamano --- fast-import.c | 10 +++++++--- t/t9300-fast-import.sh | 26 ++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 3 deletions(-) diff --git a/fast-import.c b/fast-import.c index ca21458612..4f56f772a3 100644 --- a/fast-import.c +++ b/fast-import.c @@ -2688,9 +2688,13 @@ static void parse_new_tag(void) type = oe->type; hashcpy(sha1, oe->idx.sha1); } else if (!get_sha1(from, sha1)) { - type = sha1_object_info(sha1, NULL); - if (type < 0) - die("Not a valid object: %s", from); + 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 80b06f0714..ab9493478c 100755 --- a/t/t9300-fast-import.sh +++ b/t/t9300-fast-import.sh @@ -188,12 +188,32 @@ test_expect_success \ test_cmp expect marks.new' test_tick +new_blob=$(echo testing | git hash-object --stdin) cat >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