Merge pull request #109 from cjappl/git-cherry

git cherry working in fish shell
This commit is contained in:
Chris Apple 2020-09-03 10:49:58 -07:00 committed by GitHub
commit 522547af28
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -201,6 +201,26 @@ function forgit::clean
echo 'Nothing to clean.'
end
function forgit::cherry::pick
forgit::inside_work_tree || return 1
set base (git branch --show-current)
if not count $argv > /dev/null
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
-m -0
"
echo $base
echo $target
git cherry "$base" "$target" --abbrev -v | cut -d ' ' -f2- |
env FZF_DEFAULT_OPTS="$opts" fzf --preview="$preview" | cut -d' ' -f1 |
xargs -I% git cherry-pick %
end
# git ignore generator
if test -z "$FORGIT_GI_REPO_REMOTE"
set -x FORGIT_GI_REPO_REMOTE https://github.com/dvcs/gitignore
@ -342,4 +362,10 @@ if test -z "$FORGIT_NO_ALIASES"
else
alias gss 'forgit::stash::show'
end
if test -n "$forgit_cherry_pick"
alias $forgit_cherry_pick 'forgit::cherry::pick'
else
alias gcp 'forgit::cherry::pick'
end
end