Website Summary Files Commits Branches @commit @diff @stats
diff options
context:
space:
mode:
Commit81a502f3f6579c6d69dab2485bdbc4fc35d9748c (patch)
Author
 Syndamia <kamen@syndamia.com>
2026-09-27 22:04:58 +0300
Committer
 Syndamia <kamen@syndamia.com>
2026-09-27 22:14:20 +0300
Filese974026fb7909ed3f742df0a6ed330279185e703
cgit-81a502f3f6579c6d69dab2485bdbc4fc35d9748c.tar
cgit-81a502f3f6579c6d69dab2485bdbc4fc35d9748c.tar.gz
cgit-81a502f3f6579c6d69dab2485bdbc4fc35d9748c.zip
Parent156e859aad4c98a169ce4c49e839cae41a28f432 (diff)
cgit: Fix defbranch not correctly parsing HEAD
Tracing the code: - refs_resolve_ref_unsafe uses git's refs_read_raw_ref, - which uses refs_read_special_head (on certain occasions), - which uses parse_loose_ref_contents (git/refs/files-backend.c), - which has logic to skip the leading "ref: " inside HEAD
1 files changed, 1 insertions, 1 deletions
-rw-r--r--cgit.c2
diff --git a/cgit.c b/cgit.c
index 2efbb2c..6ee5530 100644
--- a/cgit.c
+++ b/cgit.c
@@ -496,7 +496,7 @@ static char *guess_defbranch(void)
ref = refs_resolve_ref_unsafe(get_main_ref_store(the_repository),
"HEAD", 0, &oid, NULL);
- if (!ref || !skip_prefix(ref, "ref: refs/heads/", &refname))
+ if (!ref || (!skip_prefix(ref, "ref: refs/heads/", &refname) && !skip_prefix(ref, "refs/heads/", &refname)))
return "master";
return xstrdup(refname);
}