# [PATCH] tag deletions not rejected with receive.denyDeletes= true

2 messages from 2011-12-09 to 2011-12-09. Participants: Jerome DE VIVIE, Junio C Hamano.
Thread: https://gitlist.dev/t/29115

## Jerome DE VIVIE, 2011-12-09 08:51

Subject: [PATCH] tag deletions not rejected with receive.denyDeletes= true
Message-ID: <18683796.591323420674000.JavaMail.root@promailix.prometil.com>
URL: https://gitlist.dev/e/18683796.591323420674000.JavaMail.root%40promailix.prometil.com
In-Reply-To: <18285669.571323420520289.JavaMail.root@promailix.prometil.com>

```
Hello,

I have try to deny tag deletion over push using denyDeletes parameter:

git config --system receive.denyDeletes true
git daemon --reuseaddr --base-path=.. --export-all --verbose --enable=receive-pack

I can push tag deletions despite what the internet says (http://progit.org/book/ch7-1.html#receivedenydeletes). I don't know if it is a bug. Could you have a look, pls ? Thank you


BR
Jérôme


Signed-off-by: Jérôme de Vivie <j.edevivie@prometil.com>
---
 builtin/receive-pack.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/builtin/receive-pack.c b/builtin/receive-pack.c
index 7ec68a1..bf91042 100644
--- a/builtin/receive-pack.c
+++ b/builtin/receive-pack.c
@@ -432,7 +432,7 @@ static const char *update(struct command *cmd)
 	}
 
 	if (!is_null_sha1(old_sha1) && is_null_sha1(new_sha1)) {
-		if (deny_deletes && !prefixcmp(name, "refs/heads/")) {
+		if (deny_deletes && (!prefixcmp(name, "refs/heads/") || !prefixcmp(name, "refs/tags/"))) {
 			rp_error("denying ref deletion for %s", name);
 			return "deletion prohibited";
 		}
-- 
1.7.6.msysgit.0

```

## Junio C Hamano, 2011-12-09 19:15

Subject: Re: [PATCH] tag deletions not rejected with receive.denyDeletes= true
Message-ID: <7vy5uleeue.fsf@alter.siamese.dyndns.org>
URL: https://gitlist.dev/e/7vy5uleeue.fsf%40alter.siamese.dyndns.org
In-Reply-To: <18683796.591323420674000.JavaMail.root@promailix.prometil.com>

```
Jerome DE VIVIE <j.devivie@prometil.com> writes:

> Hello,
>
> I have try to deny tag deletion over push using denyDeletes parameter:
>
> git config --system receive.denyDeletes true
> git daemon --reuseaddr --base-path=.. --export-all --verbose --enable=receive-pack
>
> I can push tag deletions despite what the internet says (http://progit.org/book/ch7-1.html#receivedenydeletes). I don't know if it is a bug. Could you have a look, pls ? Thank you

The code seems to be written in such a way that it _explicitly_ wants to
limit the effect of the configuration only to branches. The change was
introduced by a240de1 (Introduce receive.denyDeletes, 2008-11-01) and the
motivation was explained as:

    Introduce receive.denyDeletes
    
    Occasionally, it may be useful to prevent branches from getting deleted from
    a centralized repository, particularly when no administrative access to the
    server is available to undo it via reflog. It also makes
    receive.denyNonFastForwards more useful if it is used for access control
    since it prevents force-updating by deleting and re-creating a ref.

So I would have to say your "the internet" is wrong.

Our documentation can also use some updates, as it dates to the days back
when we more liberally used "refs" and "branches" interchangeably.

```
