| 106 | } |
| 107 | |
| 108 | static void interpret_trailers(const struct process_trailer_options *opts, |
| 109 | struct list_head *new_trailer_head, |
| 110 | const char *file) |
| 111 | { |
| 112 | struct strbuf input = STRBUF_INIT; |
| 113 | struct strbuf out = STRBUF_INIT; |
| 114 | struct tempfile *tempfile = NULL; |
| 115 | int fd = 1; |
| 116 | |
| 117 | trailer_config_init(); |
| 118 | |
| 119 | read_input_file(&input, file); |
| 120 | |
| 121 | if (opts->in_place) { |
| 122 | tempfile = trailer_create_in_place_tempfile(file); |
| 123 | if (!tempfile) |
| 124 | die(NULL); |
| 125 | fd = tempfile->fd; |
| 126 | } |
| 127 | process_trailers(opts, new_trailer_head, &input, &out); |
| 128 | |
| 129 | if (write_in_full(fd, out.buf, out.len) < 0) |
| 130 | die_errno(_("could not write to temporary file '%s'"), file); |
| 131 | if (opts->in_place) |
| 132 | if (rename_tempfile(&tempfile, file)) |
| 133 | die_errno(_("could not rename temporary file to %s"), file); |
| 134 | |
| 135 | strbuf_release(&input); |
| 136 | strbuf_release(&out); |
| 137 | } |
| 138 | |
| 139 | int cmd_interpret_trailers(int argc, |
| 140 | const char **argv, |
no test coverage detected