Re: [PATCH v3] build: add default aliases

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The subject line needs to be updated.

On Sat, Sep 21, 2013 at 02:20:21PM -0500, Felipe Contreras wrote:
> For now simply add a few common aliases.
> 
>   co = checkout
>   ci = commit
>   rb = rebase
>   st = status
> 
> Signed-off-by: Felipe Contreras <felipe.contreras@xxxxxxxxx>
> ---

[...]

> diff --git a/alias.c b/alias.c
> index eb9f08b..d6bad69 100644
> --- a/alias.c
> +++ b/alias.c
> @@ -14,11 +14,28 @@ static int alias_lookup_cb(const char *k, const char *v, void *cb)
>  	return 0;
>  }
>  
> +static struct {
> +	const char *key;
> +	const char *val;
> +} default_aliases[] = {
> +	{ "co", "checkout" },
> +	{ "ci", "checkout" },
> +	{ "rb", "rebase" },
> +	{ "st", "status" },
> +};
> +
>  char *alias_lookup(const char *alias)
>  {
> +	int i;
>  	alias_key = alias;
>  	alias_val = NULL;
>  	git_config(alias_lookup_cb, NULL);
> +	if (alias_val)
> +		return alias_val;
> +	for (i = 0; i < ARRAY_SIZE(default_aliases); i++) {
> +		if (!strcmp(alias, default_aliases[i].key))
> +			return xstrdup(default_aliases[i].val);
> +	}
>  	return alias_val;
>  }

Aliases implemented this way don't work the same way as "normal"
aliases do:

  $ # which aliases do I have?
  $ ./bin-wrappers/git config --get-regexp "alias\..*"
  $ # no aliases at all
  $ # does completion work?
  $ ./bin-wrappers/git co ma<TAB>
  mailmap.c      mailmap.h      mailmap.o      match-trees.c  match-trees.o
  $ # no refs completion
  $ # let's see a real alias
  $ git config alias.co checkout
  $ ./bin-wrappers/git config --get-regexp "alias\..*"
  alias.co checkout
  $ ./bin-wrappers/git co ma<TAB>
  maint    master
  $ # as expected


Best,
Gábor

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]