Code

show_patch_diff(): remove a call to fstat()
[git.git] / sha1_name.c
index 38c9f1b19e89401b24204b4daac26f327a8f8d8f..5d0ac0263d04d7ec72a3b7dec4aaf47aec80da5e 100644 (file)
@@ -334,7 +334,7 @@ static int get_sha1_basic(const char *str, int len, unsigned char *sha1)
 
        /* basic@{time or number or -number} format to query ref-log */
        reflog_len = at = 0;
-       if (str[len-1] == '}') {
+       if (len && str[len-1] == '}') {
                for (at = len-2; at >= 0; at--) {
                        if (str[at] == '@' && str[at+1] == '{') {
                                reflog_len = (len-1) - (at+2);
@@ -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);