summaryrefslogtreecommitdiff
path: root/cache.h
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2016-10-20 06:19:19 (GMT)
committerJunio C Hamano <gitster@pobox.com>2016-10-26 20:30:51 (GMT)
commitef2ed5013c4160284d9de18903bd4f7d0542d810 (patch)
tree6c11907a3c953aa672bfe70534fec122c22e4744 /cache.h
parent4ce742fc9c09cd3b95be309bc093f8fa54c15f96 (diff)
downloadgit-ef2ed5013c4160284d9de18903bd4f7d0542d810.zip
git-ef2ed5013c4160284d9de18903bd4f7d0542d810.tar.gz
git-ef2ed5013c4160284d9de18903bd4f7d0542d810.tar.bz2
find_unique_abbrev: use 4-buffer ring
Some code paths want to format multiple abbreviated sha1s in the same output line. Because we use a single static buffer for our return value, they have to either break their output into several calls or allocate their own arrays and use find_unique_abbrev_r(). Intead, let's mimic sha1_to_hex() and use a ring of several buffers, so that the return value stays valid through multiple calls. This shortens some of the callers, and makes it harder to for them to make a silly mistake. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'cache.h')
-rw-r--r--cache.h4
1 files changed, 2 insertions, 2 deletions
diff --git a/cache.h b/cache.h
index f7ee414..607fe6e 100644
--- a/cache.h
+++ b/cache.h
@@ -903,8 +903,8 @@ extern char *sha1_pack_index_name(const unsigned char *sha1);
* The result will be at least `len` characters long, and will be NUL
* terminated.
*
- * The non-`_r` version returns a static buffer which will be overwritten by
- * subsequent calls.
+ * The non-`_r` version returns a static buffer which remains valid until 4
+ * more calls to find_unique_abbrev are made.
*
* The `_r` variant writes to a buffer supplied by the caller, which must be at
* least `GIT_SHA1_HEXSZ + 1` bytes. The return value is the number of bytes