Andrew's git
/
gitweb.git
/ diff
summary
|
log
|
commit
| diff |
tree
commit
grep
author
committer
pickaxe
?
re
ref_transaction_commit(): simplify code using temporary variables
author
Michael Haggerty
<mhagger@alum.mit.edu>
Mon, 7 Apr 2014 13:48:15 +0000
(15:48 +0200)
committer
Junio C Hamano
<gitster@pobox.com>
Mon, 7 Apr 2014 19:09:15 +0000
(12:09 -0700)
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>
refs.c
patch
|
blob
|
history
raw
|
patch
|
inline
| side by side (parent:
8861591
)
diff --git
a/refs.c
b/refs.c
index 2ff195f4711aafe99a63f4ac42dba6af4d631c33..33c34dfeff9a9200b807f33d3b1d01b5b372faf8 100644
(file)
--- a/
refs.c
+++ b/
refs.c
@@
-3435,10
+3435,12
@@
int ref_transaction_commit(struct ref_transaction *transaction,
/* Acquire all locks while verifying old values */
for (i = 0; i < n; i++) {
/* Acquire all locks while verifying old values */
for (i = 0; i < n; i++) {
- locks[i] = update_ref_lock(updates[i]->refname,
- (updates[i]->have_old ?
- updates[i]->old_sha1 : NULL),
- updates[i]->flags,
+ struct ref_update *update = updates[i];
+
+ locks[i] = update_ref_lock(update->refname,
+ (update->have_old ?
+ update->old_sha1 : NULL),
+ update->flags,
&types[i], onerr);
if (!locks[i]) {
ret = 1;
&types[i], onerr);
if (!locks[i]) {
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++)
- if (!is_null_sha1(updates[i]->new_sha1)) {
+ for (i = 0; i < n; i++) {
+ struct ref_update *update = updates[i];
+
+ if (!is_null_sha1(update->new_sha1)) {
ret = update_ref_write(msg,
ret = update_ref_write(msg,
- update
s[i]
->refname,
- update
s[i]
->new_sha1,
+ update->refname,
+ update->new_sha1,
locks[i], onerr);
locks[i] = NULL; /* freed by update_ref_write */
if (ret)
goto cleanup;
}
locks[i], onerr);
locks[i] = NULL; /* freed by update_ref_write */
if (ret)
goto cleanup;
}
+ }
/* Perform deletes now that updates are safely completed */
for (i = 0; i < n; i++)
/* Perform deletes now that updates are safely completed */
for (i = 0; i < n; i++)