-
Notifications
You must be signed in to change notification settings - Fork 141
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
git log --graph edges point the wrong way #71
Comments
Thanks for your feedback @jcassee . I will check this after the vacation. |
Hi @jcassee . You're right, git doesn't provide such an option. There is a work around to make the graph reasonable when the commits are shown bottom-up: forgit::log() {
forgit::inside_work_tree || return 1
local cmd opts full_opts flip
cmd="echo {} |grep -Eo '[a-f0-9]+' |head -1 |xargs -I% git show --color=always % $* | $forgit_pager"
opts="
$FORGIT_FZF_DEFAULT_OPTS
+s +m --tiebreak=index --preview=\"$cmd\"
--bind=\"enter:execute($cmd | LESS='-R' less)\"
--bind=\"ctrl-y:execute-silent(echo {} |grep -Eo '[a-f0-9]+' | head -1 | tr -d '\n' |${FORGIT_COPY_CMD:-pbcopy})\"
$FORGIT_LOG_FZF_OPTS
"
full_opts="$FZF_DEFAULT_OPTS $opts"
# if `reverse` option is NOT enabled, flip the '\' and '/' to make the log graph reasonable
[[ $full_opts != *"--reverse"* ]] && [[ $full_opts != *"=reverse"* ]] && flip=true
eval "git log --graph --color=always --format='%C(auto)%h%d %s %C(black)%C(bold)%cr' $* $forgit_emojify" |
if [[ $flip == "true" ]]; then sed -e 's#/#{slash}#' -e 's#\\#/#' -e 's#{slash}#\\#'; else cat; fi |
FZF_DEFAULT_OPTS="$opts" fzf
} But before we have a better implementation I do not want to merge it into the code base. The main reason is we don't find a not complicated way to check if reverse option is enabled for fzf. The above code does simple string pattern matching but we are not sure whether |
@wfxr Yeah, determining how fzf is used exactly is difficult. (By the way, the I know you did not want to, but maybe this is a good reason to allow customization of the |
@jcassee I understand your suggestion. Someone also mentioned this before. Because the extraction of the commit hash relies heavily on the output format of the git log I haven't adopted the suggestion before. But I will reconsider it. I will keep this issue open and try to find a relatively reasonable solution. |
Good point. But that means it will only replace the first slash, while there may be multiple. 😄 Anyway, I understand you want to think it over some more. It's a subtle issue. |
Hey any progress on this issue? :) Is there maybe an option to turn off the graph output? |
I believe we can close this now @wfxr, fish has the appropriate behavior as well |
Thanks, @wfxr! |
just as a heads up, I faced the same thing and added this to my
It displays correctly, only the typing box of |
Check list
Environment info
Problem / Steps to reproduce
The git log viewer calls
git log --graph
. Because the commits are shown bottom-up, the graph edges point the wrong way. See for example the log of forgit itself:I don't think it is possible to have git output a reverse graph (
--graph
and--reverse
are mutually exclusive). Maybe--graph
should be omitted from thegit log
command?The text was updated successfully, but these errors were encountered: