{"thread":{"id":"29172","subject":"[PATCH] Gitweb: Avoid warnings when a repo does not have a valid HEAD","startedAt":"2011-12-15T20:58:57Z","lastAt":"2011-12-16T14:55:36Z","messageCount":4,"participants":["Joe Ratterman","Junio C Hamano","Jakub Narebski"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"181251","messageId":"1323982737-19065-1-git-send-email-jratt0@gmail.com","threadId":"29172","inReplyTo":null,"subject":"[PATCH] Gitweb: Avoid warnings when a repo does not have a valid HEAD","fromName":"Joe Ratterman","fromEmail":"jratt0@gmail.com","sentAt":"2011-12-15T20:58:57Z","receivedAt":"2011-12-15T20:58:57Z","isPatch":true,"sender":{"key":"jratt0@gmail.com","avatar":"https://avatars.githubusercontent.com/u/66082737?v=4"},"body":"It is possible that the HEAD reference does not point to an existing\nbranch.  When viewing such a repository in gitweb, a message like this\none was sent to the error log:\n\n  gitweb.cgi: Use of uninitialized value in string eq at /usr/src/git/gitweb/gitweb.cgi line 5115.\n\nSigned-off-by: Joe Ratterman <jratt0@gmail.com>\n---\n gitweb/gitweb.perl |    2 +-\n 1 files changed, 1 insertions(+), 1 deletions(-)\n\ndiff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl\nindex 4f0c3bd..5af06d6 100755\n--- a/gitweb/gitweb.perl\n+++ b/gitweb/gitweb.perl\n@@ -5440,7 +5440,7 @@ sub git_heads_body {\n \tfor (my $i = $from; $i <= $to; $i++) {\n \t\tmy $entry = $headlist->[$i];\n \t\tmy %ref = %$entry;\n-\t\tmy $curr = $ref{'id'} eq $head;\n+\t\tmy $curr = $head ? ($ref{'id'} eq $head) : 0;\n \t\tif ($alternate) {\n \t\t\tprint \"<tr class=\\\"dark\\\">\\n\";\n \t\t} else {\n-- \n1.7.7.1\n"},{"id":"181264","messageId":"7v62hhmr2s.fsf@alter.siamese.dyndns.org","threadId":"29172","inReplyTo":"1323982737-19065-1-git-send-email-jratt0@gmail.com","subject":"Re: [PATCH] Gitweb: Avoid warnings when a repo does not have a valid HEAD","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2011-12-15T22:02:19Z","receivedAt":"2011-12-15T22:02:19Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Joe Ratterman <jratt0@gmail.com> writes:\n\n> It is possible that the HEAD reference does not point to an existing\n> branch.  When viewing such a repository in gitweb, a message like this\n> one was sent to the error log:\n>\n>   gitweb.cgi: Use of uninitialized value in string eq at /usr/src/git/gitweb/gitweb.cgi line 5115.\n>\n> Signed-off-by: Joe Ratterman <jratt0@gmail.com>\n> ---\n>  gitweb/gitweb.perl |    2 +-\n>  1 files changed, 1 insertions(+), 1 deletions(-)\n>\n> diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl\n> index 4f0c3bd..5af06d6 100755\n> --- a/gitweb/gitweb.perl\n> +++ b/gitweb/gitweb.perl\n> @@ -5440,7 +5440,7 @@ sub git_heads_body {\n>  \tfor (my $i = $from; $i <= $to; $i++) {\n>  \t\tmy $entry = $headlist->[$i];\n>  \t\tmy %ref = %$entry;\n> -\t\tmy $curr = $ref{'id'} eq $head;\n> +\t\tmy $curr = $head ? ($ref{'id'} eq $head) : 0;\n\nMakes one wonder if $head could be '0', but I presume this is about the\ncase where (!defined $head) holds true. Also makes one wonder if a similar\nissue exists on the $ref{\"id\"} side. I suspect that won't be true unless\nyou have a very screwed-up repository, but in that case a repository with\na HEAD that points at an unborn branch _and_ have other refs that do point\nat existing commit is already screwed-up, so if we want to be extremely\npedantic then perhaps ...\n\n    my $curr = ((defined $head && exists $ref{\"id\"} && defined $ref{\"id\"})\n\t\t? ($ref{\"id\"} eq $head)\n                : 0);\n"},{"id":"181267","messageId":"7vty51lbb0.fsf@alter.siamese.dyndns.org","threadId":"29172","inReplyTo":"7v62hhmr2s.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH] Gitweb: Avoid warnings when a repo does not have a valid HEAD","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2011-12-15T22:28:19Z","receivedAt":"2011-12-15T22:28:19Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n> Joe Ratterman <jratt0@gmail.com> writes:\n>\n>> It is possible that the HEAD reference does not point to an existing\n>> branch.  When viewing such a repository in gitweb, a message like this\n>> one was sent to the error log:\n>>\n>>   gitweb.cgi: Use of uninitialized value in string eq at /usr/src/git/gitweb/gitweb.cgi line 5115.\n>>\n> ..., but in that case a repository with\n> a HEAD that points at an unborn branch _and_ have other refs that do point\n> at existing commit is already screwed-up, so if we want to be extremely\n> pedantic then perhaps ...\n>\n>     my $curr = ((defined $head && exists $ref{\"id\"} && defined $ref{\"id\"})\n> \t\t? ($ref{\"id\"} eq $head)\n>                 : 0);\n\nJust in case, I was not suggesting to update the patch to look like the\nabove by \"if we want to be extremely pedantic\".\n\nAfter all, that error message in the log may be a good thing that notifies\nthe site administrators about a suspicious repository so that it can be\nfixed (even though it was not a designed \"feature\" but something that\nhappens to work).\n"},{"id":"181298","messageId":"201112161555.37472.jnareb@gmail.com","threadId":"29172","inReplyTo":"7vty51lbb0.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH] Gitweb: Avoid warnings when a repo does not have a valid HEAD","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2011-12-16T14:55:36Z","receivedAt":"2011-12-16T14:55:36Z","isPatch":true,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"On Thu, 15 Dec 2011, Junio C Hamano wrote:\n> Junio C Hamano <gitster@pobox.com> writes:\n>> Joe Ratterman <jratt0@gmail.com> writes:\n>>\n>>> It is possible that the HEAD reference does not point to an existing\n>>> branch.  When viewing such a repository in gitweb, a message like this\n>>> one was sent to the error log:\n>>>\n>>>   gitweb.cgi: Use of uninitialized value in string eq at /usr/src/git/gitweb/gitweb.cgi line 5115.\n>>>\n>> ..., but in that case a repository with\n>> a HEAD that points at an unborn branch _and_ have other refs that do point\n>> at existing commit is already screwed-up, so if we want to be extremely\n>> pedantic then perhaps ...\n>>\n>>     my $curr = ((defined $head && exists $ref{\"id\"} && defined $ref{\"id\"})\n\n       my $curr = ((defined $head && defined $ref{\"id\"})\n\nis enough, because '!exists $hash{key}' implies '!defined $hash{key}'\n(though reverse is not true).\n\n>> \t\t? ($ref{\"id\"} eq $head)\n>>                 : 0);\n> \n> Just in case, I was not suggesting to update the patch to look like the\n> above by \"if we want to be extremely pedantic\".\n> \n> After all, that error message in the log may be a good thing that notifies\n> the site administrators about a suspicious repository so that it can be\n> fixed (even though it was not a designed \"feature\" but something that\n> happens to work).\n\nWell, but for that those error messages should describe error; the above\nis quite hard to translate to \n\n  warning: HEAD points to an unborn branch in repository foo.git\n\nBTW. we should probably warn about this situation more clear, perhaps\nby showing warning instead of empty place where subject of current commit\nis usually shown.\n\n\nAnyway git marks up branches (sic!) that _point to_ the same commit as\nHEAD because we calculate it anyway, at least for 'summary' view.\n\nBetter solution would be to examine HEAD (either using Perl, or using\n\"git symbolic-ref\") to get _name_ of current branch.  I'd rather avoid\nyet another command call.\n\n-- \nJakub Narebski\nPoland\n"}]}