]> git.ipfire.org Git - thirdparty/git.git/commitdiff
Merge branch 'pw/rebase-i-ignore-cherry-pick-help-environment'
authorJunio C Hamano <gitster@pobox.com>
Mon, 18 Mar 2024 20:04:25 +0000 (13:04 -0700)
committerJunio C Hamano <gitster@pobox.com>
Mon, 18 Mar 2024 20:04:25 +0000 (13:04 -0700)
Code simplification by getting rid of code that sets an environment
variable that is no longer used.

* pw/rebase-i-ignore-cherry-pick-help-environment:
  rebase -i: stop setting GIT_CHERRY_PICK_HELP

1  2 
builtin/rebase.c
sequencer.c

diff --combined builtin/rebase.c
index be787690bd7c2b6396784a1476314b8f757ab749,d0cc518c9313e259f8fec34e2f9688c7bf65e821..e444ab102dfe5c99dae8b004960b27a8a600a16b
@@@ -567,13 -567,6 +567,6 @@@ static int move_to_original_branch(stru
        return ret;
  }
  
- static const char *resolvemsg =
- N_("Resolve all conflicts manually, mark them as resolved with\n"
- "\"git add/rm <conflicted_files>\", then run \"git rebase --continue\".\n"
- "You can instead skip this commit: run \"git rebase --skip\".\n"
- "To abort and get back to the state before \"git rebase\", run "
- "\"git rebase --abort\".");
  static int run_am(struct rebase_options *opts)
  {
        struct child_process am = CHILD_PROCESS_INIT;
                     opts->reflog_action);
        if (opts->action == ACTION_CONTINUE) {
                strvec_push(&am.args, "--resolved");
-               strvec_pushf(&am.args, "--resolvemsg=%s", resolvemsg);
+               strvec_pushf(&am.args, "--resolvemsg=%s", rebase_resolvemsg);
                if (opts->gpg_sign_opt)
                        strvec_push(&am.args, opts->gpg_sign_opt);
                status = run_command(&am);
        }
        if (opts->action == ACTION_SKIP) {
                strvec_push(&am.args, "--skip");
-               strvec_pushf(&am.args, "--resolvemsg=%s", resolvemsg);
+               strvec_pushf(&am.args, "--resolvemsg=%s", rebase_resolvemsg);
                status = run_command(&am);
                if (status)
                        return status;
  
        strvec_pushv(&am.args, opts->git_am_opts.v);
        strvec_push(&am.args, "--rebasing");
-       strvec_pushf(&am.args, "--resolvemsg=%s", resolvemsg);
+       strvec_pushf(&am.args, "--resolvemsg=%s", rebase_resolvemsg);
        strvec_push(&am.args, "--patch-format=mboxrd");
        if (opts->allow_rerere_autoupdate == RERERE_AUTOUPDATE)
                strvec_push(&am.args, "--rerere-autoupdate");
@@@ -700,7 -693,6 +693,6 @@@ static int run_specific_rebase(struct r
  
        if (opts->type == REBASE_MERGE) {
                /* Run sequencer-based rebase */
-               setenv("GIT_CHERRY_PICK_HELP", resolvemsg, 1);
                if (!(opts->flags & REBASE_INTERACTIVE_EXPLICIT))
                        setenv("GIT_SEQUENCE_EDITOR", ":", 1);
                if (opts->gpg_sign_opt) {
@@@ -867,8 -859,7 +859,8 @@@ static int can_fast_forward(struct comm
        if (!upstream)
                goto done;
  
 -      merge_bases = repo_get_merge_bases(the_repository, upstream, head);
 +      if (repo_get_merge_bases(the_repository, upstream, head, &merge_bases) < 0)
 +              exit(128);
        if (!merge_bases || merge_bases->next)
                goto done;
  
@@@ -887,9 -878,8 +879,9 @@@ static void fill_branch_base(struct reb
  {
        struct commit_list *merge_bases = NULL;
  
 -      merge_bases = repo_get_merge_bases(the_repository, options->onto,
 -                                         options->orig_head);
 +      if (repo_get_merge_bases(the_repository, options->onto,
 +                               options->orig_head, &merge_bases) < 0)
 +              exit(128);
        if (!merge_bases || merge_bases->next)
                oidcpy(branch_base, null_oid());
        else
@@@ -1256,7 -1246,7 +1248,7 @@@ int cmd_rebase(int argc, const char **a
                die(_("options '%s' and '%s' cannot be used together"), "--root", "--fork-point");
  
        if (options.action != ACTION_NONE && !in_progress)
 -              die(_("No rebase in progress?"));
 +              die(_("no rebase in progress"));
  
        if (options.action == ACTION_EDIT_TODO && !is_merge(&options))
                die(_("The --edit-todo action can only be used during "
diff --combined sequencer.c
index ea1441e617400717458a805b1c27766e27ea7a34,76027ad5f5cb473ebb9616e0680f581da76fc8ae..4e14fa6541c7012c8549e84957c47f386efbc7ec
@@@ -332,7 -332,7 +332,7 @@@ static int has_conforming_footer(struc
                sb->buf[sb->len - ignore_footer] = '\0';
        }
  
 -      trailer_info_get(&info, sb->buf, &opts);
 +      trailer_info_get(&opts, sb->buf, &info);
  
        if (ignore_footer)
                sb->buf[sb->len - ignore_footer] = saved_char;
@@@ -461,10 -461,22 +461,22 @@@ static void free_message(struct commit 
        repo_unuse_commit_buffer(the_repository, commit, msg->message);
  }
  
+ const char *rebase_resolvemsg =
+ N_("Resolve all conflicts manually, mark them as resolved with\n"
+ "\"git add/rm <conflicted_files>\", then run \"git rebase --continue\".\n"
+ "You can instead skip this commit: run \"git rebase --skip\".\n"
+ "To abort and get back to the state before \"git rebase\", run "
+ "\"git rebase --abort\".");
  static void print_advice(struct repository *r, int show_hint,
                         struct replay_opts *opts)
  {
-       char *msg = getenv("GIT_CHERRY_PICK_HELP");
+       const char *msg;
+       if (is_rebase_i(opts))
+               msg = rebase_resolvemsg;
+       else
+               msg = getenv("GIT_CHERRY_PICK_HELP");
  
        if (msg) {
                advise("%s\n", msg);
@@@ -707,8 -719,6 +719,8 @@@ static int do_recursive_merge(struct re
        o.show_rename_progress = 1;
  
        head_tree = parse_tree_indirect(head);
 +      if (!head_tree)
 +              return error(_("unable to read tree (%s)"), oid_to_hex(head));
        next_tree = next ? repo_get_commit_tree(r, next) : empty_tree(r);
        base_tree = base ? repo_get_commit_tree(r, base) : empty_tree(r);
  
@@@ -3884,8 -3894,6 +3896,8 @@@ static int do_reset(struct repository *
        }
  
        tree = parse_tree_indirect(&oid);
 +      if (!tree)
 +              return error(_("unable to read tree (%s)"), oid_to_hex(&oid));
        prime_cache_tree(r, r->index, tree);
  
        if (write_locked_index(r->index, &lock, COMMIT_LOCK) < 0)
@@@ -3912,7 -3920,7 +3924,7 @@@ static int do_merge(struct repository *
        int run_commit_flags = 0;
        struct strbuf ref_name = STRBUF_INIT;
        struct commit *head_commit, *merge_commit, *i;
 -      struct commit_list *bases, *j;
 +      struct commit_list *bases = NULL, *j;
        struct commit_list *to_merge = NULL, **tail = &to_merge;
        const char *strategy = !opts->xopts.nr &&
                (!opts->strategy ||
        }
  
        merge_commit = to_merge->item;
 -      bases = repo_get_merge_bases(r, head_commit, merge_commit);
 +      if (repo_get_merge_bases(r, head_commit, merge_commit, &bases) < 0) {
 +              ret = -1;
 +              goto leave_merge;
 +      }
 +
        if (bases && oideq(&merge_commit->object.oid,
                           &bases->item->object.oid)) {
                ret = 0;