From: Conrad Irwin <conrad.irwin@gmail.com>
To: Jonathan Nieder <jrnieder@gmail.com>
Cc: "☂Josh Chia (谢任中)" <joshchia@gmail.com>,
git@vger.kernel.org, "Soeren Sonnenburg" <sonne@debian.org>
Subject: Re: git branch -M" regression in 1.7.7?
Date: Fri, 25 Nov 2011 23:05:26 -0800 [thread overview]
Message-ID: <CAOTq_pv4dyAkbqye+diK9mTTsrTg9OKg0tExKcfDgs8RfiTwTQ@mail.gmail.com> (raw)
In-Reply-To: <20111126023002.GA17652@elie.hsd1.il.comcast.net>
On Fri, Nov 25, 2011 at 6:30 PM, Jonathan Nieder <jrnieder@gmail.com> wrote:
> A reproduction recipe (preferrably in the form of a patch to
> t/t3200-branch.sh would be welcome.
Sent in a separate email. Feel free to add a "Tested-by:" header to
your patch if you want :).
>
> -- >8 --
> Subject: treat "git branch -M master master" as a no-op again
>
> Before v1.7.7-rc2~1^2~2 (Prevent force-updating of the current branch,
> 2011-08-20), commands like "git branch -M topic master" could be used
> even when "master" was the current branch, with the somewhat
> counterintuitive result that HEAD would point to some place new while
> the index and worktree kept the content of the old commit. This is
> not a very sensible operation and the result is what almost nobody
> would expect, so erroring out in this case was a good change.
>
> However, there is one exception to the "it's usually not obvious what
> it would mean to overwrite the current branch by another one" rule.
> Namely:
>
> git branch -M master master
>
> is clearly meant to be a no-op, even if you are on the master branch.
Agreed. I thought after reading your patch about making it just do:
if (!strcmp(oldname, newname))
exit(0);
but I guess it would then not mark an entry in the reflog that people
could be relying on...
> + clobber_head_ok = !strcmp(oldname, newname);
> +
> + validate_new_branchname(newname, &newref, force, clobber_head_ok);
This looks ok, and will be improvable if the NEEDSWORK in branch.h is done.
The other thing I wonder is whether "git checkout -B master HEAD" or
"git branch -f master master" should have the same short-cut?
Conrad
next prev parent reply other threads:[~2011-11-26 7:07 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-11-26 0:36 git branch -M" regression in 1.7.7? ☂Josh Chia (谢任中)
2011-11-26 2:30 ` Jonathan Nieder
2011-11-26 6:52 ` [PATCH] Test renaming a branch to itself Conrad Irwin
2011-11-26 6:59 ` Jonathan Nieder
2011-11-26 7:05 ` Conrad Irwin [this message]
2011-11-26 8:54 ` git branch -M" regression in 1.7.7? Jonathan Nieder
2011-11-26 22:38 ` Junio C Hamano
2011-11-26 23:09 ` Andreas Schwab
2011-11-28 19:38 ` Junio C Hamano
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAOTq_pv4dyAkbqye+diK9mTTsrTg9OKg0tExKcfDgs8RfiTwTQ@mail.gmail.com \
--to=conrad.irwin@gmail.com \
--cc=git@vger.kernel.org \
--cc=joshchia@gmail.com \
--cc=jrnieder@gmail.com \
--cc=sonne@debian.org \
/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.
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 NNTP newsgroup(s).