From: Wincent Colaiuta Date: Mon, 26 Nov 2007 13:15:29 GMT Subject: Re: Rebase/cherry-picking idea Message-ID: <451492C9-F3EA-4C37-A1AD-59FC72E0A0A2@wincent.com> In-Reply-To: <474AC136.8060906@viscovery.net> El 26/11/2007, a las 13:51, Johannes Sixt escribió: > Wincent Colaiuta schrieb: >> El 26/11/2007, a las 12:27, Wincent Colaiuta escribió: >>> So I think that misleading noise needs to be suppressed or >>> reworded when rebasing. Will look into it. >> How about something like this? It would obviously be nice if we >> could avoid adding another option to builtin-revert; perhaps when/ >> if git-rebase becomes a builtin we can avoid that. The other >> alternative, and probably one I like I bit more, would be to auto- >> detect that a rebase is in progress by looking inside the GIT_DIR, >> although that would also alter the behaviour of manual invocations >> of git-revert and git-cherry-pick during an interactive rebase (do >> people actually do that?). What do you think? > > Introduce an environment variable _GIT_CHERRY_PICK_HELP (note the > leading underscore), which git-rebase sets; if it's set, git-cherry- > pick uses that text instead of the usual one. Good idea, quite a bit less cruddy: 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 ' " - "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" ;;