stash -p: respect the add.interactive.usebuiltin setting

As `git add` traditionally did not expose the `--patch=<mode>` modes via
command-line options, `git stash` had to call `git add--interactive`
directly.

But this prevents the built-in `add -p` from kicking in, as
`add--interactive` is the Perl script.

So let's introduce support for an optional `<mode>` argument in `git add
--patch[=<mode>]`, and use that in `git stash -p`, so that the built-in
interactive add can do its job if configured.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
This commit is contained in:
Johannes Schindelin
2019-03-24 19:55:08 +01:00
parent 2235a37cb7
commit f55e209db6
4 changed files with 20 additions and 9 deletions

View File

@@ -355,7 +355,8 @@ static const char *prepare_index(int argc, const char **argv, const char *prefix
old_index_env = xstrdup_or_null(getenv(INDEX_ENVIRONMENT));
setenv(INDEX_ENVIRONMENT, get_lock_file_path(&index_lock), 1);
if (interactive_add(argc, argv, prefix, patch_interactive) != 0)
if (interactive_add(argc, argv, prefix,
patch_interactive ? "" : NULL) != 0)
die(_("interactive add failed"));
if (old_index_env && *old_index_env)