From: Kaartic Sivaraam <kaarticsivaraam91196@gmail.com>
To: git@vger.kernel.org
Cc: Junio C Hamano <gitster@pobox.com>
Subject: Re: [BUG] Incosistent repository state when trying to rename HEAD in the middle of a rebase
Date: Thu, 02 Nov 2017 11:03:34 +0530 [thread overview]
Message-ID: <1509600814.9254.6.camel@gmail.com> (raw)
In-Reply-To: <1509209933.2256.4.camel@gmail.com>
I was able to spare some time to dig into this and found a few things.
First, it seems that the issue is more generic and the BUG kicks in
whenever HEAD is not a symbolic ref. I noticed that because when HEAD
is a symbolic ref there was a change in the error message shown by git.
In (2.11.0) I get this error message,
error: refname refs/heads/HEAD not found
fatal: Branch rename failed
while in the version build from 'next', I get the following error
message,
error: refname HEAD is a symbolic ref, renaming it is not supported
fatal: Branch rename failed
That made me suspicious and I wanted to find where the error message
got changed and bisected this which pointed to,
9416812db (branch: forbid refs/heads/HEAD, 2017-10-13)
This is the same commit which also causes the bug of allowing HEAD to
be renamed when it is not a symbolic ref. I found a way to fix this but
am not so sure if it's the right way to do this. (the diff patch is
found at the end of this mail).
One more observation I made was that without the patch at the end it is
NOT possible to rename a branch named "HEAD" created using the older
version!
On Sat, 2017-10-28 at 22:28 +0530, Kaartic Sivaraam wrote:
> git rebase-i HEAD~
>
Small correction here. Now you could replace that with the simpler,
git checkout HEAD^
diff --git a/sha1_name.c b/sha1_name.c
index c7c5ab376..4345e14c9 100644
--- a/sha1_name.c
+++ b/sha1_name.c
@@ -1334,7 +1334,13 @@ int strbuf_check_branch_ref(struct strbuf *sb, const char *name)
strbuf_branchname(sb, name, INTERPRET_BRANCH_LOCAL);
if (name[0] == '-')
return -1;
+
strbuf_splice(sb, 0, 0, "refs/heads/", 11);
+
+ /* HEAD is not to be used as a branch name */
+ if(!strcmp(sb->buf, "refs/heads/HEAD"))
+ return -1;
+
return check_refname_format(sb->buf, 0);
}
HTH,
Kaartic
next prev parent reply other threads:[~2017-11-02 5:36 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-28 16:58 [BUG] Incosistent repository state when trying to rename HEAD in the middle of a rebase Kaartic Sivaraam
2017-11-02 5:33 ` Kaartic Sivaraam [this message]
2017-11-02 7:51 ` Junio C Hamano
2017-11-03 9:23 ` Kaartic Sivaraam
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1509600814.9254.6.camel@gmail.com \
--to=kaarticsivaraam91196@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).