Merge branch 'ab/cmd-foo-should-return'
Code clean-up.
* ab/cmd-foo-should-return:
builtins + test helpers: use return instead of exit() in cmd_*
diff --git a/builtin/difftool.c b/builtin/difftool.c
index 89334b7..6a9242a 100644
--- a/builtin/difftool.c
+++ b/builtin/difftool.c
@@ -675,7 +675,7 @@
"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";
@@ -686,8 +686,7 @@
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)
diff --git a/builtin/merge-ours.c b/builtin/merge-ours.c
index 4594507..3583cff 100644
--- a/builtin/merge-ours.c
+++ b/builtin/merge-ours.c
@@ -28,6 +28,6 @@
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;
}
diff --git a/builtin/mktree.c b/builtin/mktree.c
index 891991b..ae78ca1 100644
--- a/builtin/mktree.c
+++ b/builtin/mktree.c
@@ -189,5 +189,5 @@
used=0; /* reset tree entry buffer for re-use in batch mode */
}
strbuf_release(&sb);
- exit(0);
+ return 0;
}
diff --git a/sh-i18n--envsubst.c b/sh-i18n--envsubst.c
index e7430b9..6cd307a 100644
--- a/sh-i18n--envsubst.c
+++ b/sh-i18n--envsubst.c
@@ -104,12 +104,12 @@
if (ferror (stderr) || fflush (stderr))
{
fclose (stderr);
- exit (EXIT_FAILURE);
+ return (EXIT_FAILURE);
}
if (fclose (stderr) && errno != EBADF)
- exit (EXIT_FAILURE);
+ return (EXIT_FAILURE);
- exit (EXIT_SUCCESS);
+ return (EXIT_SUCCESS);
}
/* Parse the string and invoke the callback each time a $VARIABLE or
diff --git a/shell.c b/shell.c
index cef7ffd..811e13b 100644
--- a/shell.c
+++ b/shell.c
@@ -177,7 +177,7 @@
default:
continue;
}
- exit(cmd->exec(cmd->name, arg));
+ return cmd->exec(cmd->name, arg);
}
cd_to_homedir();
diff --git a/t/helper/test-hash-speed.c b/t/helper/test-hash-speed.c
index 432233c..f40d9ad 100644
--- a/t/helper/test-hash-speed.c
+++ b/t/helper/test-hash-speed.c
@@ -57,5 +57,5 @@
free(p);
}
- exit(0);
+ return 0;
}
diff --git a/t/helper/test-hash.c b/t/helper/test-hash.c
index 0a31de6..261c545 100644
--- a/t/helper/test-hash.c
+++ b/t/helper/test-hash.c
@@ -54,5 +54,5 @@
fwrite(hash, 1, algop->rawsz, stdout);
else
puts(hash_to_hex_algop(hash, algop));
- exit(0);
+ return 0;
}
diff --git a/t/helper/test-match-trees.c b/t/helper/test-match-trees.c
index b9fd427..4079fde 100644
--- a/t/helper/test-match-trees.c
+++ b/t/helper/test-match-trees.c
@@ -23,5 +23,5 @@
shift_tree(the_repository, &one->object.oid, &two->object.oid, &shifted, -1);
printf("shifted: %s\n", oid_to_hex(&shifted));
- exit(0);
+ return 0;
}
diff --git a/t/helper/test-reach.c b/t/helper/test-reach.c
index cda804e..2f65c7f 100644
--- a/t/helper/test-reach.c
+++ b/t/helper/test-reach.c
@@ -166,5 +166,5 @@
print_sorted_commit_ids(list);
}
- exit(0);
+ return 0;
}