From d21878f073043b9205f5049f1cd53560d67b9f3f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=86var=20Arnfj=C3=B6r=C3=B0=20Bjarmason?= Date: Mon, 6 Feb 2023 23:58:57 +0100 Subject: add API: remove run_add_interactive() wrapper function MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Now that the Perl "git-add--interactive" has gone away in the preceding commit we don't need to pass along our desire for a mode as a string, and can instead directly use the "enum add_p_mode", see d2a233cb8b9 (built-in add -p: prepare for patch modes other than "stage", 2019-12-21) for its introduction. As a result of that the run_add_interactive() function would become a trivial wrapper which would only run run_add_i() if a 0 (or now, "NULL") "patch_mode" was provided. Let's instead remove it, and have the one callsite that wanted the "NULL" case (interactive_add()) handle it. Signed-off-by: Ævar Arnfjörð Bjarmason Signed-off-by: Junio C Hamano --- builtin/checkout.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'builtin/checkout.c') diff --git a/builtin/checkout.c b/builtin/checkout.c index 5963e1b74b..a5155cf55c 100644 --- a/builtin/checkout.c +++ b/builtin/checkout.c @@ -29,6 +29,7 @@ #include "xdiff-interface.h" #include "entry.h" #include "parallel-checkout.h" +#include "add-interactive.h" static const char * const checkout_usage[] = { N_("git checkout [] "), @@ -499,7 +500,7 @@ static int checkout_paths(const struct checkout_opts *opts, "--merge", "--conflict", "--staged"); if (opts->patch_mode) { - const char *patch_mode; + enum add_p_mode patch_mode; const char *rev = new_branch_info->name; char rev_oid[GIT_MAX_HEXSZ + 1]; @@ -517,15 +518,16 @@ static int checkout_paths(const struct checkout_opts *opts, rev = oid_to_hex_r(rev_oid, &new_branch_info->commit->object.oid); if (opts->checkout_index && opts->checkout_worktree) - patch_mode = "--patch=checkout"; + patch_mode = ADD_P_CHECKOUT; else if (opts->checkout_index && !opts->checkout_worktree) - patch_mode = "--patch=reset"; + patch_mode = ADD_P_RESET; else if (!opts->checkout_index && opts->checkout_worktree) - patch_mode = "--patch=worktree"; + patch_mode = ADD_P_WORKTREE; else BUG("either flag must have been set, worktree=%d, index=%d", opts->checkout_worktree, opts->checkout_index); - return run_add_interactive(rev, patch_mode, &opts->pathspec); + return !!run_add_p(the_repository, patch_mode, rev, + &opts->pathspec); } repo_hold_locked_index(the_repository, &lock_file, LOCK_DIE_ON_ERROR); -- cgit v1.2.1