From 7c3c55026c25f038d790d21fb7242229a9a08fed Mon Sep 17 00:00:00 2001 From: ZheNing Hu Date: Wed, 1 Mar 2023 10:20:29 +0000 Subject: push: allow delete single-level ref We discourage the creation/update of single-level refs because some upper-layer applications only work in specified reference namespaces, such as "refs/heads/*" or "refs/tags/*", these single-level refnames may not be recognized. However, we still hope users can delete them which have been created by mistake. Therefore, when updating branches on the server with "git receive-pack", by checking whether it is a branch deletion operation, it will determine whether to allow the update of a single-level refs. This avoids creating/updating such single-level refs, but allows them to be deleted. On the client side, "git push" also does not properly fill in the old-oid of single-level refs, which causes the server-side "git receive-pack" to think that the ref's old-oid has changed when deleting single-level refs, this causes the push to be rejected. So the solution is to fix the client to be able to delete single-level refs by properly filling old-oid. Signed-off-by: ZheNing Hu Signed-off-by: Junio C Hamano --- connect.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'connect.c') diff --git a/connect.c b/connect.c index 63e59641c0..7a396ad72e 100644 --- a/connect.c +++ b/connect.c @@ -30,7 +30,8 @@ static int check_ref(const char *name, unsigned int flags) return 0; /* REF_NORMAL means that we don't want the magic fake tag refs */ - if ((flags & REF_NORMAL) && check_refname_format(name, 0)) + if ((flags & REF_NORMAL) && check_refname_format(name, + REFNAME_ALLOW_ONELEVEL)) return 0; /* REF_HEADS means that we want regular branch heads */ -- cgit v1.3