Merge branch 'bf/set-head-symref'
When "git fetch $remote" notices that refs/remotes/$remote/HEAD is missing and discovers what branch the other side points with its HEAD, refs/remotes/$remote/HEAD is updated to point to it. * bf/set-head-symref: fetch set_head: handle mirrored bare repositories fetch: set remote/HEAD if it does not exist refs: add create_only option to refs_update_symref_extended refs: add TRANSACTION_CREATE_EXISTS error remote set-head: better output for --auto remote set-head: refactor for readability refs: atomically record overwritten ref in update_symref refs: standardize output of refs_read_symbolic_ref t/t5505-remote: test failure of set-head t/t5505-remote: set default branch to main
This commit is contained in:
19
refs.h
19
refs.h
@@ -83,6 +83,17 @@ int refs_read_ref_full(struct ref_store *refs, const char *refname,
|
||||
|
||||
int refs_read_ref(struct ref_store *refs, const char *refname, struct object_id *oid);
|
||||
|
||||
#define NOT_A_SYMREF -2
|
||||
|
||||
/*
|
||||
* Read the symbolic ref named "refname" and write its immediate referent into
|
||||
* the provided buffer. Referent is left empty if "refname" is not a symbolic
|
||||
* ref. It does not resolve the symbolic reference recursively in case the
|
||||
* target is also a symbolic ref.
|
||||
*
|
||||
* Returns 0 on success, -2 if the "refname" is not a symbolic ref,
|
||||
* -1 otherwise.
|
||||
*/
|
||||
int refs_read_symbolic_ref(struct ref_store *ref_store, const char *refname,
|
||||
struct strbuf *referent);
|
||||
|
||||
@@ -604,6 +615,10 @@ int refs_copy_existing_ref(struct ref_store *refs, const char *oldref,
|
||||
int refs_update_symref(struct ref_store *refs, const char *refname,
|
||||
const char *target, const char *logmsg);
|
||||
|
||||
int refs_update_symref_extended(struct ref_store *refs, const char *refname,
|
||||
const char *target, const char *logmsg,
|
||||
struct strbuf *referent, int create_only);
|
||||
|
||||
enum action_on_err {
|
||||
UPDATE_REFS_MSG_ON_ERR,
|
||||
UPDATE_REFS_DIE_ON_ERR,
|
||||
@@ -805,8 +820,10 @@ int ref_transaction_verify(struct ref_transaction *transaction,
|
||||
|
||||
/* Naming conflict (for example, the ref names A and A/B conflict). */
|
||||
#define TRANSACTION_NAME_CONFLICT -1
|
||||
/* When only creation was requested, but the ref already exists. */
|
||||
#define TRANSACTION_CREATE_EXISTS -2
|
||||
/* All other errors. */
|
||||
#define TRANSACTION_GENERIC_ERROR -2
|
||||
#define TRANSACTION_GENERIC_ERROR -3
|
||||
|
||||
/*
|
||||
* Perform the preparatory stages of committing `transaction`. Acquire
|
||||
|
||||
Reference in New Issue
Block a user