207d29b716301c77392ae140b1482eeba44e9102

Author
Zeeshan <equbalzeeshan@gmail.com>
Committer
Marc Cornellà <marc@mcornella.com>
Date

Message

fix(git)!: standardize `git pull --rebase` aliases (#11224)

BREAKING CHANGE: The alias `gup` for `git pull --rebase` and its derivatives
are replaced by `gpr` for standardization. This means the previous aliases will
no longer be available after a few months. Meanwhile, the original aliases are
still working, with a deprecation notice.
See https://github.com/ohmyzsh/ohmyzsh/blob/master/plugins/git/README.md#deprecated-aliases
for the full list of deprecated aliases.

Fixes #11104
Closes #11224

Co-authored-by: Marc Cornellà <marc@mcornella.com>

Diff

This diff is truncated to protect this page.

  1diff --git a/plugins/git/README.md b/plugins/git/README.md
  2index 724965302693e9f6acf770ca25f78221208f9bf7..93dc8ccea5096081dd6cb63ed23f321baf199bbb 100644
  3--- a/plugins/git/README.md
  4+++ b/plugins/git/README.md
  5@@ -10,207 +10,205 @@ plugins=(... git)
  6 
  7 ## Aliases
  8 
  9-| Alias                  | Command                                                                                                                                                             |
 10-| :--------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
 11-| `grt`                  | `cd "$(git rev-parse --show-toplevel \|\| echo .)"`                                                                                                                 |
 12-| `ggpnp`                | `ggl && ggp`                                                                                                                                                        |
 13-| `ggpur`                | `ggu`                                                                                                                                                               |
 14-| `g`                    | `git`                                                                                                                                                               |
 15-| `ga`                   | `git add`                                                                                                                                                           |
 16-| `gaa`                  | `git add --all`                                                                                                                                                     |
 17-| `gapa`                 | `git add --patch`                                                                                                                                                   |
 18-| `gau`                  | `git add --update`                                                                                                                                                  |
 19-| `gav`                  | `git add --verbose`                                                                                                                                                 |
 20-| `gwip`                 | `git add -A; git rm $(git ls-files --deleted) 2> /dev/null; git commit --no-verify --no-gpg-sign --message "--wip-- [skip ci]"`                                     |
 21-| `gam`                  | `git am`                                                                                                                                                            |
 22-| `gama`                 | `git am --abort`                                                                                                                                                    |
 23-| `gamc`                 | `git am --continue`                                                                                                                                                 |
 24-| `gamscp`               | `git am --show-current-patch`                                                                                                                                       |
 25-| `gams`                 | `git am --skip`                                                                                                                                                     |
 26-| `gap`                  | `git apply`                                                                                                                                                         |
 27-| `gapt`                 | `git apply --3way`                                                                                                                                                  |
 28-| `gbs`                  | `git bisect`                                                                                                                                                        |
 29-| `gbsb`                 | `git bisect bad`                                                                                                                                                    |
 30-| `gbsg`                 | `git bisect good`                                                                                                                                                   |
 31-| `gbsn`                 | `git bisect new`                                                                                                                                                    |
 32-| `gbso`                 | `git bisect old`                                                                                                                                                    |
 33-| `gbsr`                 | `git bisect reset`                                                                                                                                                  |
 34-| `gbss`                 | `git bisect start`                                                                                                                                                  |
 35-| `gbl`                  | `git blame -w`                                                                                                                                                      |
 36-| `gb`                   | `git branch`                                                                                                                                                        |
 37-| `gba`                  | `git branch --all`                                                                                                                                                  |
 38-| `gbd`                  | `git branch --delete`                                                                                                                                               |
 39-| `gbD`                  | `git branch --delete --force`                                                                                                                                       |
 40-| `gbgd`                 | `LANG=C git branch --no-color -vv \| grep ": gone\]" \| awk '"'"'{print $1}'"'"' \| xargs git branch -d`                                                            |
 41-| `gbgD`                 | `LANG=C git branch --no-color -vv \| grep ": gone\]" \| awk '"'"'{print $1}'"'"' \| xargs git branch -D`                                                            |
 42-| `gbm`                  | `git branch --move`                                                                                                                                                 |
 43-| `gbnm`                 | `git branch --no-merged`                                                                                                                                            |
 44-| `gbr`                  | `git branch --remote`                                                                                                                                               |
 45-| `ggsup`                | `git branch --set-upstream-to=origin/$(git_current_branch)`                                                                                                         |
 46-| `gbg`                  | `LANG=C git branch -vv \| grep ": gone\]"`                                                                                                                          |
 47-| `gco`                  | `git checkout`                                                                                                                                                      |
 48-| `gcor`                 | `git checkout --recurse-submodules`                                                                                                                                 |
 49-| `gcb`                  | `git checkout -b`                                                                                                                                                   |
 50-| `gcd`                  | `git checkout $(git_develop_branch)`                                                                                                                                |
 51-| `gcm`                  | `git checkout $(git_main_branch)`                                                                                                                                   |
 52-| `gcp`                  | `git cherry-pick`                                                                                                                                                   |
 53-| `gcpa`                 | `git cherry-pick --abort`                                                                                                                                           |
 54-| `gcpc`                 | `git cherry-pick --continue`                                                                                                                                        |
 55-| `gclean`               | `git clean --interactive -d`                                                                                                                                        |
 56-| `gcl`                  | `git clone --recurse-submodules`                                                                                                                                    |
 57-| `gccd`                 | `git clone --recurse-submodules "$@" && cd "$(basename $\_ .git)"`                                                                                                  |
 58-| `gcam`                 | `git commit --all --message`                                                                                                                                        |
 59-| `gcas`                 | `git commit --all --signoff`                                                                                                                                        |
 60-| `gcasm`                | `git commit --all --signoff --message`                                                                                                                              |
 61-| `gcmsg`                | `git commit --message`                                                                                                                                              |
 62-| `gcsm`                 | `git commit --signoff --message`                                                                                                                                    |
 63-| `gc`                   | `git commit --verbose`                                                                                                                                              |
 64-| `gca`                  | `git commit --verbose --all`                                                                                                                                        |
 65-| `gca!`                 | `git commit --verbose --all --amend`                                                                                                                                |
 66-| `gcan!`                | `git commit --verbose --all --no-edit --amend`                                                                                                                      |
 67-| `gcans!`               | `git commit --verbose --all --signoff --no-edit --amend`                                                                                                            |
 68-| `gc!`                  | `git commit --verbose --amend`                                                                                                                                      |
 69-| `gcn!`                 | `git commit --verbose --no-edit --amend`                                                                                                                            |
 70-| `gcs`                  | `git commit -S`                                                                                                                                                     |
 71-| `gcss`                 | `git commit -S -s`                                                                                                                                                  |
 72-| `gcssm`                | `git commit -S -s -m`                                                                                                                                               |
 73-| `gcf`                  | `git config --list`                                                                                                                                                 |
 74-| `gdct`                 | `git describe --tags $(git rev-list --tags --max-count=1)`                                                                                                          |
 75-| `gd`                   | `git diff`                                                                                                                                                          |
 76-| `gdca`                 | `git diff --cached`                                                                                                                                                 |
 77-| `gdcw`                 | `git diff --cached --word-diff`                                                                                                                                     |
 78-| `gds`                  | `git diff --staged`                                                                                                                                                 |
 79-| `gdw`                  | `git diff --word-diff`                                                                                                                                              |
 80-| `gdv`                  | `git diff -w "$@" \| view -`                                                                                                                                        |
 81-| `gdup`                 | `git diff @{upstream}`                                                                                                                                              |
 82-| `gdnolock`             | `git diff $@ ":(exclude)package-lock.json" ":(exclude)\*.lock"`                                                                                                     |
 83-| `gdt`                  | `git diff-tree --no-commit-id --name-only -r`                                                                                                                       |
 84-| `gf`                   | `git fetch`                                                                                                                                                         |
 85-| `gfa`                  | `git fetch --all --prune`                                                                                                                                           |
 86-| `gfo`                  | `git fetch origin`                                                                                                                                                  |
 87-| `gg`                   | `git gui citool`                                                                                                                                                    |
 88-| `gga`                  | `git gui citool --amend`                                                                                                                                            |
 89-| `ghh`                  | `git help`                                                                                                                                                          |
 90-| `glgg`                 | `git log --graph`                                                                                                                                                   |
 91-| `glgga`                | `git log --graph --decorate --all`                                                                                                                                  |
 92-| `glgm`                 | `git log --graph --max-count=10`                                                                                                                                    |
 93-| `glod`                 | `git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ad) %C(bold blue)<%an>%Creset'`                                                            |
 94-| `glods`                | `git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ad) %C(bold blue)<%an>%Creset' --date=short`                                               |
 95-| `glol`                 | `git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ar) %C(bold blue)<%an>%Creset'`                                                            |
 96-| `glola`                | `git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ar) %C(bold blue)<%an>%Creset' --all`                                                      |
 97-| `glols`                | `git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ar) %C(bold blue)<%an>%Creset' --stat`                                                     |
 98-| `glo`                  | `git log --oneline --decorate`                                                                                                                                      |
 99-| `glog`                 | `git log --oneline --decorate --graph`                                                                                                                              |
100-| `gloga`                | `git log --oneline --decorate --graph --all`                                                                                                                        |
101-| `glp`                  | `git log --pretty=<format>`                                                                                                                                         |
102-| `glg`                  | `git log --stat`                                                                                                                                                    |
103-| `glgp`                 | `git log --stat --patch`                                                                                                                                            |
104-| `gignored`             | `git ls-files -v \| grep "^[[:lower:]]"`                                                                                                                            |
105diff --git a/plugins/git/git.plugin.zsh b/plugins/git/git.plugin.zsh
106index 48937cb83778c3a0e49ad8f61b511310ef835a58..5ec2bbe2bb59006f118a04914b2a923b26cdc972 100644
107--- a/plugins/git/git.plugin.zsh
108+++ b/plugins/git/git.plugin.zsh
109@@ -246,12 +246,12 @@ alias gmom='git merge origin/$(git_main_branch)'
110 alias gmum='git merge upstream/$(git_main_branch)'
111 alias gmtl='git mergetool --no-prompt'
112 alias gmtlvim='git mergetool --no-prompt --tool=vimdiff'
113+
114 alias gl='git pull'
115 alias gpr='git pull --rebase'
116-alias gup='git pull --rebase'
117-alias gupa='git pull --rebase --autostash'
118-alias gupav='git pull --rebase --autostash --verbose'
119-alias gupv='git pull --rebase --verbose'
120+alias gprv='git pull --rebase -v'
121+alias gpra='git pull --rebase --autostash'
122+alias gprav='git pull --rebase --autostash -v'
123 
124 function ggu() {
125   [[ "$#" != 1 ]] && local b="$(git_current_branch)"
126@@ -259,8 +259,8 @@ function ggu() {
127 }
128 compdef _git ggu=git-checkout
129 
130-alias gupom='git pull --rebase origin $(git_main_branch)'
131-alias gupomi='git pull --rebase=interactive origin $(git_main_branch)'
132+alias gprom='git pull --rebase origin $(git_main_branch)'
133+alias gpromi='git pull --rebase=interactive origin $(git_main_branch)'
134 alias ggpull='git pull origin "$(git_current_branch)"'
135 
136 function ggl() {
137@@ -388,3 +388,20 @@ alias gk='\gitk --all --branches &!'
138 alias gke='\gitk --all $(git log --walk-reflogs --pretty=%h) &!'
139 
140 unset git_version
141+
142+# Logic for adding warnings on deprecated aliases
143+local old_alias new_alias
144+for old_alias new_alias (
145+  # TODO(2023-10-19): remove deprecated `git pull --rebase` aliases
146+  gup     gpr
147+  gupv    gprv
148+  gupa    gpra
149+  gupav   gprav
150+  gupom   gprom
151+  gupomi  gpromi
152+); do
153+  aliases[$old_alias]="
154+    print -Pu2 \"%F{yellow}[oh-my-zsh] '%F{red}${old_alias}%F{yellow}' is a deprecated alias, using '%F{green}${new_alias}%F{yellow}' instead.%f\"
155+    $new_alias"
156+done
157+unset old_alias new_alias