From: Paul Tan <pyokagan@gmail.com>
To: git@vger.kernel.org
Cc: Johannes Schindelin <johannes.schindelin@gmx.de>,
Stefan Beller <sbeller@google.com>, Paul Tan <pyokagan@gmail.com>
Subject: [PATCH v6 21/45] builtin-am: implement --rebasing mode
Date: Mon, 20 Jul 2015 00:10:13 +0800 [thread overview]
Message-ID: <1437322237-29863-22-git-send-email-pyokagan@gmail.com> (raw)
In-Reply-To: <1437322237-29863-1-git-send-email-pyokagan@gmail.com>
Since 3041c32 (am: --rebasing, 2008-03-04), git-am.sh supported the
--rebasing option, which is used internally by git-rebase to tell git-am
that it is being used for its purpose. It would create the empty file
$state_dir/rebasing to help "completion" scripts tell if the ongoing
operation is am or rebase.
As of 0fbb95d (am: don't call mailinfo if $rebasing, 2012-06-26),
--rebasing also implies --3way as well.
Since a1549e1 (am: return control to caller, for housekeeping,
2013-05-12), git-am.sh would only clean up the state directory when it
is not --rebasing, instead deferring cleanup to git-rebase.sh.
Re-implement the above in builtin/am.c.
Signed-off-by: Paul Tan <pyokagan@gmail.com>
---
builtin/am.c | 30 ++++++++++++++++++++++++++----
1 file changed, 26 insertions(+), 4 deletions(-)
diff --git a/builtin/am.c b/builtin/am.c
index 7237fff..3107aba 100644
--- a/builtin/am.c
+++ b/builtin/am.c
@@ -89,6 +89,7 @@ struct am_state {
int quiet;
int append_signoff;
const char *resolvemsg;
+ int rebasing;
};
/**
@@ -366,6 +367,8 @@ static void am_load(struct am_state *state)
read_state_file(&sb, state, "sign", 1);
state->append_signoff = !strcmp(sb.buf, "t");
+ state->rebasing = !!file_exists(am_path(state, "rebasing"));
+
strbuf_release(&sb);
}
@@ -544,18 +547,29 @@ static void am_setup(struct am_state *state, enum patch_format patch_format,
die(_("Failed to split patches."));
}
+ if (state->rebasing)
+ state->threeway = 1;
+
write_file(am_path(state, "threeway"), 1, state->threeway ? "t" : "f");
write_file(am_path(state, "quiet"), 1, state->quiet ? "t" : "f");
write_file(am_path(state, "sign"), 1, state->append_signoff ? "t" : "f");
+ if (state->rebasing)
+ write_file(am_path(state, "rebasing"), 1, "%s", "");
+ else
+ write_file(am_path(state, "applying"), 1, "%s", "");
+
if (!get_sha1("HEAD", curr_head)) {
write_file(am_path(state, "abort-safety"), 1, "%s", sha1_to_hex(curr_head));
- update_ref("am", "ORIG_HEAD", curr_head, NULL, 0, UPDATE_REFS_DIE_ON_ERR);
+ if (!state->rebasing)
+ update_ref("am", "ORIG_HEAD", curr_head, NULL, 0,
+ UPDATE_REFS_DIE_ON_ERR);
} else {
write_file(am_path(state, "abort-safety"), 1, "%s", "");
- delete_ref("ORIG_HEAD", NULL, 0);
+ if (!state->rebasing)
+ delete_ref("ORIG_HEAD", NULL, 0);
}
/*
@@ -1056,8 +1070,14 @@ next:
am_next(state);
}
- am_destroy(state);
- run_command_v_opt(argv_gc_auto, RUN_GIT_CMD);
+ /*
+ * In rebasing mode, it's up to the caller to take care of
+ * housekeeping.
+ */
+ if (!state->rebasing) {
+ am_destroy(state);
+ run_command_v_opt(argv_gc_auto, RUN_GIT_CMD);
+ }
}
/**
@@ -1326,6 +1346,8 @@ int cmd_am(int argc, const char **argv, const char *prefix)
OPT_CMDMODE(0, "abort", &resume,
N_("restore the original branch and abort the patching operation."),
RESUME_ABORT),
+ OPT_HIDDEN_BOOL(0, "rebasing", &state.rebasing,
+ N_("(internal use for git-rebase)")),
OPT_END()
};
--
2.5.0.rc2.110.gb39b692
next prev parent reply other threads:[~2015-07-19 16:11 UTC|newest]
Thread overview: 47+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-19 16:09 [PATCH v6 00/45] Make git-am a builtin Paul Tan
2015-07-19 16:09 ` [PATCH v6 01/45] wrapper: implement xopen() Paul Tan
2015-07-19 16:09 ` [PATCH v6 02/45] wrapper: implement xfopen() Paul Tan
2015-07-19 16:09 ` [PATCH v6 03/45] builtin-am: implement skeletal builtin am Paul Tan
2015-07-19 16:09 ` [PATCH v6 04/45] builtin-am: implement patch queue mechanism Paul Tan
2015-07-19 16:09 ` [PATCH v6 05/45] builtin-am: split out mbox/maildir patches with git-mailsplit Paul Tan
2015-07-19 16:09 ` [PATCH v6 06/45] builtin-am: auto-detect mbox patches Paul Tan
2015-07-19 16:09 ` [PATCH v6 07/45] builtin-am: extract patch and commit info with git-mailinfo Paul Tan
2015-07-19 16:10 ` [PATCH v6 08/45] builtin-am: apply patch with git-apply Paul Tan
2015-07-19 16:10 ` [PATCH v6 09/45] builtin-am: implement committing applied patch Paul Tan
2015-07-19 16:10 ` [PATCH v6 10/45] builtin-am: refuse to apply patches if index is dirty Paul Tan
2015-07-19 16:10 ` [PATCH v6 11/45] builtin-am: implement --resolved/--continue Paul Tan
2015-07-19 16:10 ` [PATCH v6 12/45] builtin-am: don't parse mail when resuming Paul Tan
2015-07-19 16:10 ` [PATCH v6 13/45] builtin-am: implement --skip Paul Tan
2015-07-19 16:10 ` [PATCH v6 14/45] builtin-am: implement --abort Paul Tan
2015-07-31 23:42 ` Stefan Beller
2015-07-19 16:10 ` [PATCH v6 15/45] builtin-am: reject patches when there's a session in progress Paul Tan
2015-07-19 16:10 ` [PATCH v6 16/45] builtin-am: implement -q/--quiet Paul Tan
2015-07-19 16:10 ` [PATCH v6 17/45] builtin-am: exit with user friendly message on failure Paul Tan
2015-07-19 16:10 ` [PATCH v6 18/45] builtin-am: implement -s/--signoff Paul Tan
2015-07-19 16:10 ` [PATCH v6 19/45] cache-tree: introduce write_index_as_tree() Paul Tan
2015-07-19 16:10 ` [PATCH v6 20/45] builtin-am: implement --3way, am.threeWay Paul Tan
2015-07-19 16:10 ` Paul Tan [this message]
2015-07-19 16:10 ` [PATCH v6 22/45] builtin-am: bypass git-mailinfo when --rebasing Paul Tan
2015-07-19 16:10 ` [PATCH v6 23/45] builtin-am: handle stray state directory Paul Tan
2015-07-19 16:10 ` [PATCH v6 24/45] builtin-am: implement -u/--utf8 Paul Tan
2015-07-19 16:10 ` [PATCH v6 25/45] builtin-am: implement -k/--keep, --keep-non-patch Paul Tan
2015-07-19 16:10 ` [PATCH v6 26/45] builtin-am: implement --[no-]message-id, am.messageid Paul Tan
2015-07-19 16:10 ` [PATCH v6 27/45] builtin-am: support --keep-cr, am.keepcr Paul Tan
2015-07-19 16:10 ` [PATCH v6 28/45] builtin-am: implement --[no-]scissors Paul Tan
2015-07-19 16:10 ` [PATCH v6 29/45] builtin-am: pass git-apply's options to git-apply Paul Tan
2015-07-19 16:10 ` [PATCH v6 30/45] builtin-am: implement --ignore-date Paul Tan
2015-07-19 16:10 ` [PATCH v6 31/45] builtin-am: implement --committer-date-is-author-date Paul Tan
2015-07-19 16:10 ` [PATCH v6 32/45] builtin-am: implement -S/--gpg-sign, commit.gpgsign Paul Tan
2015-07-19 16:10 ` [PATCH v6 33/45] builtin-am: invoke post-rewrite hook Paul Tan
2015-07-19 16:10 ` [PATCH v6 34/45] builtin-am: support automatic notes copying Paul Tan
2015-07-19 16:10 ` [PATCH v6 35/45] builtin-am: invoke applypatch-msg hook Paul Tan
2015-07-19 16:10 ` [PATCH v6 36/45] builtin-am: invoke pre-applypatch hook Paul Tan
2015-07-19 16:10 ` [PATCH v6 37/45] builtin-am: invoke post-applypatch hook Paul Tan
2015-07-19 16:10 ` [PATCH v6 38/45] builtin-am: rerere support Paul Tan
2015-07-19 16:10 ` [PATCH v6 39/45] builtin-am: support and auto-detect StGit patches Paul Tan
2015-07-19 16:10 ` [PATCH v6 40/45] builtin-am: support and auto-detect StGit series files Paul Tan
2015-07-19 16:10 ` [PATCH v6 41/45] builtin-am: support and auto-detect mercurial patches Paul Tan
2015-07-19 16:10 ` [PATCH v6 42/45] builtin-am: implement -i/--interactive Paul Tan
2015-07-19 16:10 ` [PATCH v6 43/45] builtin-am: implement legacy -b/--binary option Paul Tan
2015-07-19 16:10 ` [PATCH v6 44/45] builtin-am: check for valid committer ident Paul Tan
2015-07-19 16:10 ` [PATCH v6 45/45] builtin-am: remove redirection to git-am.sh Paul Tan
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=1437322237-29863-22-git-send-email-pyokagan@gmail.com \
--to=pyokagan@gmail.com \
--cc=git@vger.kernel.org \
--cc=johannes.schindelin@gmx.de \
--cc=sbeller@google.com \
/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).