summaryrefslogtreecommitdiff
path: root/refs.c
diff options
context:
space:
mode:
authorMichael Haggerty <mhagger@alum.mit.edu>2016-04-24 07:48:26 (GMT)
committerMichael Haggerty <mhagger@alum.mit.edu>2016-06-13 09:23:49 (GMT)
commitc52ce248d63a185eb0a616b361d1fd72c5c66451 (patch)
tree035bec75e98005be432d414db665abdac2e25be0 /refs.c
parent0568c8e9dce2aa0dd18f41f23e3465f3639e371e (diff)
downloadgit-c52ce248d63a185eb0a616b361d1fd72c5c66451.zip
git-c52ce248d63a185eb0a616b361d1fd72c5c66451.tar.gz
git-c52ce248d63a185eb0a616b361d1fd72c5c66451.tar.bz2
ref_transaction_create(): disallow recursive pruning
It is nonsensical (and a little bit dangerous) to use REF_ISPRUNING without REF_NODEREF. Forbid it explicitly. Change the one REF_ISPRUNING caller to pass REF_NODEREF too. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Diffstat (limited to 'refs.c')
-rw-r--r--refs.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/refs.c b/refs.c
index ba14105..5dc2473 100644
--- a/refs.c
+++ b/refs.c
@@ -790,6 +790,9 @@ int ref_transaction_update(struct ref_transaction *transaction,
if (transaction->state != REF_TRANSACTION_OPEN)
die("BUG: update called for transaction that is not open");
+ if ((flags & REF_ISPRUNING) && !(flags & REF_NODEREF))
+ die("BUG: REF_ISPRUNING set without REF_NODEREF");
+
if (new_sha1 && !is_null_sha1(new_sha1) &&
check_refname_format(refname, REFNAME_ALLOW_ONELEVEL)) {
strbuf_addf(err, "refusing to update ref with bad name '%s'",