summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc Cornellà <marc.cornella@live.com>2020-07-09 11:16:16 +0200
committerMarc Cornellà <marc.cornella@live.com>2020-07-09 11:17:07 +0200
commit1db79f97f5523cd2c76b5dfb8185a6d3b7a789d9 (patch)
tree1107f2ff0eef0fc5e5641a8ad22c44d47ab0f593
parentd79941b78997f7c11e247c08678fd57827db3b42 (diff)
downloadzsh-1db79f97f5523cd2c76b5dfb8185a6d3b7a789d9.tar.gz
zsh-1db79f97f5523cd2c76b5dfb8185a6d3b7a789d9.tar.bz2
zsh-1db79f97f5523cd2c76b5dfb8185a6d3b7a789d9.zip
git: use `master` if it exists, otherwise use `main`
See https://github.com/ohmyzsh/ohmyzsh/pull/9049#issuecomment-654537347 Co-authored-by: Yufan You <ouuansteve@gmail.com>
-rw-r--r--plugins/git/README.md6
-rw-r--r--plugins/git/git.plugin.zsh6
2 files changed, 6 insertions, 6 deletions
diff --git a/plugins/git/README.md b/plugins/git/README.md
index b7f216813..e809e1bcd 100644
--- a/plugins/git/README.md
+++ b/plugins/git/README.md
@@ -183,8 +183,8 @@ plugins=(... git)
Following the recent push for removing racially-charged words from our technical vocabulary, the git plugin favors using
a branch name other than `master`. In this case, we favor the shorter, neutral and descriptive term `main`. This means
-that any aliases and functions that previously used `master`, will use `main` if that branch exists. We do this via the
-function `git_main_branch`.
+that any aliases and functions that previously used `master`, will use `main` if `master` doesn't exist. We do this via
+the function `git_main_branch`.
### Deprecated aliases
@@ -214,7 +214,7 @@ These are aliases that have been removed, renamed, or otherwise modified in a wa
| current_branch | Return the name of the current branch |
| git_current_user_name | Returns the `user.name` config value |
| git_current_user_email | Returns the `user.email` config value |
-| git_main_branch | Returns the name of the main branch: `main` if it exists, `master` otherwise |
+| git_main_branch | Returns the name of the main branch: `master` if it exists, `main` otherwise |
### Work in Progress (WIP)
diff --git a/plugins/git/git.plugin.zsh b/plugins/git/git.plugin.zsh
index 5a9ccff5c..6cae3dac2 100644
--- a/plugins/git/git.plugin.zsh
+++ b/plugins/git/git.plugin.zsh
@@ -27,10 +27,10 @@ function work_in_progress() {
# Check if main exists and use instead of master
function git_main_branch() {
- if [[ -n "$(git branch --list main)" ]]; then
- echo main
- else
+ if [[ -n "$(git branch --list master)" ]]; then
echo master
+ else
+ echo main
fi
}