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

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

From
ZheNing Hu via GitGitGadget <gitgitgadget@gmail.com>
Date
Jan 17, 2023, 10:32 UTC
Message-ID
<pull.1465.git.1673951562.gitgitgadget@gmail.com>

This might be an odd request: allow git push to delete one level refs like "ref/foo".

Some users on my side often push "refs/for/master" to the remote for code review, but due to a user's typo, "refs/master" is pushed to the remote.

Pushing a one level ref like "refs/foo" should not have been successful, but since my server side directly updated the ref during the proc-receive-hook phase of git receive-pack, "refs/foo" was mistakenly left at on the server.

But for some reasons, users cannot delete this special branch through "git push -d".

First, I executed git update-ref --stdin inside my proc-receive-hook to delete the branch. As a result, update-ref reported an error: "cannot lock ref 'refs/foo': reference already exists".

So I tried GIT_TRACKET_PACKET to debug and found that git push did not seem to pass the correct ref old-oid, which is why update-ref reported an error.

"18:13:41.214872 pkt-line.c:80           packet: receive-pack< 0000000000000000000000000000000000000000 0000000000000000000000000000000000000000 refs/foo\0 report-status-v2 side-band-64k object-format=sha1 agent=git/2.39.0.227.g262c45b6a1"

Tracing it back, the check_ref() in the git push link didn't record the old-oid for the remote "refs/foo".

At the same time, the server update() process will reject the one level ref by default and return a "funny refname" error.

It is worth mentioning that since I deleted the branch, the error message returned here is "refusing to create funny ref 'refs/foo' remotely", which is also worth fixing.

So this patch series do:
v1.
 1. fix funny refname error message from "create" to "update".
 2. let server allow delete one level ref.
 3. let client pass correct one level ref old-oid.
ZheNing Hu (2):
  receive-pack: fix funny ref error messsage
  [RFC] push: allow delete one level ref
 builtin/receive-pack.c |  7 +++++--
 connect.c              |  2 +-
 t/t5516-fetch-push.sh  | 18 ++++++++++++++++++
 3 files changed, 24 insertions(+), 3 deletions(-)
base-commit: a38d39a4c50d1275833aba54c4dbdfce9e2e9ca1
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-1465%2Fadlternative%2Fzh%2Fdelete-one-level-ref-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-1465/adlternative/zh/delete-one-level-ref-v1
Pull-Request: https://github.com/gitgitgadget/git/pull/1465
-- 
gitgitgadget
Next: ZheNing Hu via GitGitGadget
Message 1 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.