ref_transaction_commit(): simplify code using temporary variables

Use temporary variables in the for-loop blocks to simplify expressions
in the rest of the loop.

Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
maint
Michael Haggerty 2014-04-07 15:48:15 +02:00 committed by Junio C Hamano
parent 88615910db
commit cb198d21d3
1 changed files with 13 additions and 8 deletions

21
refs.c
View File

@ -3435,10 +3435,12 @@ int ref_transaction_commit(struct ref_transaction *transaction,


/* Acquire all locks while verifying old values */ /* Acquire all locks while verifying old values */
for (i = 0; i < n; i++) { for (i = 0; i < n; i++) {
locks[i] = update_ref_lock(updates[i]->refname, struct ref_update *update = updates[i];
(updates[i]->have_old ?
updates[i]->old_sha1 : NULL), locks[i] = update_ref_lock(update->refname,
updates[i]->flags, (update->have_old ?
update->old_sha1 : NULL),
update->flags,
&types[i], onerr); &types[i], onerr);
if (!locks[i]) { if (!locks[i]) {
ret = 1; ret = 1;
@ -3447,16 +3449,19 @@ int ref_transaction_commit(struct ref_transaction *transaction,
} }


/* Perform updates first so live commits remain referenced */ /* Perform updates first so live commits remain referenced */
for (i = 0; i < n; i++) for (i = 0; i < n; i++) {
if (!is_null_sha1(updates[i]->new_sha1)) { struct ref_update *update = updates[i];

if (!is_null_sha1(update->new_sha1)) {
ret = update_ref_write(msg, ret = update_ref_write(msg,
updates[i]->refname, update->refname,
updates[i]->new_sha1, update->new_sha1,
locks[i], onerr); locks[i], onerr);
locks[i] = NULL; /* freed by update_ref_write */ locks[i] = NULL; /* freed by update_ref_write */
if (ret) if (ret)
goto cleanup; goto cleanup;
} }
}


/* Perform deletes now that updates are safely completed */ /* Perform deletes now that updates are safely completed */
for (i = 0; i < n; i++) for (i = 0; i < n; i++)