| 310 | } |
| 311 | |
| 312 | static void write_buf_to_worktree(const struct object_id *obj, |
| 313 | const char *buf, unsigned long size) |
| 314 | { |
| 315 | int fd; |
| 316 | char *path = repo_git_path(the_repository, NOTES_MERGE_WORKTREE "/%s", oid_to_hex(obj)); |
| 317 | if (safe_create_leading_directories_const(the_repository, path)) |
| 318 | die_errno("unable to create directory for '%s'", path); |
| 319 | |
| 320 | fd = xopen(path, O_WRONLY | O_EXCL | O_CREAT, 0666); |
| 321 | |
| 322 | while (size > 0) { |
| 323 | ssize_t ret = write_in_full(fd, buf, size); |
| 324 | if (ret < 0) { |
| 325 | /* Ignore epipe */ |
| 326 | if (errno == EPIPE) |
| 327 | break; |
| 328 | die_errno("notes-merge"); |
| 329 | } |
| 330 | size -= ret; |
| 331 | buf += ret; |
| 332 | } |
| 333 | |
| 334 | close(fd); |
| 335 | free(path); |
| 336 | } |
| 337 | |
| 338 | static void write_note_to_worktree(const struct object_id *obj, |
| 339 | const struct object_id *note) |
no test coverage detected