From 3faab44f666cd10137eae3d34b8c55776ef54f09 Mon Sep 17 00:00:00 2001 From: Carlos de Paula Date: Mon, 8 Mar 2021 20:07:54 -0300 Subject: [PATCH 1/3] Use argument to create new branch on gcb --- forgit.plugin.zsh | 1 + 1 file changed, 1 insertion(+) diff --git a/forgit.plugin.zsh b/forgit.plugin.zsh index 94f75fd..8bad968 100755 --- a/forgit.plugin.zsh +++ b/forgit.plugin.zsh @@ -184,6 +184,7 @@ forgit::rebase() { forgit::checkout::branch() { forgit::inside_work_tree || return 1 + [[ $# -ne 0 ]] && { git checkout -b "$*"; return $?; } local cmd preview opts cmd="git branch --color=always --verbose --all --format=\"%(if:equals=HEAD)%(refname:strip=3)%(then)%(else)%(refname:short)%(end)\" $* $forgit_emojify | sed '/^$/d'" preview="git log {} --graph --pretty=format:'%C(auto)%h%d %s %C(black)%C(bold)%cr%Creset' --color=always --abbrev-commit --date=relative" From 58ae7dce8707c20b6bfc12878dcdd8885554a634 Mon Sep 17 00:00:00 2001 From: Christopher Apple Date: Fri, 12 Mar 2021 12:58:32 -0800 Subject: [PATCH 2/3] first attempt at fixing both --- conf.d/forgit.plugin.fish | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/conf.d/forgit.plugin.fish b/conf.d/forgit.plugin.fish index d6bede5..0a8047a 100644 --- a/conf.d/forgit.plugin.fish +++ b/conf.d/forgit.plugin.fish @@ -61,7 +61,6 @@ function forgit::diff -d "git diff viewer" forgit::inside_work_tree || return 1 if count $argv > /dev/null if git rev-parse "$1" > /dev/null 2>&1 - #set commit "$1" && set files ("${@:2}") set commit "$1" && set files "$2" else set files "$argv" @@ -171,6 +170,11 @@ end function forgit::checkout::branch -d "git checkout branch selector" forgit::inside_work_tree || return 1 + if count $argv > /dev/null + git checkout -b $argv[1] + git status --short + end + set cmd "git branch --color=always --verbose --all --format=\"%(if:equals=HEAD)%(refname:strip=3)%(then)%(else)%(refname:short)%(end)\" $argv $forgit_emojify | sed '/^\$/d'" set preview "git log {} --graph --pretty=format:'%C(auto)%h%d %s %C(black)%C(bold)%cr%Creset' --color=always --abbrev-commit --date=relative" @@ -262,9 +266,12 @@ function forgit::rebase -d "git rebase " --bind=\"ctrl-y:execute-silent(echo {} |grep -Eo '[a-f0-9]+' | head -1 | tr -d '[:space:]' |$copy_cmd)\" $FORGIT_REBASE_FZF_OPTS " - eval "$cmd" | FZF_DEFAULT_OPTS="$opts" fzf --preview="$preview" | - grep -Eo '[a-f0-9]+' | head -1 | - xargs -I% git rebase -i % + set commit (eval "$cmd" | FZF_DEFAULT_OPTS="$opts" fzf --preview="$preview" | + grep -Eo '[a-f0-9]+' | head -1) + + if test $commit + git rebase -i "$commit" + end end # git ignore generator From 74724a80cba762e6f378561b21f64e5ba3c2ccf3 Mon Sep 17 00:00:00 2001 From: Christopher Apple Date: Fri, 12 Mar 2021 13:15:48 -0800 Subject: [PATCH 3/3] Moved to new argument names version of arg parsing --- conf.d/forgit.plugin.fish | 16 ++++++++-------- forgit.plugin.zsh | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/conf.d/forgit.plugin.fish b/conf.d/forgit.plugin.fish index 0a8047a..9aa197c 100644 --- a/conf.d/forgit.plugin.fish +++ b/conf.d/forgit.plugin.fish @@ -57,7 +57,7 @@ function forgit::log -d "git commit viewer" end ## git diff viewer -function forgit::diff -d "git diff viewer" +function forgit::diff -d "git diff viewer" forgit::inside_work_tree || return 1 if count $argv > /dev/null if git rev-parse "$1" > /dev/null 2>&1 @@ -167,12 +167,13 @@ function forgit::checkout::file -d "git checkout-file selector" echo 'Nothing to restore.' end -function forgit::checkout::branch -d "git checkout branch selector" +function forgit::checkout::branch -d "git checkout branch selector" --argument-names 'branch_name' forgit::inside_work_tree || return 1 - if count $argv > /dev/null - git checkout -b $argv[1] + if test -n "$branch_name" + git checkout -b "$branch_name" git status --short + return end set cmd "git branch --color=always --verbose --all --format=\"%(if:equals=HEAD)%(refname:strip=3)%(then)%(else)%(refname:short)%(end)\" $argv $forgit_emojify | sed '/^\$/d'" @@ -220,14 +221,13 @@ function forgit::clean -d "git clean selector" echo 'Nothing to clean.' end -function forgit::cherry::pick -d "git cherry-picking" +function forgit::cherry::pick -d "git cherry-picking" --argument-names 'target' forgit::inside_work_tree || return 1 set base (git branch --show-current) - if not count $argv > /dev/null + if test -n "$target" echo "Please specify target branch" return 1 end - set target $argv[1] set preview "echo {1} | xargs -I% git show --color=always % | $forgit_show_pager" set opts " $FORGIT_FZF_DEFAULT_OPTS @@ -241,7 +241,7 @@ function forgit::cherry::pick -d "git cherry-picking" end -function forgit::rebase -d "git rebase " +function forgit::rebase -d "git rebase" forgit::inside_work_tree || return 1 if set -q FORGIT_LOG_GRAPH_ENABLE diff --git a/forgit.plugin.zsh b/forgit.plugin.zsh index 8bad968..a48b267 100755 --- a/forgit.plugin.zsh +++ b/forgit.plugin.zsh @@ -186,7 +186,7 @@ forgit::checkout::branch() { forgit::inside_work_tree || return 1 [[ $# -ne 0 ]] && { git checkout -b "$*"; return $?; } local cmd preview opts - cmd="git branch --color=always --verbose --all --format=\"%(if:equals=HEAD)%(refname:strip=3)%(then)%(else)%(refname:short)%(end)\" $* $forgit_emojify | sed '/^$/d'" + cmd="git branch --color=always --verbose --all --format=\"%(if:equals=HEAD)%(refname:strip=3)%(then)%(else)%(refname:short)%(end)\" $forgit_emojify | sed '/^$/d'" preview="git log {} --graph --pretty=format:'%C(auto)%h%d %s %C(black)%C(bold)%cr%Creset' --color=always --abbrev-commit --date=relative" opts=" $FORGIT_FZF_DEFAULT_OPTS