summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2011-02-10 00:41:16 (GMT)
committerJunio C Hamano <gitster@pobox.com>2011-02-10 00:41:16 (GMT)
commitf5bbbf9cad167044a3560542c93faa12c90204e0 (patch)
tree89cba6141a2007afccbbbc8dee6c2d925b2d51bc
parent05f08e4c9ed4a9c34eb2d62300189a3e8a86b5a5 (diff)
parent7f51f8bc2b9d0556f2fbe20056e8fc8839766c99 (diff)
downloadgit-f5bbbf9cad167044a3560542c93faa12c90204e0.zip
git-f5bbbf9cad167044a3560542c93faa12c90204e0.tar.gz
git-f5bbbf9cad167044a3560542c93faa12c90204e0.tar.bz2
Merge branch 'ef/alias-via-run-command'
* ef/alias-via-run-command: alias: use run_command api to execute aliases
-rw-r--r--git.c34
1 files changed, 17 insertions, 17 deletions
diff --git a/git.c b/git.c
index 68334f6..23610aa 100644
--- a/git.c
+++ b/git.c
@@ -177,24 +177,24 @@ static int handle_alias(int *argcp, const char ***argv)
alias_string = alias_lookup(alias_command);
if (alias_string) {
if (alias_string[0] == '!') {
+ const char **alias_argv;
+ int argc = *argcp, i;
+
commit_pager_choice();
- if (*argcp > 1) {
- struct strbuf buf;
-
- strbuf_init(&buf, PATH_MAX);
- strbuf_addstr(&buf, alias_string);
- sq_quote_argv(&buf, (*argv) + 1, PATH_MAX);
- free(alias_string);
- alias_string = buf.buf;
- }
- trace_printf("trace: alias to shell cmd: %s => %s\n",
- alias_command, alias_string + 1);
- ret = system(alias_string + 1);
- if (ret >= 0 && WIFEXITED(ret) &&
- WEXITSTATUS(ret) != 127)
- exit(WEXITSTATUS(ret));
- die("Failed to run '%s' when expanding alias '%s'",
- alias_string + 1, alias_command);
+
+ /* build alias_argv */
+ alias_argv = xmalloc(sizeof(*alias_argv) * (argc + 1));
+ alias_argv[0] = alias_string + 1;
+ for (i = 1; i < argc; ++i)
+ alias_argv[i] = (*argv)[i];
+ alias_argv[argc] = NULL;
+
+ ret = run_command_v_opt(alias_argv, RUN_USING_SHELL);
+ if (ret >= 0) /* normal exit */
+ exit(ret);
+
+ die_errno("While expanding alias '%s': '%s'",
+ alias_command, alias_string + 1);
}
count = split_cmdline(alias_string, &new_argv);
if (count < 0)