* $GIT_DIR/MERGE_RR file is a collection of records, each of which is * "conflict ID", a HT and pathname, terminated with a NUL, and is * used to keep track of the set of paths that "rerere" may need to * work on (i.e. what is left by the previous invocation of "git * rerere" during the current conflict resolution session). */
| 198 | * rerere" during the current conflict resolution session). |
| 199 | */ |
| 200 | static void read_rr(struct repository *r, struct string_list *rr) |
| 201 | { |
| 202 | struct strbuf buf = STRBUF_INIT; |
| 203 | FILE *in = fopen_or_warn(git_path_merge_rr(r), "r"); |
| 204 | |
| 205 | if (!in) |
| 206 | return; |
| 207 | while (!strbuf_getwholeline(&buf, in, '\0')) { |
| 208 | char *path; |
| 209 | unsigned char hash[GIT_MAX_RAWSZ]; |
| 210 | struct rerere_id *id; |
| 211 | int variant; |
| 212 | const unsigned hexsz = the_hash_algo->hexsz; |
| 213 | |
| 214 | /* There has to be the hash, tab, path and then NUL */ |
| 215 | if (buf.len < hexsz + 2 || get_hash_hex(buf.buf, hash)) |
| 216 | die(_("corrupt MERGE_RR")); |
| 217 | |
| 218 | if (buf.buf[hexsz] != '.') { |
| 219 | variant = 0; |
| 220 | path = buf.buf + hexsz; |
| 221 | } else { |
| 222 | errno = 0; |
| 223 | variant = strtol(buf.buf + hexsz + 1, &path, 10); |
| 224 | if (errno) |
| 225 | die(_("corrupt MERGE_RR")); |
| 226 | } |
| 227 | if (*(path++) != '\t') |
| 228 | die(_("corrupt MERGE_RR")); |
| 229 | buf.buf[hexsz] = '\0'; |
| 230 | id = new_rerere_id_hex(buf.buf); |
| 231 | id->variant = variant; |
| 232 | /* |
| 233 | * make sure id->collection->status has enough space |
| 234 | * for the variant we are interested in |
| 235 | */ |
| 236 | fit_variant(id->collection, variant); |
| 237 | string_list_insert(rr, path)->util = id; |
| 238 | } |
| 239 | strbuf_release(&buf); |
| 240 | fclose(in); |
| 241 | } |
| 242 | |
| 243 | static struct lock_file write_lock; |
| 244 |
no test coverage detected