From: Junio C Hamano <gitster@pobox•com>
To: Shawn Pearce <spearce@spearce•org>
Cc: git <git@vger•kernel.org>
Subject: Re: git commit --amend safety check?
Date: Tue, 10 Mar 2015 22:11:43 -0700 [thread overview]
Message-ID: <xmqq8uf46ru8.fsf@gitster.dls.corp.google.com> (raw)
In-Reply-To: <CAJo=hJuwdOzNZSVBRAPDz97Gdoi6JWvYxE0ufY+Hd9K8jjCqfA@mail.gmail.com> (Shawn Pearce's message of "Tue, 10 Mar 2015 21:31:40 -0700")
Shawn Pearce <spearce@spearce•org> writes:
> We keep seeing reports of Gerrit Code Review users who incorrectly do
> something like:
>
> git clone URL foo
> cd foo
> git commit --amend -m "My first change!" -a
> git push URL HEAD:refs/for/master
>
> Step #3 is where they get into trouble. They just amended the
> published tip commit and pushed it back to the server. That is... lets
> just say not good.
>
> Hg is known to be more user friendly. One way its user friendly is it
> by default refuses to let you amend a change set that the client has
> reasonable assertion to believe was already published through a remote
> repository.
Well, it is not Git that is less user friendly, but Gerrit is the
problem. More specifically, the last line:
> git push URL HEAD:refs/for/master
is what catches this non-fast-forward in usual workflow with Git.
Wouldn't the real problem that the refs/for/master magic accepts
anything, even a non-fast-forward?
Having said that, disabling --amend and forcing to use --force or
something when it is clear that the user is attempting something
unusual is a good idea. But I am not sure what the definition of
unusual should be. In a non-Gerrit central repository workflow, the
rule might be "HEAD must not be reachable from @{upstream}"
(otherwise you are rewriting what you got from elsewhere), or it may
be "HEAD must not be reachable from @{publish}'s remote tracking
branch", or perhaps both, as these two could be different in
triangular workflow.
But I am not sure what the sensible rules are when the user prepares
the commit, planning to push it to a ref like refs/for/master that
does not have a counterpart on our side.
next prev parent reply other threads:[~2015-03-11 5:11 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-11 4:31 git commit --amend safety check? Shawn Pearce
2015-03-11 5:11 ` Junio C Hamano [this message]
2015-03-11 6:00 ` Shawn Pearce
2015-03-11 6:18 ` Junio C Hamano
2015-03-11 6:33 ` Mike Hommey
2015-03-11 8:13 ` Jeff King
2015-03-11 8:37 ` Peter Krefting
2015-03-11 17:56 ` 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=xmqq8uf46ru8.fsf@gitster.dls.corp.google.com \
--to=gitster@pobox$(echo .)com \
--cc=git@vger$(echo .)kernel.org \
--cc=spearce@spearce$(echo .)org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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