]> Lady’s Gitweb - Gitweb/commit
gitweb: Fix "heads" view when there is no current branch
authorJakub Narebski <redacted>
Wed, 15 Feb 2012 15:36:41 +0000 (16:36 +0100)
committerLady <redacted>
Mon, 6 Apr 2026 04:51:31 +0000 (00:51 -0400)
commit053713b077eb87270f5bfa4e015a537848ba230a9973231eeaf409dfa2b158dd
treeab23446e89d19af9dceeb8d6ea5e9df284d0d1e677814c1ddeba272f24e2aeab
parent8c5876e8803cb89d50d4ee6b5f8259941844b941a9425534e36b4a2f581244d7
gitweb: Fix "heads" view when there is no current branch

In a repository whose HEAD points to an unborn branch with no commits,
"heads" view and "summary" view (which shows what is shown in "heads"
view) compared the object names of commits at the tip of branches with the
output from "git rev-parse HEAD", which caused comparison of a string with
undef and resulted in a warning in the server log.

This can happen if non-bare repository (with default 'master' branch)
is updated not via committing but by other means like push to it, or
Gerrit.  It can happen also just after running "git checkout --orphan
<new branch>" but before creating any new commit on this branch.

Rewrite the comparison so that it also works when $head points at nothing;
in such a case, no branch can be "the current branch", add a test for it.
While at it, rename local variable $head to $head_at, as it points to
current commit rather than current branch name (HEAD contents).

The code still incorrectly shows all branches that point at the same
commit as what HEAD points as "the current branch", even when HEAD is
detached. Fixing this bug is outside the scope of this patch.

Reported-by: Rajesh Boyapati
Signed-off-by: Jakub Narebski <redacted>
Signed-off-by: Junio C Hamano <redacted>
gitweb.perl
This page took 0.169149 seconds and 5 git commands to generate.