From: SZEDER Gábor Date: Tue, 24 Sep 2013 15:21:40 GMT Subject: Re: [PATCH v3] build: add default aliases Message-ID: <20130924152140.GA4259@goldbirke> 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 > --- [...] > 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 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 maint master $ # as expected Best, Gábor