Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRené Scharfe <l.s.r@web.de>2017-07-08 13:35:35 +0300
committerJunio C Hamano <gitster@pobox.com>2017-07-11 00:24:36 +0300
commit42c78a216e751cfa2720c8276c9e9f2b81640e6b (patch)
treeff12c046af74e524d80ec247f8039592337afee6 /sha1_name.c
parent8c8e978f5719c6a58fb998742207bf907f963143 (diff)
use DIV_ROUND_UP
Convert code that divides and rounds up to use DIV_ROUND_UP to make the intent clearer and reduce the number of magic constants. Signed-off-by: Rene Scharfe <l.s.r@web.de> Reviewed-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'sha1_name.c')
-rw-r--r--sha1_name.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/sha1_name.c b/sha1_name.c
index 5e2ec37b65..f7b6242914 100644
--- a/sha1_name.c
+++ b/sha1_name.c
@@ -479,10 +479,9 @@ int find_unique_abbrev_r(char *hex, const unsigned char *sha1, int len)
* We now know we have on the order of 2^len objects, which
* expects a collision at 2^(len/2). But we also care about hex
* chars, not bits, and there are 4 bits per hex. So all
- * together we need to divide by 2; but we also want to round
- * odd numbers up, hence adding one before dividing.
+ * together we need to divide by 2 and round up.
*/
- len = (len + 1) / 2;
+ len = DIV_ROUND_UP(len, 2);
/*
* For very small repos, we stick with our regular fallback.
*/