aboutsummaryrefslogtreecommitdiff
path: root/builtin-receive-pack.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2009-12-26 14:03:17 -0800
committerJunio C Hamano <gitster@pobox.com>2009-12-26 14:03:17 -0800
commit7ad9cec81d86ccf7a693ad7e1218e238aee5ca9d (patch)
treecd2824a4db13560c32edea6e979931fbbcd9ddac /builtin-receive-pack.c
parenta19f101e3f31234db23bd1eb24994db6e4caa443 (diff)
parent375881fa6a43e21ab922b20b2061f9868ef18644 (diff)
downloadgit-7ad9cec81d86ccf7a693ad7e1218e238aee5ca9d.tar.gz
git-7ad9cec81d86ccf7a693ad7e1218e238aee5ca9d.tar.xz
Merge branch 'jc/1.7.0-push-safety'
* jc/1.7.0-push-safety: Refuse deleting the current branch via push Refuse updating the current branch in a non-bare repository via push
Diffstat (limited to 'builtin-receive-pack.c')
-rw-r--r--builtin-receive-pack.c70
1 files changed, 29 insertions, 41 deletions
diff --git a/builtin-receive-pack.c b/builtin-receive-pack.c
index 78c0e69cd..4320c93e7 100644
--- a/builtin-receive-pack.c
+++ b/builtin-receive-pack.c
@@ -204,59 +204,47 @@ static int is_ref_checked_out(const char *ref)
return !strcmp(head_name, ref);
}
-static char *warn_unconfigured_deny_msg[] = {
- "Updating the currently checked out branch may cause confusion,",
- "as the index and work tree do not reflect changes that are in HEAD.",
- "As a result, you may see the changes you just pushed into it",
- "reverted when you run 'git diff' over there, and you may want",
- "to run 'git reset --hard' before starting to work to recover.",
+static char *refuse_unconfigured_deny_msg[] = {
+ "By default, updating the current branch in a non-bare repository",
+ "is denied, because it will make the index and work tree inconsistent",
+ "with what you pushed, and will require 'git reset --hard' to match",
+ "the work tree to HEAD.",
"",
"You can set 'receive.denyCurrentBranch' configuration variable to",
- "'refuse' in the remote repository to forbid pushing into its",
- "current branch."
+ "'ignore' or 'warn' in the remote repository to allow pushing into",
+ "its current branch; however, this is not recommended unless you",
+ "arranged to update its work tree to match what you pushed in some",
+ "other way.",
"",
- "To allow pushing into the current branch, you can set it to 'ignore';",
- "but this is not recommended unless you arranged to update its work",
- "tree to match what you pushed in some other way.",
- "",
- "To squelch this message, you can set it to 'warn'.",
- "",
- "Note that the default will change in a future version of git",
- "to refuse updating the current branch unless you have the",
- "configuration variable set to either 'ignore' or 'warn'."
+ "To squelch this message and still keep the default behaviour, set",
+ "'receive.denyCurrentBranch' configuration variable to 'refuse'."
};
-static void warn_unconfigured_deny(void)
+static void refuse_unconfigured_deny(void)
{
int i;
- for (i = 0; i < ARRAY_SIZE(warn_unconfigured_deny_msg); i++)
- warning("%s", warn_unconfigured_deny_msg[i]);
+ for (i = 0; i < ARRAY_SIZE(refuse_unconfigured_deny_msg); i++)
+ 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.",
- "",
- "You can set it to 'ignore' to allow such a delete without a warning.",
+ "'warn' or 'ignore' in the remote repository to allow deleting the",
+ "current branch, with or without a warning message.",
"",
- "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)
@@ -276,14 +264,14 @@ static const char *update(struct command *cmd)
switch (deny_current_branch) {
case DENY_IGNORE:
break;
- case DENY_UNCONFIGURED:
case DENY_WARN:
warning("updating the current branch");
- if (deny_current_branch == DENY_UNCONFIGURED)
- warn_unconfigured_deny();
break;
case DENY_REFUSE:
+ case DENY_UNCONFIGURED:
error("refusing to update checked out branch: %s", name);
+ if (deny_current_branch == DENY_UNCONFIGURED)
+ refuse_unconfigured_deny();
return "branch is currently checked out";
}
}
@@ -305,12 +293,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";
}