return REF_WORKTREE_SHARED;
}
-long get_files_ref_lock_timeout_ms(void)
+long get_files_ref_lock_timeout_ms(struct repository *repo)
{
static int configured = 0;
static int timeout_ms = 100;
if (!configured) {
- repo_config_get_int(the_repository, "core.filesreflocktimeout", &timeout_ms);
+ repo_config_get_int(repo, "core.filesreflocktimeout", &timeout_ms);
configured = 1;
}
if (hold_lock_file_for_update_timeout(
&lock->lk, ref_file.buf, LOCK_NO_DEREF,
- get_files_ref_lock_timeout_ms()) < 0) {
+ get_files_ref_lock_timeout_ms(transaction->ref_store->repo)) < 0) {
int myerr = errno;
errno = 0;
if (myerr == ENOENT && --attempts_remaining > 0) {
return remove_dir_recursively(path, REMOVE_DIR_EMPTY_ONLY);
}
+struct create_reflock_cb {
+ struct lock_file *lk;
+ struct repository *repo;
+};
+
static int create_reflock(const char *path, void *cb)
{
- struct lock_file *lk = cb;
-
+ struct create_reflock_cb *data = cb;
return hold_lock_file_for_update_timeout(
- lk, path, LOCK_NO_DEREF,
- get_files_ref_lock_timeout_ms()) < 0 ? -1 : 0;
+ data->lk, path, LOCK_NO_DEREF,
+ get_files_ref_lock_timeout_ms(data->repo)) < 0 ? -1 : 0;
}
/*
{
struct strbuf ref_file = STRBUF_INIT;
struct ref_lock *lock;
+ struct create_reflock_cb cb_data;
files_assert_main_repository(refs, "lock_ref_oid_basic");
assert(err);
lock->ref_name = xstrdup(refname);
lock->count = 1;
+ cb_data.lk = &lock->lk;
+ cb_data.repo = refs->base.repo;
- if (raceproof_create_file(ref_file.buf, create_reflock, &lock->lk)) {
+ if (raceproof_create_file(ref_file.buf, create_reflock, &cb_data)) {
unable_to_lock_message(ref_file.buf, errno, err);
goto error_return;
}
* Return the length of time to retry acquiring a loose reference lock
* before giving up, in milliseconds:
*/
-long get_files_ref_lock_timeout_ms(void);
+long get_files_ref_lock_timeout_ms(struct repository *repo);
/*
* Return true iff refname is minimally safe. "Safe" here means that