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

RE: [PATCH] Lengthening FORMAT_PATCH_NAME_MAX to 80

From
hukeping <hukeping@huawei.com>
Date
Nov 6, 2020, 08:51 UTC
Message-ID
<d5338d5f83584f7caf3ff0f4309f2275@huawei.com>
In-Reply-To
<xmqqimajijwa.fsf@gitster.c.googlers.com>
Show 66 quoted lines
>-----Original Message-----
>From: Junio C Hamano [mailto:gitster@pobox.com]
>Sent: Friday, November 6, 2020 5:17 AM
>To: Jeff King <peff@peff.net>
>Cc: hukeping <hukeping@huawei.com>; git@vger.kernel.org; Zhengjunling (JRing,
>Task Force) <zhengjunling@huawei.com>; zhuangbiaowei
><zhuangbiaowei@huawei.com>; git@stormcloud9.net; rafa.almas@gmail.com;
>l.s.r@web.de
>Subject: Re: [PATCH] Lengthening FORMAT_PATCH_NAME_MAX to 80
>
>Jeff King <peff@peff.net> writes:
>
>>> Considered the prefix patch number "0001-" would take 5 characters,
>>> increase the FORMAT_PATCH_NAME_MAX to 80.
>>
>> As the code is written now, the length also includes the ".patch"
>> suffix, as well as an extra byte (maybe for a NUL? Once upon a time I
>> imagine we used static buffers, but these days it's all in a strbuf).
>>
>> A simple test with:
>>
>>   git init
>>   for i in $(seq 8); do printf 1234567890; done |
>>   git commit --allow-empty -F -
>>   git format-patch -1
>>
>> shows us generating:
>>
>>   0001-1234567890123456789012345678901234567890123456789012.patch
>>
>> So that's only 52 characters, from our constant of 64. Bumping to 80
>> gives us 66, which is reasonable though probably still involves
>> occasional truncation. But maybe keeping the total length to 80 (79,
>> really, because of the extra byte) may be worth doing.
>>
>> Which is all a long-winded way of saying that your patch seems
>> reasonable to me.
>
>A devil's advocate thinks that we should shorten it (and rename it to format-
>patch-subject-prefix-length or something) instead.  That way, "ls" output can
>show more than one files on a single line even on a 80-column terminal.  The
>leading digits already guarantee the uniqueness anyway.
>
>I do not mind getting rid of the "FORMAT_PATCH_NAME_MAX" constant and
>replacing it with a variable that defaults to 64 and can be tweaked by a command
>line option and/or a configuration variable.
>It does not feel it is worth the effort to replace one hardcoded constant with
>another hardcoded constant.
>
>> Looking at the code which uses the constant, I suspect it could also
>> be made simpler:
>>
>>   - the PATH_MAX check in open_next_file() seems pointless. Once upon a
>>     time it mattered for fitting into a PATH_MAX buffer, but these days
>>     we use a dynamic buffer anyway. We are probably better off to just
>>     feed the result to the filesystem and see if it complains (since
>>     either way we are aborting; I'd feel differently if we adjusted our
>>     truncation size)
>>
>>   - the logic in fmt_output_subject() could probably be simpler if the
>>     constant was "here's how long the subject should be", not "here's
>>     how long the whole thing must be".
>>
>> But those are both orthogonal to your patch and can be done separately.
>
>Yes, these clean-ups seem worth doing.
Agreed, and I'd like to do it with two separated commits:
- commit-1,  cleanup the open_next_file() by drop the if (filename.len>=..) statements.
- commit-2,  replace FORMAT_PATCH_NAME_MAX in fmt_output_subject() with a constant
  in there and make it to 80(or other value?), and drop FORMAT_PATCH_NAME_MAX
  from log-tree.h.
Is this works for you?
Thanks.
Previous: Junio C HamanoNext: Junio C Hamano
Message 4 of 15 in “Lengthening FORMAT_PATCH_NAME_MAX to 80”
  1. Lengthening FORMAT_PATCH_NAME_MAX to 80Hu Keping, Nov 5, 2020
  2. Jeff KingNov 5, 2020
  3. Junio C HamanoNov 5, 2020
  4. hukepingNov 6, 2020
  5. Junio C HamanoNov 6, 2020
  6. Junio C HamanoNov 6, 2020
  7. format-patch: make output filename configurableJunio C Hamano, Nov 6, 2020
  8. Eric SunshineNov 6, 2020
  9. format-patch: make output filename configurableJunio C Hamano, Nov 9, 2020
  10. Jeff KingNov 10, 2020
  11. Junio C HamanoNov 10, 2020
  12. hukepingNov 10, 2020
  13. Junio C HamanoNov 10, 2020
  14. hukepingNov 10, 2020
  15. Junio C HamanoNov 10, 2020

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.