Skip to content

Fixes for git branch -m / update-ref --no-deref -d

Miklos Vajna git 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest2 patches 1 replyIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2Fix git branch -m for symrefs.builtin-branch.c builtin-receive-pack.c builtin-remote.c +7 more+53 -3013 replies
2/2Fix git update-ref --no-deref -d.builtin-update-ref.c t/t1400-update-ref.sh+12 -30 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH 0/2] Fixes for git branch -m / update-ref --no-deref -d
Quoted 6 lines · Junio C Hamano

Hmm, remote_get() can read from all three supported places that you can
define remotes. Could you explain what happens if the old remote is read
from say $GIT_DIR/remotes/origin and you are renaming it to "upstream" with "git remote rename origin upstream"?

While trying to answer your question, I noticed that rename_ref()/delete_ref() did not really handled symrefs.

Regarding rename_ref() (for users: git branch -m) I think you can't create symrefs in the refs/heads namespace without using plumbing, so most users are not affected.

Regarding delete_ref() (for users: git update-ref --no-deref -d) in most repos you just have HEAD as symref and you never want to delete it, but in case the user asks for it, I think we just have to do so.

Here are two patches to fix these issues (and in fact they will be required for git remote rename as well).

Miklos Vajna (2):
Fix git branch -m for symrefs.
Fix git update-ref --no-deref -d.

 builtin-branch.c       |    2 +-
 builtin-receive-pack.c |    2 +-
 builtin-remote.c       |    4 +-
 builtin-reset.c        |    2 +-
 builtin-send-pack.c    |    2 +-
 builtin-tag.c          |    2 +-
 builtin-update-ref.c   |    8 ++++--
 cache.h                |    2 +-
 refs.c                 |   56 ++++++++++++++++++++++++++++++------------------
 t/t1400-update-ref.sh  |    7 ++++++
 t/t3200-branch.sh      |    9 +++++++
 11 files changed, 64 insertions(+), 32 deletions(-)