diff options
author | Michael J Gruber <git@drmicha.warpmail.net> | 2011-04-27 10:36:27 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2011-04-27 10:50:05 -0700 |
commit | 7cf16a14f5c070f7b14cf28023769450133172ae (patch) | |
tree | 6d90ac2effe3cb7ec57ad9172b0563b11c9c35d8 /git.c | |
parent | 0daed41791373a5530c2b33e09b134ce8820e0c2 (diff) | |
download | git-7cf16a14f5c070f7b14cf28023769450133172ae.tar.gz |
handle_alias: provide GIT_PREFIX to !alias
Provide an environment variable GIT_PREFIX which contains the subdirectory
from which a !alias was called (i.e. 'git rev-parse --show-prefix') since
these cd to the to level directory before they are executed.
Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'git.c')
-rw-r--r-- | git.c | 10 |
1 files changed, 9 insertions, 1 deletions
@@ -179,6 +179,8 @@ static int handle_alias(int *argcp, const char ***argv) if (alias_string[0] == '!') { const char **alias_argv; int argc = *argcp, i; + struct strbuf sb = STRBUF_INIT; + const char *env[2]; commit_pager_choice(); @@ -189,7 +191,13 @@ static int handle_alias(int *argcp, const char ***argv) alias_argv[i] = (*argv)[i]; alias_argv[argc] = NULL; - ret = run_command_v_opt(alias_argv, RUN_USING_SHELL); + strbuf_addstr(&sb, "GIT_PREFIX="); + if (subdir) + strbuf_addstr(&sb, subdir); + env[0] = sb.buf; + env[1] = NULL; + ret = run_command_v_opt_cd_env(alias_argv, RUN_USING_SHELL, NULL, env); + strbuf_release(&sb); if (ret >= 0) /* normal exit */ exit(ret); |