From: Junio C Hamano Date: Wed, 5 Feb 2020 22:34:58 +0000 (-0800) Subject: Merge branch 'js/patch-mode-in-others-in-c' X-Git-Tag: v2.26.0-rc0~97 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=9a5315edfdf;p=thirdparty%2Fgit.git Merge branch 'js/patch-mode-in-others-in-c' The effort to move "git-add--interactive" to C continues. * js/patch-mode-in-others-in-c: commit --interactive: make it work with the built-in `add -i` built-in add -p: implement the "worktree" patch modes built-in add -p: implement the "checkout" patch modes built-in stash: use the built-in `git add -p` if so configured legacy stash -p: respect the add.interactive.usebuiltin setting built-in add -p: implement the "stash" and "reset" patch modes built-in add -p: prepare for patch modes other than "stage" --- 9a5315edfdf662c4d9bf444ebc297bc802fa5e04 diff --cc builtin/add.c index 4c38aff419,b5927105aa..f7e627f3b9 --- a/builtin/add.c +++ b/builtin/add.c @@@ -29,8 -29,7 +29,9 @@@ static const char * const builtin_add_u static int patch_interactive, add_interactive, edit_interactive; static int take_worktree_changes; static int add_renormalize; +static int pathspec_file_nul; +static const char *pathspec_from_file; + static int legacy_stash_p; /* support for the scripted `git stash` */ struct update_callback_data { int flags; @@@ -327,8 -339,8 +341,10 @@@ static struct option builtin_add_option N_("override the executable bit of the listed files")), OPT_HIDDEN_BOOL(0, "warn-embedded-repo", &warn_on_embedded_repo, N_("warn when adding an embedded repository")), + OPT_HIDDEN_BOOL(0, "legacy-stash-p", &legacy_stash_p, + N_("backend for `git stash -p`")), + OPT_PATHSPEC_FROM_FILE(&pathspec_from_file), + OPT_PATHSPEC_FILE_NUL(&pathspec_file_nul), OPT_END(), }; @@@ -423,17 -435,22 +439,28 @@@ int cmd_add(int argc, const char **argv builtin_add_usage, PARSE_OPT_KEEP_ARGV0); if (patch_interactive) add_interactive = 1; - if (add_interactive) + if (add_interactive) { + if (pathspec_from_file) + die(_("--pathspec-from-file is incompatible with --interactive/--patch")); exit(interactive_add(argc - 1, argv + 1, prefix, patch_interactive)); + } + if (legacy_stash_p) { + struct pathspec pathspec; + + parse_pathspec(&pathspec, 0, + PATHSPEC_PREFER_FULL | + PATHSPEC_SYMLINK_LEADING_PATH | + PATHSPEC_PREFIX_ORIGIN, + prefix, argv); + + return run_add_interactive(NULL, "--patch=stash", &pathspec); + } - if (edit_interactive) + if (edit_interactive) { + if (pathspec_from_file) + die(_("--pathspec-from-file is incompatible with --edit")); return(edit_patch(argc, argv, prefix)); + } argc--; argv++;