summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Wu <lekensteyn@gmail.com>2013-11-23 00:32:17 +0100
committerPeter Wu <lekensteyn@gmail.com>2013-11-23 00:32:17 +0100
commit28b092d1e0b29e07f71f28bdb7bf7ffba465210c (patch)
tree5fa8408b7f9e965f552cde22325c0433f12ebe8e
parent033551b758ce400a2209ef2e8223abb3cf17ebed (diff)
downloadscripts-28b092d1e0b29e07f71f28bdb7bf7ffba465210c.tar.gz
git-log-describe: describe first tag following a commit
Instead of showing where a commit was derived from, use `--contains` to show a description relative to a tag containing the commit.
-rwxr-xr-xgit-log-describe.awk15
1 files changed, 12 insertions, 3 deletions
diff --git a/git-log-describe.awk b/git-log-describe.awk
index 27063c4..c0ab37e 100755
--- a/git-log-describe.awk
+++ b/git-log-describe.awk
@@ -1,6 +1,8 @@
#!/usr/bin/awk -f
-# Adds a "git describe" (nearest tag) output for `git log` (with support for
-# color escapes and --graph markers). --oneline is not supported.
+# Adds the first tag containing a commit for each git-log entry.
+# `git log --color` and `git log --graph` are supported. --oneline is not
+# supported (yet).
+# If there is no tag after the commit, no description is shown.
#
# Optional variables:
# -vcache={0|1} Enable a cache for git describe outputs. If set to 1,
@@ -9,6 +11,10 @@
# be created if non-existent. Implies -vcache=1.
# -vcache_ro={0|1} Set to 1 to prevent creating new files in cache.
#
+# NOTE: when cache is enabled, one must clear it when the `git describe` options
+# are changed (see variable "opts" below) or when a new tag is added before an
+# existing tag.
+#
# Copyright (c) 2013 Peter Wu <lekensteyn@gmail.com>
# Licensed under GPLv3 or any latter version
@@ -26,6 +32,9 @@ BEGIN {
if (cache_ro && !is_dir(cache_dir) || !mkdir_p(cache_dir))
cache_dir = "";
}
+
+ # Use `git-describe --contains` to show which tag contains this commit.
+ opts = "--contains";
}
{ print; }
@@ -97,7 +106,7 @@ function git_describe(hash) {
# cache entry was unavailable, get a description now.
if (!desc) {
- "git describe --first-parent " hash | getline desc;
+ "git describe " opts " " hash " 2>/dev/null" | getline desc;
# write description to cache if allowed.
if (cache_dir && desc && !cache_ro) {