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

Re: [PATCH v5 2/2] strbuf: change an always NULL/"" strbuf_addftime() param to bool

From
Junio C Hamano <gitster@pobox.com>
Date
Jun 24, 2017, 18:21 UTC
Message-ID
<xmqqk2419rhg.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<9f3720e5-b8be-978d-4f6c-8c082aef3680@web.de>
René Scharfe <l.s.r@web.de> writes:
Show 14 quoted lines
> Am 24.06.2017 um 14:14 schrieb Ævar Arnfjörð Bjarmason:
>> Change the code for deciding what's to be done about %Z to stop
>> passing always either a NULL or "" char * to
>> strbuf_addftime(). Instead pass a boolean int to indicate whether the
>> strftime() %Z format should be suppressed by converting it to an empty
>> string, which is what this code is actually doing.
>>
>> This code grew organically between the changes in 9eafe86d58 ("Merge
>> branch 'rs/strbuf-addftime-zZ'", 2017-06-22). The intent was to use
>> this API in the future to pass a custom leave the door open to pass a
>> custom timezone name to the function (see my [1] and related
>> messages).
>
> "leave the door open to pass a" seems redundant.
    The intent was to use this API in the future to leave the door open
    to pass a custom timezone name to the function (see my [1] and
    related messages).
perhaps?
Show 9 quoted lines
>> But that's not what this code does now, and this strbuf_addstr() call
>> always being redundant makes it hard to understand the current
>> functionality. So simplify this internal API to match its use, we can
>> always change it in the future if it gets a different use-case.
>
> I don't understand the confusion, but of course I'm biased. And I don't
> like binary parameters in general and would use named flags or two
> function names in most cases.  But that aside I find the description
> hard to follow (perhaps I should do something about my attention span).
I share this feeling.
Show 8 quoted lines
> Here's an attempt at a commit message that would have be easier to
> understand for me:
>
>   strbuf_addstr() allows callers to pass a time zone name for expanding
>   %Z.  The only current caller either passes the empty string or NULL,
>   in which case %Z is handed over verbatim to strftime(3).  Replace that
>   string parameter with a flag controlling whether to remove %Z from the
>   format specification.  This simplifies the code.

I think the first one is strbuf_addftime(); other than that, I think this version explains what is going on in this patch than the original.

I'll wait for Ævar to respond, but my inclination is to take the patch with the above tweaks to the log message, as the change is easy to revert if we find it necessary.

Previous: René ScharfeNext: Ævar Arnfjörð Bjarmason
Message 20 of 29 in “strbuf: change an always NULL/"" strbuf_addftime() param to bool”
  1. strbuf: change an always NULL/"" strbuf_addftime() param to boolÆvar Arnfjörð Bjarmason, Jun 23, 2017
  2. Jeff KingJun 23, 2017
  3. Ævar Arnfjörð BjarmasonJun 23, 2017
  4. Jeff KingJun 23, 2017
  5. René ScharfeJun 23, 2017
  6. Jeff KingJun 23, 2017
  7. Ævar Arnfjörð BjarmasonJun 24, 2017
  8. strbuf: change an always NULL/"" strbuf_addftime() param to boolÆvar Arnfjörð Bjarmason, Jun 23, 2017
  9. Jeff KingJun 23, 2017
  10. 1/2 strbuf.h comment: discuss strbuf_addftime() arguments in orderÆvar Arnfjörð Bjarmason, Jun 24, 2017
  11. 2/2 strbuf: change an always NULL/"" strbuf_addftime() param to boolÆvar Arnfjörð Bjarmason, Jun 24, 2017
  12. Jeff KingJun 24, 2017
  13. 1/2 strbuf.h comment: discuss strbuf_addftime() arguments in orderÆvar Arnfjörð Bjarmason, Jun 24, 2017
  14. 2/2 strbuf: change an always NULL/"" strbuf_addftime() param to boolÆvar Arnfjörð Bjarmason, Jun 24, 2017
  15. Jeff KingJun 24, 2017
  16. 1/2 strbuf.h comment: discuss strbuf_addftime() arguments in orderÆvar Arnfjörð Bjarmason, Jun 24, 2017
  17. 2/2 strbuf: change an always NULL/"" strbuf_addftime() param to boolÆvar Arnfjörð Bjarmason, Jun 24, 2017
  18. Jeff KingJun 24, 2017
  19. René ScharfeJun 24, 2017
  20. Junio C HamanoJun 24, 2017
  21. 1/2 strbuf.h comment: discuss strbuf_addftime() arguments in orderÆvar Arnfjörð Bjarmason, Jul 1, 2017
  22. 2/2 strbuf: change an always NULL/"" strbuf_addftime() param to boolÆvar Arnfjörð Bjarmason, Jul 1, 2017
  23. René ScharfeJul 1, 2017
  24. 1/2 strbuf.h comment: discuss strbuf_addftime() arguments in orderÆvar Arnfjörð Bjarmason, Jul 1, 2017
  25. 2/2 strbuf: change an always NULL/"" strbuf_addftime() param to boolÆvar Arnfjörð Bjarmason, Jul 1, 2017
  26. Junio C HamanoJun 23, 2017
  27. René ScharfeJun 23, 2017
  28. Jeff KingJun 23, 2017
  29. René ScharfeJun 23, 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.