[PATCH 0/2] Fixes for git branch -m / update-ref --no-deref -d
From: Miklos Vajna <hidden>
Date: 2016-06-15 22:45:31
On Fri, Oct 24, 2008 at 04:33:28PM -0700, Junio C Hamano [off-list ref] wrote:
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(-)