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

Re: [PATCHv8 1/5] string list: improve comment

From
Stefan Beller <sbeller@google.com>
Date
May 19, 2016, 18:12 UTC
Message-ID
<CAGZ79kZ9bsuBU+CKuw+kZ+f6JZEPHvYFM3R0rre51jChVxHAfQ@mail.gmail.com>
In-Reply-To
<xmqq60u9kjjh.fsf@gitster.mtv.corp.google.com>
On Thu, May 19, 2016 at 11:08 AM, Junio C Hamano <gitster@pobox.com> wrote:
Show 28 quoted lines
> Stefan Beller <sbeller@google.com> writes:
>
>> Signed-off-by: Stefan Beller <sbeller@google.com>
>> ---
>>  string-list.h | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/string-list.h b/string-list.h
>> index d3809a1..465a1f0 100644
>> --- a/string-list.h
>> +++ b/string-list.h
>> @@ -106,7 +106,7 @@ void unsorted_string_list_delete_item(struct string_list *list, int i, int free_
>>   * list->strdup_strings must be set, as new memory needs to be
>>   * allocated to hold the substrings.  If maxsplit is non-negative,
>>   * then split at most maxsplit times.  Return the number of substrings
>> - * appended to list.
>> + * appended to list. The list may be non-empty already.
>
> I personally find that the original comment is clear enough, though.
>
> When somebody says "resulting elements of the split are appended to
> the list" without saying either:
>
>   a. "the list MUST be empty in the beginning", or
>   b. "the list will be emptied first before the split result are appended",
>
> wouldn't it be natural to take it as "you can append them to any
> list, be it empty or not, and they are _appended_, not replaced"?

That is true. I missed that though when reading the documentation and read the source code to be clear.

Show 16 quoted lines
>
> So while this is not incorrect per-se, I am not sure if it adds much
> value.  If somebody needs this additional clarification, because the
> original did not say a. above, she would certainly need more
> clarification because the original did not say b. above, either.
>
> "The list may be non-empty already", but she would keep wondering if
> the existing contents would be discarded before the result gets
> appended to it.
>
> You may say "No, there won't be such a confusion, because we say
> 'append'; empty and then append is 'replace'".  But then the same
> logic would say "There cannot be a requirement for the list to be
> empty in the first place, because we say 'append'".
>
> So...
So, please drop?

I do not feel strongly about this patch. I basically wrote to for myself after I consulted the source.

Previous: Junio C HamanoNext: Stefan Beller
Message 4 of 22 in “[PATCHv8 0/5] pathspec magic extension to search for attributes”
  1. Stefan BellerMay 19, 2016
  2. 1/5 string list: improve commentStefan Beller, May 19, 2016
  3. Junio C HamanoMay 19, 2016
  4. Stefan BellerMay 19, 2016
  5. 2/5 Documentation: fix a typoStefan Beller, May 19, 2016
  6. 3/5 pathspec: move long magic parsing out of prefix_pathspecStefan Beller, May 19, 2016
  7. 4/5 pathspec: move prefix check out of the inner loopStefan Beller, May 19, 2016
  8. 5/5 pathspec: allow querying for attributesStefan Beller, May 19, 2016
  9. Junio C HamanoMay 19, 2016
  10. Stefan BellerMay 19, 2016
  11. Junio C HamanoMay 19, 2016
  12. Junio C HamanoMay 19, 2016
  13. Junio C HamanoMay 19, 2016
  14. Stefan BellerMay 19, 2016
  15. Junio C HamanoMay 19, 2016
  16. Stefan BellerMay 19, 2016
  17. Junio C HamanoMay 20, 2016
  18. Stefan BellerMay 20, 2016
  19. Junio C HamanoMay 20, 2016
  20. Duy NguyenMay 22, 2016
  21. Stefan BellerMay 23, 2016
  22. Duy NguyenMay 24, 2016

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.