MCPcopy Index your code
hub / github.com/git/git / refs_update_ref

Function refs_update_ref

refs.c:1548–1585  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1546}
1547
1548int refs_update_ref(struct ref_store *refs, const char *msg,
1549 const char *refname, const struct object_id *new_oid,
1550 const struct object_id *old_oid, unsigned int flags,
1551 enum action_on_err onerr)
1552{
1553 struct ref_transaction *t = NULL;
1554 struct strbuf err = STRBUF_INIT;
1555 int ret = 0;
1556
1557 t = ref_store_transaction_begin(refs, 0, &err);
1558 if (!t ||
1559 ref_transaction_update(t, refname, new_oid, old_oid, NULL, NULL,
1560 flags, msg, &err) ||
1561 ref_transaction_commit(t, &err)) {
1562 ret = 1;
1563 ref_transaction_free(t);
1564 }
1565 if (ret) {
1566 const char *str = _("update_ref failed for ref '%s': %s");
1567
1568 switch (onerr) {
1569 case UPDATE_REFS_MSG_ON_ERR:
1570 error(str, refname, err.buf);
1571 break;
1572 case UPDATE_REFS_DIE_ON_ERR:
1573 die(str, refname, err.buf);
1574 break;
1575 case UPDATE_REFS_QUIET_ON_ERR:
1576 break;
1577 }
1578 strbuf_release(&err);
1579 return 1;
1580 }
1581 strbuf_release(&err);
1582 if (t)
1583 ref_transaction_free(t);
1584 return 0;
1585}
1586
1587/*
1588 * Check that the string refname matches a rule of the form

Callers 15

merge_switch_to_resultFunction · 0.85
update_one_tracking_refFunction · 0.85
update_refsFunction · 0.85
write_rebase_headFunction · 0.85
do_pick_commitFunction · 0.85
do_resetFunction · 0.85
do_update_refsFunction · 0.85
pick_commitsFunction · 0.85
notes_cache_writeFunction · 0.85
unbundle_from_fileFunction · 0.85
bisect_checkoutFunction · 0.85

Calls 7

ref_transaction_updateFunction · 0.85
ref_transaction_commitFunction · 0.85
ref_transaction_freeFunction · 0.85
errorFunction · 0.85
strbuf_releaseFunction · 0.85
dieFunction · 0.70

Tested by 1

cmd_update_refFunction · 0.68