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>
Junio C Hamano committed
Feb 9, 2009 at 00:19 UTC
375881fa6a43e21ab922b20b2061f9868ef18644
2 files changed
+14
-25
builtin-receive-pack.c
+12
-18
@@ -241,30 +241,24 @@ static void refuse_unconfigured_deny(void)
241
error("%s", refuse_unconfigured_deny_msg[i]);
242
}
243
244
-static char *warn_unconfigured_deny_delete_current_msg[] = {
245
- "Deleting the current branch can cause confusion by making the next",
246
- "'git clone' not check out any file.",
244
+static char *refuse_unconfigured_deny_delete_current_msg[] = {
245
+ "By default, deleting the current branch is denied, because the next",
246
+ "'git clone' won't result in any file checked out, causing confusion.",
247
"",
248
"You can set 'receive.denyDeleteCurrent' configuration variable to",
249
- "'refuse' in the remote repository to disallow deleting the current",
250
- "branch.",
249
+ "'warn' or 'ignore' in the remote repository to allow deleting the",
250
+ "current branch, with or without a warning message.",
251
"",
252
- "You can set it to 'ignore' to allow such a delete without a warning.",
253
- "",
254
- "To make this warning message less loud, you can set it to 'warn'.",
255
- "",
256
- "Note that the default will change in a future version of git",
257
- "to refuse deleting the current branch unless you have the",
258
- "configuration variable set to either 'ignore' or 'warn'."
252
+ "To squelch this message, you can set it to 'refuse'."
253
};
254
261
-static void warn_unconfigured_deny_delete_current(void)
255
+static void refuse_unconfigured_deny_delete_current(void)
256
{
257
int i;
258
for (i = 0;
265
- i < ARRAY_SIZE(warn_unconfigured_deny_delete_current_msg);
259
+ i < ARRAY_SIZE(refuse_unconfigured_deny_delete_current_msg);
260
i++)
267
- warning("%s", warn_unconfigured_deny_delete_current_msg[i]);
261
+ error("%s", refuse_unconfigured_deny_delete_current_msg[i]);
262
}
263
264
static const char *update(struct command *cmd)
@@ -313,12 +307,12 @@ static const char *update(struct command *cmd)
307
case DENY_IGNORE:
308
break;
309
case DENY_WARN:
316
- case DENY_UNCONFIGURED:
317
- if (deny_delete_current == DENY_UNCONFIGURED)
318
- warn_unconfigured_deny_delete_current();
310
warning("deleting the current branch");
311
break;
312
case DENY_REFUSE:
313
+ case DENY_UNCONFIGURED:
314
+ if (deny_delete_current == DENY_UNCONFIGURED)
315
+ refuse_unconfigured_deny_delete_current();
316
error("refusing to delete the current branch: %s", name);
317
return "deletion of the current branch prohibited";
318
}
t/t5400-send-pack.sh
+2
-7
@@ -191,16 +191,11 @@ test_expect_success 'pushing wildcard refspecs respects forcing' '
191
test "$parent_head" = "$child_head"
192
'
193
194
-test_expect_success 'warn pushing to delete current branch' '
194
+test_expect_success 'deny pushing to delete current branch' '
195
rewound_push_setup &&
196
(
197
cd child &&
198
- git send-pack ../parent :refs/heads/master 2>errs
199
- ) &&
200
- grep "warning: to refuse deleting" child/errs &&
201
- (
202
- cd parent &&
203
- test_must_fail git rev-parse --verify master
198
+ test_must_fail git send-pack ../parent :refs/heads/master 2>errs
199
)
200
'
201