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

Re: [PATCH 2/4] builtin/blame: dim uninteresting metadata

From
Eric Sunshine <sunshine@sunshineco.com>
Date
Jan 6, 2018, 08:26 UTC
Message-ID
<CAPig+cQg3o2iicGhSmwPM8dDjtUFSGow5dwprbRNnq4-m5EmFA@mail.gmail.com>
In-Reply-To
<CAGZ79ka22DPHX5_etFREvdVjfsQPzQG66iFgyfsjCdLnwUcAdA@mail.gmail.com>
On Thu, Jan 4, 2018 at 5:10 PM, Stefan Beller <sbeller@google.com> wrote:
Show 26 quoted lines
> On Thu, Dec 28, 2017 at 2:29 PM, Eric Sunshine <sunshine@sunshineco.com> wrote:
>> On Thu, Dec 28, 2017 at 4:03 PM, Stefan Beller <sbeller@google.com> wrote:
>>> +static inline void colors_unset(const char **use_color, const char **reset_color)
>>> +{
>>> +       *use_color = "";
>>> +       *reset_color = "";
>>> +}
>>> +
>>> +static inline void colors_set(const char **use_color, const char **reset_color)
>>> +{
>>> +       *use_color = repeated_meta_color;
>>> +       *reset_color = GIT_COLOR_RESET;
>>> +}
>>
>> I'm not convinced that this colors_unset() / colors_set() /
>> setup_line_color() abstraction is buying much. With this abstraction,
>> I found the code more difficult to reason about than if the colors
>> were just set/unset manually in the code which needs the colors. I
>> *could* perhaps imagine setup_line_color() existing as a separate
>> function since it is slightly more complex than the other two, but as
>> it has only a single caller through all patches, even that may not be
>> sufficient to warrant its existence.
>
> Have you viewed this patch in context of the following patch?
> Originally I was convinced an abstraction was not needed, but
> as the next patch shows, a helper per field seems handy.

I did take the other patch into consideration when making the observation, and I still found the code more difficult to reason about than if these minor bits of code had merely been inlined into the callers. I neglected to mention previously that part of the problem may be that these function names do not do a good job of conveying what is being done, thus I repeatedly had to consult the function implementations while reading callers in order to understand what was going on.

Previous: Stefan BellerNext: Stefan Beller
Message 8 of 12 in “[PATCHv2 0/4] blame: (dim rep. metadata lines or fields, decay date coloring)”
  1. Stefan BellerDec 28, 2017
  2. 1/4 color.h: document and modernize headerStefan Beller, Dec 28, 2017
  3. Eric SunshineDec 28, 2017
  4. Stefan BellerJan 4, 2018
  5. 2/4 builtin/blame: dim uninteresting metadataStefan Beller, Dec 28, 2017
  6. Eric SunshineDec 28, 2017
  7. Stefan BellerJan 4, 2018
  8. Eric SunshineJan 6, 2018
  9. Stefan BellerJan 8, 2018
  10. 4/4 builtin/blame: highlight recently changed linesStefan Beller, Dec 28, 2017
  11. Eric SunshineDec 28, 2017
  12. 3/4 builtin/blame: add option to color metadata fields separatelyStefan Beller, Dec 28, 2017

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.