Code

approxidate_careful() reports errorneous date string
[git.git] / sha1_name.c
index 904bcd96a54a1cc33386a56a16d07dce34cbb90b..f4a74fe99fc69d6cc297fbf321624428793dd2e5 100644 (file)
@@ -395,8 +395,11 @@ static int get_sha1_basic(const char *str, int len, unsigned char *sha1)
                } else if (0 <= nth)
                        at_time = 0;
                else {
+                       int errors = 0;
                        char *tmp = xstrndup(str + at + 2, reflog_len);
-                       at_time = approxidate(tmp);
+                       at_time = approxidate_careful(tmp, &errors);
+                       if (errors)
+                               die("Bogus timestamp '%s'", tmp);
                        free(tmp);
                }
                if (read_ref_at(real_ref, at_time, nth, sha1, NULL,
@@ -777,8 +780,6 @@ int interpret_branch_name(const char *name, struct strbuf *buf)
        for_each_recent_reflog_ent("HEAD", grab_nth_branch_switch, 40960, &cb);
        if (cb.cnt < nth) {
                cb.cnt = 0;
-               for (i = 0; i < nth; i++)
-                       strbuf_release(&cb.buf[i]);
                for_each_reflog_ent("HEAD", grab_nth_branch_switch, &cb);
        }
        if (cb.cnt < nth)