X-Git-Url: https://asedeno.scripts.mit.edu/gitweb/?a=blobdiff_plain;f=builtin-receive-pack.c;h=2c0225c89a44a28150806608ea3956c44e27ef6f;hb=7429ed2bad6297f0aef921b83083c572975fde71;hp=9f60f31c2bb7da7095de8d692d215c485ab5da0c;hpb=304d058370a9a797c38ec739c6d39fa45d9ed8e5;p=git.git diff --git a/builtin-receive-pack.c b/builtin-receive-pack.c index 9f60f31c2..2c0225c89 100644 --- a/builtin-receive-pack.c +++ b/builtin-receive-pack.c @@ -11,6 +11,7 @@ static const char receive_pack_usage[] = "git-receive-pack "; +static int deny_deletes = 0; static int deny_non_fast_forwards = 0; static int receive_fsck_objects; static int receive_unpack_limit = -1; @@ -23,6 +24,11 @@ static int capabilities_sent; static int receive_pack_config(const char *var, const char *value, void *cb) { + if (strcmp(var, "receive.denydeletes") == 0) { + deny_deletes = git_config_bool(var, value); + return 0; + } + if (strcmp(var, "receive.denynonfastforwards") == 0) { deny_non_fast_forwards = git_config_bool(var, value); return 0; @@ -185,6 +191,12 @@ static const char *update(struct command *cmd) "but I can't find it!", sha1_to_hex(new_sha1)); return "bad pack"; } + if (deny_deletes && is_null_sha1(new_sha1) && + !is_null_sha1(old_sha1) && + !prefixcmp(name, "refs/heads/")) { + error("denying ref deletion for %s", name); + return "deletion prohibited"; + } if (deny_non_fast_forwards && !is_null_sha1(new_sha1) && !is_null_sha1(old_sha1) && !prefixcmp(name, "refs/heads/")) {