summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 96256bb)
raw | patch | inline | side by side (parent: 96256bb)
author | Johannes Schindelin <Johannes.Schindelin@gmx.de> | |
Mon, 24 Jul 2006 12:10:45 +0000 (14:10 +0200) | ||
committer | Junio C Hamano <junkio@cox.net> | |
Tue, 25 Jul 2006 21:15:46 +0000 (14:15 -0700) |
Now, something like
[alias]
pd = -p diff
works as expected.
[jc: a follow-up fix from Jeff King folded in.]
Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Signed-off-by: Junio C Hamano <junkio@cox.net>
[alias]
pd = -p diff
works as expected.
[jc: a follow-up fix from Jeff King folded in.]
Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Signed-off-by: Junio C Hamano <junkio@cox.net>
git.c | patch | blob | history |
index ee5a0e86a71119b5ac11c351a982e31c87649a15..c0bd19d0ef2f44608425e35b6e80ff1baef31564 100644 (file)
--- a/git.c
+++ b/git.c
setenv("PATH", path, 1);
}
+static int handle_options(const char*** argv, int* argc)
+{
+ int handled = 0;
+
+ while (*argc > 0) {
+ const char *cmd = (*argv)[0];
+ if (cmd[0] != '-')
+ break;
+
+ if (!strcmp(cmd, "-p") || !strcmp(cmd, "--paginate")) {
+ setup_pager();
+ } else
+ die ("Unknown option: %s", cmd);
+
+ (*argv)++;
+ (*argc)--;
+ handled++;
+ }
+ return handled;
+}
+
static const char *alias_command;
static char *alias_string = NULL;
subdir = setup_git_directory_gently(&nongit);
if (!nongit) {
- int count;
+ int count, option_count;
const char** new_argv;
alias_command = (*argv)[0];
if (alias_string) {
count = split_cmdline(alias_string, &new_argv);
+ option_count = handle_options(&new_argv, &count);
+ memmove(new_argv - option_count, new_argv,
+ count * sizeof(char *));
+ new_argv -= option_count;
if (count < 1)
die("empty alias for %s", alias_command);
/* Look for flags.. */
while (argc > 1) {
- cmd = *++argv;
+ argv++;
argc--;
- if (!strcmp(cmd, "-p") || !strcmp(cmd, "--paginate")) {
- setup_pager();
- continue;
- }
+ handle_options(&argv, &argc);
+
+ cmd = *argv;
if (strncmp(cmd, "--", 2))
break;