git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
Dec 18, 2008, 19:45 UTC
Message-ID
<alpine.DEB.1.00.0812182044100.6952@intel-tinevez-2-302>
In-Reply-To
<7vbpv9guqd.fsf@gitster.siamese.dyndns.org>

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@gmx.de>
---
	On Thu, 18 Dec 2008, Junio C Hamano wrote:
	> Miklos Vajna <vmiklos@frugalware.org> 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
Previous: Junio C HamanoNext: Miklos Vajna
Message 3 of 11 in “git-fast-export and tags without a tagger”
  1. Miklos VajnaDec 18, 2008
  2. Junio C HamanoDec 18, 2008
  3. fast-export: deal with tag objects that do not have a taggerJohannes Schindelin, Dec 18, 2008
  4. Miklos VajnaDec 18, 2008
  5. Junio C HamanoDec 18, 2008
  6. Miklos VajnaDec 18, 2008
  7. fast-export: deal with tag objects that do not have a taggerJohannes Schindelin, Dec 20, 2008
  8. fast-import: make tagger information optionalJunio C Hamano, Dec 20, 2008
  9. Miklos VajnaDec 20, 2008
  10. Shawn O. PearceDec 20, 2008
  11. Miklos VajnaDec 18, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.