commit_ref_update(): 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 f18a7892500d494b96c992084951fa85dec4abc2
1 file changed +8 -6
refs/files-backend.c
+8 -6
@@ -2574,12 +2574,14 @@ static int files_verify_refname_available(struct ref_store *ref_store,
2574
2575 static int write_ref_to_lockfile(struct ref_lock *lock,
2576 const unsigned char *sha1, struct strbuf *err);
2577 -static int commit_ref_update(struct ref_lock *lock,
2577 +static int commit_ref_update(struct files_ref_store *refs,
2578 + struct ref_lock *lock,
2579 const unsigned char *sha1, const char *logmsg,
2580 struct strbuf *err);
2581
2582 int rename_ref(const char *oldrefname, const char *newrefname, const char *logmsg)
2583 {
2584 + struct files_ref_store *refs = get_files_ref_store(NULL, "rename_ref");
2585 unsigned char sha1[20], orig_sha1[20];
2586 int flag = 0, logmoved = 0;
2587 struct ref_lock *lock;
@@ -2652,7 +2654,7 @@ int rename_ref(const char *oldrefname, const char *newrefname, const char *logms
2654 hashcpy(lock->old_oid.hash, orig_sha1);
2655
2656 if (write_ref_to_lockfile(lock, orig_sha1, &err) ||
2655 - commit_ref_update(lock, orig_sha1, logmsg, &err)) {
2657 + commit_ref_update(refs, lock, orig_sha1, logmsg, &err)) {
2658 error("unable to write current sha1 into %s: %s", newrefname, err.buf);
2659 strbuf_release(&err);
2660 goto rollback;
@@ -2672,7 +2674,7 @@ int rename_ref(const char *oldrefname, const char *newrefname, const char *logms
2674 flag = log_all_ref_updates;
2675 log_all_ref_updates = 0;
2676 if (write_ref_to_lockfile(lock, orig_sha1, &err) ||
2675 - commit_ref_update(lock, orig_sha1, NULL, &err)) {
2677 + commit_ref_update(refs, lock, orig_sha1, NULL, &err)) {
2678 error("unable to write current sha1 into %s: %s", oldrefname, err.buf);
2679 strbuf_release(&err);
2680 }
@@ -2908,12 +2910,12 @@ static int write_ref_to_lockfile(struct ref_lock *lock,
2910 * to the loose reference lockfile. Also update the reflogs if
2911 * necessary, using the specified lockmsg (which can be NULL).
2912 */
2911 -static int commit_ref_update(struct ref_lock *lock,
2913 +static int commit_ref_update(struct files_ref_store *refs,
2914 + struct ref_lock *lock,
2915 const unsigned char *sha1, const char *logmsg,
2916 struct strbuf *err)
2917 {
2915 - struct files_ref_store *refs =
2916 - get_files_ref_store(NULL, "commit_ref_update");
2918 + assert_main_repository(&refs->base, "commit_ref_update");
2919
2920 clear_loose_ref_cache(refs);
2921 if (log_ref_write(lock->ref_name, lock->old_oid.hash, sha1, logmsg, 0, err)) {