From f1934d2c769e43d87fd6b2138bed90ed6b1455fe Mon Sep 17 00:00:00 2001 From: hanskr Date: Tue, 21 Oct 2025 10:48:56 +0200 Subject: [PATCH] fix(git): improve ggu, ggl, gp, ggfl, ggp functions (#13370) Co-authored-by: Hans Kristian Kismul --- plugins/git/git.plugin.zsh | 35 ++++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/plugins/git/git.plugin.zsh b/plugins/git/git.plugin.zsh index adca1c3c5..a0052891a 100644 --- a/plugins/git/git.plugin.zsh +++ b/plugins/git/git.plugin.zsh @@ -280,10 +280,11 @@ alias gpra='git pull --rebase --autostash' alias gprav='git pull --rebase --autostash -v' function ggu() { - [[ "$#" != 1 ]] && local b="$(git_current_branch)" - git pull --rebase origin "${b:=$1}" + local b + [[ "$#" != 1 ]] && b="$(git_current_branch)" + git pull --rebase origin "${b:-$1}" } -compdef _git ggu=git-checkout +compdef _git ggu=git-pull alias gprom='git pull --rebase origin $(git_main_branch)' alias gpromi='git pull --rebase=interactive origin $(git_main_branch)' @@ -295,11 +296,12 @@ function ggl() { if [[ "$#" != 0 ]] && [[ "$#" != 1 ]]; then git pull origin "${*}" else - [[ "$#" == 0 ]] && local b="$(git_current_branch)" - git pull origin "${b:=$1}" + local b + [[ "$#" == 0 ]] && b="$(git_current_branch)" + git pull origin "${b:-$1}" fi } -compdef _git ggl=git-checkout +compdef _git ggl=git-pull alias gluc='git pull upstream $(git_current_branch)' alias glum='git pull upstream $(git_main_branch)' @@ -307,10 +309,11 @@ alias gp='git push' alias gpd='git push --dry-run' function ggf() { - [[ "$#" != 1 ]] && local b="$(git_current_branch)" - git push --force origin "${b:=$1}" + local b + [[ "$#" != 1 ]] && b="$(git_current_branch)" + git push --force origin "${b:-$1}" } -compdef _git ggf=git-checkout +compdef _git ggf=git-push alias gpf!='git push --force' is-at-least 2.30 "$git_version" \ @@ -318,10 +321,11 @@ is-at-least 2.30 "$git_version" \ || alias gpf='git push --force-with-lease' function ggfl() { - [[ "$#" != 1 ]] && local b="$(git_current_branch)" - git push --force-with-lease origin "${b:=$1}" + local b + [[ "$#" != 1 ]] && b="$(git_current_branch)" + git push --force-with-lease origin "${b:-$1}" } -compdef _git ggfl=git-checkout +compdef _git ggfl=git-push alias gpsup='git push --set-upstream origin $(git_current_branch)' is-at-least 2.30 "$git_version" \ @@ -336,11 +340,12 @@ function ggp() { if [[ "$#" != 0 ]] && [[ "$#" != 1 ]]; then git push origin "${*}" else - [[ "$#" == 0 ]] && local b="$(git_current_branch)" - git push origin "${b:=$1}" + local b + [[ "$#" == 0 ]] && b="$(git_current_branch)" + git push origin "${b:-$1}" fi } -compdef _git ggp=git-checkout +compdef _git ggp=git-push alias gpu='git push upstream' alias grb='git rebase'