From: Felipe Contreras <felipe.contreras@gmail.com>
To: git@vger.kernel.org
Cc: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>,
"Junio C Hamano" <gitster@pobox.com>,
"Felipe Contreras" <felipe.contreras@gmail.com>
Subject: [PATCH 5/5] config: add default aliases
Date: Fri, 2 Jul 2021 05:05:06 -0500 [thread overview]
Message-ID: <20210702100506.1422429-6-felipe.contreras@gmail.com> (raw)
In-Reply-To: <20210702100506.1422429-1-felipe.contreras@gmail.com>
These are all the aliases everyone agrees are essential.
Virtually all VCS in the world have aliases, except git, so let's change
that.
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
Documentation/git-branch.txt | 4 ++++
Documentation/git-cherry-pick.txt | 4 ++++
Documentation/git-commit.txt | 4 ++++
Documentation/git-mergetool.txt | 4 ++++
Documentation/git-rebase.txt | 4 ++++
Documentation/git-status.txt | 4 ++++
config.c | 29 +++++++++++++++++++++++++++++
config.h | 3 ++-
t/test-lib.sh | 2 ++
9 files changed, 57 insertions(+), 1 deletion(-)
diff --git a/Documentation/git-branch.txt b/Documentation/git-branch.txt
index 94dc9a54f2..fbf5ebd27a 100644
--- a/Documentation/git-branch.txt
+++ b/Documentation/git-branch.txt
@@ -24,6 +24,10 @@ SYNOPSIS
'git branch' (-d | -D) [-r] <branchname>...
'git branch' --edit-description [<branchname>]
+ALIAS
+~~~~~
+'git br'
+
DESCRIPTION
-----------
diff --git a/Documentation/git-cherry-pick.txt b/Documentation/git-cherry-pick.txt
index 5d750314b2..b43b1a3a30 100644
--- a/Documentation/git-cherry-pick.txt
+++ b/Documentation/git-cherry-pick.txt
@@ -12,6 +12,10 @@ SYNOPSIS
[-S[<keyid>]] <commit>...
'git cherry-pick' (--continue | --skip | --abort | --quit)
+ALIAS
+~~~~~
+'git pi'
+
DESCRIPTION
-----------
diff --git a/Documentation/git-commit.txt b/Documentation/git-commit.txt
index 340c5fbb48..32b1fdba45 100644
--- a/Documentation/git-commit.txt
+++ b/Documentation/git-commit.txt
@@ -17,6 +17,10 @@ SYNOPSIS
[(--trailer <token>[(=|:)<value>])...] [-S[<keyid>]]
[--] [<pathspec>...]
+ALIAS
+~~~~~
+'git co'
+
DESCRIPTION
-----------
Create a new commit containing the current contents of the index and
diff --git a/Documentation/git-mergetool.txt b/Documentation/git-mergetool.txt
index e587c7763a..59708a1f3e 100644
--- a/Documentation/git-mergetool.txt
+++ b/Documentation/git-mergetool.txt
@@ -10,6 +10,10 @@ SYNOPSIS
[verse]
'git mergetool' [--tool=<tool>] [-y | --[no-]prompt] [<file>...]
+ALIAS
+~~~~~
+'git mt'
+
DESCRIPTION
-----------
diff --git a/Documentation/git-rebase.txt b/Documentation/git-rebase.txt
index 55af6fd24e..21f5ae9d0e 100644
--- a/Documentation/git-rebase.txt
+++ b/Documentation/git-rebase.txt
@@ -14,6 +14,10 @@ SYNOPSIS
--root [<branch>]
'git rebase' (--continue | --skip | --abort | --quit | --edit-todo | --show-current-patch)
+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 83f38e3198..fcc89fa8d4 100644
--- a/Documentation/git-status.txt
+++ b/Documentation/git-status.txt
@@ -11,6 +11,10 @@ SYNOPSIS
[verse]
'git status' [<options>...] [--] [<pathspec>...]
+ALIAS
+~~~~~
+'git st'
+
DESCRIPTION
-----------
Displays paths that have differences between the index file and the
diff --git a/config.c b/config.c
index 666fb2c689..c42f41599c 100644
--- a/config.c
+++ b/config.c
@@ -501,6 +501,30 @@ int git_config_key_is_valid(const char *key)
return !git_config_parse_key_1(key, NULL, NULL, 1);
}
+static int git_config_default(config_fn_t fn, void *data)
+{
+ int ret = 0;
+ struct config_source source;
+
+ if (getenv("GIT_NO_DEFAULT_ALIASES"))
+ return 0;
+
+ memset(&source, 0, sizeof(source));
+ source.prev = cf;
+ source.origin_type = CONFIG_ORIGIN_DEFAULT;
+ cf = &source;
+
+ ret += fn("alias.co", "commit", data);
+ ret += fn("alias.rb", "rebase", data);
+ ret += fn("alias.st", "status", data);
+ ret += fn("alias.br", "branch", data);
+ ret += fn("alias.pi", "cherry-pick", data);
+ ret += fn("alias.mt", "mergetool", data);
+
+ cf = source.prev;
+ return ret;
+}
+
static int config_parse_pair(const char *key, const char *value,
config_fn_t fn, void *data)
{
@@ -1897,6 +1921,9 @@ static int do_git_config_sequence(const struct config_options *opts,
repo_config = NULL;
current_parsing_scope = CONFIG_SCOPE_SYSTEM;
+
+ git_config_default(fn, data);
+
if (git_config_system() && system_config &&
!access_or_die(system_config, R_OK,
opts->system_gently ? ACCESS_EACCES_OK : 0))
@@ -3497,6 +3524,8 @@ const char *current_config_origin_type(void)
return "submodule-blob";
case CONFIG_ORIGIN_CMDLINE:
return "command line";
+ case CONFIG_ORIGIN_DEFAULT:
+ return "default";
default:
BUG("unknown config origin type");
}
diff --git a/config.h b/config.h
index 9038538ffd..bc3ecca313 100644
--- a/config.h
+++ b/config.h
@@ -58,7 +58,8 @@ enum config_origin_type {
CONFIG_ORIGIN_FILE,
CONFIG_ORIGIN_STDIN,
CONFIG_ORIGIN_SUBMODULE_BLOB,
- CONFIG_ORIGIN_CMDLINE
+ CONFIG_ORIGIN_CMDLINE,
+ CONFIG_ORIGIN_DEFAULT
};
enum config_event_t {
diff --git a/t/test-lib.sh b/t/test-lib.sh
index 49b80a4eb5..a15965e2f4 100644
--- a/t/test-lib.sh
+++ b/t/test-lib.sh
@@ -456,6 +456,8 @@ GIT_DEFAULT_HASH="${GIT_TEST_DEFAULT_HASH:-sha1}"
export GIT_DEFAULT_HASH
GIT_TEST_MERGE_ALGORITHM="${GIT_TEST_MERGE_ALGORITHM:-ort}"
export GIT_TEST_MERGE_ALGORITHM
+GIT_NO_DEFAULT_ALIASES=1
+export GIT_NO_DEFAULT_ALIASES
# Tests using GIT_TRACE typically don't want <timestamp> <file>:<line> output
GIT_TRACE_BARE=1
--
2.32.0.94.g4574ca548c
next prev parent reply other threads:[~2021-07-02 10:05 UTC|newest]
Thread overview: 41+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-02 10:05 [PATCH 0/5] Default aliases Felipe Contreras
2021-07-02 10:05 ` [PATCH 1/5] test: add missing whitespaces Felipe Contreras
2021-07-02 10:05 ` [PATCH 2/5] config: trivial style fix Felipe Contreras
2021-07-02 10:05 ` [PATCH 3/5] config: trivial struct initialization cleanup Felipe Contreras
2021-07-02 10:05 ` [PATCH 4/5] config: initialize origin_type correctly Felipe Contreras
2021-07-02 10:05 ` Felipe Contreras [this message]
2021-07-02 10:10 ` [PATCH 5/5] config: add default aliases Andreas Schwab
2021-07-02 10:17 ` Felipe Contreras
2021-07-02 10:31 ` Andreas Schwab
2021-07-02 10:46 ` Felipe Contreras
2021-07-02 10:54 ` Andreas Schwab
2021-07-02 10:44 ` martin
2021-07-02 10:54 ` Felipe Contreras
2021-07-02 11:15 ` martin
2021-07-02 13:26 ` Randall S. Becker
2021-07-02 13:41 ` Ævar Arnfjörð Bjarmason
2021-07-02 14:15 ` Randall S. Becker
2021-07-02 14:43 ` martin
2021-07-02 20:44 ` Felipe Contreras
2021-07-02 22:03 ` Randall S. Becker
2021-07-02 22:32 ` Felipe Contreras
2021-07-02 15:39 ` Junio C Hamano
2021-07-02 20:41 ` Felipe Contreras
2021-07-02 21:02 ` Felipe Contreras
2021-07-02 21:40 ` martin
2021-07-02 22:16 ` Felipe Contreras
2021-07-02 22:00 ` Randall S. Becker
2021-07-02 22:31 ` Felipe Contreras
2021-07-02 21:12 ` Felipe Contreras
2021-07-02 21:31 ` martin
2021-07-02 22:14 ` Felipe Contreras
2021-07-02 11:32 ` Ævar Arnfjörð Bjarmason
2021-07-02 21:58 ` Felipe Contreras
2021-07-02 22:38 ` martin
2021-07-02 23:48 ` Felipe Contreras
2021-07-05 14:02 ` Randall S. Becker
2021-07-06 15:27 ` Randall S. Becker
2021-07-06 21:59 ` Felipe Contreras
2021-07-10 15:30 ` Philip Oakley
2021-07-03 10:50 ` Jeff King
2021-07-06 21:54 ` 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=20210702100506.1422429-6-felipe.contreras@gmail.com \
--to=felipe.contreras@gmail.com \
--cc=avarab@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
/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).