From 26a063a10bca57f65d8fed6c4550a70d44a70b81 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Sun, 1 Oct 2006 11:41:00 -0700 Subject: [PATCH 1/4] Fix refs.c;:repack_without_ref() clean-up path The function repack_without_ref() passes a lock-file structure on the stack to hold_lock_file_for_update(), which in turn registers it to be cleaned up via atexit(). This is a big no-no. This is the same bug James Bottomley fixed with commit 31f584c242e7af28018ff920b6c8d1952beadbd4. Signed-off-by: Junio C Hamano --- refs.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/refs.c b/refs.c index 221eb3896e..aa4c4e0b94 100644 --- a/refs.c +++ b/refs.c @@ -621,12 +621,13 @@ struct ref_lock *lock_any_ref_for_update(const char *ref, const unsigned char *o return lock_ref_sha1_basic(ref, old_sha1, NULL); } +static struct lock_file packlock; + static int repack_without_ref(const char *refname) { struct ref_list *list, *packed_ref_list; int fd; int found = 0; - struct lock_file packlock; packed_ref_list = get_packed_refs(); for (list = packed_ref_list; list; list = list->next) { From d3d0013c59ed840520b86a65697137cb2c62819c Mon Sep 17 00:00:00 2001 From: Christian Couder Date: Sun, 1 Oct 2006 22:16:22 +0200 Subject: [PATCH 2/4] Use git-update-ref to delete a tag instead of rm()ing the ref file. Signed-off-by: Christian Couder Signed-off-by: Junio C Hamano --- git-tag.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/git-tag.sh b/git-tag.sh index 2bde3c05fc..6463b314c6 100755 --- a/git-tag.sh +++ b/git-tag.sh @@ -47,8 +47,10 @@ do -d) shift tag_name="$1" - rm "$GIT_DIR/refs/tags/$tag_name" && \ - echo "Deleted tag $tag_name." + tag=$(git-show-ref --verify --hash -- "refs/tags/$tag_name") || + die "Seriously, what tag are you talking about?" + git-update-ref -m 'tag: delete' -d "refs/tags/$tag_name" "$tag" && + echo "Deleted tag $tag_name." exit $? ;; -*) From b431b2822f361efcb940adbc1f2097e122e90ed9 Mon Sep 17 00:00:00 2001 From: Christian Couder Date: Sun, 1 Oct 2006 22:33:04 +0200 Subject: [PATCH 3/4] Check that a tag exists using show-ref instead of looking for the ref file. Signed-off-by: Christian Couder Signed-off-by: Junio C Hamano --- git-tag.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/git-tag.sh b/git-tag.sh index 6463b314c6..a3f1819b0e 100755 --- a/git-tag.sh +++ b/git-tag.sh @@ -66,7 +66,7 @@ done name="$1" [ "$name" ] || usage prev=0000000000000000000000000000000000000000 -if test -e "$GIT_DIR/refs/tags/$name" +if git-show-ref --verify --quiet -- "refs/tags/$name" then test -n "$force" || die "tag '$name' already exists" prev=`git rev-parse "refs/tags/$name"` From 367337040d8d39294bf676672dfefc542717195b Mon Sep 17 00:00:00 2001 From: Christian Couder Date: Mon, 2 Oct 2006 06:36:15 +0200 Subject: [PATCH 4/4] Do not create tag leading directories since git update-ref does it. Signed-off-by: Christian Couder Signed-off-by: Junio C Hamano --- git-tag.sh | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/git-tag.sh b/git-tag.sh index a3f1819b0e..ac269e3277 100755 --- a/git-tag.sh +++ b/git-tag.sh @@ -112,6 +112,5 @@ if [ "$annotate" ]; then object=$(git-mktag < "$GIT_DIR"/TAG_TMP) fi -leading=`expr "refs/tags/$name" : '\(.*\)/'` && -mkdir -p "$GIT_DIR/$leading" && -GIT_DIR="$GIT_DIR" git update-ref "refs/tags/$name" "$object" "$prev" +git update-ref "refs/tags/$name" "$object" "$prev" +