git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] Gitweb: Avoid warnings when a repo does not have a valid HEAD

From
Joe Ratterman <jratt0@gmail.com>
Date
Dec 13, 2011, 22:35 UTC
Message-ID
<1323815706-10560-1-git-send-email-jratt0@gmail.com>

It is possible that the HEAD reference does not point to an existing branch. When viewing such a repository in gitweb, a message like this one was sent to the error log:

  gitweb.cgi: Use of uninitialized value in string eq at /usr/src/git/gitweb/gitweb.cgi line 5115.
Signed-off-by: Joe Ratterman <jratt0@gmail.com>
---
 gitweb/gitweb.perl |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 4f0c3bd..5af06d6 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -5440,7 +5440,7 @@ sub git_heads_body {
 	for (my $i = $from; $i <= $to; $i++) {
 		my $entry = $headlist->[$i];
 		my %ref = %$entry;
-		my $curr = $ref{'id'} eq $head;
+		my $curr = $head ? ($ref{'id'} eq $head) : 0;
 		if ($alternate) {
 			print "<tr class=\"dark\">\n";
 		} else {
-- 
1.7.7.1
Next: Joe Ratterman
Message 1 of 7 in “Gitweb: Avoid warnings when a repo does not have a valid HEAD”
  1. Gitweb: Avoid warnings when a repo does not have a valid HEADJoe Ratterman, Dec 13, 2011
  2. Add '-P' as a synonym for '--no-pager' in the git commandJoe Ratterman, Dec 13, 2011
  3. Johannes SixtDec 14, 2011
  4. test: errors preparing for a test are not specialJonathan Nieder, Dec 14, 2011
  5. Johannes SixtDec 14, 2011
  6. Jonathan NiederDec 14, 2011
  7. Jonathan NiederDec 14, 2011

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.