void git_attr_set_direction(enum git_attr_direction new_direction)
{
- if (is_bare_repository() && new_direction != GIT_ATTR_INDEX)
+ if (is_bare_repository(the_repository) && new_direction != GIT_ATTR_INDEX)
BUG("non-INDEX attr direction in a bare repo");
if (new_direction != direction)
res = read_attr_from_index(istate, path, flags);
} else if (tree_oid) {
res = read_attr_from_blob(istate, tree_oid, path, flags);
- } else if (!is_bare_repository()) {
+ } else if (!is_bare_repository(the_repository)) {
if (direction == GIT_ATTR_CHECKOUT) {
res = read_attr_from_index(istate, path, flags);
if (!res)
struct object_id oid;
const char *head;
- if (is_bare_repository())
+ if (is_bare_repository(the_repository))
no_checkout = 1;
/*
revs.disable_stdin = 1;
setup_revisions(argc, argv, &revs, NULL);
- if (!revs.pending.nr && is_bare_repository()) {
+ if (!revs.pending.nr && is_bare_repository(the_repository)) {
struct commit *head_commit;
struct object_id head_oid;
struct object_id initialized_oid;
int cnt, i, doubledash, filei;
- if (!is_bare_repository())
+ if (!is_bare_repository(the_repository))
setup_work_tree(the_repository);
repo_config(the_repository, git_default_config, NULL);
if (!head_name)
goto cleanup;
- baremirror = is_bare_repository() && remote->mirror;
+ baremirror = is_bare_repository(the_repository) && remote->mirror;
create_only = follow_remote_head == FOLLOW_REMOTE_ALWAYS ? 0 : !baremirror;
if (baremirror) {
strbuf_addstr(&b_head, "HEAD");
die(_("failed to parse gc.logExpiry value %s"), cfg.gc_log_expire);
if (cfg.pack_refs < 0)
- cfg.pack_refs = !is_bare_repository();
+ cfg.pack_refs = !is_bare_repository(the_repository);
argc = parse_options(argc, argv, prefix, builtin_gc_options,
builtin_gc_usage, 0);
if (action == REF_ACTION_DEFAULT)
action = REF_ACTION_BRANCHES;
- if (is_bare_repository()) {
+ if (is_bare_repository(repo)) {
ret = error(_("cannot run fixup in a bare repository"));
goto out;
}
if (write_bitmaps < 0) {
if (write_midx == REPACK_WRITE_MIDX_NONE &&
- (!(pack_everything & ALL_INTO_ONE) || !is_bare_repository()))
+ (!(pack_everything & ALL_INTO_ONE) || !is_bare_repository(the_repository)))
write_bitmaps = 0;
}
if (po_args.pack_kept_objects < 0)
static int get_layout_bare(struct repository *repo UNUSED, struct strbuf *buf)
{
- strbuf_addstr(buf, is_bare_repository() ? "true" : "false");
+ strbuf_addstr(buf, is_bare_repository(the_repository) ? "true" : "false");
return 0;
}
if (reset_type != SOFT && (reset_type != MIXED || repo_get_work_tree(the_repository)))
setup_work_tree(the_repository);
- if (reset_type == MIXED && is_bare_repository())
+ if (reset_type == MIXED && is_bare_repository(the_repository))
die(_("%s reset is not allowed in a bare repository"),
_(reset_type_names[reset_type]));
continue;
}
if (!strcmp(arg, "--is-bare-repository")) {
- printf("%s\n", is_bare_repository() ? "true"
+ printf("%s\n", is_bare_repository(the_repository) ? "true"
: "false");
continue;
}
return argv->v[argv->nr - 1];
}
-int is_bare_repository(void)
+int is_bare_repository(struct repository *repo)
{
/* if core.bare is not 'false', let's see if there is a work tree */
- return the_repository->bare_cfg && !repo_get_work_tree(the_repository);
+ return repo->bare_cfg && !repo_get_work_tree(repo);
}
int have_git_dir(void)
void repo_config_values_init(struct repo_config_values *cfg);
+int is_bare_repository(struct repository *repo);
+
/*
* TODO: All the below state either explicitly or implicitly relies on
* `the_repository`. We should eventually get rid of these and make the
*/
int have_git_dir(void);
-int is_bare_repository(void);
-
/* Environment bits from configuration mechanism */
extern int trust_executable_bit;
extern int trust_ctime;
map->strdup_strings = 1;
map->cmp = namemap_cmp;
- if (!mailmap_blob && is_bare_repository())
+ if (!mailmap_blob && is_bare_repository(the_repository))
mailmap_blob = xstrdup("HEAD:.mailmap");
- if (!startup_info->have_repository || !is_bare_repository())
+ if (!startup_info->have_repository || !is_bare_repository(the_repository))
err |= read_mailmap_file(map, ".mailmap",
startup_info->have_repository ?
MAILMAP_NOFOLLOW : 0);
char *logfile;
if (log_refs_cfg == LOG_REFS_UNSET)
- log_refs_cfg = is_bare_repository() ? LOG_REFS_NONE : LOG_REFS_NORMAL;
+ log_refs_cfg = is_bare_repository(the_repository) ? LOG_REFS_NONE : LOG_REFS_NORMAL;
files_reflog_path(refs, &logfile_sb, refname);
logfile = strbuf_detach(&logfile_sb, NULL);
{
enum log_refs_config log_refs_cfg = refs->log_all_ref_updates;
if (log_refs_cfg == LOG_REFS_UNSET)
- log_refs_cfg = is_bare_repository() ? LOG_REFS_NONE : LOG_REFS_NORMAL;
+ log_refs_cfg = is_bare_repository(the_repository) ? LOG_REFS_NONE : LOG_REFS_NORMAL;
switch (log_refs_cfg) {
case LOG_REFS_NONE:
}
repo_config_set(repo, "core.filemode", filemode ? "true" : "false");
- if (is_bare_repository())
+ if (is_bare_repository(the_repository))
repo_config_set(repo, "core.bare", "true");
else {
repo_config_set(repo, "core.bare", "false");
if ((flags & (TRANSPORT_RECURSE_SUBMODULES_ON_DEMAND |
TRANSPORT_RECURSE_SUBMODULES_ONLY)) &&
- !is_bare_repository()) {
+ !is_bare_repository(the_repository)) {
struct ref *ref = remote_refs;
struct oid_array commits = OID_ARRAY_INIT;
if (((flags & TRANSPORT_RECURSE_SUBMODULES_CHECK) ||
((flags & (TRANSPORT_RECURSE_SUBMODULES_ON_DEMAND |
TRANSPORT_RECURSE_SUBMODULES_ONLY)) &&
- !pretend)) && !is_bare_repository()) {
+ !pretend)) && !is_bare_repository(the_repository)) {
struct ref *ref = remote_refs;
struct string_list needs_pushing = STRING_LIST_INIT_DUP;
struct oid_array commits = OID_ARRAY_INIT;
worktree->path = strbuf_detach(&worktree_path, NULL);
worktree->is_current = is_current_worktree(worktree);
worktree->is_bare = (the_repository->bare_cfg == 1) ||
- is_bare_repository() ||
+ is_bare_repository(the_repository) ||
/*
* When in a secondary worktree we have to also verify if the main
* worktree is bare in $commondir/config.worktree.