summaryrefslogtreecommitdiff
path: root/builtin-receive-pack.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2009-02-11 02:28:03 -0800
committerJunio C Hamano <gitster@pobox.com>2009-07-29 10:15:00 -0700
commitacd2a45b83e50c0f33b01ee74df241f1adfdff39 (patch)
tree2dd1dd6c6c0630ebb43b88e1cbd8256ebbd83659 /builtin-receive-pack.c
parent6641575963388b61f408f177d91cdacad25d2e26 (diff)
downloadgit-acd2a45b83e50c0f33b01ee74df241f1adfdff39.tar.gz
Refuse updating the current branch in a non-bare repository via push
This makes git-push refuse pushing into a non-bare repository to update the current branch by default. To help people who are used to be able to do this (and later "reset --hard" it in some other way), an error message is issued when this refusal is triggered, instructing how to resurrect the old behaviour. Hosting sites that do not give the users direct access to customize their repositories (e.g. repo.or.cz, gitorious, github etc.) may further want to explicitly set the configuration variable to "refuse" for their customers' repositories. Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin-receive-pack.c')
-rw-r--r--builtin-receive-pack.c40
1 files changed, 17 insertions, 23 deletions
diff --git a/builtin-receive-pack.c b/builtin-receive-pack.c
index 6ec1d056e6..b8b69dde48 100644
--- a/builtin-receive-pack.c
+++ b/builtin-receive-pack.c
@@ -218,33 +218,27 @@ 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[] = {
@@ -290,14 +284,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";
}
}