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

Function ref_transaction_maybe_set_rejected

refs.c:1268–1304  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1266}
1267
1268int ref_transaction_maybe_set_rejected(struct ref_transaction *transaction,
1269 size_t update_idx,
1270 enum ref_transaction_error err,
1271 struct strbuf *details)
1272{
1273 if (update_idx >= transaction->nr)
1274 BUG("trying to set rejection on invalid update index");
1275
1276 if (!(transaction->flags & REF_TRANSACTION_ALLOW_FAILURE))
1277 return 0;
1278
1279 if (!transaction->rejections)
1280 BUG("transaction not initialized with failure support");
1281
1282 /*
1283 * Don't accept generic errors, since these errors are not user
1284 * input related.
1285 */
1286 if (err == REF_TRANSACTION_ERROR_GENERIC)
1287 return 0;
1288
1289 /*
1290 * Rejected refnames shouldn't be considered in the availability
1291 * checks, so remove them from the list.
1292 */
1293 string_list_remove(&transaction->refnames,
1294 transaction->updates[update_idx]->refname, 0);
1295
1296 transaction->updates[update_idx]->rejection_err = err;
1297 transaction->updates[update_idx]->rejection_details = strbuf_detach(details, NULL);
1298 ALLOC_GROW(transaction->rejections->update_indices,
1299 transaction->rejections->nr + 1,
1300 transaction->rejections->alloc);
1301 transaction->rejections->update_indices[transaction->rejections->nr++] = update_idx;
1302
1303 return 1;
1304}
1305
1306struct ref_update *ref_transaction_add_update(
1307 struct ref_transaction *transaction,

Callers 4

write_with_updatesFunction · 0.85

Calls 2

string_list_removeFunction · 0.85
strbuf_detachFunction · 0.85

Tested by

no test coverage detected