pack-refs: prune top-level refs like "refs/foo"
[gitweb.git] / refs.c
diff --git a/refs.c b/refs.c
index 59fb70087a438a763cdbfb2c4e75de36d533aead..130b89e92b6c8ff005e61fd5051845bf1b247fd0 100644 (file)
--- a/refs.c
+++ b/refs.c
@@ -1520,9 +1520,8 @@ static enum peel_status peel_object(const unsigned char *name, unsigned char *sh
 
        if (o->type == OBJ_NONE) {
                int type = sha1_object_info(name, NULL);
-               if (type < 0)
+               if (type < 0 || !object_as_type(o, type, 0))
                        return PEEL_INVALID;
-               o->type = type;
        }
 
        if (o->type != OBJ_TAG)
@@ -2354,7 +2353,8 @@ static void try_remove_empty_parents(char *name)
 /* make sure nobody touched the ref, and unlink */
 static void prune_ref(struct ref_to_prune *r)
 {
-       struct ref_lock *lock = lock_ref_sha1(r->name + 5, r->sha1);
+       struct ref_lock *lock = lock_any_ref_for_update(r->name, r->sha1,
+                                                       0, NULL);
 
        if (lock) {
                unlink_or_warn(git_path("%s", r->name));