git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3] build: add default aliases
@ 2013-09-21 19:20 Felipe Contreras
  2013-09-24  4:53 ` Jeff King
                   ` (2 more replies)
  0 siblings, 3 replies; 34+ messages in thread
From: Felipe Contreras @ 2013-09-21 19:20 UTC (permalink / raw)
  To: git; +Cc: David Aguilar, Felipe Contreras

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>
---

I still think we should ship a default /etc/gitconfig, but the project needs to
agree it's a good change, and nobody every agrees changes are good. So this is
the minimal change that achieves the desired result.

 Documentation/git-checkout.txt |  5 +++++
 Documentation/git-commit.txt   |  5 +++++
 Documentation/git-rebase.txt   |  5 +++++
 Documentation/git-status.txt   |  5 +++++
 alias.c                        | 17 +++++++++++++++++
 5 files changed, 37 insertions(+)

diff --git a/Documentation/git-checkout.txt b/Documentation/git-checkout.txt
index ca118ac..7597813 100644
--- a/Documentation/git-checkout.txt
+++ b/Documentation/git-checkout.txt
@@ -14,6 +14,11 @@ SYNOPSIS
 'git checkout' [-f|--ours|--theirs|-m|--conflict=<style>] [<tree-ish>] [--] <paths>...
 'git checkout' [-p|--patch] [<tree-ish>] [--] [<paths>...]
 
+ALIAS
+-----
+
+git co
+
 DESCRIPTION
 -----------
 Updates files in the working tree to match the version in the index
diff --git a/Documentation/git-commit.txt b/Documentation/git-commit.txt
index 1a7616c..8705abc 100644
--- a/Documentation/git-commit.txt
+++ b/Documentation/git-commit.txt
@@ -15,6 +15,11 @@ SYNOPSIS
 	   [--date=<date>] [--cleanup=<mode>] [--[no-]status]
 	   [-i | -o] [-S[<keyid>]] [--] [<file>...]
 
+ALIAS
+-----
+
+git ci
+
 DESCRIPTION
 -----------
 Stores the current contents of the index in a new commit along
diff --git a/Documentation/git-rebase.txt b/Documentation/git-rebase.txt
index 6b2e1c8..bb18fea 100644
--- a/Documentation/git-rebase.txt
+++ b/Documentation/git-rebase.txt
@@ -14,6 +14,11 @@ SYNOPSIS
 	--root [<branch>]
 'git rebase' --continue | --skip | --abort | --edit-todo
 
+ALIAS
+-----
+
+git rb
+
 DESCRIPTION
 -----------
 If <branch> is specified, 'git rebase' will perform an automatic
diff --git a/Documentation/git-status.txt b/Documentation/git-status.txt
index 9046df9..30ecd25 100644
--- a/Documentation/git-status.txt
+++ b/Documentation/git-status.txt
@@ -11,6 +11,11 @@ SYNOPSIS
 [verse]
 'git status' [<options>...] [--] [<pathspec>...]
 
+ALIAS
+-----
+
+git st
+
 DESCRIPTION
 -----------
 Displays paths that have differences between the index file and the
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;
 }
 
-- 
1.8.4-fc

^ permalink raw reply related	[flat|nested] 34+ messages in thread

end of thread, other threads:[~2013-10-17 21:50 UTC | newest]

Thread overview: 34+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
2013-09-24 15:33   ` [PATCH v4] " Felipe Contreras

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 NNTP newsgroup(s).