Skip to content

Commit cc5b594

Browse files
avargitster
authored andcommitted
difftool: use run_command() API in run_file_diff()
Change the run_file_diff() function to use the run_command() API directly, instead of invoking the run_command_v_opt_cd_env() wrapper. This allows it, like run_dir_diff(), to use the "args" from "struct strvec", instead of the "const char **argv" passed into cmd_difftool(). This will be used in the subsequent commit to get rid of OPT_ARGUMENT() from cmd_difftool(). Signed-off-by: Ævar Arnfjörð Bjarmason <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent b4c7aab commit cc5b594

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

builtin/difftool.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -663,24 +663,23 @@ static int run_dir_diff(const char *extcmd, int symlinks, const char *prefix,
663663
}
664664

665665
static int run_file_diff(int prompt, const char *prefix,
666-
int argc, const char **argv)
666+
struct child_process *child)
667667
{
668-
struct strvec args = STRVEC_INIT;
669668
const char *env[] = {
670669
"GIT_PAGER=", "GIT_EXTERNAL_DIFF=git-difftool--helper", NULL,
671670
NULL
672671
};
673-
int i;
674672

675673
if (prompt > 0)
676674
env[2] = "GIT_DIFFTOOL_PROMPT=true";
677675
else if (!prompt)
678676
env[2] = "GIT_DIFFTOOL_NO_PROMPT=true";
679677

678+
child->git_cmd = 1;
679+
child->dir = prefix;
680+
strvec_pushv(&child->env_array, env);
680681

681-
for (i = 0; i < argc; i++)
682-
strvec_push(&args, argv[i]);
683-
return run_command_v_opt_cd_env(args.v, RUN_GIT_CMD, prefix, env);
682+
return run_command(child);
684683
}
685684

686685
int cmd_difftool(int argc, const char **argv, const char *prefix)
@@ -770,5 +769,5 @@ int cmd_difftool(int argc, const char **argv, const char *prefix)
770769

771770
if (dir_diff)
772771
return run_dir_diff(extcmd, symlinks, prefix, &child);
773-
return run_file_diff(prompt, prefix, child.args.nr, child.args.v);
772+
return run_file_diff(prompt, prefix, &child);
774773
}

0 commit comments

Comments
 (0)