From 4b8234a9ff9d97a3d4cb8bac2c6e14f58abe1654 Mon Sep 17 00:00:00 2001 From: Tim <45259958+carlfriedrich@users.noreply.github.com> Date: Sat, 18 Mar 2023 12:10:26 +0100 Subject: [PATCH] Only show available cherry picks in preview (#293) This is a follow-up to #266, which already switched to showing only available commits during cherry-picking. This patch does the same for the branch preview in _forgit_cherry_pick_from_branch. --- bin/git-forgit | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/bin/git-forgit b/bin/git-forgit index 149d617..506960d 100755 --- a/bin/git-forgit +++ b/bin/git-forgit @@ -315,13 +315,17 @@ _forgit_cherry_pick() { _forgit_cherry_pick_from_branch() { _forgit_inside_work_tree || return 1 - local cmd preview opts branch exitval input_branch args + local cmd preview opts branch exitval input_branch args base + + base=$(git branch --show-current) + [[ -z "$base" ]] && echo "Current commit is not on a branch." && return 1 + args=("$@") if [[ $# -ne 0 ]]; then input_branch=${args[0]} fi cmd="git branch --color=always --all | LC_ALL=C sort -k1.1,1.1 -rs" - preview="git log {1} $_forgit_log_preview_options" + preview="git log --right-only --color=always --cherry-pick --oneline $base...{1}" opts=" $FORGIT_FZF_DEFAULT_OPTS +s +m --tiebreak=index --header-lines=1