git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: "SZEDER Gábor" <szeder@fzi.de>
To: Felipe Contreras <felipe.contreras@gmail.com>
Cc: git@vger.kernel.org, David Aguilar <davvid@gmail.com>
Subject: Re: [PATCH v3] build: add default aliases
Date: Tue, 24 Sep 2013 17:21:40 +0200	[thread overview]
Message-ID: <20130924152140.GA4259@goldbirke> (raw)
In-Reply-To: <1379791221-29925-1-git-send-email-felipe.contreras@gmail.com>

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@gmail.com>
> ---

[...]

> 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

  parent reply	other threads:[~2013-09-24 15:21 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-21 19:20 [PATCH v3] build: add default aliases Felipe Contreras
2013-09-24  4:53 ` Jeff King
2013-09-24  5:32   ` Felipe Contreras
2013-09-24  5:37     ` Jeff King
2013-09-24  5:49       ` Felipe Contreras
2013-09-24  6:18         ` Jeff King
2013-09-24  6:41           ` Felipe Contreras
2013-09-24  6:46             ` Jeff King
2013-09-24  6:59               ` Felipe Contreras
2013-09-24 18:39   ` Jonathan Nieder
2013-09-24 19:30     ` John Szakmeister
2013-09-28 22:41     ` Felipe Contreras
2013-09-29  3:18       ` Michael Haggerty
2013-09-29  3:37         ` Felipe Contreras
2013-09-30 19:33         ` Jonathan Nieder
2013-10-01  1:12           ` Duy Nguyen
2013-10-15 22:34   ` Junio C Hamano
2013-10-16  3:43     ` Felipe Contreras
2013-10-17 19:51       ` Junio C Hamano
2013-10-17 21:34         ` Felipe Contreras
2013-09-24  9:19 ` John Szakmeister
2013-09-24 10:25   ` Felipe Contreras
2013-09-24 11:06     ` John Szakmeister
2013-09-24 14:35       ` Felipe Contreras
2013-09-25 13:33         ` John Szakmeister
2013-09-25 14:29           ` Felipe Contreras
2013-09-25 14:55             ` Matthieu Moy
2013-09-25 15:08               ` Felipe Contreras
2013-09-25 15:13                 ` Matthieu Moy
2013-09-25 15:16                   ` Felipe Contreras
2013-09-25 16:05                     ` Matthieu Moy
2013-09-25 16:36                       ` Felipe Contreras
2013-09-24 15:21 ` SZEDER Gábor [this message]
2013-09-24 15:33   ` [PATCH v4] " Felipe Contreras

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

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20130924152140.GA4259@goldbirke \
    --to=szeder@fzi.de \
    --cc=davvid@gmail.com \
    --cc=felipe.contreras@gmail.com \
    --cc=git@vger.kernel.org \
    /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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).