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>maint
parent
9dd389f3d8
commit
a6e19bcdad
|
@ -2,7 +2,6 @@
|
||||||
#include "../config.h"
|
#include "../config.h"
|
||||||
#include "../refs.h"
|
#include "../refs.h"
|
||||||
#include "refs-internal.h"
|
#include "refs-internal.h"
|
||||||
#include "ref-cache.h"
|
|
||||||
#include "packed-backend.h"
|
#include "packed-backend.h"
|
||||||
#include "../iterator.h"
|
#include "../iterator.h"
|
||||||
#include "../lockfile.h"
|
#include "../lockfile.h"
|
||||||
|
@ -226,6 +225,14 @@ static NORETURN void die_invalid_line(const char *path,
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This value is set in `base.flags` if the peeled value of the
|
||||||
|
* current reference is known. In that case, `peeled` contains the
|
||||||
|
* correct peeled value for the reference, which might be `null_sha1`
|
||||||
|
* if the reference is not a tag or if it is broken.
|
||||||
|
*/
|
||||||
|
#define REF_KNOWS_PEELED 0x40
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* An iterator over a packed-refs file that is currently mmapped.
|
* An iterator over a packed-refs file that is currently mmapped.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -38,7 +38,6 @@ struct ref_entry *create_ref_entry(const char *refname,
|
||||||
|
|
||||||
FLEX_ALLOC_STR(ref, name, refname);
|
FLEX_ALLOC_STR(ref, name, refname);
|
||||||
oidcpy(&ref->u.value.oid, oid);
|
oidcpy(&ref->u.value.oid, oid);
|
||||||
oidclr(&ref->u.value.peeled);
|
|
||||||
ref->flag = flag;
|
ref->flag = flag;
|
||||||
return ref;
|
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,
|
static int cache_ref_iterator_peel(struct ref_iterator *ref_iterator,
|
||||||
struct object_id *peeled)
|
struct object_id *peeled)
|
||||||
{
|
{
|
||||||
struct cache_ref_iterator *iter =
|
return peel_object(ref_iterator->oid->hash, peeled->hash);
|
||||||
(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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int cache_ref_iterator_abort(struct ref_iterator *ref_iterator)
|
static int cache_ref_iterator_abort(struct ref_iterator *ref_iterator)
|
||||||
|
|
|
@ -38,14 +38,6 @@ struct ref_value {
|
||||||
* referred to by the last reference in the symlink chain.
|
* referred to by the last reference in the symlink chain.
|
||||||
*/
|
*/
|
||||||
struct object_id oid;
|
struct object_id oid;
|
||||||
|
|
||||||
/*
|
|
||||||
* If REF_KNOWS_PEELED, then this field holds the peeled value
|
|
||||||
* of this reference, or null if the reference is known not to
|
|
||||||
* be peelable. See the documentation for peel_ref() for an
|
|
||||||
* exact definition of "peelable".
|
|
||||||
*/
|
|
||||||
struct object_id peeled;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -97,21 +89,14 @@ struct ref_dir {
|
||||||
* public values; see refs.h.
|
* public values; see refs.h.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
|
||||||
* The field ref_entry->u.value.peeled of this value entry contains
|
|
||||||
* the correct peeled value for the reference, which might be
|
|
||||||
* null_sha1 if the reference is not a tag or if it is broken.
|
|
||||||
*/
|
|
||||||
#define REF_KNOWS_PEELED 0x10
|
|
||||||
|
|
||||||
/* ref_entry represents a directory of references */
|
/* ref_entry represents a directory of references */
|
||||||
#define REF_DIR 0x20
|
#define REF_DIR 0x10
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Entry has not yet been read from disk (used only for REF_DIR
|
* Entry has not yet been read from disk (used only for REF_DIR
|
||||||
* entries representing loose references)
|
* entries representing loose references)
|
||||||
*/
|
*/
|
||||||
#define REF_INCOMPLETE 0x40
|
#define REF_INCOMPLETE 0x20
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* A ref_entry represents either a reference or a "subdirectory" of
|
* 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,
|
||||||
const char *prefix,
|
const char *prefix,
|
||||||
int prime_dir);
|
int prime_dir);
|
||||||
|
|
||||||
/*
|
|
||||||
* Peel the entry (if possible) and return its new peel_status. If
|
|
||||||
* repeel is true, re-peel the entry even if there is an old peeled
|
|
||||||
* value that is already stored in it.
|
|
||||||
*
|
|
||||||
* It is OK to call this function with a packed reference entry that
|
|
||||||
* might be stale and might even refer to an object that has since
|
|
||||||
* been garbage-collected. In such a case, if the entry has
|
|
||||||
* REF_KNOWS_PEELED then leave the status unchanged and return
|
|
||||||
* PEEL_PEELED or PEEL_NON_TAG; otherwise, return PEEL_INVALID.
|
|
||||||
*/
|
|
||||||
enum peel_status peel_entry(struct ref_entry *entry, int repeel);
|
|
||||||
|
|
||||||
#endif /* REFS_REF_CACHE_H */
|
#endif /* REFS_REF_CACHE_H */
|
||||||
|
|
Loading…
Reference in New Issue