refs: tidy up and adjust visibility of the ref_update flags
The constants used for `ref_update::flags` were rather disorganized: * The definitions in `refs.h` were not close to the functions that used them. * Maybe constants were defined in `refs-internal.h`, making them visible to the whole refs module, when in fact they only made sense for the files backend. * Their documentation wasn't very consistent and partly still referred to sha1s rather than oids. * The numerical values followed no rational scheme Fix all of these problems. The main functional improvement is that some constants' visibility is now limited to `files-backend.c`. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
committed by
Junio C Hamano
parent
62c72d1fd0
commit
5ac95fee3d
@ -8,58 +8,22 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* Flag passed to lock_ref_sha1_basic() telling it to tolerate broken
|
||||
* refs (i.e., because the reference is about to be deleted anyway).
|
||||
*/
|
||||
#define REF_DELETING 0x02
|
||||
|
||||
/*
|
||||
* Used as a flag in ref_update::flags when a loose ref is being
|
||||
* pruned. This flag must only be used when REF_NODEREF is set.
|
||||
*/
|
||||
#define REF_ISPRUNING 0x04
|
||||
|
||||
/*
|
||||
* Used as a flag in ref_update::flags when the reference should be
|
||||
* updated to new_sha1.
|
||||
*/
|
||||
#define REF_HAVE_NEW 0x08
|
||||
|
||||
/*
|
||||
* Used as a flag in ref_update::flags when old_sha1 should be
|
||||
* checked.
|
||||
*/
|
||||
#define REF_HAVE_OLD 0x10
|
||||
|
||||
/*
|
||||
* Used as a flag in ref_update::flags when the lockfile needs to be
|
||||
* committed.
|
||||
*/
|
||||
#define REF_NEEDS_COMMIT 0x20
|
||||
|
||||
/*
|
||||
* 0x40 is REF_FORCE_CREATE_REFLOG, so skip it if you're adding a
|
||||
* value to ref_update::flags
|
||||
* The following flags can appear in `ref_update::flags`. Their
|
||||
* numerical values must not conflict with those of REF_NODEREF and
|
||||
* REF_FORCE_CREATE_REFLOG, which are also stored in
|
||||
* `ref_update::flags`.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Used as a flag in ref_update::flags when we want to log a ref
|
||||
* update but not actually perform it. This is used when a symbolic
|
||||
* ref update is split up.
|
||||
* The reference should be updated to new_sha1.
|
||||
*/
|
||||
#define REF_LOG_ONLY 0x80
|
||||
#define REF_HAVE_NEW (1 << 2)
|
||||
|
||||
/*
|
||||
* Internal flag, meaning that the containing ref_update was via an
|
||||
* update to HEAD.
|
||||
* The current reference's value should be checked to make sure that
|
||||
* it agrees with old_sha1.
|
||||
*/
|
||||
#define REF_UPDATE_VIA_HEAD 0x100
|
||||
|
||||
/*
|
||||
* Used as a flag in ref_update::flags when the loose reference has
|
||||
* been deleted.
|
||||
*/
|
||||
#define REF_DELETED_LOOSE 0x200
|
||||
#define REF_HAVE_OLD (1 << 3)
|
||||
|
||||
/*
|
||||
* Return the length of time to retry acquiring a loose reference lock
|
||||
@ -141,23 +105,22 @@ int copy_reflog_msg(char *buf, const char *msg);
|
||||
* not exist before update.
|
||||
*/
|
||||
struct ref_update {
|
||||
|
||||
/*
|
||||
* If (flags & REF_HAVE_NEW), set the reference to this value:
|
||||
* If (flags & REF_HAVE_NEW), set the reference to this value
|
||||
* (or delete it, if `new_oid` is `null_oid`).
|
||||
*/
|
||||
struct object_id new_oid;
|
||||
|
||||
/*
|
||||
* If (flags & REF_HAVE_OLD), check that the reference
|
||||
* previously had this value:
|
||||
* previously had this value (or didn't previously exist, if
|
||||
* `old_oid` is `null_oid`).
|
||||
*/
|
||||
struct object_id old_oid;
|
||||
|
||||
/*
|
||||
* One or more of REF_HAVE_NEW, REF_HAVE_OLD, REF_NODEREF,
|
||||
* REF_DELETING, REF_ISPRUNING, REF_LOG_ONLY,
|
||||
* REF_UPDATE_VIA_HEAD, REF_NEEDS_COMMIT, and
|
||||
* REF_DELETED_LOOSE:
|
||||
* One or more of REF_NODEREF, REF_FORCE_CREATE_REFLOG,
|
||||
* REF_HAVE_NEW, REF_HAVE_OLD, or backend-specific flags.
|
||||
*/
|
||||
unsigned int flags;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user