ref_cache: remove support for storing peeled values

Now that the `packed-refs` backend doesn't use `ref_cache`, there is nobody left who might want to store peeled values of references in `ref_cache`. So remove that feature. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Michael Haggerty committed Sep 25, 2017 at 10:00 UTC a6e19bcdadf782079cf88609b928519c2dee3378
3 files changed +11 -72
refs/packed-backend.c
+8 -1
@@ -2,7 +2,6 @@
2 #include "../config.h"
3 #include "../refs.h"
4 #include "refs-internal.h"
5 -#include "ref-cache.h"
5 #include "packed-backend.h"
6 #include "../iterator.h"
7 #include "../lockfile.h"
@@ -226,6 +225,14 @@ static NORETURN void die_invalid_line(const char *path,
225
226 }
227
228 +/*
229 + * This value is set in `base.flags` if the peeled value of the
230 + * current reference is known. In that case, `peeled` contains the
231 + * correct peeled value for the reference, which might be `null_sha1`
232 + * if the reference is not a tag or if it is broken.
233 + */
234 +#define REF_KNOWS_PEELED 0x40
235 +
236 /*
237 * An iterator over a packed-refs file that is currently mmapped.
238 */
refs/ref-cache.c
+1 -41
@@ -38,7 +38,6 @@ struct ref_entry *create_ref_entry(const char *refname,
38
39 FLEX_ALLOC_STR(ref, name, refname);
40 oidcpy(&ref->u.value.oid, oid);
41 - oidclr(&ref->u.value.peeled);
41 ref->flag = flag;
42 return ref;
43 }
@@ -491,49 +490,10 @@ static int cache_ref_iterator_advance(struct ref_iterator *ref_iterator)
490 }
491 }
492
494 -enum peel_status peel_entry(struct ref_entry *entry, int repeel)
495 -{
496 - enum peel_status status;
497 -
498 - if (entry->flag & REF_KNOWS_PEELED) {
499 - if (repeel) {
500 - entry->flag &= ~REF_KNOWS_PEELED;
501 - oidclr(&entry->u.value.peeled);
502 - } else {
503 - return is_null_oid(&entry->u.value.peeled) ?
504 - PEEL_NON_TAG : PEEL_PEELED;
505 - }
506 - }
507 - if (entry->flag & REF_ISBROKEN)
508 - return PEEL_BROKEN;
509 - if (entry->flag & REF_ISSYMREF)
510 - return PEEL_IS_SYMREF;
511 -
512 - status = peel_object(entry->u.value.oid.hash, entry->u.value.peeled.hash);
513 - if (status == PEEL_PEELED || status == PEEL_NON_TAG)
514 - entry->flag |= REF_KNOWS_PEELED;
515 - return status;
516 -}
517 -
493 static int cache_ref_iterator_peel(struct ref_iterator *ref_iterator,
494 struct object_id *peeled)
495 {
521 - struct cache_ref_iterator *iter =
522 - (struct cache_ref_iterator *)ref_iterator;
523 - struct cache_ref_iterator_level *level;
524 - struct ref_entry *entry;
525 -
526 - level = &iter->levels[iter->levels_nr - 1];
527 -
528 - if (level->index == -1)
529 - die("BUG: peel called before advance for cache iterator");
530 -
531 - entry = level->dir->entries[level->index];
532 -
533 - if (peel_entry(entry, 0))
534 - return -1;
535 - oidcpy(peeled, &entry->u.value.peeled);
536 - return 0;
496 + return peel_object(ref_iterator->oid->hash, peeled->hash);
497 }
498
499 static int cache_ref_iterator_abort(struct ref_iterator *ref_iterator)
refs/ref-cache.h
+2 -30
@@ -38,14 +38,6 @@ struct ref_value {
38 * referred to by the last reference in the symlink chain.
39 */
40 struct object_id oid;
41 -
42 - /*
43 - * If REF_KNOWS_PEELED, then this field holds the peeled value
44 - * of this reference, or null if the reference is known not to
45 - * be peelable. See the documentation for peel_ref() for an
46 - * exact definition of "peelable".
47 - */
48 - struct object_id peeled;
41 };
42
43 /*
@@ -97,21 +89,14 @@ struct ref_dir {
89 * public values; see refs.h.
90 */
91
100 -/*
101 - * The field ref_entry->u.value.peeled of this value entry contains
102 - * the correct peeled value for the reference, which might be
103 - * null_sha1 if the reference is not a tag or if it is broken.
104 - */
105 -#define REF_KNOWS_PEELED 0x10
106 -
92 /* ref_entry represents a directory of references */
108 -#define REF_DIR 0x20
93 +#define REF_DIR 0x10
94
95 /*
96 * Entry has not yet been read from disk (used only for REF_DIR
97 * entries representing loose references)
98 */
114 -#define REF_INCOMPLETE 0x40
99 +#define REF_INCOMPLETE 0x20
100
101 /*
102 * A ref_entry represents either a reference or a "subdirectory" of
@@ -252,17 +237,4 @@ struct ref_iterator *cache_ref_iterator_begin(struct ref_cache *cache,
237 const char *prefix,
238 int prime_dir);
239
255 -/*
256 - * Peel the entry (if possible) and return its new peel_status. If
257 - * repeel is true, re-peel the entry even if there is an old peeled
258 - * value that is already stored in it.
259 - *
260 - * It is OK to call this function with a packed reference entry that
261 - * might be stale and might even refer to an object that has since
262 - * been garbage-collected. In such a case, if the entry has
263 - * REF_KNOWS_PEELED then leave the status unchanged and return
264 - * PEEL_PEELED or PEEL_NON_TAG; otherwise, return PEEL_INVALID.
265 - */
266 -enum peel_status peel_entry(struct ref_entry *entry, int repeel);
267 -
240 #endif /* REFS_REF_CACHE_H */