diff options
author | Ævar Arnfjörð Bjarmason <avarab@gmail.com> | 2021-06-08 10:48:03 (GMT) |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2021-06-09 00:15:58 (GMT) |
commit | 338abb0f045b87df5e628543800e74dec0e72cdf (patch) | |
tree | 52e8b1cb82decf173d31647abca84a65945fc93c /builtin/difftool.c | |
parent | 48bf2fa8bad054d66bd79c6ba903c89c704201f7 (diff) | |
download | git-338abb0f045b87df5e628543800e74dec0e72cdf.zip git-338abb0f045b87df5e628543800e74dec0e72cdf.tar.gz git-338abb0f045b87df5e628543800e74dec0e72cdf.tar.bz2 |
builtins + test helpers: use return instead of exit() in cmd_*
Change various cmd_* functions that claim to return an "int" to use
"return" instead of exit() to indicate an exit code. These were not
marked with NORETURN, and by directly exit()-ing we'll skip the
cleanup git.c would otherwise do (e.g. closing fd's, erroring if we
can't). See run_builtin() in git.c.
In the case of shell.c and sh-i18n--envsubst.c this was the result of
an incomplete migration to using a cmd_main() in 3f2e2297b9 (add an
extra level of indirection to main(), 2016-07-01).
This was spotted by SunCC 12.5 on Solaris 10 (gcc210 on the gccfarm).
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/difftool.c')
-rw-r--r-- | builtin/difftool.c | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/builtin/difftool.c b/builtin/difftool.c index 6e18e62..6861f33 100644 --- a/builtin/difftool.c +++ b/builtin/difftool.c @@ -671,7 +671,7 @@ static int run_file_diff(int prompt, const char *prefix, "GIT_PAGER=", "GIT_EXTERNAL_DIFF=git-difftool--helper", NULL, NULL }; - int ret = 0, i; + int i; if (prompt > 0) env[2] = "GIT_DIFFTOOL_PROMPT=true"; @@ -682,8 +682,7 @@ static int run_file_diff(int prompt, const char *prefix, strvec_push(&args, "diff"); for (i = 0; i < argc; i++) strvec_push(&args, argv[i]); - ret = run_command_v_opt_cd_env(args.v, RUN_GIT_CMD, prefix, env); - exit(ret); + return run_command_v_opt_cd_env(args.v, RUN_GIT_CMD, prefix, env); } int cmd_difftool(int argc, const char **argv, const char *prefix) |