| 1105 | } |
| 1106 | |
| 1107 | static int gitdiff_index(struct gitdiff_data *state, |
| 1108 | const char *line, |
| 1109 | struct patch *patch) |
| 1110 | { |
| 1111 | /* |
| 1112 | * index line is N hexadecimal, "..", N hexadecimal, |
| 1113 | * and optional space with octal mode. |
| 1114 | */ |
| 1115 | const char *ptr, *eol; |
| 1116 | int len; |
| 1117 | const unsigned hexsz = the_hash_algo->hexsz; |
| 1118 | |
| 1119 | ptr = strchr(line, '.'); |
| 1120 | if (!ptr || ptr[1] != '.' || hexsz < ptr - line) |
| 1121 | return 0; |
| 1122 | len = ptr - line; |
| 1123 | memcpy(patch->old_oid_prefix, line, len); |
| 1124 | patch->old_oid_prefix[len] = 0; |
| 1125 | |
| 1126 | line = ptr + 2; |
| 1127 | ptr = strchr(line, ' '); |
| 1128 | eol = strchrnul(line, '\n'); |
| 1129 | |
| 1130 | if (!ptr || eol < ptr) |
| 1131 | ptr = eol; |
| 1132 | len = ptr - line; |
| 1133 | |
| 1134 | if (hexsz < len) |
| 1135 | return 0; |
| 1136 | memcpy(patch->new_oid_prefix, line, len); |
| 1137 | patch->new_oid_prefix[len] = 0; |
| 1138 | if (*ptr == ' ') |
| 1139 | return gitdiff_oldmode(state, ptr + 1, patch); |
| 1140 | return 0; |
| 1141 | } |
| 1142 | |
| 1143 | /* |
| 1144 | * This is normal for a diff that doesn't change anything: we'll fall through |
nothing calls this directly
no test coverage detected