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

Function refs_delete_refs

refs.c:3058–3110  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3056}
3057
3058int refs_delete_refs(struct ref_store *refs, const char *logmsg,
3059 struct string_list *refnames, unsigned int flags)
3060{
3061 struct ref_transaction *transaction;
3062 struct strbuf err = STRBUF_INIT;
3063 struct string_list_item *item;
3064 int ret = 0, failures = 0;
3065 char *msg;
3066
3067 if (!refnames->nr)
3068 return 0;
3069
3070 msg = normalize_reflog_message(logmsg);
3071
3072 /*
3073 * Since we don't check the references' old_oids, the
3074 * individual updates can't fail, so we can pack all of the
3075 * updates into a single transaction.
3076 */
3077 transaction = ref_store_transaction_begin(refs, 0, &err);
3078 if (!transaction) {
3079 ret = error("%s", err.buf);
3080 goto out;
3081 }
3082
3083 for_each_string_list_item(item, refnames) {
3084 ret = ref_transaction_delete(transaction, item->string,
3085 NULL, NULL, flags, msg, &err);
3086 if (ret) {
3087 warning(_("could not delete reference %s: %s"),
3088 item->string, err.buf);
3089 strbuf_reset(&err);
3090 failures = 1;
3091 }
3092 }
3093
3094 ret = ref_transaction_commit(transaction, &err);
3095 if (ret) {
3096 if (refnames->nr == 1)
3097 error(_("could not delete reference %s: %s"),
3098 refnames->items[0].string, err.buf);
3099 else
3100 error(_("could not delete references: %s"), err.buf);
3101 }
3102
3103out:
3104 if (!ret && failures)
3105 ret = -1;
3106 ref_transaction_free(transaction);
3107 strbuf_release(&err);
3108 free(msg);
3109 return ret;
3110}
3111
3112int refs_rename_ref(struct ref_store *refs, const char *oldref,
3113 const char *newref, const char *logmsg)

Callers 7

bisect_clean_stateFunction · 0.85
cmd_delete_refsFunction · 0.85
delete_tagsFunction · 0.85
prune_refsFunction · 0.85
rmFunction · 0.85
prune_remoteFunction · 0.85
delete_branchesFunction · 0.85

Calls 8

normalize_reflog_messageFunction · 0.85
errorFunction · 0.85
ref_transaction_deleteFunction · 0.85
warningFunction · 0.85
ref_transaction_commitFunction · 0.85
ref_transaction_freeFunction · 0.85
strbuf_releaseFunction · 0.85

Tested by 1

cmd_delete_refsFunction · 0.68