git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Wincent Colaiuta <win@wincent.com>
To: git@vger.kernel.org
Cc: gitster@pobox.com, tsuna@lrde.epita.fr, j.sixt@viscovery.net,
	Johannes.Schindelin@gmx.de, mcostalba@gmail.com,
	Wincent Colaiuta <win@wincent.com>
Subject: [PATCH] Replace misleading message during interactive rebasing
Date: Mon, 26 Nov 2007 22:18:11 +0100	[thread overview]
Message-ID: <1196111891-18518-1-git-send-email-win@wincent.com> (raw)

git-rebase--interactive uses git-cherry-pick under the covers to reorder
commits, which in turn means that in the event of a conflict a message
will be shown advising the user to commit the results and use the -c
switch to retain authorship after fixing the conflict.

The message is misleading because what the user really needs to do is
run "git rebase --continue"; the committing is handled by git-rebase
and the authorship of the commit message is retained automatically.

We solve this problem by using an environment variable to communicate
to git-cherry-pick that rebasing is underway and replace the misleading
error message with a more helpful one.

Signed-off-by: Wincent Colaiuta <win@wincent.com>
---

This applies on top of "master".

The question of whether the environment variable should have a leading
underscore came up on the mailing list. I don't really care at all either
way, I'd just like to see the misleading message go away. I'll leave it
up to others to decide.

Another thing to decide is whether the help text should be more than
just "run 'git rebase --continue'", but should mention
"git rebase --abort" as well. Junio, please feel free to modify the
patch if you think it would be appropriate.

 builtin-revert.c           |    8 +++++---
 git-rebase--interactive.sh |    2 ++
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/builtin-revert.c b/builtin-revert.c
index a0586f9..5a57574 100644
--- a/builtin-revert.c
+++ b/builtin-revert.c
@@ -229,7 +229,7 @@ static int revert_or_cherry_pick(int argc, const char **argv)
 	unsigned char head[20];
 	struct commit *base, *next, *parent;
 	int i;
-	char *oneline, *reencoded_message = NULL;
+	char *oneline, *reencoded_message = NULL, *help_message;
 	const char *message, *encoding;
 	const char *defmsg = xstrdup(git_path("MERGE_MSG"));
 
@@ -352,11 +352,13 @@ static int revert_or_cherry_pick(int argc, const char **argv)
 		}
 		if (close(msg_fd) || commit_lock_file(&msg_file) < 0)
 			die ("Error wrapping up %s", defmsg);
+		help_message = getenv("_GIT_CHERRY_PICK_HELP");
 		fprintf(stderr, "Automatic %s failed.  "
 			"After resolving the conflicts,\n"
 			"mark the corrected paths with 'git add <paths>' "
-			"and commit the result.\n", me);
-		if (action == CHERRY_PICK) {
+			"and %s.\n", me,
+			help_message ? help_message : "commit the result");
+		if (action == CHERRY_PICK && !help_message) {
 			fprintf(stderr, "When commiting, use the option "
 				"'-c %s' to retain authorship and message.\n",
 				find_unique_abbrev(commit->object.sha1,
diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh
index bf44b6a..e5f9810 100755
--- a/git-rebase--interactive.sh
+++ b/git-rebase--interactive.sh
@@ -117,6 +117,7 @@ pick_one () {
 		sha1=$(git rev-parse --short $sha1)
 		output warn Fast forward to $sha1
 	else
+		export _GIT_CHERRY_PICK_HELP="run 'git rebase --continue'"
 		output git cherry-pick "$@"
 	fi
 }
@@ -187,6 +188,7 @@ pick_one_preserving_merges () {
 			fi
 			;;
 		*)
+			export _GIT_CHERRY_PICK_HELP="run 'git rebase --continue'"
 			output git cherry-pick "$@" ||
 				die_with_patch $sha1 "Could not pick $sha1"
 			;;
-- 
1.5.3.6.952.g84ef

             reply	other threads:[~2007-11-26 21:24 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-11-26 21:18 Wincent Colaiuta [this message]
2007-11-27  8:31 ` [PATCH] Replace misleading message during interactive rebasing Johannes Sixt
2007-11-27  8:49   ` Wincent Colaiuta
2007-11-27  9:46   ` Jeff King
2007-11-27  9:49     ` Jakub Narebski
2007-11-27  9:52       ` Jeff King
2007-11-27 10:15       ` Jeff King
2007-11-28  4:37   ` Junio C Hamano
2007-11-28  8:26     ` Wincent Colaiuta
2007-11-28 12:41       ` Johannes Schindelin
2007-11-28 12:53         ` Johannes Sixt

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=1196111891-18518-1-git-send-email-win@wincent.com \
    --to=win@wincent.com \
    --cc=Johannes.Schindelin@gmx.de \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=j.sixt@viscovery.net \
    --cc=mcostalba@gmail.com \
    --cc=tsuna@lrde.epita.fr \
    /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).