threads / discuss / 41221

git add -p doesn't respect diff.context

Subject: git add -p doesn't respect diff.context

## tl;dr

2 messages between Jan 20, 2016 and Feb 4, 2016.

replies: 1people: 2as markdown or json

Mike Hommey· Jan 20, 2016, 06:35 UTC · lore
Hi,

When doing git add -p, the default of 3 context lines is used, ignoring the diff.context.

git add -p is using git-diff-files, and diff.context is being read in
git_diff_ui_config, so the comment above that function applies:
/*
 * These are to give UI layer defaults.
 * The core-level commands such as git-diff-files should
 * never be affected by the setting of diff.renames
 * the user happens to have in the configuration file.
 */

I guess the question is whether it's diff-files or add -p that should honor diff.context. Or should it have its own separate config?

Mike
Jeff King· Feb 4, 2016, 08:02 UTC · re: Mike Hommey · lore

Re: git add -p doesn't respect diff.context

On Wed, Jan 20, 2016 at 03:35:23PM +0900, Mike Hommey wrote:
Show 14 quoted lines
> When doing git add -p, the default of 3 context lines is used, ignoring
> the diff.context.
> 
> git add -p is using git-diff-files, and diff.context is being read in
> git_diff_ui_config, so the comment above that function applies:
> /*
>  * These are to give UI layer defaults.
>  * The core-level commands such as git-diff-files should
>  * never be affected by the setting of diff.renames
>  * the user happens to have in the configuration file.
>  */
> 
> I guess the question is whether it's diff-files or add -p that should
> honor diff.context. Or should it have its own separate config?

I think it must be "add -p", as otherwise we risk breaking scripts which try to build on diff-tree but can't handle extra context (though I have to admit that unlike something like diff.color, it would be a pretty poor consumer of a diff that couldn't handle varying context).

We already do something similar with diff.algorithm. I think you could probably just cargo-cult the handling of $diff_algorithm in git-add--interactive.perl.

It might also make a nice GSoC microproject.
-Peff

← back to recent threads