From: Hariom Verma <hariom18599@xxxxxxxxx> git supports an interesting feature 'Git namespaces' that allows dividing the refs of a single repository into multiple namespaces, each of which has its own branches, tags, and HEAD. But unfortunately, there exists a bug in `denyCurrentBranch` which allows pushing into a non-bare repository using a ref namespace even if it does not have any commits Here is a nice and short demonstration of that bug. Helped-by: Johannes Schindelin <johannes.schindelin@xxxxxx> Signed-off-by: Hariom Verma <hariom18599@xxxxxxxxx> --- t/t5509-fetch-push-namespaces.sh | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/t/t5509-fetch-push-namespaces.sh b/t/t5509-fetch-push-namespaces.sh index e3975bd21de..c89483fdba2 100755 --- a/t/t5509-fetch-push-namespaces.sh +++ b/t/t5509-fetch-push-namespaces.sh @@ -152,4 +152,13 @@ test_expect_success 'clone chooses correct HEAD (v2)' ' test_cmp expect actual ' +test_expect_failure 'denyCurrentBranch and unborn branch with ref namespace' ' + cd original && + git init unborn && + git remote add unborn-namespaced "ext::git --namespace=namespace %s unborn" && + test_must_fail git push unborn-namespaced HEAD:master && + test_config -C unborn receive.denyCurrentBranch updateInstead && + git push unborn-namespaced HEAD:master +' + test_done -- gitgitgadget