-#define USE_THE_REPOSITORY_VARIABLE
#define DISABLE_SIGN_COMPARE_WARNINGS
#include "../git-compat-util.h"
#include "../revision.h"
#include <wildmatch.h>
+/* So that we can drop `USE_THE_REPOSITORY_VARIABLE`. */
+extern int ignore_case;
+
/*
* This backend uses the following flags in `ref_update::flags` for
* internal bookkeeping purposes. Their numerical values must not
files_ref_path(refs, &ref_file, refname);
retry:
- switch (safe_create_leading_directories(the_repository, ref_file.buf)) {
+ switch (safe_create_leading_directories(refs->base.repo, ref_file.buf)) {
case SCLD_OK:
break; /* success */
case SCLD_EXISTS:
* recent call of fn. fn is always called at least once, and will be
* called more than once if it returns ENOENT or EISDIR.
*/
-static int raceproof_create_file(const char *path, create_file_fn fn, void *cb)
+static int raceproof_create_file(struct files_ref_store *refs,
+ const char *path, create_file_fn fn, void *cb)
{
/*
* The number of times we will try to remove empty directories
strbuf_addstr(&path_copy, path);
do {
- scld_result = safe_create_leading_directories(the_repository, path_copy.buf);
+ scld_result = safe_create_leading_directories(refs->base.repo, path_copy.buf);
if (scld_result == SCLD_OK)
goto retry_fn;
} while (scld_result == SCLD_VANISHED && create_directories_remaining-- > 0);
cb_data.lk = &lock->lk;
cb_data.repo = refs->base.repo;
- if (raceproof_create_file(ref_file.buf, create_reflock, &cb_data)) {
+ if (raceproof_create_file(refs, ref_file.buf, create_reflock, &cb_data)) {
unable_to_lock_message(ref_file.buf, errno, err);
goto error_return;
}
ref_transaction_add_update(
transaction, r->name,
REF_NO_DEREF | REF_HAVE_NEW | REF_HAVE_OLD | REF_IS_PRUNING,
- null_oid(the_hash_algo), &r->oid, NULL, NULL, NULL,
+ null_oid(refs->base.repo->hash_algo), &r->oid, NULL, NULL, NULL,
NULL, NULL);
if (ref_transaction_commit(transaction, &err))
goto cleanup;
files_reflog_path(refs, &path, newrefname);
files_reflog_path(refs, &tmp, TMP_RENAMED_LOG);
cb.tmp_renamed_log = tmp.buf;
- ret = raceproof_create_file(path.buf, rename_tmp_log_callback, &cb);
+ ret = raceproof_create_file(refs, path.buf, rename_tmp_log_callback, &cb);
if (ret) {
if (errno == EISDIR)
error("directory not empty: %s", path.buf);
char *logfile;
if (log_refs_cfg == LOG_REFS_UNSET)
- log_refs_cfg = is_bare_repository(the_repository) ? LOG_REFS_NONE : LOG_REFS_NORMAL;
+ log_refs_cfg = is_bare_repository(refs->base.repo) ? LOG_REFS_NONE : LOG_REFS_NORMAL;
files_reflog_path(refs, &logfile_sb, refname);
logfile = strbuf_detach(&logfile_sb, NULL);
if (force_create || should_autocreate_reflog(log_refs_cfg, refname)) {
- if (raceproof_create_file(logfile, open_or_create_logfile, logfd)) {
+ if (raceproof_create_file(refs, logfile, open_or_create_logfile, logfd)) {
if (errno == ENOENT)
strbuf_addf(err, "unable to create directory for '%s': "
"%s", logfile, strerror(errno));
}
if (*logfd >= 0)
- adjust_shared_perm(the_repository, logfile);
+ adjust_shared_perm(refs->base.repo, logfile);
free(logfile);
return 0;
* they do not understand the reference format extension.
*/
strbuf_addf(&sb, "%s/refs", ref_store->gitdir);
- safe_create_dir(the_repository, sb.buf, 1);
- adjust_shared_perm(the_repository, sb.buf);
+ safe_create_dir(refs->base.repo, sb.buf, 1);
+ adjust_shared_perm(refs->base.repo, sb.buf);
/*
* There is no need to create directories for common refs when creating
*/
strbuf_reset(&sb);
files_ref_path(refs, &sb, "refs/heads");
- safe_create_dir(the_repository, sb.buf, 1);
+ safe_create_dir(refs->base.repo, sb.buf, 1);
strbuf_reset(&sb);
files_ref_path(refs, &sb, "refs/tags");
- safe_create_dir(the_repository, sb.buf, 1);
+ safe_create_dir(refs->base.repo, sb.buf, 1);
}
strbuf_release(&sb);