summaryrefslogtreecommitdiff
path: root/builtin/merge-ours.c
diff options
context:
space:
mode:
authorLibravatar Ævar Arnfjörð Bjarmason <avarab@gmail.com>2021-06-08 12:48:03 +0200
committerLibravatar Junio C Hamano <gitster@pobox.com>2021-06-09 09:15:58 +0900
commit338abb0f045b87df5e628543800e74dec0e72cdf (patch)
tree52e8b1cb82decf173d31647abca84a65945fc93c /builtin/merge-ours.c
parentGit 2.31.1 (diff)
downloadtgif-338abb0f045b87df5e628543800e74dec0e72cdf.tar.xz
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/merge-ours.c')
-rw-r--r--builtin/merge-ours.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/builtin/merge-ours.c b/builtin/merge-ours.c
index 4594507420..3583cff71c 100644
--- a/builtin/merge-ours.c
+++ b/builtin/merge-ours.c
@@ -28,6 +28,6 @@ int cmd_merge_ours(int argc, const char **argv, const char *prefix)
if (read_cache() < 0)
die_errno("read_cache failed");
if (index_differs_from(the_repository, "HEAD", NULL, 0))
- exit(2);
- exit(0);
+ return 2;
+ return 0;
}