| 243 | static struct lock_file write_lock; |
| 244 | |
| 245 | static int write_rr(struct string_list *rr, int out_fd) |
| 246 | { |
| 247 | int i; |
| 248 | for (i = 0; i < rr->nr; i++) { |
| 249 | struct strbuf buf = STRBUF_INIT; |
| 250 | struct rerere_id *id; |
| 251 | |
| 252 | assert(rr->items[i].util != RERERE_RESOLVED); |
| 253 | |
| 254 | id = rr->items[i].util; |
| 255 | if (!id) |
| 256 | continue; |
| 257 | assert(id->variant >= 0); |
| 258 | if (0 < id->variant) |
| 259 | strbuf_addf(&buf, "%s.%d\t%s%c", |
| 260 | rerere_id_hex(id), id->variant, |
| 261 | rr->items[i].string, 0); |
| 262 | else |
| 263 | strbuf_addf(&buf, "%s\t%s%c", |
| 264 | rerere_id_hex(id), |
| 265 | rr->items[i].string, 0); |
| 266 | |
| 267 | if (write_in_full(out_fd, buf.buf, buf.len) < 0) |
| 268 | die(_("unable to write rerere record")); |
| 269 | |
| 270 | strbuf_release(&buf); |
| 271 | } |
| 272 | if (commit_lock_file(&write_lock) != 0) |
| 273 | die(_("unable to write rerere record")); |
| 274 | return 0; |
| 275 | } |
| 276 | |
| 277 | /* |
| 278 | * "rerere" interacts with conflicted file contents using this I/O |
no test coverage detected