Skip to content

Commit 62c72d1

Browse files
mhaggergitster
authored andcommitted
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>
1 parent a9bbbce commit 62c72d1

2 files changed

Lines changed: 6 additions & 4 deletions

File tree

refs.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -906,9 +906,6 @@ struct ref_update *ref_transaction_add_update(
906906
if (transaction->state != REF_TRANSACTION_OPEN)
907907
die("BUG: update called for transaction that is not open");
908908

909-
if ((flags & REF_ISPRUNING) && !(flags & REF_NODEREF))
910-
die("BUG: REF_ISPRUNING set without REF_NODEREF");
911-
912909
FLEX_ALLOC_STR(update, refname, refname);
913910
ALLOC_GROW(transaction->updates, transaction->nr + 1, transaction->alloc);
914911
transaction->updates[transaction->nr++] = update;

refs/files-backend.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2518,13 +2518,18 @@ static int files_transaction_prepare(struct ref_store *ref_store,
25182518
* transaction. (If we end up splitting up any updates using
25192519
* split_symref_update() or split_head_update(), those
25202520
* 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.
25222523
*/
25232524
for (i = 0; i < transaction->nr; i++) {
25242525
struct ref_update *update = transaction->updates[i];
25252526
struct string_list_item *item =
25262527
string_list_append(&affected_refnames, update->refname);
25272528

2529+
if ((update->flags & REF_ISPRUNING) &&
2530+
!(update->flags & REF_NODEREF))
2531+
BUG("REF_ISPRUNING set without REF_NODEREF");
2532+
25282533
/*
25292534
* We store a pointer to update in item->util, but at
25302535
* the moment we never use the value of this field

0 commit comments

Comments
 (0)