diff options
-rwxr-xr-x | git-log-describe.awk | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/git-log-describe.awk b/git-log-describe.awk index 1ab3a98..a491e13 100755 --- a/git-log-describe.awk +++ b/git-log-describe.awk @@ -10,6 +10,10 @@ # -vcache_dir=DIR Use DIR to store cached git-describe results. DIR will # be created if non-existent. Implies -vcache=1. # -vcache_ro={0|1} Set to 1 to prevent creating new files in cache. +# -vfast={0|1} If 0 (default), then --contains will be used which +# relates to the first tag containing this commit. +# Otherwise, --first-parent will be used which relates to +# the tag on which the commit is based. # # 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 @@ -28,15 +32,22 @@ BEGIN { cache_dir = cache_dir "/.git/describe-cache.d"; } + if (fast) { + # Faster, but it relates to base of this commit. + opts = "--first-parent --tags"; + if (cache_dir) cache_dir = cache_dir "/first-parent"; + } else { + # Slower, but relates to the first tag containing this commit. + opts = "--contains"; + if (cache_dir) cache_dir = cache_dir "/contains"; + } + if (cache_dir) { # Skip cache directory if non-existent and read only or if the # directory cannot be created. 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; } |