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

Perhaps we want {diff,log,format}.noprefix and friends?

From
Junio C Hamano <gitster@pobox.com>
Date
May 18, 2022, 17:21 UTC
Message-ID
<xmqqh75mwycb.fsf_-_@gitster.g>
In-Reply-To
<CAN3rvwBWBPLB+Pm14S5Nb9LOV6ajhT8qMbwi5bBm1pK_8AgN5g@mail.gmail.com>
Show 11 quoted lines
>>   git -c diff.noprefix=no format-patch ...
>>
>> to cancel the config. (If that config really does want to be on, that
>> is.)
>>
>> That said, something like
>>
>>   git am -p0 ...
>>
>> should help on the receiving side, by way of skipping fewer path
>> components when applying the patch.

While it is very reasonable for end-users to make the output of their local "git diff" output to their taste by setting the diff.noprefix and other configuration options in the diff.* namespace, it is wrong to inflict such a personal preference on other project participants by sending such a no-prefix patch via "git format-patch", when the convention at the receiving project is to use "git am -p1" to accept them.

We would need to tweak the configuration system so that we can more easily introduce "format.noprefix" that overrides "diff.noprefix" only when the command being run is "git format-patch", perhaps?

As things stand, we could teach builtin/log.c::git_format_config() about "format.noprefix" and make "git format-patch" pay attention to that in addition to "diff.noprefix" fairly easily, but such an approach poorly scales. When a new configuration gets introduced in diff.c::git_diff_ui_config(), builtin/log.c::git_format_config() would also need to be updated.

I initially started writing this with "left over bits" mark, but it seems it is a bit larger in scope than that.

I also noticed that some format.* configuration variables are parsed in git_log_config(), not git_format_config(), so "git log" would end up honoring format.pretty and format.subjectprefix, etc., which look wrong but probably is way too late to "fix".

Previous: Theodore Dubois
Message 6 of 6 in “Re: [PATCH] getpriority: Only getpriority translation the priority values”
  1. Alejandro ColomarMay 14, 2022
  2. Alejandro ColomarMay 14, 2022
  3. Martin ÅgrenMay 14, 2022
  4. Alejandro ColomarMay 14, 2022
  5. Theodore DuboisMay 17, 2022
  6. Perhaps we want {diff,log,format}.noprefix and friends?Junio C Hamano, May 18, 2022

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.