threads / discuss / 44607

git add -p doesn't honor diff.noprefix config

Subject: git add -p doesn't honor diff.noprefix config

## tl;dr

2 messages between Dec 3, 2016 and Dec 6, 2016.

replies: 1people: 2as markdown or json

paddor· Dec 3, 2016, 06:45 UTC · lore
Hi all
I set the config diff.noprefix = true because I don't like the a/ and b/ prefixes, which nicely changed the output of `git diff`. Unfortunately, the filenames in the output of `git add --patch` are still prefixed.
To me, this seems like a bug. Or there's a config option missing.

Best regards, Patrik

Jeff King· Dec 6, 2016, 13:56 UTC · re: paddor · lore

Re: git add -p doesn't honor diff.noprefix config

On Sat, Dec 03, 2016 at 07:45:18AM +0100, paddor wrote:
Show 6 quoted lines
> I set the config diff.noprefix = true because I don't like the a/ and
> b/ prefixes, which nicely changed the output of `git diff`.
> Unfortunately, the filenames in the output of `git add --patch` are
> still prefixed.
> 
> To me, this seems like a bug. Or there's a config option missing.

The interactive-add process is a perl script built around plumbing commands like diff-tree, diff-files, etc. Plumbing commands do not respect some config options, so that the output remains stable or scripts built around them. And diff.noprefix is one of these. So scripts have to get the value themselves and decide whether to pass it along to the plumbing.

In this case, I think there are two steps needed:
  1. Confirm that git-add--interactive.perl can actually handle
     no-prefix patches. It feeds the patches back to git-apply, which
     may be a complication (so it may need, for example, to pass a
     special flag to git-apply).
  2. git-add--interactive.perl needs to parse the config value, and if
     set, pass the appropriate option to the diff plumbing. This should
     only be one or two lines; see how $diff_algorithm is handled in
     that script.
-Peff

← back to recent threads