diff options
author | Linus Torvalds <torvalds@osdl.org> | 2006-05-03 17:21:08 -0700 |
---|---|---|
committer | Junio C Hamano <junkio@cox.net> | 2006-05-03 22:06:45 -0700 |
commit | dcb3450fd8785d76dd3d25aa49be66190aa5e7f3 (patch) | |
tree | d67f23c99110c10edb5383bf5d98dc0da16edd39 /diff.c | |
parent | 935e714204fe167aa6172a733e7131ee5b4577f4 (diff) | |
download | git-dcb3450fd8785d76dd3d25aa49be66190aa5e7f3.tar.gz git-dcb3450fd8785d76dd3d25aa49be66190aa5e7f3.tar.xz |
sha1_to_hex() usage cleanup
Somebody on the #git channel complained that the sha1_to_hex() thing uses
a static buffer which caused an error message to show the same hex output
twice instead of showing two different ones.
That's pretty easily rectified by making it uses a simple LRU of a few
buffers, which also allows some other users (that were aware of the buffer
re-use) to be written in a more straightforward manner.
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
Diffstat (limited to 'diff.c')
-rw-r--r-- | diff.c | 6 |
1 files changed, 2 insertions, 4 deletions
@@ -1018,14 +1018,12 @@ static void run_diff(struct diff_filepair *p, struct diff_options *o) } if (memcmp(one->sha1, two->sha1, 20)) { - char one_sha1[41]; int abbrev = o->full_index ? 40 : DEFAULT_ABBREV; - memcpy(one_sha1, sha1_to_hex(one->sha1), 41); len += snprintf(msg + len, sizeof(msg) - len, "index %.*s..%.*s", - abbrev, one_sha1, abbrev, - sha1_to_hex(two->sha1)); + abbrev, sha1_to_hex(one->sha1), + abbrev, sha1_to_hex(two->sha1)); if (one->mode == two->mode) len += snprintf(msg + len, sizeof(msg) - len, " %06o", one->mode); |