Merge branch 'ks/verify-filename-non-option-error-message-tweak'
[gitweb.git] / refs / ref-cache.c
index 76bb723c8674c3022b271c93b587d941c8e6d397..4f850e1b5c9ed1fae746a804ceceee42e2f54b86 100644 (file)
@@ -38,7 +38,6 @@ struct ref_entry *create_ref_entry(const char *refname,
 
        FLEX_ALLOC_STR(ref, name, refname);
        oidcpy(&ref->u.value.oid, oid);
-       oidclr(&ref->u.value.peeled);
        ref->flag = flag;
        return ref;
 }
@@ -491,49 +490,10 @@ static int cache_ref_iterator_advance(struct ref_iterator *ref_iterator)
        }
 }
 
-enum peel_status peel_entry(struct ref_entry *entry, int repeel)
-{
-       enum peel_status status;
-
-       if (entry->flag & REF_KNOWS_PEELED) {
-               if (repeel) {
-                       entry->flag &= ~REF_KNOWS_PEELED;
-                       oidclr(&entry->u.value.peeled);
-               } else {
-                       return is_null_oid(&entry->u.value.peeled) ?
-                               PEEL_NON_TAG : PEEL_PEELED;
-               }
-       }
-       if (entry->flag & REF_ISBROKEN)
-               return PEEL_BROKEN;
-       if (entry->flag & REF_ISSYMREF)
-               return PEEL_IS_SYMREF;
-
-       status = peel_object(entry->u.value.oid.hash, entry->u.value.peeled.hash);
-       if (status == PEEL_PEELED || status == PEEL_NON_TAG)
-               entry->flag |= REF_KNOWS_PEELED;
-       return status;
-}
-
 static int cache_ref_iterator_peel(struct ref_iterator *ref_iterator,
                                   struct object_id *peeled)
 {
-       struct cache_ref_iterator *iter =
-               (struct cache_ref_iterator *)ref_iterator;
-       struct cache_ref_iterator_level *level;
-       struct ref_entry *entry;
-
-       level = &iter->levels[iter->levels_nr - 1];
-
-       if (level->index == -1)
-               die("BUG: peel called before advance for cache iterator");
-
-       entry = level->dir->entries[level->index];
-
-       if (peel_entry(entry, 0))
-               return -1;
-       oidcpy(peeled, &entry->u.value.peeled);
-       return 0;
+       return peel_object(ref_iterator->oid->hash, peeled->hash);
 }
 
 static int cache_ref_iterator_abort(struct ref_iterator *ref_iterator)
@@ -574,7 +534,7 @@ struct ref_iterator *cache_ref_iterator_begin(struct ref_cache *cache,
 
        iter = xcalloc(1, sizeof(*iter));
        ref_iterator = &iter->base;
-       base_ref_iterator_init(ref_iterator, &cache_ref_iterator_vtable);
+       base_ref_iterator_init(ref_iterator, &cache_ref_iterator_vtable, 1);
        ALLOC_GROW(iter->levels, 10, iter->levels_alloc);
 
        iter->levels_nr = 1;