{"thread":{"id":"30948","subject":"[PATCH v2 2/3] gitweb: Handle other types of tag in git_print_log","startedAt":"2012-07-04T02:47:24Z","lastAt":"2012-07-05T22:29:00Z","messageCount":5,"participants":["Namhyung Kim","Junio C Hamano"],"isPatch":true,"patchVersion":2,"patchTotal":3},"messages":[{"id":"194593","messageId":"1341370046-19913-1-git-send-email-namhyung@kernel.org","threadId":"30948","inReplyTo":null,"subject":"[PATCH v2 1/3] gitweb: Cleanup git_print_log()","fromName":"Namhyung Kim","fromEmail":"namhyung@kernel.org","sentAt":"2012-07-04T02:47:24Z","receivedAt":"2012-07-04T02:47:24Z","isPatch":true,"sender":{"key":"namhyung@gmail.com","avatar":"https://avatars.githubusercontent.com/u/48503?v=4"},"body":"If $signoff set to 1, the $line would be handled in\nthe if statement for the both cases. So the outer of\nthe conditional always sees the $signoff always set\nto 0 and no need to check it. Thus we can finally get\nrid of it.\n\nAlso rename $empty to more clear $skip_blank_line as\nsuggested by Junio.\n\nSigned-off-by: Namhyung Kim <namhyung@kernel.org>\n---\n gitweb/gitweb.perl |   21 +++++++--------------\n 1 file changed, 7 insertions(+), 14 deletions(-)\n\ndiff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl\nindex 55e0e9e..82c5da7 100755\n--- a/gitweb/gitweb.perl\n+++ b/gitweb/gitweb.perl\n@@ -4484,30 +4484,23 @@ sub git_print_log {\n \t}\n \n \t# print log\n-\tmy $signoff = 0;\n-\tmy $empty = 0;\n+\tmy $skip_blank_line = 0;\n \tforeach my $line (@$log) {\n \t\tif ($line =~ m/^ *(signed[ \\-]off[ \\-]by[ :]|acked[ \\-]by[ :]|cc[ :])/i) {\n-\t\t\t$signoff = 1;\n-\t\t\t$empty = 0;\n \t\t\tif (! $opts{'-remove_signoff'}) {\n \t\t\t\tprint \"<span class=\\\"signoff\\\">\" . esc_html($line) . \"</span><br/>\\n\";\n-\t\t\t\tnext;\n-\t\t\t} else {\n-\t\t\t\t# remove signoff lines\n-\t\t\t\tnext;\n+\t\t\t\t$skip_blank_line = 1;\n \t\t\t}\n-\t\t} else {\n-\t\t\t$signoff = 0;\n+\t\t\tnext;\n \t\t}\n \n \t\t# print only one empty line\n \t\t# do not print empty line after signoff\n \t\tif ($line eq \"\") {\n-\t\t\tnext if ($empty || $signoff);\n-\t\t\t$empty = 1;\n+\t\t\tnext if ($skip_blank_line);\n+\t\t\t$skip_blank_line = 1;\n \t\t} else {\n-\t\t\t$empty = 0;\n+\t\t\t$skip_blank_line = 0;\n \t\t}\n \n \t\tprint format_log_line_html($line) . \"<br/>\\n\";\n@@ -4515,7 +4508,7 @@ sub git_print_log {\n \n \tif ($opts{'-final_empty_line'}) {\n \t\t# end with single empty line\n-\t\tprint \"<br/>\\n\" unless $empty;\n+\t\tprint \"<br/>\\n\" unless $skip_blank_line;\n \t}\n }\n \n-- \n1.7.10.4\n"},{"id":"194592","messageId":"1341370046-19913-2-git-send-email-namhyung@kernel.org","threadId":"30948","inReplyTo":"1341370046-19913-1-git-send-email-namhyung@kernel.org","subject":"[PATCH v2 2/3] gitweb: Handle other types of tag in git_print_log","fromName":"Namhyung Kim","fromEmail":"namhyung@kernel.org","sentAt":"2012-07-04T02:47:25Z","receivedAt":"2012-07-04T02:47:25Z","isPatch":true,"sender":{"key":"namhyung@gmail.com","avatar":"https://avatars.githubusercontent.com/u/48503?v=4"},"body":"There are many types of tags used in S-o-b area [1].\nUpdate the regex to handle them properly. It requires\nthe tag should be started by a capital letter and ended\nby '-by: ' or '-By: '. The only exception is 'Cc: '.\n\n[1] http://lwn.net/Articles/503829/\n\nSigned-off-by: Namhyung Kim <namhyung@kernel.org>\n---\n gitweb/gitweb.perl |    2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl\nindex 82c5da7..362784d 100755\n--- a/gitweb/gitweb.perl\n+++ b/gitweb/gitweb.perl\n@@ -4486,7 +4486,7 @@ sub git_print_log {\n \t# print log\n \tmy $skip_blank_line = 0;\n \tforeach my $line (@$log) {\n-\t\tif ($line =~ m/^ *(signed[ \\-]off[ \\-]by[ :]|acked[ \\-]by[ :]|cc[ :])/i) {\n+\t\tif ($line =~ m/^\\s*([A-Z][-A-Za-z]*-[Bb]y|C[Cc]): /) {\n \t\t\tif (! $opts{'-remove_signoff'}) {\n \t\t\t\tprint \"<span class=\\\"signoff\\\">\" . esc_html($line) . \"</span><br/>\\n\";\n \t\t\t\t$skip_blank_line = 1;\n-- \n1.7.10.4\n"},{"id":"194594","messageId":"1341370046-19913-3-git-send-email-namhyung@kernel.org","threadId":"30948","inReplyTo":"1341370046-19913-1-git-send-email-namhyung@kernel.org","subject":"[PATCH v2 3/3] gitweb: Add support to Link: tag","fromName":"Namhyung Kim","fromEmail":"namhyung@kernel.org","sentAt":"2012-07-04T02:47:26Z","receivedAt":"2012-07-04T02:47:26Z","isPatch":true,"sender":{"key":"namhyung@gmail.com","avatar":"https://avatars.githubusercontent.com/u/48503?v=4"},"body":"The tip tree is the one of major subsystem tree in the\nLinux kernel project. On the tip tree, the Link: (or\nsimilar Buglink:) tag is used for tracking the original\ndiscussion or context. Since it's ususally in the S-o-b\narea, it'd be better using same style with others.\n\nAlso as it tends to contain a message-id sent from git\nsend-email, a part of the line would set a wrong hyperlink\nlike [1]. Fix it by not using format_log_line_html().\n\n[1] git.kernel.org/?p=linux/kernel/git/tip/tip.git;a=commit;h=08942f6d5d992e9486b07653fd87ea8182a22fa0\n\nSigned-off-by: Namhyung Kim <namhyung@kernel.org>\n---\n gitweb/gitweb.perl |   10 ++++++++++\n 1 file changed, 10 insertions(+)\n\ndiff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl\nindex 362784d..3d6a705 100755\n--- a/gitweb/gitweb.perl\n+++ b/gitweb/gitweb.perl\n@@ -4494,6 +4494,16 @@ sub git_print_log {\n \t\t\tnext;\n \t\t}\n \n+\t\tif ($line =~ m,\\s*([a-z]*link): (https?://\\S+),i) {\n+\t\t\tif (! $opts{'-remove_signoff'}) {\n+\t\t\t\tprint \"<span class=\\\"signoff\\\">\" . esc_html($1) . \": \" .\n+\t\t\t\t\t\"<a href=\\\"\" . esc_html($2) . \"\\\">\" . esc_html($2) . \"</a>\" .\n+\t\t\t\t\t\"</span><br/>\\n\";\n+\t\t\t\t$skip_blank_line = 1;\n+\t\t\t}\n+\t\t\tnext;\n+\t\t}\n+\n \t\t# print only one empty line\n \t\t# do not print empty line after signoff\n \t\tif ($line eq \"\") {\n-- \n1.7.10.4\n"},{"id":"194678","messageId":"7vhatlrgp9.fsf@alter.siamese.dyndns.org","threadId":"30948","inReplyTo":"1341370046-19913-1-git-send-email-namhyung@kernel.org","subject":"Re: [PATCH v2 1/3] gitweb: Cleanup git_print_log()","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-07-05T22:22:42Z","receivedAt":"2012-07-05T22:22:42Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Namhyung Kim <namhyung@kernel.org> writes:\n\n> If $signoff set to 1, the $line would be handled in\n> the if statement for the both cases. So the outer of\n> the conditional always sees the $signoff always set\n> to 0 and no need to check it. Thus we can finally get\n> rid of it.\n>\n> Also rename $empty to more clear $skip_blank_line as\n> suggested by Junio.\n\nThanks.  It does not make it clear that you fixed a bug in the\noriginal, so let me rephrase it like so:\n\n-- >8 --\nFrom: Namhyung Kim <namhyung@kernel.org>\nDate: Wed, 4 Jul 2012 11:47:24 +0900\nSubject: [PATCH] gitweb: Cleanup git_print_log()\n\nWhen we see a signed-off-by line (and its friends), we set $signoff\nto true, but then we process the next line after we are done without\ngiving control to the rest of the loop.  And when the line we saw is\nnot a signed-off-by line, we reset $signoff to false before running\nthe remainder of the loop.\n\nHence, the check for $signoff that attempts to remove an extra empty\nline between two signed-off-by line was not doing anything useful.\n\nRename $empty to a more explicit name $skip_blank_line to tell us to\nskip a blank line when we see one, set it after we see and emit a\nblank line (to avoid showing more than one empty lines in a raw) or\nafter we handle a signed-off-by line (to avoid empty lines after\nsuch a line), to fix this bug, and get rid of the $signoff variable\nthat is not useful.\n\nSigned-off-by: Namhyung Kim <namhyung@kernel.org>\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n"},{"id":"194679","messageId":"7vd349rger.fsf@alter.siamese.dyndns.org","threadId":"30948","inReplyTo":"1341370046-19913-3-git-send-email-namhyung@kernel.org","subject":"Re: [PATCH v2 3/3] gitweb: Add support to Link: tag","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-07-05T22:29:00Z","receivedAt":"2012-07-05T22:29:00Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Namhyung Kim <namhyung@kernel.org> writes:\n\n> The tip tree is the one of major subsystem tree in the\n> Linux kernel project. On the tip tree, the Link: (or\n> similar Buglink:) tag is used for tracking the original\n> discussion or context. Since it's ususally in the S-o-b\n> area, it'd be better using same style with others.\n>\n> Also as it tends to contain a message-id sent from git\n> send-email, a part of the line would set a wrong hyperlink\n> like [1]. Fix it by not using format_log_line_html().\n>\n> [1] git.kernel.org/?p=linux/kernel/git/tip/tip.git;a=commit;h=08942f6d5d992e9486b07653fd87ea8182a22fa0\n>\n> Signed-off-by: Namhyung Kim <namhyung@kernel.org>\n> ---\n>  gitweb/gitweb.perl |   10 ++++++++++\n>  1 file changed, 10 insertions(+)\n>\n> diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl\n> index 362784d..3d6a705 100755\n> --- a/gitweb/gitweb.perl\n> +++ b/gitweb/gitweb.perl\n> @@ -4494,6 +4494,16 @@ sub git_print_log {\n>  \t\t\tnext;\n>  \t\t}\n>  \n> +\t\tif ($line =~ m,\\s*([a-z]*link): (https?://\\S+),i) {\n> +\t\t\tif (! $opts{'-remove_signoff'}) {\n> +\t\t\t\tprint \"<span class=\\\"signoff\\\">\" . esc_html($1) . \": \" .\n> +\t\t\t\t\t\"<a href=\\\"\" . esc_html($2) . \"\\\">\" . esc_html($2) . \"</a>\" .\n> +\t\t\t\t\t\"</span><br/>\\n\";\n\nThanks.  Is the first use of esc_html($2) correct (I am always\nconfused between esc_html, esc_param and esc_url)?\n\n> +\t\t\t\t$skip_blank_line = 1;\n> +\t\t\t}\n> +\t\t\tnext;\n> +\t\t}\n> +\n>  \t\t# print only one empty line\n>  \t\t# do not print empty line after signoff\n>  \t\tif ($line eq \"\") {\n"}]}