From: Theodore Tso <tytso@mit.edu>
To: Junio C Hamano <junkio@cox.net>
Cc: git@vger.kernel.org
Subject: Re: [PATCH] Allow aliases to expand to shell commands
Date: Sat, 10 Feb 2007 13:13:57 -0500 [thread overview]
Message-ID: <20070210181357.GE25607@thunk.org> (raw)
In-Reply-To: <11711235042388-git-send-email-tytso@mit.edu>
Here's a revised patch which fixes a stupid spelling typo in the
documentation. ("eqvuialent" --> "equivalent")
>From c16544aa786b0fb244fd974a22831a1210286ec5 Mon Sep 17 00:00:00 2001
From: Theodore Ts'o <tytso@mit.edu>
Date: Sat, 10 Feb 2007 10:50:58 -0500
Subject: [PATCH] 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>
---
Documentation/config.txt | 6 ++++++
git.c | 10 ++++++++++
2 files changed, 16 insertions(+), 0 deletions(-)
diff --git a/Documentation/config.txt b/Documentation/config.txt
index 4e650af..e6e9409 100644
--- a/Documentation/config.txt
+++ b/Documentation/config.txt
@@ -222,6 +222,12 @@ alias.*::
spaces, the usual shell quoting and escaping is supported.
quote pair and a backslash can be used to quote them.
+ If the alias expansion is prefixed with an exclamation point,
+ it will be treated as a shell command. For example, defining
+ "alias.new = !gitk --all --not ORIG_HEAD", the invocation
+ "git new" is equivalent to running the shell command
+ "gitk --all --not ORIG_HEAD".
+
apply.whitespace::
Tells `git-apply` how to handle whitespaces, in the same way
as the '--whitespace' option. See gitlink:git-apply[1].
diff --git a/git.c b/git.c
index c43d4ff..fc08396 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, alias_command);
+ }
count = split_cmdline(alias_string, &new_argv);
option_count = handle_options(&new_argv, &count);
memmove(new_argv - option_count, new_argv,
--
1.5.0.rc4.2.g4249
next prev parent reply other threads:[~2007-02-10 18:14 UTC|newest]
Thread overview: 51+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-02-08 0:18 Git rescue mission Bill Lear
2007-02-08 0:22 ` Johannes Schindelin
2007-02-08 0:24 ` Bill Lear
2007-02-08 0:25 ` Johannes Schindelin
2007-02-08 0:34 ` Bill Lear
2007-02-08 0:48 ` Junio C Hamano
2007-02-08 4:28 ` Alexander Litvinov
2007-02-09 0:53 ` Junio C Hamano
2007-02-09 3:32 ` Alexander Litvinov
2007-02-08 15:27 ` Bill Lear
2007-02-08 15:56 ` Jakub Narebski
2007-02-08 23:24 ` Jeff King
2007-02-08 23:32 ` Bill Lear
2007-02-08 17:27 ` Linus Torvalds
2007-02-08 20:12 ` Kalle Pokki
2007-02-08 21:23 ` Linus Torvalds
2007-02-08 22:03 ` Kalle Pokki
2007-02-08 22:10 ` Shawn O. Pearce
2007-02-09 1:48 ` Theodore Tso
2007-02-09 1:58 ` Shawn O. Pearce
2007-02-09 2:01 ` Jakub Narebski
2007-02-10 16:05 ` Theodore Ts'o
2007-02-10 16:05 ` [PATCH] Print a sane error message if an alias expands to an invalid git command Theodore Ts'o
2007-02-10 16:05 ` [PATCH] Allow aliases to expand to shell commands Theodore Ts'o
2007-02-10 18:04 ` Linus Torvalds
2007-02-10 18:13 ` Theodore Tso [this message]
2007-02-10 20:34 ` Johannes Schindelin
2007-02-11 0:13 ` Theodore Tso
2007-02-11 16:03 ` Johannes Schindelin
2007-02-11 16:21 ` Theodore Tso
2007-02-11 16:36 ` Johannes Schindelin
2007-02-11 21:44 ` Junio C Hamano
2007-02-11 22:03 ` Johannes Schindelin
2007-02-12 3:56 ` Theodore Tso
2007-02-12 6:53 ` Shawn O. Pearce
2007-02-10 16:50 ` [PATCH] Print a sane error message if an alias expands to an invalid git command Junio C Hamano
2007-02-09 19:21 ` Git rescue mission Kalle Pokki
2007-02-08 21:57 ` Bill Lear
2007-02-08 22:13 ` Linus Torvalds
2007-02-08 22:33 ` Bill Lear
2007-02-08 23:25 ` Bill Lear
2007-02-08 23:33 ` Shawn O. Pearce
2007-02-08 23:40 ` Bill Lear
2007-02-08 23:50 ` Shawn O. Pearce
2007-02-09 0:03 ` Jakub Narebski
2007-02-09 0:17 ` Linus Torvalds
2007-02-09 8:58 ` Michael S. Tsirkin
2007-02-08 23:38 ` Jakub Narebski
2007-02-08 23:46 ` Linus Torvalds
2007-02-09 4:38 ` Junio C Hamano
2007-02-08 22:29 ` Jakub Narebski
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20070210181357.GE25607@thunk.org \
--to=tytso@mit.edu \
--cc=git@vger.kernel.org \
--cc=junkio@cox.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.