| 1420 | } |
| 1421 | |
| 1422 | static int write_transaction_table(struct reftable_writer *writer, void *cb_data) |
| 1423 | { |
| 1424 | struct write_transaction_table_arg *arg = cb_data; |
| 1425 | uint64_t ts = reftable_stack_next_update_index(arg->be->stack); |
| 1426 | struct reftable_log_record *logs = NULL; |
| 1427 | struct ident_split committer_ident = {0}; |
| 1428 | size_t logs_nr = 0, logs_alloc = 0, i; |
| 1429 | const char *committer_info; |
| 1430 | int ret = 0; |
| 1431 | |
| 1432 | committer_info = git_committer_info(0); |
| 1433 | if (split_ident_line(&committer_ident, committer_info, strlen(committer_info))) |
| 1434 | BUG("failed splitting committer info"); |
| 1435 | |
| 1436 | QSORT(arg->updates, arg->updates_nr, transaction_update_cmp); |
| 1437 | |
| 1438 | /* |
| 1439 | * During reflog migration, we add indexes for a single reflog with |
| 1440 | * multiple entries. Each entry will contain a different update_index, |
| 1441 | * so set the limits accordingly. |
| 1442 | */ |
| 1443 | ret = reftable_writer_set_limits(writer, ts, ts + arg->max_index); |
| 1444 | if (ret < 0) |
| 1445 | goto done; |
| 1446 | |
| 1447 | for (i = 0; i < arg->updates_nr; i++) { |
| 1448 | struct reftable_transaction_update *tx_update = &arg->updates[i]; |
| 1449 | struct ref_update *u = tx_update->update; |
| 1450 | |
| 1451 | if (u->rejection_err) |
| 1452 | continue; |
| 1453 | |
| 1454 | /* |
| 1455 | * Write a reflog entry when updating a ref to point to |
| 1456 | * something new in either of the following cases: |
| 1457 | * |
| 1458 | * - The reference is about to be deleted. We always want to |
| 1459 | * delete the reflog in that case. |
| 1460 | * - REF_FORCE_CREATE_REFLOG is set, asking us to always create |
| 1461 | * the reflog entry. |
| 1462 | * - `core.logAllRefUpdates` tells us to create the reflog for |
| 1463 | * the given ref. |
| 1464 | */ |
| 1465 | if ((u->flags & REF_HAVE_NEW) && |
| 1466 | !(u->type & REF_ISSYMREF) && |
| 1467 | ref_update_has_null_new_value(u)) { |
| 1468 | struct reftable_log_record log = {0}; |
| 1469 | struct reftable_iterator it = {0}; |
| 1470 | |
| 1471 | ret = reftable_stack_init_log_iterator(arg->be->stack, &it); |
| 1472 | if (ret < 0) |
| 1473 | goto done; |
| 1474 | |
| 1475 | /* |
| 1476 | * When deleting refs we also delete all reflog entries |
| 1477 | * with them. While it is not strictly required to |
| 1478 | * delete reflogs together with their refs, this |
| 1479 | * matches the behaviour of the files backend. |
nothing calls this directly
no test coverage detected