mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-05-27 16:51:15 -03:00
[git completions] Shorten commit SHA ourselves
This is much quicker - on the order of 100ms vs 50ms. We shorten to 10 characters, which is statistically suitable - 3 out of 600k commits in the linux kernel need 11 characters.
This commit is contained in:
@@ -6,7 +6,15 @@ function __fish_git_commits
|
||||
# This allows filtering by subject with the new pager!
|
||||
# Because even subject lines can be quite long,
|
||||
# trim them (abbrev'd hash+tab+subject) to 73 characters
|
||||
command git log --pretty=tformat:"%h"\t"%<(64,trunc)%s" --all --max-count=1000 2>/dev/null
|
||||
#
|
||||
# Hashes we just truncate ourselves to 10 characters, without disambiguating.
|
||||
# That technically means that sometimes we don't give usable SHAs,
|
||||
# but according to https://stackoverflow.com/a/37403152/3150338,
|
||||
# that happens for 3 commits out of 600k.
|
||||
# For fish, at the time of writing, out of 12200 commits, 7 commits need 8 characters.
|
||||
# And since this takes about 1/3rd of the time that disambiguating takes...
|
||||
command git log --pretty=tformat:"%H"\t"%<(64,trunc)%s" --all --max-count=1000 2>/dev/null \
|
||||
| string replace -r '^([0-9a-f]{10})[0-9a-f]*\t(.*)' '$1\t$2'
|
||||
end
|
||||
|
||||
function __fish_git_recent_commits
|
||||
|
||||
Reference in New Issue
Block a user