Skip to contentSkip to conversation

Fix ref log parsing so it works properly.

RFC Shawn Pearce 1 participant 1 message Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

The log parser was only ever matching the last log record due to calling strtoul on "> 1136091609" rather than " 1136091609". Also once a match for '@' has been found after the name of the ref there is no point in looking for another '@' within the remaining text.

---
Uh yea, I found a couple of bugs. :-)
This applies on top of the other 5 patches (hence the 6/5).

 refs.c      |    2 +-
 sha1_name.c |    1 +
 2 files changed, 2 insertions(+), 1 deletions(-)

fbc7bf049255370f1611a5772c39d35422a81e24

refs.c +1 -1
index 4c99e37..ae9825d 100644
@@ -459,7 +459,7 @@ int read_ref_at(const char *ref, unsigne
 			c++;
 		if (c == logend || *c == '\n')
 			die("Log %s is corrupt.", logfile);
-		date = strtoul(c, NULL, 10);
+		date = strtoul(c + 1, NULL, 10);
 		if (date <= at_time) {
 			if (get_sha1_hex(rec + 41, sha1))
 				die("Log %s is corrupt.", logfile);
sha1_name.c +1 -0
index 3ac3ab4..4376cb3 100644
@@ -267,6 +267,7 @@ static int get_sha1_basic(const char *st
 			at_time = approxidate(date_spec);
 			free(date_spec);
 			len = at_mark;
+			break;
 		}
 	}
 
Signature · 1 line
1.3.2.g7278