Re: [PATCH] Move all dashed form git commands to libexecdir
- From
Johannes Schindelin <johannes.schindelin@gmx.de>
- Date
- Nov 30, 2007, 18:28 UTC
- Message-ID
- <Pine.LNX.4.64.0711301828050.27959@racer.site>
- In-Reply-To
- <20071130162257.GA22882@coredump.intra.peff.net>
Hi,
On Fri, 30 Nov 2007, Jeff King wrote:
Show 40 quoted lines
> Support builtin aliases
>
> Builtin aliases are "default" alias values that can be
> overridden by user-configured aliases.
>
> For example, the first such alias is "view", an alias for
> gitk. A user with no further configuration can run
> "git view" to use gitk. However, they can also set the
> config option "alias.view" to "!tig" to run tig.
> ---
> git.c | 9 +++++++++
> 1 files changed, 9 insertions(+), 0 deletions(-)
>
> diff --git a/git.c b/git.c
> index f220284..95296aa 100644
> --- a/git.c
> +++ b/git.c
> @@ -151,6 +151,13 @@ static int split_cmdline(char *cmdline, const char ***argv)
> return count;
> }
>
> +static char *builtin_alias(const char *cmd)
> +{
> + if (!strcmp(cmd, "view"))
> + return xstrdup("!gitk");
> + return NULL;
> +}
> +
> static int handle_alias(int *argcp, const char ***argv)
> {
> int nongit = 0, envchanged = 0, ret = 0, saved_errno = errno;
> @@ -162,6 +169,8 @@ static int handle_alias(int *argcp, const char ***argv)
>
> alias_command = (*argv)[0];
> git_config(git_alias_config);
> + if (!alias_string)
> + alias_string = builtin_alias(alias_command);
> if (alias_string) {
> if (alias_string[0] == '!') {
> if (*argcp > 1) {Didn't you mean to put this _before_ the git_config() call? As you wrote it, the "soft" alias overrides the user-specified one.
Ciao, Dscho