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

[PATCH] git-revover-tags-script

From
Eric W. Biederman <ebiederm@xmission.com>
Date
Jul 16, 2005, 20:20 UTC
Message-ID
<m1u0iuo63i.fsf@ebiederm.dsl.xmission.com>

First pass at a script to dig through .git/objects and find dangling tags. It likely has a lot of weird limitations, I don't know if it will work with packs, and the policy it implments is pretty stupid, but it is a sane start and should keep people from needing to rsync anything except the .git/objects part of the tree.

The current policy is if a tag's gpg signature can be verified and if the tag name does not conflict with an existing tag place it in .git/refs/tags/. So far this only works with dangling tags so I don't know if these tags will even be pulled with the pack methods. But since we aren't quite going at full speed on those yet we should be good.

Signed-off-by: Eric W. Biederman <ebiederm@xmission.com>
---
 Makefile                |    3 ++-
 git-recover-tags-script |   27 +++++++++++++++++++++++++++
 2 files changed, 29 insertions(+), 1 deletions(-)
 create mode 100755 git-recover-tags-script
4b171e71fd6b5de56dd4a93ea203e49115c2caee
diff --git a/Makefile b/Makefile
--- a/Makefile
+++ b/Makefile
@@ -36,7 +36,8 @@ SCRIPTS=git git-apply-patch-script git-m
 	git-reset-script git-add-script git-checkout-script git-clone-script \
 	gitk git-cherry git-rebase-script git-relink-script git-repack-script \
 	git-format-patch-script git-sh-setup-script git-push-script \
-	git-branch-script git-parse-remote git-verify-tag-script
+	git-branch-script git-parse-remote git-verify-tag-script \
+	git-recover-tags-script
 
 PROG=   git-update-cache git-diff-files git-init-db git-write-tree \
 	git-read-tree git-commit-tree git-cat-file git-fsck-cache \
diff --git a/git-recover-tags-script b/git-recover-tags-script
new file mode 100755
--- /dev/null
+++ b/git-recover-tags-script
@@ -0,0 +1,27 @@
+#!/bin/sh
+# Copyright (c) 2005 Eric Biederman
+
+. git-sh-setup-script || die "Not a git archive"
+
+TMP_TAG=".tmp-tag.$$"
+git-fsck-cache |
+while read status type sha1 rest ; do
+	if [ '(' "$status" == "dangling" ')' -a '(' "$type" == "tag" ')' ] ; then
+		if ! git-verify-tag-script $sha1 ; then
+			echo "Could not verify tag $sha1"
+		else
+			tag=$(git-cat-file tag $sha1 | sed -ne 's/^tag //p')
+			tagger=$(git-cat-file tag $sha1 | sed -ne 's/^tagger //p')
+			if [ ! -e $GIT_DIR/refs/tags/$tag ]; then
+				echo "installing tag $tag tagger $tagger"
+				mkdir -p $GIT_DIR/refs/tags
+				echo "$sha1" > $GIT_DIR/refs/tags/$tag
+			fi
+		fi
+	else
+		if [ "$status" != "dangling" ] ; then
+			echo "$status $type $sha1 $rest";
+		fi
+	fi
+done
+rm -f $TMP_TAG
Next: Junio C Hamano
Message 1 of 12 in “git-revover-tags-script”
  1. git-revover-tags-scriptEric W. Biederman, Jul 16, 2005
  2. Junio C HamanoJul 17, 2005
  3. Eric W. BiedermanJul 17, 2005
  4. Junio C HamanoJul 17, 2005
  5. Eric W. BiedermanJul 18, 2005
  6. Junio C HamanoJul 18, 2005
  7. Eric W. BiedermanJul 18, 2005
  8. Junio C HamanoJul 18, 2005
  9. Eric W. BiedermanJul 18, 2005
  10. [RFD] server-info to help clientsJunio C Hamano, Jul 20, 2005
  11. David LangJul 20, 2005
  12. Junio C HamanoJul 20, 2005

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.