MCPcopy Create free account
hub / github.com/git/git / amend_strbuf_with_trailers

Function amend_strbuf_with_trailers

trailer.c:1286–1318  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1284}
1285
1286int 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);
1313out:
1314 strbuf_release(&out);
1315 free_trailers(&new_trailer_head);
1316
1317 return ret;
1318}
1319
1320static int write_file_in_place(const char *path, const struct strbuf *buf)
1321{

Callers 3

append_squash_messageFunction · 0.85
do_pick_commitFunction · 0.85
amend_file_with_trailersFunction · 0.85

Calls 8

errorFunction · 0.85
xcallocFunction · 0.85
xstrdupFunction · 0.85
list_add_tailFunction · 0.85
process_trailersFunction · 0.85
strbuf_swapFunction · 0.85
strbuf_releaseFunction · 0.85
free_trailersFunction · 0.85

Tested by

no test coverage detected