| 1266 | } |
| 1267 | |
| 1268 | int 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 | |
| 1306 | struct ref_update *ref_transaction_add_update( |
| 1307 | struct ref_transaction *transaction, |
no test coverage detected