aboutsummaryrefslogtreecommitdiffstats
path: root/builtin/refs.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2024-12-04 10:14:42 +0900
committerJunio C Hamano <gitster@pobox.com>2024-12-04 10:14:42 +0900
commit57e81b59f35198afedae18e8363dbffdc96c481d (patch)
tree3c529bb89a7bfd7851f6bea33d93e1505fa678b0 /builtin/refs.c
parentMerge branch 'ps/ref-backend-migration-optim' (diff)
parentref: add symlink ref content check for files backend (diff)
downloadgit-57e81b59f35198afedae18e8363dbffdc96c481d.tar.gz
git-57e81b59f35198afedae18e8363dbffdc96c481d.zip
Merge branch 'sj/ref-contents-check'
"git fsck" learned to issue warnings on "curiously formatted" ref contents that have always been taken valid but something Git wouldn't have written itself (e.g., missing terminating end-of-line after the full object name). * sj/ref-contents-check: ref: add symlink ref content check for files backend ref: check whether the target of the symref is a ref ref: add basic symref content check for files backend ref: add more strict checks for regular refs ref: port git-fsck(1) regular refs check for files backend ref: support multiple worktrees check for refs ref: initialize ref name outside of check functions ref: check the full refname instead of basename ref: initialize "fsck_ref_report" with zero
Diffstat (limited to 'builtin/refs.c')
-rw-r--r--builtin/refs.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/builtin/refs.c b/builtin/refs.c
index 24978a7b7b..394b4101c6 100644
--- a/builtin/refs.c
+++ b/builtin/refs.c
@@ -5,6 +5,7 @@
#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]")
@@ -66,6 +67,7 @@ out:
static int cmd_refs_verify(int argc, const char **argv, const char *prefix)
{
struct fsck_options fsck_refs_options = FSCK_REFS_OPTIONS_DEFAULT;
+ struct worktree **worktrees;
const char * const verify_usage[] = {
REFS_VERIFY_USAGE,
NULL,
@@ -75,7 +77,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,9 +86,13 @@ 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();
+ 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;
}