rebase -i: stop setting GIT_CHERRY_PICK_HELP

Setting this environment variable causes the sequencer to display a custom message when it stops for the user to resolve conflicts and remove CHERRY_PICK_HEAD. Setting it in "git rebase" is a vestige of the scripted implementation, now that it is a builtin command we do not need to communicate with the sequencer machinery via environment variables. Move the conflicts advice to use when rebasing into sequencer.c so we do not need to pass it via the environment. Note that we retain the changes in e4301f73fff (sequencer: unset GIT_CHERRY_PICK_HELP for 'exec' commands, 2024-02-02) just in case GIT_CHERRY_PICK_HELP is set in the environment when "git rebase" is run. Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Phillip Wood committed Feb 27, 2024 at 14:06 UTC 72a8d3f027a5ea04ac453583105b368cd88648cd
3 files changed +18 -12
builtin/rebase.c
+3 -11
@@ -567,13 +567,6 @@ static int move_to_original_branch(struct rebase_options *opts)
567 return ret;
568 }
569
570 -static const char *resolvemsg =
571 -N_("Resolve all conflicts manually, mark them as resolved with\n"
572 -"\"git add/rm <conflicted_files>\", then run \"git rebase --continue\".\n"
573 -"You can instead skip this commit: run \"git rebase --skip\".\n"
574 -"To abort and get back to the state before \"git rebase\", run "
575 -"\"git rebase --abort\".");
576 -
570 static int run_am(struct rebase_options *opts)
571 {
572 struct child_process am = CHILD_PROCESS_INIT;
@@ -587,7 +580,7 @@ static int run_am(struct rebase_options *opts)
580 opts->reflog_action);
581 if (opts->action == ACTION_CONTINUE) {
582 strvec_push(&am.args, "--resolved");
590 - strvec_pushf(&am.args, "--resolvemsg=%s", resolvemsg);
583 + strvec_pushf(&am.args, "--resolvemsg=%s", rebase_resolvemsg);
584 if (opts->gpg_sign_opt)
585 strvec_push(&am.args, opts->gpg_sign_opt);
586 status = run_command(&am);
@@ -598,7 +591,7 @@ static int run_am(struct rebase_options *opts)
591 }
592 if (opts->action == ACTION_SKIP) {
593 strvec_push(&am.args, "--skip");
601 - strvec_pushf(&am.args, "--resolvemsg=%s", resolvemsg);
594 + strvec_pushf(&am.args, "--resolvemsg=%s", rebase_resolvemsg);
595 status = run_command(&am);
596 if (status)
597 return status;
@@ -672,7 +665,7 @@ static int run_am(struct rebase_options *opts)
665
666 strvec_pushv(&am.args, opts->git_am_opts.v);
667 strvec_push(&am.args, "--rebasing");
675 - strvec_pushf(&am.args, "--resolvemsg=%s", resolvemsg);
668 + strvec_pushf(&am.args, "--resolvemsg=%s", rebase_resolvemsg);
669 strvec_push(&am.args, "--patch-format=mboxrd");
670 if (opts->allow_rerere_autoupdate == RERERE_AUTOUPDATE)
671 strvec_push(&am.args, "--rerere-autoupdate");
@@ -700,7 +693,6 @@ static int run_specific_rebase(struct rebase_options *opts)
693
694 if (opts->type == REBASE_MERGE) {
695 /* Run sequencer-based rebase */
703 - setenv("GIT_CHERRY_PICK_HELP", resolvemsg, 1);
696 if (!(opts->flags & REBASE_INTERACTIVE_EXPLICIT))
697 setenv("GIT_SEQUENCE_EDITOR", ":", 1);
698 if (opts->gpg_sign_opt) {
sequencer.c
+13 -1
@@ -461,10 +461,22 @@ static void free_message(struct commit *commit, struct commit_message *msg)
461 repo_unuse_commit_buffer(the_repository, commit, msg->message);
462 }
463
464 +const char *rebase_resolvemsg =
465 +N_("Resolve all conflicts manually, mark them as resolved with\n"
466 +"\"git add/rm <conflicted_files>\", then run \"git rebase --continue\".\n"
467 +"You can instead skip this commit: run \"git rebase --skip\".\n"
468 +"To abort and get back to the state before \"git rebase\", run "
469 +"\"git rebase --abort\".");
470 +
471 static void print_advice(struct repository *r, int show_hint,
472 struct replay_opts *opts)
473 {
467 - char *msg = getenv("GIT_CHERRY_PICK_HELP");
474 + const char *msg;
475 +
476 + if (is_rebase_i(opts))
477 + msg = rebase_resolvemsg;
478 + else
479 + msg = getenv("GIT_CHERRY_PICK_HELP");
480
481 if (msg) {
482 advise("%s\n", msg);
sequencer.h
+2
@@ -14,6 +14,8 @@ const char *rebase_path_todo(void);
14 const char *rebase_path_todo_backup(void);
15 const char *rebase_path_dropped(void);
16
17 +extern const char *rebase_resolvemsg;
18 +
19 #define APPEND_SIGNOFF_DEDUP (1u << 0)
20
21 enum replay_action {