Skip to content

Commit

Permalink
Remove deferred execution in _forgit_log
Browse files Browse the repository at this point in the history
  • Loading branch information
carlfriedrich committed Nov 3, 2023
1 parent 94fe15d commit f37b74c
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions bin/git-forgit
Original file line number Diff line number Diff line change
Expand Up @@ -95,25 +95,30 @@ _forgit_is_file_tracked() {
git ls-files "$1" --error-unmatch &> /dev/null
}

_forgit_log_preview() {
sha=$1
shift
echo $sha | xargs -I% git show --color=always -U$_forgit_preview_context % -- "$@" | $_forgit_show_pager
}

# git commit viewer
_forgit_log() {
_forgit_inside_work_tree || return 1
local opts graph files log_format preview_cmd enter_cmd
local opts graph files log_format enter_cmd
files=$(sed -nE 's/.*-- (.*)/\1/p' <<< "$*") # extract files parameters for `git show` command
preview_cmd="echo {} | $_forgit_extract_sha | xargs -I% git show --color=always -U$_forgit_preview_context % -- $files | $_forgit_show_pager"
enter_cmd="echo {} | $_forgit_extract_sha | xargs -I% ${FORGIT} diff %^! $files"
enter_cmd="echo {1} | xargs -I% ${FORGIT} diff %^! $files"
opts="
$FORGIT_FZF_DEFAULT_OPTS
+s +m --tiebreak=index
--bind=\"enter:execute($enter_cmd)\"
--bind=\"ctrl-y:execute-silent(echo {} | $_forgit_extract_sha | ${FORGIT_COPY_CMD:-pbcopy})\"
--preview=\"$preview_cmd\"
--preview=\"$FORGIT log_preview {1} $file\"
$FORGIT_LOG_FZF_OPTS
"
graph=--graph
[[ $FORGIT_LOG_GRAPH_ENABLE == false ]] && graph=
log_format=${FORGIT_GLO_FORMAT:-$_forgit_log_format}
eval "git log $graph --color=always --format='$log_format' $FORGIT_LOG_GIT_OPTS $* $_forgit_emojify" |
git log $graph --color=always --format="$log_format" $FORGIT_LOG_GIT_OPTS $* $_forgit_emojify |
FZF_DEFAULT_OPTS="$opts" fzf
fzf_exit_code=$?
# exit successfully on 130 (ctrl-c/esc)
Expand Down Expand Up @@ -722,6 +727,7 @@ private_commands=(
"ignore_preview"
"revert_preview"
"yank_sha"
"log_preview"
)

cmd="$1"
Expand Down

0 comments on commit f37b74c

Please sign in to comment.