Skip to content

Commit d7c03c1

Browse files
committed
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 <[email protected]>
1 parent 101d15e commit d7c03c1

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

sha1_name.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -723,17 +723,13 @@ static int grab_nth_branch_switch(unsigned char *osha1, unsigned char *nsha1,
723723

724724
if (!prefixcmp(message, "checkout: moving from ")) {
725725
match = message + strlen("checkout: moving from ");
726-
if ((target = strstr(match, " to ")) != NULL)
727-
target += 4;
726+
target = strstr(match, " to ");
728727
}
729728

730729
if (!match || !target)
731730
return 0;
732731

733-
len = target - match - 4;
734-
if (target[len] == '\n' && !strncmp(match, target, len))
735-
return 0;
736-
732+
len = target - match;
737733
nth = cb->cnt++ % cb->alloc;
738734
strbuf_reset(&cb->buf[nth]);
739735
strbuf_add(&cb->buf[nth], match, len);

0 commit comments

Comments
 (0)