Skip to content

Commit 9bbb0fa

Browse files
bradkinggitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 2be778a commit 9bbb0fa

File tree

11 files changed

+17
-13
lines changed

11 files changed

+17
-13
lines changed

branch.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ void create_branch(const char *head,
291291
hashcpy(sha1, commit->object.sha1);
292292

293293
if (!dont_change_ref) {
294-
lock = lock_any_ref_for_update(ref.buf, NULL, 0);
294+
lock = lock_any_ref_for_update(ref.buf, NULL, 0, NULL);
295295
if (!lock)
296296
die_errno(_("Failed to lock ref for update"));
297297
}

builtin/commit.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1618,7 +1618,7 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
16181618
!current_head
16191619
? NULL
16201620
: current_head->object.sha1,
1621-
0);
1621+
0, NULL);
16221622

16231623
nl = strchr(sb.buf, '\n');
16241624
if (nl)

builtin/fetch.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,8 @@ static int s_update_ref(const char *action,
246246
rla = default_rla.buf;
247247
snprintf(msg, sizeof(msg), "%s: %s", rla, action);
248248
lock = lock_any_ref_for_update(ref->name,
249-
check_old ? ref->old_sha1 : NULL, 0);
249+
check_old ? ref->old_sha1 : NULL,
250+
0, NULL);
250251
if (!lock)
251252
return errno == ENOTDIR ? STORE_REF_ERROR_DF_CONFLICT :
252253
STORE_REF_ERROR_OTHER;

builtin/receive-pack.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -524,7 +524,8 @@ static const char *update(struct command *cmd)
524524
return NULL; /* good */
525525
}
526526
else {
527-
lock = lock_any_ref_for_update(namespaced_name, old_sha1, 0);
527+
lock = lock_any_ref_for_update(namespaced_name, old_sha1,
528+
0, NULL);
528529
if (!lock) {
529530
rp_error("failed to lock %s", name);
530531
return "failed to lock";

builtin/reflog.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ static int expire_reflog(const char *ref, const unsigned char *sha1, int unused,
366366
* we take the lock for the ref itself to prevent it from
367367
* getting updated.
368368
*/
369-
lock = lock_any_ref_for_update(ref, sha1, 0);
369+
lock = lock_any_ref_for_update(ref, sha1, 0, NULL);
370370
if (!lock)
371371
return error("cannot lock ref '%s'", ref);
372372
log_file = git_pathdup("logs/%s", ref);

builtin/replace.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ static int replace_object(const char *object_ref, const char *replace_ref,
105105
else if (!force)
106106
die("replace ref '%s' already exists", ref);
107107

108-
lock = lock_any_ref_for_update(ref, prev, 0);
108+
lock = lock_any_ref_for_update(ref, prev, 0, NULL);
109109
if (!lock)
110110
die("%s: cannot lock the ref", ref);
111111
if (write_ref_sha1(lock, repl, NULL) < 0)

builtin/tag.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -577,7 +577,7 @@ int cmd_tag(int argc, const char **argv, const char *prefix)
577577
if (annotate)
578578
create_tag(object, tag, &buf, &opt, prev, object);
579579

580-
lock = lock_any_ref_for_update(ref.buf, prev, 0);
580+
lock = lock_any_ref_for_update(ref.buf, prev, 0, NULL);
581581
if (!lock)
582582
die(_("%s: cannot lock the ref"), ref.buf);
583583
if (write_ref_sha1(lock, object, NULL) < 0)

fast-import.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1678,7 +1678,7 @@ static int update_branch(struct branch *b)
16781678
return 0;
16791679
if (read_ref(b->name, old_sha1))
16801680
hashclr(old_sha1);
1681-
lock = lock_any_ref_for_update(b->name, old_sha1, 0);
1681+
lock = lock_any_ref_for_update(b->name, old_sha1, 0, NULL);
16821682
if (!lock)
16831683
return error("Unable to lock %s", b->name);
16841684
if (!force_update && !is_null_sha1(old_sha1)) {

refs.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2121,11 +2121,12 @@ struct ref_lock *lock_ref_sha1(const char *refname, const unsigned char *old_sha
21212121
}
21222122

21232123
struct ref_lock *lock_any_ref_for_update(const char *refname,
2124-
const unsigned char *old_sha1, int flags)
2124+
const unsigned char *old_sha1,
2125+
int flags, int *type_p)
21252126
{
21262127
if (check_refname_format(refname, REFNAME_ALLOW_ONELEVEL))
21272128
return NULL;
2128-
return lock_ref_sha1_basic(refname, old_sha1, flags, NULL);
2129+
return lock_ref_sha1_basic(refname, old_sha1, flags, type_p);
21292130
}
21302131

21312132
/*
@@ -3174,7 +3175,7 @@ int update_ref(const char *action, const char *refname,
31743175
int flags, enum action_on_err onerr)
31753176
{
31763177
static struct ref_lock *lock;
3177-
lock = lock_any_ref_for_update(refname, oldval, flags);
3178+
lock = lock_any_ref_for_update(refname, oldval, flags, NULL);
31783179
if (!lock) {
31793180
const char *str = "Cannot lock the ref '%s'.";
31803181
switch (onerr) {

refs.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ extern struct ref_lock *lock_ref_sha1(const char *refname, const unsigned char *
137137
#define REF_NODEREF 0x01
138138
extern struct ref_lock *lock_any_ref_for_update(const char *refname,
139139
const unsigned char *old_sha1,
140-
int flags);
140+
int flags, int *type_p);
141141

142142
/** Close the file descriptor owned by a lock and return the status */
143143
extern int close_ref(struct ref_lock *lock);

0 commit comments

Comments
 (0)