]> git.ipfire.org Git - thirdparty/git.git/blobdiff - builtin/name-rev.c
Merge branch 'js/update-index-ignore-removal-for-skip-worktree'
[thirdparty/git.git] / builtin / name-rev.c
index c785fe16bade1a67d4da782d91b61bdd61d99115..b0f0776947f05e551f5bd06a4a0e291aa19a56f3 100644 (file)
@@ -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) {