ref_transaction_add_update(): remove a check

We want to make `REF_ISPRUNING` internal to the files backend. For this to be possible, `ref_transaction_add_update()` mustn't know about it. So move the check that `REF_ISPRUNING` is only used with `REF_NODEREF` from this function to `files_transaction_prepare()`. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Michael Haggerty committed Nov 5, 2017 at 09:42 UTC 62c72d1fd0aa39429011b76ff5b1953a561e6581
2 files changed +6 -4
refs.c
-3
@@ -906,9 +906,6 @@ struct ref_update *ref_transaction_add_update(
906 if (transaction->state != REF_TRANSACTION_OPEN)
907 die("BUG: update called for transaction that is not open");
908
909 - if ((flags & REF_ISPRUNING) && !(flags & REF_NODEREF))
910 - die("BUG: REF_ISPRUNING set without REF_NODEREF");
911 -
909 FLEX_ALLOC_STR(update, refname, refname);
910 ALLOC_GROW(transaction->updates, transaction->nr + 1, transaction->alloc);
911 transaction->updates[transaction->nr++] = update;
refs/files-backend.c
+6 -1
@@ -2518,13 +2518,18 @@ static int files_transaction_prepare(struct ref_store *ref_store,
2518 * transaction. (If we end up splitting up any updates using
2519 * split_symref_update() or split_head_update(), those
2520 * functions will check that the new updates don't have the
2521 - * same refname as any existing ones.)
2521 + * same refname as any existing ones.) Also fail if any of the
2522 + * updates use REF_ISPRUNING without REF_NODEREF.
2523 */
2524 for (i = 0; i < transaction->nr; i++) {
2525 struct ref_update *update = transaction->updates[i];
2526 struct string_list_item *item =
2527 string_list_append(&affected_refnames, update->refname);
2528
2529 + if ((update->flags & REF_ISPRUNING) &&
2530 + !(update->flags & REF_NODEREF))
2531 + BUG("REF_ISPRUNING set without REF_NODEREF");
2532 +
2533 /*
2534 * We store a pointer to update in item->util, but at
2535 * the moment we never use the value of this field