Skip to content

Commit

Permalink
[Search git log] improve compatibility with older git versions (#151)
Browse files Browse the repository at this point in the history
The git log format placeholder %as wasn't added until Git 2.25.0. Unfortunately, people are often stuck on older Git versions (one possibility is that their git binary is managed by their company). To resolve this, we swap out %as with %ad but pass in --date=short.
  • Loading branch information
kidonng authored Apr 15, 2021
1 parent e5f9def commit 8e25976
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions functions/__fzf_search_git_log.fish
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ function __fzf_search_git_log --description "Search the output of git log and pr
# See similar comment in __fzf_search_shell_variables.fish.
set --local --export SHELL (command --search fish)

set log_fmt_str '%C(bold blue)%h%C(reset) - %C(cyan)%as%C(reset) %C(yellow)%d%C(reset) %C(normal)%s%C(reset) %C(dim normal)[%an]%C(reset)'
# see documentation for git format placeholders at https://git-scm.com/docs/git-log#Documentation/git-log.txt-emnem
# %h gives you the abbreviated commit hash, which is useful for saving screen space, but we will have to expand it later below
set log_fmt_str '%C(bold blue)%h%C(reset) - %C(cyan)%ad%C(reset) %C(yellow)%d%C(reset) %C(normal)%s%C(reset) %C(dim normal)[%an]%C(reset)'
set selected_log_line (
# see documentation for git format placeholders at https://git-scm.com/docs/git-log#Documentation/git-log.txt-emnem
# %h gives you the abbreviated commit hash, which is useful for saving screen space, but we will have to expand it later below
git log --color=always --format=format:$log_fmt_str | \
git log --color=always --format=format:$log_fmt_str --date=short | \
fzf --ansi \
--tiebreak=index \
--preview='git show --color=always {1}' \
Expand Down

0 comments on commit 8e25976

Please sign in to comment.