| 1284 | } |
| 1285 | |
| 1286 | int amend_strbuf_with_trailers(struct strbuf *buf, |
| 1287 | const struct strvec *trailer_args) |
| 1288 | { |
| 1289 | struct process_trailer_options opts = PROCESS_TRAILER_OPTIONS_INIT; |
| 1290 | LIST_HEAD(new_trailer_head); |
| 1291 | struct strbuf out = STRBUF_INIT; |
| 1292 | size_t i; |
| 1293 | int ret = 0; |
| 1294 | |
| 1295 | opts.no_divider = 1; |
| 1296 | |
| 1297 | for (i = 0; i < trailer_args->nr; i++) { |
| 1298 | const char *text = trailer_args->v[i]; |
| 1299 | struct new_trailer_item *item; |
| 1300 | |
| 1301 | if (!*text) { |
| 1302 | ret = error(_("empty --trailer argument")); |
| 1303 | goto out; |
| 1304 | } |
| 1305 | item = xcalloc(1, sizeof(*item)); |
| 1306 | item->text = xstrdup(text); |
| 1307 | list_add_tail(&item->list, &new_trailer_head); |
| 1308 | } |
| 1309 | |
| 1310 | process_trailers(&opts, &new_trailer_head, buf, &out); |
| 1311 | |
| 1312 | strbuf_swap(buf, &out); |
| 1313 | out: |
| 1314 | strbuf_release(&out); |
| 1315 | free_trailers(&new_trailer_head); |
| 1316 | |
| 1317 | return ret; |
| 1318 | } |
| 1319 | |
| 1320 | static int write_file_in_place(const char *path, const struct strbuf *buf) |
| 1321 | { |
no test coverage detected