summaryrefslogtreecommitdiff
path: root/builtin/refs.c
diff options
context:
space:
mode:
Diffstat (limited to 'builtin/refs.c')
-rw-r--r--builtin/refs.c25
1 files changed, 18 insertions, 7 deletions
diff --git a/builtin/refs.c b/builtin/refs.c
index 24978a7b7b..998d2a2c1c 100644
--- a/builtin/refs.c
+++ b/builtin/refs.c
@@ -5,14 +5,16 @@
#include "parse-options.h"
#include "refs.h"
#include "strbuf.h"
+#include "worktree.h"
#define REFS_MIGRATE_USAGE \
- N_("git refs migrate --ref-format=<format> [--dry-run]")
+ N_("git refs migrate --ref-format=<format> [--no-reflog] [--dry-run]")
#define REFS_VERIFY_USAGE \
N_("git refs verify [--strict] [--verbose]")
-static int cmd_refs_migrate(int argc, const char **argv, const char *prefix)
+static int cmd_refs_migrate(int argc, const char **argv, const char *prefix,
+ struct repository *repo UNUSED)
{
const char * const migrate_usage[] = {
REFS_MIGRATE_USAGE,
@@ -28,6 +30,9 @@ static int cmd_refs_migrate(int argc, const char **argv, const char *prefix)
OPT_BIT(0, "dry-run", &flags,
N_("perform a non-destructive dry-run"),
REPO_MIGRATE_REF_STORAGE_FORMAT_DRYRUN),
+ OPT_BIT(0, "no-reflog", &flags,
+ N_("drop reflogs entirely during the migration"),
+ REPO_MIGRATE_REF_STORAGE_FORMAT_SKIP_REFLOG),
OPT_END(),
};
struct strbuf errbuf = STRBUF_INIT;
@@ -63,9 +68,11 @@ out:
return err;
}
-static int cmd_refs_verify(int argc, const char **argv, const char *prefix)
+static int cmd_refs_verify(int argc, const char **argv, const char *prefix,
+ struct repository *repo UNUSED)
{
struct fsck_options fsck_refs_options = FSCK_REFS_OPTIONS_DEFAULT;
+ struct worktree **worktrees;
const char * const verify_usage[] = {
REFS_VERIFY_USAGE,
NULL,
@@ -75,7 +82,7 @@ static int cmd_refs_verify(int argc, const char **argv, const char *prefix)
OPT_BOOL(0, "strict", &fsck_refs_options.strict, N_("enable strict checking")),
OPT_END(),
};
- int ret;
+ int ret = 0;
argc = parse_options(argc, argv, prefix, options, verify_usage, 0);
if (argc)
@@ -84,16 +91,20 @@ static int cmd_refs_verify(int argc, const char **argv, const char *prefix)
git_config(git_fsck_config, &fsck_refs_options);
prepare_repo_settings(the_repository);
- ret = refs_fsck(get_main_ref_store(the_repository), &fsck_refs_options);
+ worktrees = get_worktrees_without_reading_head();
+ for (size_t i = 0; worktrees[i]; i++)
+ ret |= refs_fsck(get_worktree_ref_store(worktrees[i]),
+ &fsck_refs_options, worktrees[i]);
fsck_options_clear(&fsck_refs_options);
+ free_worktrees(worktrees);
return ret;
}
int cmd_refs(int argc,
const char **argv,
const char *prefix,
- struct repository *repo UNUSED)
+ struct repository *repo)
{
const char * const refs_usage[] = {
REFS_MIGRATE_USAGE,
@@ -108,5 +119,5 @@ int cmd_refs(int argc,
};
argc = parse_options(argc, argv, prefix, opts, refs_usage, 0);
- return fn(argc, argv, prefix);
+ return fn(argc, argv, prefix, repo);
}