git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dmitry Potapov <dpotapov@gmail.com>
To: Theodore Tso <tytso@mit.edu>
Cc: git@vger.kernel.org, Junio C Hamano <gitster@pobox.com>
Subject: [PATCH v2] don't allow 'commit --amend' during rebase conflict resolution
Date: Thu, 26 Jun 2008 17:33:58 +0400	[thread overview]
Message-ID: <20080626133358.GG5737@dpotapov.dyndns.org> (raw)
In-Reply-To: <20080626121303.GF8610@mit.edu>

Running 'commit --amend' during git rebase is almost certainly a mistake,
which causes that two consequent patches are squashed together. Moreover,
the commit message of the second commit is silently lost. It is almost
certainly not what the user expects. In that very unlikely case when you
really want to combine two patches during rebase conflict resolution,
you can do that using "git reset --soft HEAD^" followed by "git commit".
---

On Thu, Jun 26, 2008 at 08:13:03AM -0400, Theodore Tso wrote:
> 
> In fact, we do this already for git-merge.  Why not just do the same
> thing in the middle of a merge conflict with git-rebase?

Thank you for suggestion. I have corrected my patch to so the same as
we do in the case of git-merge conflict. MERGE_MSG is already removed
on successful commit, so the patch is very simple now.

 builtin-commit.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/builtin-commit.c b/builtin-commit.c
index e3ad38b..6d1d955 100644
--- a/builtin-commit.c
+++ b/builtin-commit.c
@@ -725,6 +725,10 @@ static int parse_and_validate_options(int argc, const char *argv[],
 		die("You have nothing to amend.");
 	if (amend && in_merge)
 		die("You are in the middle of a merge -- cannot amend.");
+	/* no MERGE_HEAD but MERGE_MSG means a conflict during rebase */
+	if (amend && !access(git_path("MERGE_MSG"), F_OK))
+		die("You are in the middle of a rebase conflict -- "
+			"cannot amend.");
 
 	if (use_message)
 		f++;
-- 
1.5.6.60.gbc566

      reply	other threads:[~2008-06-26 13:35 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-06-25 23:32 git rebase interactive: usability issue Dmitry Potapov
2008-06-26  2:17 ` Johannes Schindelin
2008-06-26  3:32   ` Junio C Hamano
2008-06-26  3:59     ` Avery Pennarun
2008-06-26 11:35     ` Dmitry Potapov
2008-06-26 12:13 ` Theodore Tso
2008-06-26 13:33   ` Dmitry Potapov [this message]

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=20080626133358.GG5737@dpotapov.dyndns.org \
    --to=dpotapov@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=tytso@mit.edu \
    /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).