git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Christian Couder <christian.couder@gmail.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: git <git@vger.kernel.org>, "SZEDER Gábor" <szeder@ira.uka.de>
Subject: Re: BUG: "cherry-pick A..B || git reset --hard OTHER"
Date: Wed, 7 Dec 2016 15:31:32 +0100	[thread overview]
Message-ID: <CAP8UFD32PcT4XgnRFaP-St3i1D-6XG1wY6qKn3bgWPKn1Y4Qwg@mail.gmail.com> (raw)
In-Reply-To: <xmqqlgvs28bh.fsf@gitster.mtv.corp.google.com>

On Tue, Dec 6, 2016 at 7:58 PM, Junio C Hamano <gitster@pobox.com> wrote:
> I was burned a few times with this in the past few years, but it did
> not irritate me often enough that I didn't write it down.  But I
> think this is serious enough that deserves attention from those who
> were involved.

Yeah, I agree that we should do something about it.

> A short reproduction recipe, using objects from git.git that are
> publicly available and stable, shows how bad it is.
>
>     $ git checkout v2.9.3^0
>
>     $ git cherry-pick 0582a34f52..a94bb68397
>     ... see conflict, decide to give up backporting to
>     ... such an old fork point.
>     ... the git-prompt gives "|CHERRY-PICKING" correctly.
>
>     $ git reset --hard v2.10.2^0
>     ... the git-prompt no longer says "|CHERRY-PICKING"
>
>     $ edit && git commit -m "prelim work for backporting"
>     [detached HEAD cc5a6a9219] prelim work for backporting
>
>     $ git cherry-pick 0582a34f52..a94bb68397
>     error: a cherry-pick or revert is already in progress
>     hint: try "git cherry-pick (--continue | --quit | --abort)"
>     fatal: cherry-pick failed
>
>     $ git cherry-pick --abort
>     ... we come back to v2.9.3^0, losing the new commit!
>
> The above shows two bugs.
>
>  (1) The third invocation of "cherry-pick" with "--abort" to get rid
>      of the state from the unfinished cherry-pick we did previously
>      is necessary, but the command does not notice that we resetted
>      to a new branch AND we even did some other work there.  This
>      loses end-user's work.
>
>      "git cherry-pick --abort" should learn from "git am --abort"
>      that has an extra safety to deal with the above workflow.  The
>      state from the unfinished "am" is removed, but the head is not
>      rewound to avoid losing end-user's work.
>
>      You can try by replacing two instances of
>
>         $ git cherry-pick 0582a34f52..a94bb68397
>
>      with
>
>         $ git format-patch --stdout 0582a34f52..a94bb68397 | git am
>
>      in the above sequence, and conclude with "git am--abort" to see
>      how much more pleasant and safe "git am --abort" is.

Ok I will try to take a look at that next week.

>  (2) The bug in "cherry-pick --abort" is made worse because the
>      git-completion script seems to be unaware of $GIT_DIR/sequencer
>      and stops saying "|CHERRY-PICKING" after the step to switch to
>      a different state with "git reset --hard v2.10.2^0".  If the
>      prompt showed it after "git reset", the end user would have
>      thought twice before starting the "prelim work".

I am not used to hacking the prompt or completion scripts, so I would
appreciate if someone else could do it.

Thanks,
Christian.

  reply	other threads:[~2016-12-07 14:31 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-12-06 18:58 BUG: "cherry-pick A..B || git reset --hard OTHER" Junio C Hamano
2016-12-07 14:31 ` Christian Couder [this message]
2016-12-07 18:36 ` Stephan Beyer
2016-12-07 20:04   ` Junio C Hamano
2016-12-07 20:35     ` Stephan Beyer
2016-12-07 23:21       ` Duy Nguyen
2016-12-09 11:33     ` Duy Nguyen
2016-12-09 11:34       ` [PATCH] rebase: rename --forget to be consistent with sequencer Nguyễn Thái Ngọc Duy
2016-12-09 11:34         ` [PATCH] revert, cherry-pick: rename --quit to be consistent with rebase Nguyễn Thái Ngọc Duy
2016-12-09 18:07       ` BUG: "cherry-pick A..B || git reset --hard OTHER" Junio C Hamano
2016-12-09 19:24         ` Stephan Beyer
2016-12-09 19:28           ` Stephan Beyer
2016-12-10 11:00           ` Duy Nguyen
2016-12-10 21:23             ` Junio C Hamano
2016-12-08  7:50   ` Christian Couder
2016-12-07 21:51 ` [PATCH 1/5] am: Fix filename in safe_to_abort() error message Stephan Beyer
2016-12-08 10:21   ` Paul Tan
2016-12-07 21:51 ` [PATCH 2/5] am: Change safe_to_abort()'s not rewinding error into a warning Stephan Beyer
2016-12-07 21:51 ` [PATCH 3/5] Add test that cherry-pick --abort does not unsafely change HEAD Stephan Beyer
2016-12-07 21:51 ` [PATCH 4/5] Make sequencer abort safer Stephan Beyer
2016-12-08 15:28   ` Johannes Schindelin
2016-12-08 17:27     ` Junio C Hamano
2016-12-08 19:17       ` Stephan Beyer
2016-12-09 18:33         ` Junio C Hamano
2016-12-09 19:01           ` [PATCH v2 1/5] am: Fix filename in safe_to_abort() error message Stephan Beyer
2016-12-09 19:01           ` [PATCH v2 2/5] am: Change safe_to_abort()'s not rewinding error into a warning Stephan Beyer
2016-12-09 19:01           ` [PATCH v2 3/5] Add test that cherry-pick --abort does not unsafely change HEAD Stephan Beyer
2016-12-09 19:01           ` [PATCH v2 4/5] Make sequencer abort safer Stephan Beyer
2016-12-10 19:56             ` Christian Couder
2016-12-10 20:04               ` Jeff King
2016-12-10 20:20                 ` Stephan Beyer
2016-12-09 19:01           ` [PATCH v2 5/5] sequencer: Remove useless get_dir() function Stephan Beyer
2016-12-07 21:51 ` [PATCH " Stephan Beyer

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=CAP8UFD32PcT4XgnRFaP-St3i1D-6XG1wY6qKn3bgWPKn1Y4Qwg@mail.gmail.com \
    --to=christian.couder@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=szeder@ira.uka.de \
    /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).