I usually have lots of git branches with various iterations of whatever I'm working on. And I lose track what each branch contains. git range-diff is great, but a bit tedious.
Here's a helper alias to "range compare" two branches. It finds their common ancestor, and range diffs them.
Usage: git range-compare rev1 [rev2]
~/.gitconfig:
[alias]
range-compare = "!f() { rev1=${1:?no branch to compare to}; rev2=${2:-HEAD}; git range-diff $(git merge-base $rev1 $rev2) $rev1 $rev2; }; f"
This is what I have to create pretty commit citations of the form d206a76d7d27 ("Linux 6.8-rc6").
Usage: git cite <commit-ish>
~/.gitconfig:
[alias]
cite = "!f() { git log -1 '--pretty=format:%H (\"%s\")%n' $1 | sed -e 's/\\([0-f]\\{12\\}\\)[0-f]*/\\1/'; }; f"
@jani comparing branches. I haven’t used your solution but the sl command helps me track the differences in my branches. Maybe these are different things.
@jani In the Mesa docs we recommend a 'git fixes' alias that could be repurposed for this:
> fixes = show -s --pretty='format:Fixes: %h (\"%s\")'
This seems to give a reasonably short SHA1 without the sed.
FWIW, the kernel has this in process/submitting-patches.rst
"'"
The following ``git config`` settings can be used […]:
[core]
abbrev = 12
[pretty]
fixes = Fixes: %h (\"%s\")
An example call::
$ git log -1 --pretty=fixes 54a4f0239f2e
Fixes: 54a4f0239f2e ("KVM: MMU: make kvm_mmu_zap_page() return the number of pages it actually freed")
"'"
/me wonders he is missing something that @jani's approach does better
@kernellogger @conor @jani @mattst88 I read that as grabbing the first 12 characters of the hash.
@jani Thanks for posting this! I've been missing it ever since I stopped having the drm maintainer tools installed on my system. Now I can just stuff that in my .gitconfig and off we go.
@jani Personally I have the following which seems equivalent:
[core]
abbrev = 12
[pretty]
cite = %h (\"%s\")
[alias]
cite = log -1 --pretty=cite
@broonie @conor @jani @mattst88
sure, but there is a way easier way to do that, see https://fosstodon.org/@kernellogger/112012959061666799