- strcpy(path, ++cp);
- return 0;
-}
-
-static int parse_diff_raw_output(const char *buf)
-{
- char path[PATH_MAX];
- unsigned char old_sha1[20], new_sha1[20];
- const char *cp = buf;
- int ch, old_mode, new_mode;
-
- switch (*cp++) {
- case 'U':
- diff_unmerge(cp + 1);
- break;
- case '+':
- if (parse_oneside_change(cp, &new_mode, new_sha1, path))
- return -1;
- diff_addremove('+', new_mode, new_sha1, path, NULL);
- break;
- case '-':
- if (parse_oneside_change(cp, &old_mode, old_sha1, path))
- return -1;
- diff_addremove('-', old_mode, old_sha1, path, NULL);
- break;
- case '*':
- 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) && strncmp(cp, " blob ", 6) &&
- strncmp(cp, "\ttree\t", 6) && strncmp(cp, " tree ", 6))
- return -1;
- cp += 6;
- if (get_sha1_hex(cp, old_sha1))
- return -1;
- cp += 40;
- if (strncmp(cp, "->", 2))
- return -1;
- cp += 2;
- if (get_sha1_hex(cp, new_sha1))
- return -1;
- cp += 40;
- if ((*cp != '\t') && *cp != ' ')
- return -1;
- strcpy(path, ++cp);
- diff_change(old_mode, new_mode, old_sha1, new_sha1, path, NULL);
- break;
- default: