aboutsummaryrefslogtreecommitdiff
path: root/git.c
diff options
context:
space:
mode:
authorJunio C Hamano <junkio@cox.net>2006-06-05 18:09:40 -0700
committerJunio C Hamano <junkio@cox.net>2006-06-05 18:09:40 -0700
commita025463bc0ec2c894a88f2dfb44cf88ba71bb712 (patch)
tree350dab16b63c36318e7a792b4f66d81a9082e06e /git.c
parent2b11e3170e919866c7f5554dd4089289a1bb6726 (diff)
downloadgit-a025463bc0ec2c894a88f2dfb44cf88ba71bb712.tar.gz
git-a025463bc0ec2c894a88f2dfb44cf88ba71bb712.tar.xz
git alias: try alias last.
This disables alias "foo" from being used for git-foo, and when we do use alias we check the built-in and then existing command names first and then alias as the fallback. This avoids the problem of common commands used in scripts getting clobbered by user specific aliases. Signed-off-by: Junio C Hamano <junkio@cox.net>
Diffstat (limited to 'git.c')
-rw-r--r--git.c20
1 files changed, 14 insertions, 6 deletions
diff --git a/git.c b/git.c
index 885447245..6db8f2bc2 100644
--- a/git.c
+++ b/git.c
@@ -202,6 +202,7 @@ int main(int argc, const char **argv, char **envp)
char *slash = strrchr(cmd, '/');
char git_command[PATH_MAX + 1];
const char *exec_path = NULL;
+ int done_alias = 0;
/*
* Take the basename of argv[0] as the command
@@ -229,7 +230,6 @@ int main(int argc, const char **argv, char **envp)
if (!strncmp(cmd, "git-", 4)) {
cmd += 4;
argv[0] = cmd;
- handle_alias(&argc, &argv);
handle_internal_command(argc, argv, envp);
die("cannot handle %s internally", cmd);
}
@@ -287,13 +287,21 @@ int main(int argc, const char **argv, char **envp)
exec_path = git_exec_path();
prepend_to_path(exec_path, strlen(exec_path));
- handle_alias(&argc, &argv);
+ while (1) {
+ /* See if it's an internal command */
+ handle_internal_command(argc, argv, envp);
- /* See if it's an internal command */
- handle_internal_command(argc, argv, envp);
+ /* .. then try the external ones */
+ execv_git_cmd(argv);
- /* .. then try the external ones */
- execv_git_cmd(argv);
+ /* It could be an alias -- this works around the insanity
+ * of overriding "git log" with "git show" by having
+ * alias.log = show
+ */
+ if (done_alias || !handle_alias(&argc, &argv))
+ break;
+ done_alias = 1;
+ }
if (errno == ENOENT)
cmd_usage(0, exec_path, "'%s' is not a git-command", cmd);