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

Re: [PATCH 1/3] gitweb: Get rid of unnecessary check of $signoff

From
Junio C Hamano <gitster@pobox.com>
Date
Jul 3, 2012, 19:58 UTC
Message-ID
<7v7gukvcpd.fsf@alter.siamese.dyndns.org>
In-Reply-To
<1341295377-22083-2-git-send-email-namhyung@kernel.org>
Namhyung Kim <namhyung@kernel.org> writes:
Show 5 quoted lines
> If $signoff set to 1, the $line would be handled in
> the if statement for the both cases. So the outer of
> the conditional always sees the $signoff always set
> to 0 and no need to check it. Thus we can finally get
> rid of it.

While this may not change the behaviour of the code, I think that only shows the original is broken. You even have the hint left in the context of your patch:

Show 5 quoted lines
>  		# print only one empty line
>  		# do not print empty line after signoff
>  		if ($line eq "") {
> -			next if ($empty || $signoff);
> +			next if ($empty);
Given this input:
	If $signoff is set to 1, ...
        ...
        rid of it.
	Signed-off-by: N K
        Signed-off-by: J C H

isn't the code trying (and failing) to remove the empty line between the two S-o-b lines?

So something like this on top? I renamed "$empty" which is unclear what it means ("We just saw an empty line? What does the variable want us to do?") to "$skip_blank_line" which more clearly instructs us what to do. If we see a blank line when it is set, we skip it.

 gitweb/gitweb.perl | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 7585e08..202286b 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -4484,12 +4484,12 @@ sub git_print_log {
 	}
 
 	# print log
-	my $empty = 0;
+	my $skip_blank_line = 0;
 	foreach my $line (@$log) {
 		if ($line =~ m/^ *(signed[ \-]off[ \-]by[ :]|acked[ \-]by[ :]|cc[ :])/i) {
-			$empty = 0;
 			if (! $opts{'-remove_signoff'}) {
 				print "<span class=\"signoff\">" . esc_html($line) . "</span><br/>\n";
+				$skip_blank_line = 1;
 			}
 			next;
 		}
@@ -4497,10 +4497,10 @@ sub git_print_log {
 		# print only one empty line
 		# do not print empty line after signoff
 		if ($line eq "") {
-			next if ($empty);
-			$empty = 1;
+			next if ($skip_blank_line);
+			$skip_blank_line = 1;
 		} else {
-			$empty = 0;
+			$skip_blank_line = 0;
 		}
 
 		print format_log_line_html($line) . "<br/>\n";
Previous: Namhyung KimNext: Namhyung Kim
Message 3 of 10 in “gitweb changes”
  1. 0/3 gitweb changesNamhyung Kim, Jul 3, 2012
  2. 1/3 gitweb: Get rid of unnecessary check of $signoffNamhyung Kim, Jul 3, 2012
  3. Junio C HamanoJul 3, 2012
  4. 2/3 gitweb: Handle a few other tags in git_print_logNamhyung Kim, Jul 3, 2012
  5. Junio C HamanoJul 3, 2012
  6. 3/3 gitweb: Add support to Link: tagNamhyung Kim, Jul 3, 2012
  7. Junio C HamanoJul 3, 2012
  8. Namhyung KimJul 4, 2012
  9. Namhyung KimJul 4, 2012
  10. Namhyung KimJul 4, 2012

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.