summaryrefslogtreecommitdiff
path: root/git.c
diff options
context:
space:
mode:
authorTheodore Ts'o <tytso@mit.edu>2007-02-11 00:33:58 (GMT)
committerJunio C Hamano <junkio@cox.net>2007-02-11 06:46:34 (GMT)
commitdfd42a3c6281275b518f10938dcd858558cd82e3 (patch)
treede0831a6b88036f483f0d7ae9df04cdf56f55554 /git.c
parentf3dd015c9147e3116fc1941d96f4dad38386b1db (diff)
downloadgit-dfd42a3c6281275b518f10938dcd858558cd82e3.zip
git-dfd42a3c6281275b518f10938dcd858558cd82e3.tar.gz
git-dfd42a3c6281275b518f10938dcd858558cd82e3.tar.bz2
Allow aliases to expand to shell commands
If the alias expansion is prefixed with an exclamation point, treat it as a shell command which is run using system(3). Signed-off-by: "Theodore Ts'o" <tytso@mit.edu> Signed-off-by: Junio C Hamano <junkio@cox.net>
Diffstat (limited to 'git.c')
-rw-r--r--git.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/git.c b/git.c
index c43d4ff..45265f1 100644
--- a/git.c
+++ b/git.c
@@ -159,6 +159,16 @@ static int handle_alias(int *argcp, const char ***argv)
alias_command = (*argv)[0];
git_config(git_alias_config);
if (alias_string) {
+ if (alias_string[0] == '!') {
+ 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'\n",
+ alias_string + 1, alias_command);
+ }
count = split_cmdline(alias_string, &new_argv);
option_count = handle_options(&new_argv, &count);
memmove(new_argv - option_count, new_argv,