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>maint
parent
f7b0a987b5
commit
f18a789250
|
@ -2574,12 +2574,14 @@ static int files_verify_refname_available(struct ref_store *ref_store,
|
||||||
|
|
||||||
static int write_ref_to_lockfile(struct ref_lock *lock,
|
static int write_ref_to_lockfile(struct ref_lock *lock,
|
||||||
const unsigned char *sha1, struct strbuf *err);
|
const unsigned char *sha1, struct strbuf *err);
|
||||||
static int commit_ref_update(struct ref_lock *lock,
|
static int commit_ref_update(struct files_ref_store *refs,
|
||||||
|
struct ref_lock *lock,
|
||||||
const unsigned char *sha1, const char *logmsg,
|
const unsigned char *sha1, const char *logmsg,
|
||||||
struct strbuf *err);
|
struct strbuf *err);
|
||||||
|
|
||||||
int rename_ref(const char *oldrefname, const char *newrefname, const char *logmsg)
|
int rename_ref(const char *oldrefname, const char *newrefname, const char *logmsg)
|
||||||
{
|
{
|
||||||
|
struct files_ref_store *refs = get_files_ref_store(NULL, "rename_ref");
|
||||||
unsigned char sha1[20], orig_sha1[20];
|
unsigned char sha1[20], orig_sha1[20];
|
||||||
int flag = 0, logmoved = 0;
|
int flag = 0, logmoved = 0;
|
||||||
struct ref_lock *lock;
|
struct ref_lock *lock;
|
||||||
|
@ -2652,7 +2654,7 @@ int rename_ref(const char *oldrefname, const char *newrefname, const char *logms
|
||||||
hashcpy(lock->old_oid.hash, orig_sha1);
|
hashcpy(lock->old_oid.hash, orig_sha1);
|
||||||
|
|
||||||
if (write_ref_to_lockfile(lock, orig_sha1, &err) ||
|
if (write_ref_to_lockfile(lock, orig_sha1, &err) ||
|
||||||
commit_ref_update(lock, orig_sha1, logmsg, &err)) {
|
commit_ref_update(refs, lock, orig_sha1, logmsg, &err)) {
|
||||||
error("unable to write current sha1 into %s: %s", newrefname, err.buf);
|
error("unable to write current sha1 into %s: %s", newrefname, err.buf);
|
||||||
strbuf_release(&err);
|
strbuf_release(&err);
|
||||||
goto rollback;
|
goto rollback;
|
||||||
|
@ -2672,7 +2674,7 @@ int rename_ref(const char *oldrefname, const char *newrefname, const char *logms
|
||||||
flag = log_all_ref_updates;
|
flag = log_all_ref_updates;
|
||||||
log_all_ref_updates = 0;
|
log_all_ref_updates = 0;
|
||||||
if (write_ref_to_lockfile(lock, orig_sha1, &err) ||
|
if (write_ref_to_lockfile(lock, orig_sha1, &err) ||
|
||||||
commit_ref_update(lock, orig_sha1, NULL, &err)) {
|
commit_ref_update(refs, lock, orig_sha1, NULL, &err)) {
|
||||||
error("unable to write current sha1 into %s: %s", oldrefname, err.buf);
|
error("unable to write current sha1 into %s: %s", oldrefname, err.buf);
|
||||||
strbuf_release(&err);
|
strbuf_release(&err);
|
||||||
}
|
}
|
||||||
|
@ -2908,12 +2910,12 @@ static int write_ref_to_lockfile(struct ref_lock *lock,
|
||||||
* to the loose reference lockfile. Also update the reflogs if
|
* to the loose reference lockfile. Also update the reflogs if
|
||||||
* necessary, using the specified lockmsg (which can be NULL).
|
* necessary, using the specified lockmsg (which can be NULL).
|
||||||
*/
|
*/
|
||||||
static int commit_ref_update(struct ref_lock *lock,
|
static int commit_ref_update(struct files_ref_store *refs,
|
||||||
|
struct ref_lock *lock,
|
||||||
const unsigned char *sha1, const char *logmsg,
|
const unsigned char *sha1, const char *logmsg,
|
||||||
struct strbuf *err)
|
struct strbuf *err)
|
||||||
{
|
{
|
||||||
struct files_ref_store *refs =
|
assert_main_repository(&refs->base, "commit_ref_update");
|
||||||
get_files_ref_store(NULL, "commit_ref_update");
|
|
||||||
|
|
||||||
clear_loose_ref_cache(refs);
|
clear_loose_ref_cache(refs);
|
||||||
if (log_ref_write(lock->ref_name, lock->old_oid.hash, sha1, logmsg, 0, err)) {
|
if (log_ref_write(lock->ref_name, lock->old_oid.hash, sha1, logmsg, 0, err)) {
|
||||||
|
|
Loading…
Reference in New Issue