git log --decorate
adds information about related refs to the log output:
commit 9e895ace5d82df8929b16f58e9f515f6d54ab82d (tag: v3.10-rc7)
Author: Linus Torvalds <torvalds@linux-foundation.org>
Date: Sat Jun 22 09:47:31 2013 -1000
Linux 3.10-rc7
This information helps tracking which tag (or branch) contains this commit. When viewing a restricted set of files (say, a subdirectory), there does not have to be a tag for those commits. Is there a way to put a reference to a tag in the log output?
I previously mentioned git describe
, but that yields v3.10-rc7-135-g98b6ed0
which is relative to a tag of branch where this change was committed. What I am looking for is a tag name between commits.
For clarity, this is the current situation:
$ git log --decorate --oneline
98b6ed0 (HEAD, origin/master, master) Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net
1a506e4 Merge branch 'drm-fixes' of git://people.freedesktop.org/~airlied/linux
578a131 dlci: validate the net device in dlci_del()
11eb264 dlci: acquire rtnl_lock before calling __dev_get_by_name()
...
9e895ac (tag: v3.10-rc7) Linux 3.10-rc7
What I want to have is something like:
98b6ed0 (v3.10-rc7+, HEAD, origin/master, master) Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net
1a506e4 (v3.10-rc7+) Merge branch 'drm-fixes' of git://people.freedesktop.org/~airlied/linux
578a131 (v3.10-rc7+) dlci: validate the net device in dlci_del()
11eb264 (v3.10-rc7+) dlci: acquire rtnl_lock before calling __dev_get_by_name()
...
9e895ac (tag: v3.10-rc7) Linux 3.10-rc7
Using git describe
's output instead of the commit hash would show something like:
$ git log --decorate --oneline -n4 | awk '{system("git describe " $1 " |tr -d '\''\n'\''");$1="";print}'
v3.10-rc7-135-g98b6ed0 (HEAD, origin/master, master) Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net
v3.10-rc7-54-g1a506e4 Merge branch 'drm-fixes' of git://people.freedesktop.org/~airlied/linux
v3.10-rc6-81-g578a131 dlci: validate the net device in dlci_del()
v3.10-rc6-80-g11eb264 dlci: acquire rtnl_lock before calling __dev_get_by_name()
...
v3.10-rc7 (tag: v3.10-rc7) Linux 3.10-rc7
As you can see, older tag names are used as reference point rather than the point where the commit got merged. For illustation purposes, I am using git log --oneline
here, but I actually want to use fuller output, e.g. git log -p --stat
.