summaryrefslogtreecommitdiff
path: root/builtin
diff options
context:
space:
mode:
authorLibravatar Junio C Hamano <gitster@pobox.com>2019-10-09 14:00:58 +0900
committerLibravatar Junio C Hamano <gitster@pobox.com>2019-10-09 14:00:58 +0900
commit0b4fae553cdd5aa6713137e42cc03d396ecc1264 (patch)
tree95ea3924694592fa5c2dba1d7983d1946eb0615b /builtin
parentMerge branch 'am/visual-studio-config-fix' (diff)
parentname-rev: avoid cutoff timestamp underflow (diff)
downloadtgif-0b4fae553cdd5aa6713137e42cc03d396ecc1264.tar.xz
Merge branch 'sg/name-rev-cutoff-underflow-fix'
Integer arithmetic fix. * sg/name-rev-cutoff-underflow-fix: name-rev: avoid cutoff timestamp underflow
Diffstat (limited to 'builtin')
-rw-r--r--builtin/name-rev.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/builtin/name-rev.c b/builtin/name-rev.c
index c785fe16ba..b0f0776947 100644
--- a/builtin/name-rev.c
+++ b/builtin/name-rev.c
@@ -9,7 +9,11 @@
#include "sha1-lookup.h"
#include "commit-slab.h"
-#define CUTOFF_DATE_SLOP 86400 /* one day */
+/*
+ * One day. See the 'name a rev shortly after epoch' test in t6120 when
+ * changing this value
+ */
+#define CUTOFF_DATE_SLOP 86400
typedef struct rev_name {
const char *tip_name;
@@ -481,8 +485,13 @@ int cmd_name_rev(int argc, const char **argv, const char *prefix)
add_object_array(object, *argv, &revs);
}
- if (cutoff)
- cutoff = cutoff - CUTOFF_DATE_SLOP;
+ if (cutoff) {
+ /* check for undeflow */
+ if (cutoff > TIME_MIN + CUTOFF_DATE_SLOP)
+ cutoff = cutoff - CUTOFF_DATE_SLOP;
+ else
+ cutoff = TIME_MIN;
+ }
for_each_ref(name_ref, &data);
if (transform_stdin) {