f1934d2c769e43d87fd6b2138bed90ed6b1455fe

Author
hanskr <hanskr@gmail.com>
Committer
GitHub <noreply@github.com>
Date

Message

fix(git): improve ggu, ggl, gp, ggfl, ggp functions (#13370)

Co-authored-by: Hans Kristian Kismul <hans.kristian.kismul@finn.no>

Diff

 1diff --git a/plugins/git/git.plugin.zsh b/plugins/git/git.plugin.zsh
 2index adca1c3c5b3db2ba8300f37e093dc631dfde3ca0..a0052891aae2fbcbf7d05538f5b70e5357c3e634 100644
 3--- a/plugins/git/git.plugin.zsh
 4+++ b/plugins/git/git.plugin.zsh
 5@@ -280,10 +280,11 @@ alias gpra='git pull --rebase --autostash'
 6 alias gprav='git pull --rebase --autostash -v'
 7 
 8 function ggu() {
 9-  [[ "$#" != 1 ]] && local b="$(git_current_branch)"
10-  git pull --rebase origin "${b:=$1}"
11+  local b
12+  [[ "$#" != 1 ]] && b="$(git_current_branch)"
13+  git pull --rebase origin "${b:-$1}"
14 }
15-compdef _git ggu=git-checkout
16+compdef _git ggu=git-pull
17 
18 alias gprom='git pull --rebase origin $(git_main_branch)'
19 alias gpromi='git pull --rebase=interactive origin $(git_main_branch)'
20@@ -295,11 +296,12 @@ function ggl() {
21   if [[ "$#" != 0 ]] && [[ "$#" != 1 ]]; then
22     git pull origin "${*}"
23   else
24-    [[ "$#" == 0 ]] && local b="$(git_current_branch)"
25-    git pull origin "${b:=$1}"
26+    local b
27+    [[ "$#" == 0 ]] && b="$(git_current_branch)"
28+    git pull origin "${b:-$1}"
29   fi
30 }
31-compdef _git ggl=git-checkout
32+compdef _git ggl=git-pull
33 
34 alias gluc='git pull upstream $(git_current_branch)'
35 alias glum='git pull upstream $(git_main_branch)'
36@@ -307,10 +309,11 @@ alias gp='git push'
37 alias gpd='git push --dry-run'
38 
39 function ggf() {
40-  [[ "$#" != 1 ]] && local b="$(git_current_branch)"
41-  git push --force origin "${b:=$1}"
42+  local b
43+  [[ "$#" != 1 ]] && b="$(git_current_branch)"
44+  git push --force origin "${b:-$1}"
45 }
46-compdef _git ggf=git-checkout
47+compdef _git ggf=git-push
48 
49 alias gpf!='git push --force'
50 is-at-least 2.30 "$git_version" \
51@@ -318,10 +321,11 @@ is-at-least 2.30 "$git_version" \
52   || alias gpf='git push --force-with-lease'
53 
54 function ggfl() {
55-  [[ "$#" != 1 ]] && local b="$(git_current_branch)"
56-  git push --force-with-lease origin "${b:=$1}"
57+  local b
58+  [[ "$#" != 1 ]] && b="$(git_current_branch)"
59+  git push --force-with-lease origin "${b:-$1}"
60 }
61-compdef _git ggfl=git-checkout
62+compdef _git ggfl=git-push
63 
64 alias gpsup='git push --set-upstream origin $(git_current_branch)'
65 is-at-least 2.30 "$git_version" \
66@@ -336,11 +340,12 @@ function ggp() {
67   if [[ "$#" != 0 ]] && [[ "$#" != 1 ]]; then
68     git push origin "${*}"
69   else
70-    [[ "$#" == 0 ]] && local b="$(git_current_branch)"
71-    git push origin "${b:=$1}"
72+    local b
73+    [[ "$#" == 0 ]] && b="$(git_current_branch)"
74+    git push origin "${b:-$1}"
75   fi
76 }
77-compdef _git ggp=git-checkout
78+compdef _git ggp=git-push
79 
80 alias gpu='git push upstream'
81 alias grb='git rebase'