@matheusbsbs / matheus-bagliano / commits / d7c03c1ff9
Fork 0

Simplify parsing branch switching events in reflog

We only accept "checkout: moving from A to B" newer style reflog entries, in order to pick up A. There is no point computing where B begins at after running strstr to locate " to ", nor adding 4 and then subtracting 4 from the same pointer. Signed-off-by: Junio C Hamano <gitster@pobox.com>

Junio C Hamano committed Jan 21, 2009 at 00:37 UTC d7c03c1ff98be1d22dd18b70669ffc6fb76b39b3
1 file changed +2 -6
sha1_name.c
+2 -6
@@ -723,17 +723,13 @@ static int grab_nth_branch_switch(unsigned char *osha1, unsigned char *nsha1,
723
724 if (!prefixcmp(message, "checkout: moving from ")) {
725 match = message + strlen("checkout: moving from ");
726 - if ((target = strstr(match, " to ")) != NULL)
727 - target += 4;
726 + target = strstr(match, " to ");
727 }
728
729 if (!match || !target)
730 return 0;
731
733 - len = target - match - 4;
734 - if (target[len] == '\n' && !strncmp(match, target, len))
735 - return 0;
736 -
732 + len = target - match;
733 nth = cb->cnt++ % cb->alloc;
734 strbuf_reset(&cb->buf[nth]);
735 strbuf_add(&cb->buf[nth], match, len);