lock_raw_ref(): add a files_ref_store argument
Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Michael Haggerty committed
Sep 4, 2016 at 18:08 UTC
f7b0a987b564b356ffcf7eb62fa33b200cbd5b87
1 file changed
+8
-6
refs/files-backend.c
+8
-6
@@ -1523,7 +1523,8 @@ static void unlock_ref(struct ref_lock *lock)
1523
* avoided, namely if we were successfully able to read the ref
1524
* - Generate informative error messages in the case of failure
1525
*/
1526
-static int lock_raw_ref(const char *refname, int mustexist,
1526
+static int lock_raw_ref(struct files_ref_store *refs,
1527
+ const char *refname, int mustexist,
1528
const struct string_list *extras,
1529
const struct string_list *skip,
1530
struct ref_lock **lock_p,
@@ -1531,15 +1532,14 @@ static int lock_raw_ref(const char *refname, int mustexist,
1532
unsigned int *type,
1533
struct strbuf *err)
1534
{
1534
- struct ref_store *ref_store = get_ref_store(NULL);
1535
- struct files_ref_store *refs =
1536
- files_downcast(ref_store, 0, "lock_raw_ref");
1535
struct ref_lock *lock;
1536
struct strbuf ref_file = STRBUF_INIT;
1537
int attempts_remaining = 3;
1538
int ret = TRANSACTION_GENERIC_ERROR;
1539
1540
assert(err);
1541
+ assert_main_repository(&refs->base, "lock_raw_ref");
1542
+
1543
*type = 0;
1544
1545
/* First lock the file so it can't change out from under us. */
@@ -1623,7 +1623,7 @@ retry:
1623
* fear that its value will change.
1624
*/
1625
1626
- if (files_read_raw_ref(ref_store, refname,
1626
+ if (files_read_raw_ref(&refs->base, refname,
1627
lock->old_oid.hash, referent, type)) {
1628
if (errno == ENOENT) {
1629
if (mustexist) {
@@ -3486,6 +3486,8 @@ static int lock_ref_for_update(struct ref_update *update,
3486
struct string_list *affected_refnames,
3487
struct strbuf *err)
3488
{
3489
+ struct files_ref_store *refs =
3490
+ get_files_ref_store(NULL, "lock_ref_for_update");
3491
struct strbuf referent = STRBUF_INIT;
3492
int mustexist = (update->flags & REF_HAVE_OLD) &&
3493
!is_null_sha1(update->old_sha1);
@@ -3502,7 +3504,7 @@ static int lock_ref_for_update(struct ref_update *update,
3504
return ret;
3505
}
3506
3505
- ret = lock_raw_ref(update->refname, mustexist,
3507
+ ret = lock_raw_ref(refs, update->refname, mustexist,
3508
affected_refnames, NULL,
3509
&update->lock, &referent,
3510
&update->type, err);