[PATCH] fast-export: deal with tag objects that do not have a tagger

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



When no tagger was found (old Git produced tags like this), a
tagger "No Tagger <no-tagger>" with a tag date of the beginning of
(Unix) time is output, so that fast-import is
still able to import the result.

Signed-off-by: Johannes Schindelin <johannes.schindelin@xxxxxx>
---

	On Thu, 18 Dec 2008, Junio C Hamano wrote:

	> Miklos Vajna <vmiklos@xxxxxxxxxxxxxx> writes:
	> 
	> > Tags created with ancient versions of git have no tagger. The 
	> > udev repo has such tags, for example:
	> >
	> > $ git cat-file tag 4ea98ca6db3b84f5bc16eac8574e5c209ec823ce
	> > object face198a5f21027fefe796dc01e19e349a2d36ce
	> > type commit
	> > tag 062
	> >
	> > fast-export will fail on these repos. From IRC:
	> 
	> Is "fast-export" the only thing that chokes on these tags?

	I think so.  The responsible code is in fast-export.c, in any 
	case.  Of course, fast-import refuses to import a tag without a 
	tagger, so...

 builtin-fast-export.c  |   12 ++++++++----
 t/t9301-fast-export.sh |   15 +++++++++++++++
 2 files changed, 23 insertions(+), 4 deletions(-)

diff --git a/builtin-fast-export.c b/builtin-fast-export.c
index 7d5d57a..0af4e6f 100644
--- a/builtin-fast-export.c
+++ b/builtin-fast-export.c
@@ -297,10 +297,14 @@ static void handle_tag(const char *name, struct tag *tag)
 		message_size = strlen(message);
 	}
 	tagger = memmem(buf, message ? message - buf : size, "\ntagger ", 8);
-	if (!tagger)
-		die ("No tagger for tag %s", sha1_to_hex(tag->object.sha1));
-	tagger++;
-	tagger_end = strchrnul(tagger, '\n');
+	if (!tagger) {
+		warning ("No tagger for tag %s", sha1_to_hex(tag->object.sha1));
+		tagger = "tagger No Tagger <no-tagger> 0 +0000";
+		tagger_end = tagger + strlen(tagger);
+	} else {
+		tagger++;
+		tagger_end = strchrnul(tagger, '\n');
+	}
 
 	/* handle signed tags */
 	if (message) {
diff --git a/t/t9301-fast-export.sh b/t/t9301-fast-export.sh
index 2057435..2312d7a 100755
--- a/t/t9301-fast-export.sh
+++ b/t/t9301-fast-export.sh
@@ -239,4 +239,19 @@ test_expect_success 'fast-export | fast-import when master is tagged' '
 
 '
 
+cat > tag-content << EOF
+object $(git rev-parse HEAD)
+type commit
+tag rosten
+EOF
+
+test_expect_success 'cope with tagger-less tags' '
+
+	TAG=$(git hash-object -t tag -w tag-content) &&
+	git update-ref refs/tags/sonnenschein $TAG &&
+	git fast-export -C -C --signed-tags=strip --all > output &&
+	test $(grep -c "^tag " output) = 4
+
+'
+
 test_done
-- 
1.6.1.rc3.368.g63acc

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux