+ old.file_valid = old.sha1_valid =
+ new.file_valid = new.sha1_valid = 1;
+ old.mode = new.mode = 0;
+ while ((ch = *cp) && ('0' <= ch && ch <= '7')) {
+ old.mode = (old.mode << 3) | (ch - '0');
+ cp++;
+ }
+ if (strncmp(cp, "->", 2))
+ return -1;
+ cp += 2;
+ while ((ch = *cp) && ('0' <= ch && ch <= '7')) {
+ new.mode = (new.mode << 3) | (ch - '0');
+ cp++;
+ }
+ if (strncmp(cp, "\tblob\t", 6))
+ return -1;
+ cp += 6;
+ if (get_sha1_hex(cp, old.u.sha1))
+ return -1;
+ cp += 40;
+ if (strncmp(cp, "->", 2))
+ return -1;
+ cp += 2;
+ if (get_sha1_hex(cp, new.u.sha1))
+ return -1;
+ cp += 40;
+ if (*cp++ != '\t')
+ return -1;
+ strcpy(path, cp);