Re: [PATCH] git-disambiguate: disambiguate shorthand git ids
From: Sasha Levin
Date: Thu Dec 26 2024 - 17:33:08 EST
On Thu, Dec 26, 2024 at 05:05:55PM -0500, Sasha Levin wrote:
This also allows users to use shorter commit ID prefixes than normally
required, since we can correctly identify the intended commit using the
subject line as additional context.
With this script, and a git alias:
git config --global alias.klog '!sh -c '"'"'last=""; next_to_last=""; args=""; for arg in "$@"; do [ -n "$next_to_last" ] && args="$args $next_to_last"; next_to_last="$last"; last="$arg"; done; hash=$(git-disambiguate.sh "$next_to_last" "$last") && git log $args "$hash"'"'"' -'
We can have (git-log compatible) git-klog find the right commit for us:
$ git klog --oneline -1 cff8 '("net: phy: avoid ... *_led_polarity_set()")'
cff865c70071 net: phy: avoid undefined behavior in *_led_polarity_set()
Which means that folks should be able to use a fairly short abbreviated
commit IDs in messages, specially for commits with a long subject line.
--
Thanks,
Sasha