Skip to content

Commit a6e19bc

Browse files
mhaggergitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 9dd389f commit a6e19bc

File tree

3 files changed

+11
-72
lines changed

3 files changed

+11
-72
lines changed

refs/packed-backend.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
#include "../config.h"
33
#include "../refs.h"
44
#include "refs-internal.h"
5-
#include "ref-cache.h"
65
#include "packed-backend.h"
76
#include "../iterator.h"
87
#include "../lockfile.h"
@@ -226,6 +225,14 @@ static NORETURN void die_invalid_line(const char *path,
226225

227226
}
228227

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+
229236
/*
230237
* An iterator over a packed-refs file that is currently mmapped.
231238
*/

refs/ref-cache.c

Lines changed: 1 addition & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ struct ref_entry *create_ref_entry(const char *refname,
3838

3939
FLEX_ALLOC_STR(ref, name, refname);
4040
oidcpy(&ref->u.value.oid, oid);
41-
oidclr(&ref->u.value.peeled);
4241
ref->flag = flag;
4342
return ref;
4443
}
@@ -491,49 +490,10 @@ static int cache_ref_iterator_advance(struct ref_iterator *ref_iterator)
491490
}
492491
}
493492

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-
518493
static int cache_ref_iterator_peel(struct ref_iterator *ref_iterator,
519494
struct object_id *peeled)
520495
{
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);
537497
}
538498

539499
static int cache_ref_iterator_abort(struct ref_iterator *ref_iterator)

refs/ref-cache.h

Lines changed: 2 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,6 @@ struct ref_value {
3838
* referred to by the last reference in the symlink chain.
3939
*/
4040
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;
4941
};
5042

5143
/*
@@ -97,21 +89,14 @@ struct ref_dir {
9789
* public values; see refs.h.
9890
*/
9991

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-
10792
/* ref_entry represents a directory of references */
108-
#define REF_DIR 0x20
93+
#define REF_DIR 0x10
10994

11095
/*
11196
* Entry has not yet been read from disk (used only for REF_DIR
11297
* entries representing loose references)
11398
*/
114-
#define REF_INCOMPLETE 0x40
99+
#define REF_INCOMPLETE 0x20
115100

116101
/*
117102
* 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,
252237
const char *prefix,
253238
int prime_dir);
254239

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-
268240
#endif /* REFS_REF_CACHE_H */

0 commit comments

Comments
 (0)