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

Re: [PATCH v3 4/8] gitweb: Extract print_sidebyside_diff_lines()

From
Michal Kiedrowicz <michal.kiedrowicz@gmail.com>
Date
Apr 6, 2012, 08:36 UTC
Message-ID
<20120406103603.1f1ee90d@mkiedrowicz.ivo.pl>
In-Reply-To
<201204060057.34138.jnareb@gmail.com>
Jakub Narebski <jnareb@gmail.com> wrote:
Show 49 quoted lines
> Michal Kiedrowicz wrote:
> > Jakub Narebski <jnareb@gmail.com> wrote:
> >> Junio C Hamano wrote:
> >>> Michał Kiedrowicz <michal.kiedrowicz@gmail.com> writes:
> 
> >>>> -		# empty add/rem block on start context block, or
> >>>> end of chunk
> >>>> -		if ((@rem || @add) && (!$class || $class eq
> >>>> 'ctx')) { -...
> >>>> +		## print from accumulator when have some add/rem
> >>>> lines or end
> >>>> +		# of chunk (flush context lines)
> >>>> +		if (((@rem || @add) && $class eq 'ctx')
> >>>> || !$class) {
> >>> 
> >>> This seems to change the condition.  Earlier, it held true if
> >>> (there is anything to show), and (class is unset or equal to ctx).
> >>> The new code says something different.
> >> 
> >> Yes it does, as described in the commit message:
> >> 
> >>                                                     [...] It should
> >>   not change the gitweb output, but it **slightly changes its
> >> behavior**. Before this commit, context is printed on the class
> >> change. Now,  it's printed just before printing added and removed
> >> lines, and at the end of chunk.
> >> 
> >> The difference is that context lines are also printed accumulated
> >> now. Though why this change is required for refactoring could have
> >> been described in more detail...
> > 
> > I changed that because I wanted to squash both conditions (the one
> > that checks if @ctx should be printed and the one that prints
> > @add/@rem lines) and have just one call to
> > print_sidebyside_diff_lines().  Later, this function is changed to
> > print_diff_lines() and controls whether 'inline' or 'side-by-side'
> > diff should be printed.  Having two conditions and two
> > calls/functions would make the code redundant.  Then I thought that
> > instead of calling twice print_sidebyside_diff_lines() (for @ctx
> > and @add/@rem lines, like the code from pre-image prints these
> > lines separatedly), I can just call it once.
> > 
> > I can revert this change to previous behavior but I think that would
> > make the condition more complicated.
> 
> No, I think that this change is good idea if it simplifies code flow.
> But it really should be described in commit message, not only "what"
> (which you did describe), but also "whys".
> 
Sure, I'll try to put my explanation to the commit message.
Previous: Jakub NarebskiNext: Michał Kiedrowicz
Message 12 of 19 in “Highlight interesting parts of diff”
  1. 0/8 Highlight interesting parts of diffMichał Kiedrowicz, Apr 4, 2012
  2. 1/8 gitweb: Use descriptive names in esc_html_hl_regions()Michał Kiedrowicz, Apr 4, 2012
  3. Junio C HamanoApr 4, 2012
  4. Michal KiedrowiczApr 5, 2012
  5. 2/8 gitweb: esc_html_hl_regions(): Don't create empty <span> elementsMichał Kiedrowicz, Apr 4, 2012
  6. 3/8 gitweb: Pass esc_html_hl_regions() options to esc_html()Michał Kiedrowicz, Apr 4, 2012
  7. 4/8 gitweb: Extract print_sidebyside_diff_lines()Michał Kiedrowicz, Apr 4, 2012
  8. Junio C HamanoApr 4, 2012
  9. Jakub NarebskiApr 4, 2012
  10. Michal KiedrowiczApr 5, 2012
  11. Jakub NarebskiApr 5, 2012
  12. Michal KiedrowiczApr 6, 2012
  13. 5/8 gitweb: Use print_diff_chunk() for both side-by-side and inline diffsMichał Kiedrowicz, Apr 4, 2012
  14. Jakub NarebskiApr 5, 2012
  15. Michal KiedrowiczApr 6, 2012
  16. 6/8 gitweb: Push formatting diff lines to print_diff_chunk()Michał Kiedrowicz, Apr 4, 2012
  17. 7/8 gitweb: Highlight interesting parts of diffMichał Kiedrowicz, Apr 4, 2012
  18. Michal KiedrowiczApr 5, 2012
  19. 8/8 gitweb: Refinement highlightning in combined diffsMichał Kiedrowicz, Apr 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.