Merge branch 'lj/refs' into next

* lj/refs:
  Do not create tag leading directories since git update-ref does it.
  Check that a tag exists using show-ref instead of looking for the ref file.
  Use git-update-ref to delete a tag instead of rm()ing the ref file.
  Fix refs.c;:repack_without_ref() clean-up path
This commit is contained in:
Junio C Hamano
2006-10-02 00:50:33 -07:00
2 changed files with 9 additions and 7 deletions

View File

@@ -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 $?
;;
-*)
@@ -64,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"`
@@ -110,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"

3
refs.c
View File

@@ -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) {