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

Re: [PATCH] add -p: obey diff.noprefix option if set

From
Jeff King <peff@peff.net>
Date
Mar 6, 2023, 10:31 UTC
Message-ID
<ZAXA5ikipcTCfptl@coredump.intra.peff.net>
In-Reply-To
<0ba2f495-892c-3e27-a32c-9f136e86fc26@dunelm.org.uk>
On Mon, Mar 06, 2023 at 09:39:07AM +0000, Phillip Wood wrote:
Show 10 quoted lines
> > The second is to just remember that we set noprefix and to add the
> > matching "-p0". Unfortunately we have to do so in a few places, but it's
> > not _too_ bad (and possibly some refactoring could make it less ugly).
> > Something like:
> 
> I think that is the better approach. Looking at how we handle diff.algorithm
> we should maybe add a "noprefix" member to "struct add_i_state" and
> initialize it in init_add_i_state() (which is in add-interactive.c). That
> way we're consistent with the existing code and we don't need to keep
> calling git_config_get_bool() whenever we want the value of diff.noPrefix.

Yeah, that was exactly the kind of refactoring I had in mind (but I didn't work on it, even as a "maybe something like this" patch).

I agree it's the better approach.
Show 5 quoted lines
> >   	strvec_pushv(&cp.args, s->mode->apply_check_args);
> > +	if (!git_config_get_bool("diff.noprefix", &noprefix) && noprefix)
> > +		strvec_pushf(&cp.args, "-p1");
> 
> I think you meant "-p0" here
Whoops, yes.
-Peff
Previous: Phillip Wood
Message 4 of 4 in “add -p: obey diff.noprefix option if set”
  1. add -p: obey diff.noprefix option if setMarcel Partap, Mar 4, 2023
  2. Jeff KingMar 6, 2023
  3. Phillip WoodMar 6, 2023
  4. Jeff KingMar 6, 2023

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.