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

Re: [PATCHv6 1/8] gitweb: refactor author name insertion

From
Giuseppe Bilotta <giuseppe.bilotta@gmail.com>
Date
Jun 25, 2009, 23:41 UTC
Message-ID
<cb7bb73a0906251641g71250105ob608b557cce7c454@mail.gmail.com>
In-Reply-To
<200906260055.11347.jnareb@gmail.com>
2009/6/26 Jakub Narebski <jnareb@gmail.com>:
> Do I understand it correctly that this was meant as pure refactoring,
> i.e. that none of gitweb output should have changed?  Because you made
> a mistake, and 'log' view is broken (and it doesn't look like it did
> before).  See comments below for cause and (simple) solution.

Thanks for noticing. And yes, the problem is indeed that I forgot to specify tag => span in git log view (I'm keeping div the default because that's what was there in the first place in git_print_authorship).

Show 13 quoted lines
>> +# format the author name of the given commit with the given tag
>> +# the author name is chopped and escaped according to the other
>> +# optional parameters (see chop_str).
>> +sub format_author_html {
>> +     my $tag = shift;
>> +     my $co = shift;
>> +     my $author = chop_and_escape_str($co->{'author_name'}, @_);
>> +     return "<$tag class=\"author\">" . $author . "</$tag>\n";
>> +}
>
> Good... although I wonder if we should not get rid of chop_and_escape_str
> altogether, and for example add title attribute (if needed due to having
> to do shortening) directly to $tag, and not to inner <span> element.

This would require some additional refactoring, and I don't have a clear idea on how to best implement it right now. I'm afraid it'll have to wait for another time.

> Should "\n" be in returned string? Just asking.

You're right, we probably don't want to force the newline there. The real question is, do we want the callers to put a newline there? I'm thinking no, because it's mostly used in table cells and a newline is better done at the row level, but I'm not sure either way. I'll just remove it for the time being, it should only have effects at the sourcecode level, not on the layout.

Show 10 quoted lines
> Usually though we use %opts and not %params for the name of this
> hash, and we use CGI-like keys prefixed by '-', for example
> '-z' in parse_ls_tree_line(), '-nbsp' in esc_html, '-nohtml' in
> quot_cec(),  '-remove_title', '-remove_signoff' and '-final_empty_line'
> in git_print_log().  git_commitdiff() uses %params, but it doesn't
> have non-optional parameters (still, I guess we should use %opts
> for consistency), and it uses '-format' and '-single' as names.
>
> href() subroutine uses %params... but those are not extra named
> optional parameters to subroutine; they are CGI query parameters.

I'll adjust the code accordingly. BTW the %params in git_commitdiff is my fault too, IIRC.

Show 18 quoted lines
>>       my %ad = parse_date($co->{'author_epoch'}, $co->{'author_tz'});
>> -     print "<div class=\"author_date\">" .
>> +     print "<$tag class=\"author_date\">" .
>>             esc_html($co->{'author_name'}) .
>>             " [$ad{'rfc2822'}";
>> +     if ($params{'localtime'}) {
>> +             if ($ad{'hour_local'} < 6) {
>> +                     printf(" (<span class=\"atnight\">%02d:%02d</span> %s)",
>> +                            $ad{'hour_local'}, $ad{'minute_local'}, $ad{'tz_local'});
>> +             } else {
>> +                     printf(" (%02d:%02d %s)",
>> +                            $ad{'hour_local'}, $ad{'minute_local'}, $ad{'tz_local'});
>> +             }
>> +     }
>> +     print "]</$tag>\n";
>> +}
>
> Gaah, git has chosen to show this diff a bit strangely...

Oh, very funny indeed. I hadn't realized it went that way. Wonder if the patience diff would have helped here.

> By the way, what about author / tagger info used in 'tag' view?
I totally forgot about that.
> Wouldn't it be better to factor out generating table rows for single
> author / committer / tagger header (field) info?
Good idea. I'm not sure the tagger field has all the relevant data. I'll check.
Show 7 quoted lines
> I'd rather use here (as mentioned in comment about git_print_full_authorship
> subroutine) something like the following:
>
> +       git_print_authorship_header(\%co, 'author');
> +       git_print_authorship_header(\%co, 'committer');
>
> Or something like that.  But this might be a matter of taste.

I renamed the sub to git_print_authorship_rows, and I'm making it accept a list of people to print info for. I'll make it default to both author and committer though.

-- 
Giuseppe "Oblomov" Bilotta
Previous: Jakub NarebskiNext: Jakub Narebski
Message 40 of 46 in “[PATCHv6 0/8] gitweb: gravatar support”
  1. Giuseppe BilottaJun 25, 2009
  2. 1/8 gitweb: refactor author name insertionGiuseppe Bilotta, Jun 25, 2009
  3. 2/8 gitweb: uniform author info for commit and commitdiffGiuseppe Bilotta, Jun 25, 2009
  4. 3/8 gitweb: right-align date cell in shortlogGiuseppe Bilotta, Jun 25, 2009
  5. 4/8 gitweb: (gr)avatar supportGiuseppe Bilotta, Jun 25, 2009
  6. 5/8 gitweb: gravatar url cacheGiuseppe Bilotta, Jun 25, 2009
  7. 6/8 gitweb: add 'alt' to avatar imagesGiuseppe Bilotta, Jun 25, 2009
  8. 7/8 gitweb: recognize 'trivial' acksGiuseppe Bilotta, Jun 25, 2009
  9. 8/8 gitweb: add avatar in signoff linesGiuseppe Bilotta, Jun 25, 2009
  10. 9/8 gitweb: put signoff lines in a tableGiuseppe Bilotta, Jun 25, 2009
  11. Jakub NarebskiJun 27, 2009
  12. Jakub NarebskiJun 27, 2009
  13. Giuseppe BilottaJun 27, 2009
  14. Jakub NarebskiJun 27, 2009
  15. Junio C HamanoJun 27, 2009
  16. Giuseppe BilottaJun 27, 2009
  17. Jakub NarebskiJun 26, 2009
  18. Thomas AdamJun 27, 2009
  19. Jakub NarebskiJun 26, 2009
  20. Giuseppe BilottaJun 26, 2009
  21. Jakub NarebskiJun 26, 2009
  22. Jakub NarebskiJun 26, 2009
  23. Giuseppe BilottaJun 26, 2009
  24. Jakub NarebskiJun 26, 2009
  25. Giuseppe BilottaJun 26, 2009
  26. Jakub NarebskiJun 26, 2009
  27. Junio C HamanoJun 27, 2009
  28. Giuseppe BilottaJun 27, 2009
  29. Jakub NarebskiJun 26, 2009
  30. Giuseppe BilottaJun 26, 2009
  31. Junio C HamanoJun 26, 2009
  32. Giuseppe BilottaJun 26, 2009
  33. Junio C HamanoJun 26, 2009
  34. Jakub NarebskiJun 27, 2009
  35. Jakub NarebskiJun 27, 2009
  36. Jakub NarebskiJun 25, 2009
  37. Giuseppe BilottaJun 26, 2009
  38. Jakub NarebskiJun 25, 2009
  39. Jakub NarebskiJun 25, 2009
  40. Giuseppe BilottaJun 25, 2009
  41. Jakub NarebskiJun 25, 2009
  42. Giuseppe BilottaJun 25, 2009
  43. Junio C HamanoJun 25, 2009
  44. Giuseppe BilottaJun 25, 2009
  45. Junio C HamanoJun 25, 2009
  46. Jakub NarebskiJun 25, 2009

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.