git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH v2 2/2] [RFC] push: allow delete one level ref

From
Junio C Hamano <gitster@pobox.com>
Date
Feb 6, 2023, 22:13 UTC
Message-ID
<xmqqbkm64f3t.fsf@gitster.g>
In-Reply-To
<966cb49c388b652861c773ad7430875bf7896c16.1675529298.git.gitgitgadget@gmail.com>
"ZheNing Hu via GitGitGadget" <gitgitgadget@gmail.com> writes:
Show 12 quoted lines
> diff --git a/builtin/receive-pack.c b/builtin/receive-pack.c
> index 13ff9fae3ba..77088f5ba8d 100644
> --- a/builtin/receive-pack.c
> +++ b/builtin/receive-pack.c
> @@ -1463,7 +1463,9 @@ static const char *update(struct command *cmd, struct shallow_info *si)
>  		find_shared_symref(worktrees, "HEAD", name);
>  
>  	/* only refs/... are allowed */
> -	if (!starts_with(name, "refs/") || check_refname_format(name + 5, 0)) {
> +	if (!starts_with(name, "refs/") ||
> +	    check_refname_format(name + 5, is_null_oid(new_oid) ?
> +				 REFNAME_ALLOW_ONELEVEL : 0)) {

I am somehow smelling that this is about "refs/stash" and it may be a good thing to allow removing a leftover refs/stash remotely. I am not sure why we need to treat it differently while still blocking update/modification.

Is it that we are actively discouraging one-level refs like refs/stash, so removing is fine but once removed we do not allow creating or updating? It somewhat smells a hard to explain rule to the users, at least to me.

Show 12 quoted lines
> diff --git a/connect.c b/connect.c
> index 63e59641c0d..7a396ad72e9 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;
This side of the change does make sense.
Thanks.
Previous: ZheNing Hu via GitGitGadgetNext: ZheNing Hu
Message 9 of 20 in “[RFC] push: allow delete one level ref”
  1. 0/2 [RFC] push: allow delete one level refZheNing Hu via GitGitGadget, Jan 17, 2023
  2. 1/2 receive-pack: fix funny ref error messsageZheNing Hu via GitGitGadget, Jan 17, 2023
  3. 2/2 [RFC] push: allow delete one level refZheNing Hu via GitGitGadget, Jan 17, 2023
  4. Ævar Arnfjörð BjarmasonJan 17, 2023
  5. ZheNing HuJan 19, 2023
  6. 0/2 [RFC] push: allow delete one level refZheNing Hu via GitGitGadget, Feb 4, 2023
  7. 1/2 receive-pack: fix funny ref error messsageZheNing Hu via GitGitGadget, Feb 4, 2023
  8. 2/2 [RFC] push: allow delete one level refZheNing Hu via GitGitGadget, Feb 4, 2023
  9. Junio C HamanoFeb 6, 2023
  10. ZheNing HuFeb 24, 2023
  11. Junio C HamanoFeb 24, 2023
  12. ZheNing HuFeb 25, 2023
  13. 0/2 [RFC] push: allow delete one level refZheNing Hu via GitGitGadget, Feb 27, 2023
  14. 1/2 receive-pack: fix funny ref error messsageZheNing Hu via GitGitGadget, Feb 27, 2023
  15. Junio C HamanoFeb 27, 2023
  16. ZheNing HuMar 1, 2023
  17. 2/2 [RFC] push: allow delete single-level refZheNing Hu via GitGitGadget, Feb 27, 2023
  18. 0/2 [RFC] push: allow delete one level refZheNing Hu via GitGitGadget, Mar 1, 2023
  19. 1/2 receive-pack: fix funny ref error messsageZheNing Hu via GitGitGadget, Mar 1, 2023
  20. 2/2 push: allow delete single-level refZheNing Hu via GitGitGadget, Mar 1, 2023

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.