refs: report ref type from lock_any_ref_for_update
Expose lock_ref_sha1_basic's type_p argument to callers of lock_any_ref_for_update. Update all call sites to ignore it by passing NULL for now. Signed-off-by: Brad King <brad.king@kitware.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
2be778a8ac
commit
9bbb0fa1fd
2
branch.c
2
branch.c
@ -291,7 +291,7 @@ void create_branch(const char *head,
|
|||||||
hashcpy(sha1, commit->object.sha1);
|
hashcpy(sha1, commit->object.sha1);
|
||||||
|
|
||||||
if (!dont_change_ref) {
|
if (!dont_change_ref) {
|
||||||
lock = lock_any_ref_for_update(ref.buf, NULL, 0);
|
lock = lock_any_ref_for_update(ref.buf, NULL, 0, NULL);
|
||||||
if (!lock)
|
if (!lock)
|
||||||
die_errno(_("Failed to lock ref for update"));
|
die_errno(_("Failed to lock ref for update"));
|
||||||
}
|
}
|
||||||
|
@ -1618,7 +1618,7 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
|
|||||||
!current_head
|
!current_head
|
||||||
? NULL
|
? NULL
|
||||||
: current_head->object.sha1,
|
: current_head->object.sha1,
|
||||||
0);
|
0, NULL);
|
||||||
|
|
||||||
nl = strchr(sb.buf, '\n');
|
nl = strchr(sb.buf, '\n');
|
||||||
if (nl)
|
if (nl)
|
||||||
|
@ -246,7 +246,8 @@ static int s_update_ref(const char *action,
|
|||||||
rla = default_rla.buf;
|
rla = default_rla.buf;
|
||||||
snprintf(msg, sizeof(msg), "%s: %s", rla, action);
|
snprintf(msg, sizeof(msg), "%s: %s", rla, action);
|
||||||
lock = lock_any_ref_for_update(ref->name,
|
lock = lock_any_ref_for_update(ref->name,
|
||||||
check_old ? ref->old_sha1 : NULL, 0);
|
check_old ? ref->old_sha1 : NULL,
|
||||||
|
0, NULL);
|
||||||
if (!lock)
|
if (!lock)
|
||||||
return errno == ENOTDIR ? STORE_REF_ERROR_DF_CONFLICT :
|
return errno == ENOTDIR ? STORE_REF_ERROR_DF_CONFLICT :
|
||||||
STORE_REF_ERROR_OTHER;
|
STORE_REF_ERROR_OTHER;
|
||||||
|
@ -524,7 +524,8 @@ static const char *update(struct command *cmd)
|
|||||||
return NULL; /* good */
|
return NULL; /* good */
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
lock = lock_any_ref_for_update(namespaced_name, old_sha1, 0);
|
lock = lock_any_ref_for_update(namespaced_name, old_sha1,
|
||||||
|
0, NULL);
|
||||||
if (!lock) {
|
if (!lock) {
|
||||||
rp_error("failed to lock %s", name);
|
rp_error("failed to lock %s", name);
|
||||||
return "failed to lock";
|
return "failed to lock";
|
||||||
|
@ -366,7 +366,7 @@ static int expire_reflog(const char *ref, const unsigned char *sha1, int unused,
|
|||||||
* we take the lock for the ref itself to prevent it from
|
* we take the lock for the ref itself to prevent it from
|
||||||
* getting updated.
|
* getting updated.
|
||||||
*/
|
*/
|
||||||
lock = lock_any_ref_for_update(ref, sha1, 0);
|
lock = lock_any_ref_for_update(ref, sha1, 0, NULL);
|
||||||
if (!lock)
|
if (!lock)
|
||||||
return error("cannot lock ref '%s'", ref);
|
return error("cannot lock ref '%s'", ref);
|
||||||
log_file = git_pathdup("logs/%s", ref);
|
log_file = git_pathdup("logs/%s", ref);
|
||||||
|
@ -105,7 +105,7 @@ static int replace_object(const char *object_ref, const char *replace_ref,
|
|||||||
else if (!force)
|
else if (!force)
|
||||||
die("replace ref '%s' already exists", ref);
|
die("replace ref '%s' already exists", ref);
|
||||||
|
|
||||||
lock = lock_any_ref_for_update(ref, prev, 0);
|
lock = lock_any_ref_for_update(ref, prev, 0, NULL);
|
||||||
if (!lock)
|
if (!lock)
|
||||||
die("%s: cannot lock the ref", ref);
|
die("%s: cannot lock the ref", ref);
|
||||||
if (write_ref_sha1(lock, repl, NULL) < 0)
|
if (write_ref_sha1(lock, repl, NULL) < 0)
|
||||||
|
@ -577,7 +577,7 @@ int cmd_tag(int argc, const char **argv, const char *prefix)
|
|||||||
if (annotate)
|
if (annotate)
|
||||||
create_tag(object, tag, &buf, &opt, prev, object);
|
create_tag(object, tag, &buf, &opt, prev, object);
|
||||||
|
|
||||||
lock = lock_any_ref_for_update(ref.buf, prev, 0);
|
lock = lock_any_ref_for_update(ref.buf, prev, 0, NULL);
|
||||||
if (!lock)
|
if (!lock)
|
||||||
die(_("%s: cannot lock the ref"), ref.buf);
|
die(_("%s: cannot lock the ref"), ref.buf);
|
||||||
if (write_ref_sha1(lock, object, NULL) < 0)
|
if (write_ref_sha1(lock, object, NULL) < 0)
|
||||||
|
@ -1678,7 +1678,7 @@ static int update_branch(struct branch *b)
|
|||||||
return 0;
|
return 0;
|
||||||
if (read_ref(b->name, old_sha1))
|
if (read_ref(b->name, old_sha1))
|
||||||
hashclr(old_sha1);
|
hashclr(old_sha1);
|
||||||
lock = lock_any_ref_for_update(b->name, old_sha1, 0);
|
lock = lock_any_ref_for_update(b->name, old_sha1, 0, NULL);
|
||||||
if (!lock)
|
if (!lock)
|
||||||
return error("Unable to lock %s", b->name);
|
return error("Unable to lock %s", b->name);
|
||||||
if (!force_update && !is_null_sha1(old_sha1)) {
|
if (!force_update && !is_null_sha1(old_sha1)) {
|
||||||
|
7
refs.c
7
refs.c
@ -2121,11 +2121,12 @@ struct ref_lock *lock_ref_sha1(const char *refname, const unsigned char *old_sha
|
|||||||
}
|
}
|
||||||
|
|
||||||
struct ref_lock *lock_any_ref_for_update(const char *refname,
|
struct ref_lock *lock_any_ref_for_update(const char *refname,
|
||||||
const unsigned char *old_sha1, int flags)
|
const unsigned char *old_sha1,
|
||||||
|
int flags, int *type_p)
|
||||||
{
|
{
|
||||||
if (check_refname_format(refname, REFNAME_ALLOW_ONELEVEL))
|
if (check_refname_format(refname, REFNAME_ALLOW_ONELEVEL))
|
||||||
return NULL;
|
return NULL;
|
||||||
return lock_ref_sha1_basic(refname, old_sha1, flags, NULL);
|
return lock_ref_sha1_basic(refname, old_sha1, flags, type_p);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -3174,7 +3175,7 @@ int update_ref(const char *action, const char *refname,
|
|||||||
int flags, enum action_on_err onerr)
|
int flags, enum action_on_err onerr)
|
||||||
{
|
{
|
||||||
static struct ref_lock *lock;
|
static struct ref_lock *lock;
|
||||||
lock = lock_any_ref_for_update(refname, oldval, flags);
|
lock = lock_any_ref_for_update(refname, oldval, flags, NULL);
|
||||||
if (!lock) {
|
if (!lock) {
|
||||||
const char *str = "Cannot lock the ref '%s'.";
|
const char *str = "Cannot lock the ref '%s'.";
|
||||||
switch (onerr) {
|
switch (onerr) {
|
||||||
|
2
refs.h
2
refs.h
@ -137,7 +137,7 @@ extern struct ref_lock *lock_ref_sha1(const char *refname, const unsigned char *
|
|||||||
#define REF_NODEREF 0x01
|
#define REF_NODEREF 0x01
|
||||||
extern struct ref_lock *lock_any_ref_for_update(const char *refname,
|
extern struct ref_lock *lock_any_ref_for_update(const char *refname,
|
||||||
const unsigned char *old_sha1,
|
const unsigned char *old_sha1,
|
||||||
int flags);
|
int flags, int *type_p);
|
||||||
|
|
||||||
/** Close the file descriptor owned by a lock and return the status */
|
/** Close the file descriptor owned by a lock and return the status */
|
||||||
extern int close_ref(struct ref_lock *lock);
|
extern int close_ref(struct ref_lock *lock);
|
||||||
|
@ -279,7 +279,8 @@ static int fast_forward_to(const unsigned char *to, const unsigned char *from,
|
|||||||
read_cache();
|
read_cache();
|
||||||
if (checkout_fast_forward(from, to, 1))
|
if (checkout_fast_forward(from, to, 1))
|
||||||
exit(1); /* the callee should have complained already */
|
exit(1); /* the callee should have complained already */
|
||||||
ref_lock = lock_any_ref_for_update("HEAD", unborn ? null_sha1 : from, 0);
|
ref_lock = lock_any_ref_for_update("HEAD", unborn ? null_sha1 : from,
|
||||||
|
0, NULL);
|
||||||
strbuf_addf(&sb, "%s: fast-forward", action_name(opts));
|
strbuf_addf(&sb, "%s: fast-forward", action_name(opts));
|
||||||
ret = write_ref_sha1(ref_lock, to, sb.buf);
|
ret = write_ref_sha1(ref_lock, to, sb.buf);
|
||||||
strbuf_release(&sb);
|
strbuf_release(&sb);
|
||||||
|
Loading…
Reference in New Issue
Block a user