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

Function update_head_with_reflog

sequencer.c:1259–1295  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1257}
1258
1259int update_head_with_reflog(const struct commit *old_head,
1260 const struct object_id *new_head,
1261 const char *action, const struct strbuf *msg,
1262 struct strbuf *err)
1263{
1264 struct ref_transaction *transaction;
1265 struct strbuf sb = STRBUF_INIT;
1266 const char *nl;
1267 int ret = 0;
1268
1269 if (action) {
1270 strbuf_addstr(&sb, action);
1271 strbuf_addstr(&sb, ": ");
1272 }
1273
1274 nl = strchr(msg->buf, '\n');
1275 if (nl) {
1276 strbuf_add(&sb, msg->buf, nl + 1 - msg->buf);
1277 } else {
1278 strbuf_addbuf(&sb, msg);
1279 strbuf_addch(&sb, '\n');
1280 }
1281
1282 transaction = ref_store_transaction_begin(get_main_ref_store(the_repository),
1283 0, err);
1284 if (!transaction ||
1285 ref_transaction_update(transaction, "HEAD", new_head,
1286 old_head ? &old_head->object.oid : null_oid(the_hash_algo),
1287 NULL, NULL, 0, sb.buf, err) ||
1288 ref_transaction_commit(transaction, err)) {
1289 ret = -1;
1290 }
1291 ref_transaction_free(transaction);
1292 strbuf_release(&sb);
1293
1294 return ret;
1295}
1296
1297static int pipe_from_strbuf(int hook_stdin_fd, void *pp_cb, void *pp_task_cb UNUSED)
1298{

Callers 2

try_to_commitFunction · 0.85
cmd_commitFunction · 0.85

Calls 11

strbuf_addstrFunction · 0.85
strbuf_addFunction · 0.85
strbuf_addbufFunction · 0.85
strbuf_addchFunction · 0.85
get_main_ref_storeFunction · 0.85
ref_transaction_updateFunction · 0.85
null_oidFunction · 0.85
ref_transaction_commitFunction · 0.85
ref_transaction_freeFunction · 0.85
strbuf_releaseFunction · 0.85

Tested by

no test coverage detected