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

Function pre_push_hook_feed_stdin

transport.c:1337–1371  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1335};
1336
1337static int pre_push_hook_feed_stdin(int hook_stdin_fd, void *pp_cb UNUSED, void *pp_task_cb)
1338{
1339 struct feed_pre_push_hook_data *data = pp_task_cb;
1340 const struct ref *r = data->refs;
1341 int ret = 0;
1342
1343 if (!r)
1344 return 1; /* no more refs */
1345
1346 data->refs = r->next;
1347
1348 switch (r->status) {
1349 case REF_STATUS_REJECT_NONFASTFORWARD:
1350 case REF_STATUS_REJECT_REMOTE_UPDATED:
1351 case REF_STATUS_REJECT_STALE:
1352 case REF_STATUS_UPTODATE:
1353 return 0; /* skip refs which won't be pushed */
1354 default:
1355 break;
1356 }
1357
1358 if (!r->peer_ref)
1359 return 0;
1360
1361 strbuf_reset(&data->buf);
1362 strbuf_addf(&data->buf, "%s %s %s %s\n",
1363 r->peer_ref->name, oid_to_hex(&r->new_oid),
1364 r->name, oid_to_hex(&r->old_oid));
1365
1366 ret = write_in_full(hook_stdin_fd, data->buf.buf, data->buf.len);
1367 if (ret < 0 && errno != EPIPE)
1368 return ret; /* We do not mind if a hook does not read all refs. */
1369
1370 return 0;
1371}
1372
1373static void *pre_push_hook_data_alloc(void *feed_pipe_ctx)
1374{

Callers

nothing calls this directly

Calls 3

strbuf_addfFunction · 0.85
oid_to_hexFunction · 0.85
write_in_fullFunction · 0.85

Tested by

no test coverage detected