refs: remove API function update_refs()
It has been superseded by reference transactions. This also means that struct ref_update can become private. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Michael Haggerty committed
Apr 7, 2014 at 15:48 UTC
b5c8ea2afb9bea910f0db5f9a4dfe58471184b3d
2 files changed
+20
-33
refs.c
+20
-13
@@ -3267,6 +3267,20 @@ static int update_ref_write(const char *action, const char *refname,
3267
return 0;
3268
}
3269
3270
+/**
3271
+ * Information needed for a single ref update. Set new_sha1 to the
3272
+ * new value or to zero to delete the ref. To check the old value
3273
+ * while locking the ref, set have_old to 1 and set old_sha1 to the
3274
+ * value or to zero to ensure the ref does not exist before update.
3275
+ */
3276
+struct ref_update {
3277
+ const char *ref_name;
3278
+ unsigned char new_sha1[20];
3279
+ unsigned char old_sha1[20];
3280
+ int flags; /* REF_NODEREF? */
3281
+ int have_old; /* 1 if old_sha1 is valid, 0 otherwise */
3282
+};
3283
+
3284
/*
3285
* Data structure for holding a reference transaction, which can
3286
* consist of checks and updates to multiple references, carried out
@@ -3396,16 +3410,17 @@ static int ref_update_reject_duplicates(struct ref_update **updates, int n,
3410
return 0;
3411
}
3412
3399
-int update_refs(const char *action, struct ref_update * const *updates_orig,
3400
- int n, enum action_on_err onerr)
3413
+int ref_transaction_commit(struct ref_transaction *transaction,
3414
+ const char *msg, enum action_on_err onerr)
3415
{
3416
int ret = 0, delnum = 0, i;
3417
struct ref_update **updates;
3418
int *types;
3419
struct ref_lock **locks;
3420
const char **delnames;
3421
+ int n = transaction->nr;
3422
3408
- if (!updates_orig || !n)
3423
+ if (!n)
3424
return 0;
3425
3426
/* Allocate work space */
@@ -3415,7 +3430,7 @@ int update_refs(const char *action, struct ref_update * const *updates_orig,
3430
delnames = xmalloc(sizeof(*delnames) * n);
3431
3432
/* Copy, sort, and reject duplicate refs */
3418
- memcpy(updates, updates_orig, sizeof(*updates) * n);
3433
+ memcpy(updates, transaction->updates, sizeof(*updates) * n);
3434
qsort(updates, n, sizeof(*updates), ref_update_compare);
3435
ret = ref_update_reject_duplicates(updates, n, onerr);
3436
if (ret)
@@ -3437,7 +3452,7 @@ int update_refs(const char *action, struct ref_update * const *updates_orig,
3452
/* Perform updates first so live commits remain referenced */
3453
for (i = 0; i < n; i++)
3454
if (!is_null_sha1(updates[i]->new_sha1)) {
3440
- ret = update_ref_write(action,
3455
+ ret = update_ref_write(msg,
3456
updates[i]->ref_name,
3457
updates[i]->new_sha1,
3458
locks[i], onerr);
@@ -3465,14 +3480,6 @@ cleanup:
3480
free(types);
3481
free(locks);
3482
free(delnames);
3468
- return ret;
3469
-}
3470
-
3471
-int ref_transaction_commit(struct ref_transaction *transaction,
3472
- const char *msg, enum action_on_err onerr)
3473
-{
3474
- int ret = update_refs(msg, transaction->updates, transaction->nr,
3475
- onerr);
3483
ref_transaction_free(transaction);
3484
return ret;
3485
}
refs.h
-20
@@ -10,20 +10,6 @@ struct ref_lock {
10
int force_write;
11
};
12
13
-/**
14
- * Information needed for a single ref update. Set new_sha1 to the
15
- * new value or to zero to delete the ref. To check the old value
16
- * while locking the ref, set have_old to 1 and set old_sha1 to the
17
- * value or to zero to ensure the ref does not exist before update.
18
- */
19
-struct ref_update {
20
- const char *ref_name;
21
- unsigned char new_sha1[20];
22
- unsigned char old_sha1[20];
23
- int flags; /* REF_NODEREF? */
24
- int have_old; /* 1 if old_sha1 is valid, 0 otherwise */
25
-};
26
-
13
struct ref_transaction;
14
15
/*
@@ -290,12 +276,6 @@ int update_ref(const char *action, const char *refname,
276
const unsigned char *sha1, const unsigned char *oldval,
277
int flags, enum action_on_err onerr);
278
293
-/**
294
- * Lock all refs and then perform all modifications.
295
- */
296
-int update_refs(const char *action, struct ref_update * const *updates,
297
- int n, enum action_on_err onerr);
298
-
279
extern int parse_hide_refs_config(const char *var, const char *value, const char *);
280
extern int ref_is_hidden(const char *);
281