diff options
author | Peter Wu <lekensteyn@gmail.com> | 2013-11-23 12:05:46 +0100 |
---|---|---|
committer | Peter Wu <lekensteyn@gmail.com> | 2013-11-23 12:05:46 +0100 |
commit | a165268ec8c6867216ee40744501c1867aaa6ddf (patch) | |
tree | 1a3442ac3297ca166d599d6847a8f83e74a2fae7 | |
parent | 7077bc737a34da664e6771bba7eee18aa60d1c6d (diff) | |
download | scripts-a165268ec8c6867216ee40744501c1867aaa6ddf.tar.gz |
git-log-describe: -vfast={0|1} toggle for speed
`--contains` does exactly what I need (show which tag contains the
commit), but it is very slow when getting deeper in the history.
(500 ms vs 30000ms for a subdirectory from v3.0..v3.13-rc1 with 100
commits.
For future reproduction, the command `git log v3.0..v3.13-rc1
drivers/net/wireless/rt2x00 | git-log-describe.awk` takes
12:20 minutes to complete for the slow mode (using `--contains`) where
it is finished in only 19 seconds for the fast mode (using
`--first-parent). After the cache is filled, this time gets reduced to
slightly more than a second.
-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; } |