From: "Johannes Schindelin via GitGitGadget" <gitgitgadget@gmail.com>
To: git@vger.kernel.org
Cc: Junio C Hamano <gitster@pobox.com>,
Johannes Schindelin <johannes.schindelin@gmx.de>
Subject: [PATCH v3 1/1] builtin rebase: prepare for builtin rebase -i
Date: Fri, 05 Oct 2018 08:54:38 -0700 (PDT) [thread overview]
Message-ID: <db1652ef3e6f46cace5edc9c420411f08e5420aa.1538754875.git.gitgitgadget@gmail.com> (raw)
In-Reply-To: <pull.23.v3.git.gitgitgadget@gmail.com>
From: Johannes Schindelin <johannes.schindelin@gmx.de>
The builtin rebase and the builtin interactive rebase have been
developed independently, on purpose: Google Summer of Code rules
specifically state that students have to work on independent projects,
they cannot collaborate on the same project.
One fallout is that the rebase-in-c and rebase-i-in-c patches cause no
merge conflicts but a royal number of tests in the test suite to fail.
It is easy to explain why: rebase-in-c was developed under the
assumption that all rebase backends are implemented in Unix shell script
and can be sourced via `. git-rebase--<backend>`, which is no longer
true with rebase-i-in-c, where git-rebase--interactive is a hard-linked
builtin.
This patch fixes that.
Please note that we also skip the finish_rebase() call for interactive
rebases because the built-in interactive rebase already takes care of
that. This is needed to support the upcoming `break` command that wants
to interrupt the rebase with exit code 0 (and naturally wants to keep
the state directory intact when doing so).
While at it, remove the `case` arm for the interactive rebase that is
now skipped in favor of the short-cut to the built-in rebase.
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
builtin/rebase.c | 87 +++++++++++++++++++++++++++++++++++++++++++++---
1 file changed, 83 insertions(+), 4 deletions(-)
diff --git a/builtin/rebase.c b/builtin/rebase.c
index 1a697d70c9..20f7159cf2 100644
--- a/builtin/rebase.c
+++ b/builtin/rebase.c
@@ -326,6 +326,13 @@ static void add_var(struct strbuf *buf, const char *name, const char *value)
}
}
+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_specific_rebase(struct rebase_options *opts)
{
const char *argv[] = { NULL, NULL };
@@ -333,6 +340,79 @@ static int run_specific_rebase(struct rebase_options *opts)
int status;
const char *backend, *backend_func;
+ if (opts->type == REBASE_INTERACTIVE) {
+ /* Run builtin interactive rebase */
+ struct child_process child = CHILD_PROCESS_INIT;
+
+ argv_array_pushf(&child.env_array, "GIT_CHERRY_PICK_HELP=%s",
+ resolvemsg);
+ if (!(opts->flags & REBASE_INTERACTIVE_EXPLICIT)) {
+ argv_array_push(&child.env_array, "GIT_EDITOR=:");
+ opts->autosquash = 0;
+ }
+
+ child.git_cmd = 1;
+ argv_array_push(&child.args, "rebase--interactive");
+
+ if (opts->action)
+ argv_array_pushf(&child.args, "--%s", opts->action);
+ if (opts->keep_empty)
+ argv_array_push(&child.args, "--keep-empty");
+ if (opts->rebase_merges)
+ argv_array_push(&child.args, "--rebase-merges");
+ if (opts->rebase_cousins)
+ argv_array_push(&child.args, "--rebase-cousins");
+ if (opts->autosquash)
+ argv_array_push(&child.args, "--autosquash");
+ if (opts->flags & REBASE_VERBOSE)
+ argv_array_push(&child.args, "--verbose");
+ if (opts->flags & REBASE_FORCE)
+ argv_array_push(&child.args, "--no-ff");
+ if (opts->restrict_revision)
+ argv_array_pushf(&child.args,
+ "--restrict-revision=^%s",
+ oid_to_hex(&opts->restrict_revision->object.oid));
+ if (opts->upstream)
+ argv_array_pushf(&child.args, "--upstream=%s",
+ oid_to_hex(&opts->upstream->object.oid));
+ if (opts->onto)
+ argv_array_pushf(&child.args, "--onto=%s",
+ oid_to_hex(&opts->onto->object.oid));
+ if (opts->squash_onto)
+ argv_array_pushf(&child.args, "--squash-onto=%s",
+ oid_to_hex(opts->squash_onto));
+ if (opts->onto_name)
+ argv_array_pushf(&child.args, "--onto-name=%s",
+ opts->onto_name);
+ argv_array_pushf(&child.args, "--head-name=%s",
+ opts->head_name ?
+ opts->head_name : "detached HEAD");
+ if (opts->strategy)
+ argv_array_pushf(&child.args, "--strategy=%s",
+ opts->strategy);
+ if (opts->strategy_opts)
+ argv_array_pushf(&child.args, "--strategy-opts=%s",
+ opts->strategy_opts);
+ if (opts->switch_to)
+ argv_array_pushf(&child.args, "--switch-to=%s",
+ opts->switch_to);
+ if (opts->cmd)
+ argv_array_pushf(&child.args, "--cmd=%s", opts->cmd);
+ if (opts->allow_empty_message)
+ argv_array_push(&child.args, "--allow-empty-message");
+ if (opts->allow_rerere_autoupdate > 0)
+ argv_array_push(&child.args, "--rerere-autoupdate");
+ else if (opts->allow_rerere_autoupdate == 0)
+ argv_array_push(&child.args, "--no-rerere-autoupdate");
+ if (opts->gpg_sign_opt)
+ argv_array_push(&child.args, opts->gpg_sign_opt);
+ if (opts->signoff)
+ argv_array_push(&child.args, "--signoff");
+
+ status = run_command(&child);
+ goto finished_rebase;
+ }
+
add_var(&script_snippet, "GIT_DIR", absolute_path(get_git_dir()));
add_var(&script_snippet, "state_dir", opts->state_dir);
@@ -395,10 +475,6 @@ static int run_specific_rebase(struct rebase_options *opts)
backend = "git-rebase--am";
backend_func = "git_rebase__am";
break;
- case REBASE_INTERACTIVE:
- backend = "git-rebase--interactive";
- backend_func = "git_rebase__interactive";
- break;
case REBASE_MERGE:
backend = "git-rebase--merge";
backend_func = "git_rebase__merge";
@@ -418,8 +494,11 @@ static int run_specific_rebase(struct rebase_options *opts)
argv[0] = script_snippet.buf;
status = run_command_v_opt(argv, RUN_USING_SHELL);
+finished_rebase:
if (opts->dont_finish_rebase)
; /* do nothing */
+ else if (opts->type == REBASE_INTERACTIVE)
+ ; /* interactive rebase cleans up after itself */
else if (status == 0) {
if (!file_exists(state_dir_path("stopped-sha", opts)))
finish_rebase(opts);
--
gitgitgadget
next prev parent reply other threads:[~2018-10-05 15:54 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-08-22 21:35 [PATCH 0/1] Teach the builtin rebase about the builtin interactive rebase Johannes Schindelin via GitGitGadget
2018-08-22 21:35 ` [PATCH 1/1] builtin rebase: prepare for builtin rebase -i Johannes Schindelin via GitGitGadget
2018-08-22 21:50 ` [PATCH 0/1] Teach the builtin rebase about the builtin interactive rebase Junio C Hamano
2018-08-23 2:48 ` Jonathan Nieder
2018-08-25 23:46 ` Johannes Schindelin
2018-08-27 17:48 ` Junio C Hamano
2018-08-28 12:53 ` Johannes Schindelin
2018-08-28 15:34 ` Junio C Hamano
2018-08-29 13:24 ` Johannes Schindelin
2018-08-28 17:17 ` Jonathan Nieder
2018-08-29 14:29 ` Johannes Schindelin
2018-08-29 14:31 ` [PATCH v2 " Johannes Schindelin via GitGitGadget
2018-08-29 14:31 ` [PATCH v2 1/1] builtin rebase: prepare for builtin rebase -i Johannes Schindelin via GitGitGadget
2018-08-29 22:40 ` Junio C Hamano
2018-08-30 11:03 ` Johannes Schindelin
2018-08-30 20:09 ` Jeff King
2018-08-31 20:38 ` Johannes Schindelin
2018-08-31 20:48 ` Jeff King
2018-10-05 15:54 ` [PATCH v3 0/1] Teach the builtin rebase about the builtin interactive rebase Johannes Schindelin via GitGitGadget
2018-10-05 15:54 ` Johannes Schindelin via GitGitGadget [this message]
2018-10-06 23:50 ` Junio C Hamano
2018-10-12 7:59 ` Johannes Schindelin
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
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=db1652ef3e6f46cace5edc9c420411f08e5420aa.1538754875.git.gitgitgadget@gmail.com \
--to=gitgitgadget@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=johannes.schindelin@gmx.de \
/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.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
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 read-only IMAP folder(s) and NNTP newsgroup(s).