lock_ref_sha1_basic(): 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
b3bbbc5c24
commit
7eb27cdfe6
|
@ -1983,15 +1983,14 @@ static int remove_empty_directories(struct strbuf *path)
|
||||||
* Locks a ref returning the lock on success and NULL on failure.
|
* Locks a ref returning the lock on success and NULL on failure.
|
||||||
* On failure errno is set to something meaningful.
|
* On failure errno is set to something meaningful.
|
||||||
*/
|
*/
|
||||||
static struct ref_lock *lock_ref_sha1_basic(const char *refname,
|
static struct ref_lock *lock_ref_sha1_basic(struct files_ref_store *refs,
|
||||||
|
const char *refname,
|
||||||
const unsigned char *old_sha1,
|
const unsigned char *old_sha1,
|
||||||
const struct string_list *extras,
|
const struct string_list *extras,
|
||||||
const struct string_list *skip,
|
const struct string_list *skip,
|
||||||
unsigned int flags, int *type,
|
unsigned int flags, int *type,
|
||||||
struct strbuf *err)
|
struct strbuf *err)
|
||||||
{
|
{
|
||||||
struct files_ref_store *refs =
|
|
||||||
get_files_ref_store(NULL, "lock_ref_sha1_basic");
|
|
||||||
struct strbuf ref_file = STRBUF_INIT;
|
struct strbuf ref_file = STRBUF_INIT;
|
||||||
struct ref_lock *lock;
|
struct ref_lock *lock;
|
||||||
int last_errno = 0;
|
int last_errno = 0;
|
||||||
|
@ -2001,6 +2000,7 @@ static struct ref_lock *lock_ref_sha1_basic(const char *refname,
|
||||||
int attempts_remaining = 3;
|
int attempts_remaining = 3;
|
||||||
int resolved;
|
int resolved;
|
||||||
|
|
||||||
|
assert_main_repository(&refs->base, "lock_ref_sha1_basic");
|
||||||
assert(err);
|
assert(err);
|
||||||
|
|
||||||
lock = xcalloc(1, sizeof(struct ref_lock));
|
lock = xcalloc(1, sizeof(struct ref_lock));
|
||||||
|
@ -2644,8 +2644,8 @@ int rename_ref(const char *oldrefname, const char *newrefname, const char *logms
|
||||||
|
|
||||||
logmoved = log;
|
logmoved = log;
|
||||||
|
|
||||||
lock = lock_ref_sha1_basic(newrefname, NULL, NULL, NULL, REF_NODEREF,
|
lock = lock_ref_sha1_basic(refs, newrefname, NULL, NULL, NULL,
|
||||||
NULL, &err);
|
REF_NODEREF, NULL, &err);
|
||||||
if (!lock) {
|
if (!lock) {
|
||||||
error("unable to rename '%s' to '%s': %s", oldrefname, newrefname, err.buf);
|
error("unable to rename '%s' to '%s': %s", oldrefname, newrefname, err.buf);
|
||||||
strbuf_release(&err);
|
strbuf_release(&err);
|
||||||
|
@ -2663,8 +2663,8 @@ int rename_ref(const char *oldrefname, const char *newrefname, const char *logms
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
rollback:
|
rollback:
|
||||||
lock = lock_ref_sha1_basic(oldrefname, NULL, NULL, NULL, REF_NODEREF,
|
lock = lock_ref_sha1_basic(refs, oldrefname, NULL, NULL, NULL,
|
||||||
NULL, &err);
|
REF_NODEREF, NULL, &err);
|
||||||
if (!lock) {
|
if (!lock) {
|
||||||
error("unable to lock %s for rollback: %s", oldrefname, err.buf);
|
error("unable to lock %s for rollback: %s", oldrefname, err.buf);
|
||||||
strbuf_release(&err);
|
strbuf_release(&err);
|
||||||
|
@ -3020,13 +3020,14 @@ static int files_create_symref(struct ref_store *ref_store,
|
||||||
const char *refname, const char *target,
|
const char *refname, const char *target,
|
||||||
const char *logmsg)
|
const char *logmsg)
|
||||||
{
|
{
|
||||||
|
struct files_ref_store *refs =
|
||||||
|
files_downcast(ref_store, 0, "create_symref");
|
||||||
struct strbuf err = STRBUF_INIT;
|
struct strbuf err = STRBUF_INIT;
|
||||||
struct ref_lock *lock;
|
struct ref_lock *lock;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
files_downcast(ref_store, 0, "create_symref");
|
lock = lock_ref_sha1_basic(refs, refname, NULL,
|
||||||
|
NULL, NULL, REF_NODEREF, NULL,
|
||||||
lock = lock_ref_sha1_basic(refname, NULL, NULL, NULL, REF_NODEREF, NULL,
|
|
||||||
&err);
|
&err);
|
||||||
if (!lock) {
|
if (!lock) {
|
||||||
error("%s", err.buf);
|
error("%s", err.buf);
|
||||||
|
@ -3929,6 +3930,8 @@ int reflog_expire(const char *refname, const unsigned char *sha1,
|
||||||
reflog_expiry_cleanup_fn cleanup_fn,
|
reflog_expiry_cleanup_fn cleanup_fn,
|
||||||
void *policy_cb_data)
|
void *policy_cb_data)
|
||||||
{
|
{
|
||||||
|
struct files_ref_store *refs =
|
||||||
|
get_files_ref_store(NULL, "reflog_expire");
|
||||||
static struct lock_file reflog_lock;
|
static struct lock_file reflog_lock;
|
||||||
struct expire_reflog_cb cb;
|
struct expire_reflog_cb cb;
|
||||||
struct ref_lock *lock;
|
struct ref_lock *lock;
|
||||||
|
@ -3947,7 +3950,8 @@ int reflog_expire(const char *refname, const unsigned char *sha1,
|
||||||
* reference itself, plus we might need to update the
|
* reference itself, plus we might need to update the
|
||||||
* reference if --updateref was specified:
|
* reference if --updateref was specified:
|
||||||
*/
|
*/
|
||||||
lock = lock_ref_sha1_basic(refname, sha1, NULL, NULL, REF_NODEREF,
|
lock = lock_ref_sha1_basic(refs, refname, sha1,
|
||||||
|
NULL, NULL, REF_NODEREF,
|
||||||
&type, &err);
|
&type, &err);
|
||||||
if (!lock) {
|
if (!lock) {
|
||||||
error("cannot lock ref '%s': %s", refname, err.buf);
|
error("cannot lock ref '%s': %s", refname, err.buf);
|
||||||
|
|
Loading…
Reference in New Issue