aboutsummaryrefslogtreecommitdiff
path: root/refs.c
diff options
context:
space:
mode:
authorPatrick Steinhardt <ps@pks.im>2026-01-12 10:03:05 +0100
committerJunio C Hamano <gitster@pobox.com>2026-01-12 06:55:41 -0800
commit9727336b31c055e4507248703b8a4a8ed039dc06 (patch)
tree5833f6aa7d7609de428745188d3c4eba40517534 /refs.c
parent46d611cadab500ca2b458b2fda7008c41b174011 (diff)
downloadgit-9727336b31c055e4507248703b8a4a8ed039dc06.tar.xz
builtin/fsck: move generic HEAD check into `refs_fsck()`
Move the check that detects "HEAD" refs that do not point at a branch into `refs_fsck()`. This follows the same motivation as the preceding commit. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'refs.c')
-rw-r--r--refs.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/refs.c b/refs.c
index c3528862c6..a772d371cd 100644
--- a/refs.c
+++ b/refs.c
@@ -334,8 +334,18 @@ int refs_fsck_ref(struct ref_store *refs UNUSED, struct fsck_options *o,
int refs_fsck_symref(struct ref_store *refs UNUSED, struct fsck_options *o,
struct fsck_ref_report *report,
- const char *refname UNUSED, const char *target)
+ const char *refname, const char *target)
{
+ const char *stripped_refname;
+
+ parse_worktree_ref(refname, NULL, NULL, &stripped_refname);
+
+ if (!strcmp(stripped_refname, "HEAD") &&
+ !starts_with(target, "refs/heads/") &&
+ fsck_report_ref(o, report, FSCK_MSG_BAD_HEAD_TARGET,
+ "HEAD points to non-branch '%s'", target))
+ return -1;
+
if (is_root_ref(target))
return 0;