Commit 23a3f0cb authored by Stefan Beller's avatar Stefan Beller Committed by Junio C Hamano

refs: add repository argument to get_main_ref_store

Add a repository argument to allow the get_main_ref_store caller
to be more specific about which repository to handle. This is a small
mechanical change; it doesn't change the implementation to handle
repositories other than the_repository yet.

As with the previous commits, use a macro to catch callers passing a
repository other than the_repository at compile time.
Signed-off-by: default avatarJonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Stefan Beller's avatarStefan Beller <sbeller@google.com>
Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
parent c3c36d7d
#include "builtin.h"
#include "parse-options.h"
#include "refs.h"
#include "repository.h"
static char const * const pack_refs_usage[] = {
N_("git pack-refs [<options>]"),
......@@ -17,5 +18,5 @@ int cmd_pack_refs(int argc, const char **argv, const char *prefix)
};
if (parse_options(argc, argv, prefix, opts, pack_refs_usage, 0))
usage_with_options(pack_refs_usage, opts);
return refs_pack_refs(get_main_ref_store(), flags);
return refs_pack_refs(get_main_ref_store(the_repository), flags);
}
This diff is collapsed.
......@@ -758,7 +758,9 @@ int reflog_expire(const char *refname, const struct object_id *oid,
int ref_storage_backend_exists(const char *name);
struct ref_store *get_main_ref_store(void);
#define get_main_ref_store(r) \
get_main_ref_store_##r()
struct ref_store *get_main_ref_store_the_repository(void);
/*
* Return the ref_store instance for the specified submodule. For the
* main repository, use submodule==NULL; such a call cannot fail. For
......
......@@ -6,6 +6,7 @@
#include "diff.h"
#include "refs.h"
#include "revision.h"
#include "repository.h"
#include "graph.h"
#include "grep.h"
#include "reflog-walk.h"
......@@ -1285,7 +1286,7 @@ void add_reflogs_to_pending(struct rev_info *revs, unsigned flags)
cb.all_revs = revs;
cb.all_flags = flags;
cb.refs = get_main_ref_store();
cb.refs = get_main_ref_store(the_repository);
for_each_reflog(handle_one_reflog, &cb);
if (!revs->single_worktree)
......@@ -2176,7 +2177,7 @@ static int handle_revision_pseudo_opt(const char *submodule,
die("BUG: --single-worktree cannot be used together with submodule");
refs = get_submodule_ref_store(submodule);
} else
refs = get_main_ref_store();
refs = get_main_ref_store(the_repository);
/*
* NOTE!
......
......@@ -3,6 +3,7 @@
#include "refs.h"
#include "worktree.h"
#include "object-store.h"
#include "repository.h"
static const char *notnull(const char *arg, const char *name)
{
......@@ -23,7 +24,7 @@ static const char **get_store(const char **argv, struct ref_store **refs)
if (!argv[0]) {
die("ref store required");
} else if (!strcmp(argv[0], "main")) {
*refs = get_main_ref_store();
*refs = get_main_ref_store(the_repository);
} else if (skip_prefix(argv[0], "submodule:", &gitdir)) {
struct strbuf sb = STRBUF_INIT;
int ret;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment