Andrew's git
/
gitweb.git
/ diff
summary
|
log
|
commit
| diff |
tree
commit
grep
author
committer
pickaxe
?
re
Make '!' aliases more useful
author
Johannes Schindelin
<Johannes.Schindelin@gmx.de>
Sun, 1 Jul 2007 21:51:58 +0000
(22:51 +0100)
committer
Junio C Hamano
<gitster@pobox.com>
Mon, 2 Jul 2007 08:33:44 +0000
(
01:33
-0700)
When an alias starts with an exclamation mark, the rest is interpreted
as a shell command. However, all arguments passed to git used to be
ignored.
Now you can have an alias like
$ git config alias.e '!echo'
and
$ git e Hello World
does what you expect it to do.
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
git.c
patch
|
blob
|
history
raw
|
patch
|
inline
| side by side (parent:
7627943
)
diff --git
a/git.c
b/git.c
index 696a97edca0f2765a7b417de404d103b7802dcf6..727aabcbbe4d79a2bc2d7e536bfc7a93e9db6f30 100644
(file)
--- a/
git.c
+++ b/
git.c
@@
-181,6
+181,21
@@
static int handle_alias(int *argcp, const char ***argv)
git_config(git_alias_config);
if (alias_string) {
if (alias_string[0] == '!') {
git_config(git_alias_config);
if (alias_string) {
if (alias_string[0] == '!') {
+ if (*argcp > 1) {
+ int i, sz = PATH_MAX;
+ char *s = xmalloc(sz), *new_alias = s;
+
+ add_to_string(&s, &sz, alias_string, 0);
+ free(alias_string);
+ alias_string = new_alias;
+ for (i = 1; i < *argcp &&
+ !add_to_string(&s, &sz, " ", 0) &&
+ !add_to_string(&s, &sz, (*argv)[i], 1)
+ ; i++)
+ ; /* do nothing */
+ if (!sz)
+ die("Too many or long arguments");
+ }
trace_printf("trace: alias to shell cmd: %s => %s\n",
alias_command, alias_string + 1);
ret = system(alias_string + 1);
trace_printf("trace: alias to shell cmd: %s => %s\n",
alias_command, alias_string + 1);
ret = system(alias_string + 1);