summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2009-02-09 08:19:46 (GMT)
committerJunio C Hamano <gitster@pobox.com>2009-07-29 17:15:42 (GMT)
commit375881fa6a43e21ab922b20b2061f9868ef18644 (patch)
tree8ca63abdf8437298a4587c5bdd5c2d7a1c3a2cee
parentacd2a45b83e50c0f33b01ee74df241f1adfdff39 (diff)
downloadgit-375881fa6a43e21ab922b20b2061f9868ef18644.zip
git-375881fa6a43e21ab922b20b2061f9868ef18644.tar.gz
git-375881fa6a43e21ab922b20b2061f9868ef18644.tar.bz2
Refuse deleting the current branch via push
This makes git-push refuse deleting the current branch by default. Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rw-r--r--builtin-receive-pack.c30
-rwxr-xr-xt/t5400-send-pack.sh9
2 files changed, 14 insertions, 25 deletions
diff --git a/builtin-receive-pack.c b/builtin-receive-pack.c
index b8b69dd..db12b81 100644
--- a/builtin-receive-pack.c
+++ b/builtin-receive-pack.c
@@ -241,30 +241,24 @@ static void refuse_unconfigured_deny(void)
error("%s", refuse_unconfigured_deny_msg[i]);
}
-static char *warn_unconfigured_deny_delete_current_msg[] = {
- "Deleting the current branch can cause confusion by making the next",
- "'git clone' not check out any file.",
+static char *refuse_unconfigured_deny_delete_current_msg[] = {
+ "By default, deleting the current branch is denied, because the next",
+ "'git clone' won't result in any file checked out, causing confusion.",
"",
"You can set 'receive.denyDeleteCurrent' configuration variable to",
- "'refuse' in the remote repository to disallow deleting the current",
- "branch.",
+ "'warn' or 'ignore' in the remote repository to allow deleting the",
+ "current branch, with or without a warning message.",
"",
- "You can set it to 'ignore' to allow such a delete without a warning.",
- "",
- "To make this warning message less loud, you can set it to 'warn'.",
- "",
- "Note that the default will change in a future version of git",
- "to refuse deleting the current branch unless you have the",
- "configuration variable set to either 'ignore' or 'warn'."
+ "To squelch this message, you can set it to 'refuse'."
};
-static void warn_unconfigured_deny_delete_current(void)
+static void refuse_unconfigured_deny_delete_current(void)
{
int i;
for (i = 0;
- i < ARRAY_SIZE(warn_unconfigured_deny_delete_current_msg);
+ i < ARRAY_SIZE(refuse_unconfigured_deny_delete_current_msg);
i++)
- warning("%s", warn_unconfigured_deny_delete_current_msg[i]);
+ error("%s", refuse_unconfigured_deny_delete_current_msg[i]);
}
static const char *update(struct command *cmd)
@@ -313,12 +307,12 @@ static const char *update(struct command *cmd)
case DENY_IGNORE:
break;
case DENY_WARN:
- case DENY_UNCONFIGURED:
- if (deny_delete_current == DENY_UNCONFIGURED)
- warn_unconfigured_deny_delete_current();
warning("deleting the current branch");
break;
case DENY_REFUSE:
+ case DENY_UNCONFIGURED:
+ if (deny_delete_current == DENY_UNCONFIGURED)
+ refuse_unconfigured_deny_delete_current();
error("refusing to delete the current branch: %s", name);
return "deletion of the current branch prohibited";
}
diff --git a/t/t5400-send-pack.sh b/t/t5400-send-pack.sh
index 8463332..c718253 100755
--- a/t/t5400-send-pack.sh
+++ b/t/t5400-send-pack.sh
@@ -191,16 +191,11 @@ test_expect_success 'pushing wildcard refspecs respects forcing' '
test "$parent_head" = "$child_head"
'
-test_expect_success 'warn pushing to delete current branch' '
+test_expect_success 'deny pushing to delete current branch' '
rewound_push_setup &&
(
cd child &&
- git send-pack ../parent :refs/heads/master 2>errs
- ) &&
- grep "warning: to refuse deleting" child/errs &&
- (
- cd parent &&
- test_must_fail git rev-parse --verify master
+ test_must_fail git send-pack ../parent :refs/heads/master 2>errs
)
'