summaryrefslogtreecommitdiff
path: root/sha1_name.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2009-01-21 00:37:38 -0800
committerJunio C Hamano <gitster@pobox.com>2009-01-21 00:42:22 -0800
commitd7c03c1ff98be1d22dd18b70669ffc6fb76b39b3 (patch)
treede9568c2df11408386aab00058b52fed352725b6 /sha1_name.c
parent101d15e09712a0183db99d228d975c62970654cf (diff)
downloadgit-d7c03c1ff98be1d22dd18b70669ffc6fb76b39b3.tar.gz
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>
Diffstat (limited to 'sha1_name.c')
-rw-r--r--sha1_name.c8
1 files changed, 2 insertions, 6 deletions
diff --git a/sha1_name.c b/sha1_name.c
index 38c9f1b19e..7d95bbb27a 100644
--- a/sha1_name.c
+++ b/sha1_name.c
@@ -723,17 +723,13 @@ static int grab_nth_branch_switch(unsigned char *osha1, unsigned char *nsha1,
if (!prefixcmp(message, "checkout: moving from ")) {
match = message + strlen("checkout: moving from ");
- if ((target = strstr(match, " to ")) != NULL)
- target += 4;
+ target = strstr(match, " to ");
}
if (!match || !target)
return 0;
- len = target - match - 4;
- if (target[len] == '\n' && !strncmp(match, target, len))
- return 0;
-
+ len = target - match;
nth = cb->cnt++ % cb->alloc;
strbuf_reset(&cb->buf[nth]);
strbuf_add(&cb->buf[nth], match, len);