From: "Michael S. Tsirkin" <mst@redhat.com>
To: git@vger.kernel.org
Cc: Junio C Hamano <gitster@pobox.com>,
Christian Couder <christian.couder@gmail.com>,
Matthieu Moy <Matthieu.Moy@grenoble-inp.fr>
Subject: [PATCH 4/4] builtin/am: passthrough -t and --trailer flags
Date: Thu, 7 Apr 2016 18:23:16 +0300 [thread overview]
Message-ID: <1460042563-32741-5-git-send-email-mst@redhat.com> (raw)
In-Reply-To: <1460042563-32741-1-git-send-email-mst@redhat.com>
Pass -t and --trailer flags to git-reinterpret-trailers.
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
builtin/am.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 48 insertions(+)
diff --git a/builtin/am.c b/builtin/am.c
index 4180b04..480c4c2 100644
--- a/builtin/am.c
+++ b/builtin/am.c
@@ -122,6 +122,7 @@ struct am_state {
int message_id;
int scissors; /* enum scissors_type */
struct argv_array git_apply_opts;
+ struct argv_array git_interpret_trailers_opts;
const char *resolvemsg;
int committer_date_is_author_date;
int ignore_date;
@@ -157,6 +158,8 @@ static void am_state_init(struct am_state *state, const char *dir)
if (!git_config_get_bool("commit.gpgsign", &gpgsign))
state->sign_commit = gpgsign ? "" : NULL;
+
+ argv_array_init(&state->git_interpret_trailers_opts);
}
/**
@@ -170,6 +173,7 @@ static void am_state_release(struct am_state *state)
free(state->author_date);
free(state->msg);
argv_array_clear(&state->git_apply_opts);
+ argv_array_clear(&state->git_interpret_trailers_opts);
}
/**
@@ -472,6 +476,11 @@ static void am_load(struct am_state *state)
if (sq_dequote_to_argv_array(sb.buf, &state->git_apply_opts) < 0)
die(_("could not parse %s"), am_path(state, "apply-opt"));
+ read_state_file(&sb, state, "interpret-trailers-opt", 1);
+ argv_array_clear(&state->git_interpret_trailers_opts);
+ if (sq_dequote_to_argv_array(sb.buf, &state->git_interpret_trailers_opts) < 0)
+ die(_("could not parse %s"), am_path(state, "interpret-trailers-opt"));
+
state->rebasing = !!file_exists(am_path(state, "rebasing"));
strbuf_release(&sb);
@@ -988,6 +997,7 @@ static void am_setup(struct am_state *state, enum patch_format patch_format,
unsigned char curr_head[GIT_SHA1_RAWSZ];
const char *str;
struct strbuf sb = STRBUF_INIT;
+ struct strbuf tsb = STRBUF_INIT;
if (!patch_format)
patch_format = detect_patch_format(paths);
@@ -1048,6 +1058,9 @@ static void am_setup(struct am_state *state, enum patch_format patch_format,
sq_quote_argv(&sb, state->git_apply_opts.argv, 0);
write_state_text(state, "apply-opt", sb.buf);
+ sq_quote_argv(&tsb, state->git_interpret_trailers_opts.argv, 0);
+ write_state_text(state, "interpret-trailers-opt", tsb.buf);
+
if (state->rebasing)
write_state_text(state, "rebasing", "");
else
@@ -1072,6 +1085,7 @@ static void am_setup(struct am_state *state, enum patch_format patch_format,
write_state_count(state, "next", state->cur);
write_state_count(state, "last", state->last);
+ strbuf_release(&tsb);
strbuf_release(&sb);
}
@@ -1233,6 +1247,34 @@ static void am_append_signoff(struct am_state *state)
}
/**
+ * Processes the supplied message file in-place with git-interpret-trailers.
+ * Returns 0 on success, -1 otherwise.
+ */
+static int run_interpret_trailers(const struct am_state *state, const char *msg)
+{
+ struct child_process cp = CHILD_PROCESS_INIT;
+
+ if (!state->git_interpret_trailers_opts.argc)
+ return 0;
+
+ cp.git_cmd = 1;
+
+ argv_array_push(&cp.args, "interpret-trailers");
+
+ argv_array_push(&cp.args, "--in-place");
+ argv_array_push(&cp.args, "--suppress-blank-line");
+
+ argv_array_pushv(&cp.args, state->git_interpret_trailers_opts.argv);
+
+ argv_array_push(&cp.args, msg);
+
+ if (run_command(&cp))
+ return -1;
+
+ return 0;
+}
+
+/**
* Parses `mail` using git-mailinfo, extracting its patch and authorship info.
* state->msg will be set to the patch message. state->author_name,
* state->author_email and state->author_date will be set to the patch author's
@@ -1301,6 +1343,9 @@ static int parse_mail(struct am_state *state, const char *mail)
fclose(mi.input);
fclose(mi.output);
+ if (run_interpret_trailers(state, am_path(state, "msg")) < 0)
+ die("could not interpret trailers");
+
/* Extract message and author information */
fp = xfopen(am_path(state, "info"), "r");
while (!strbuf_getline_lf(&sb, fp)) {
@@ -2299,6 +2344,9 @@ int cmd_am(int argc, const char **argv, const char *prefix)
OPT_PASSTHRU_ARGV('p', NULL, &state.git_apply_opts, N_("num"),
N_("pass it through git-apply"),
0),
+ OPT_PASSTHRU_ARGV('t', "trailer", &state.git_interpret_trailers_opts, N_("trailer"),
+ N_("pass it through git-interpret-trailers"),
+ 0),
OPT_CALLBACK(0, "patch-format", &patch_format, N_("format"),
N_("format the patch(es) are in"),
parse_opt_patchformat),
--
MST
next prev parent reply other threads:[~2016-04-07 15:23 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-07 15:23 [PATCH 0/4] git-am: use trailers to add extra signatures Michael S. Tsirkin
2016-04-07 15:23 ` [PATCH 1/4] builtin/interpret-trailers.c: allow -t Michael S. Tsirkin
2016-04-07 16:55 ` Junio C Hamano
2016-04-07 17:17 ` Matthieu Moy
2016-04-07 17:26 ` Junio C Hamano
2016-04-07 17:30 ` Michael S. Tsirkin
2016-04-07 17:28 ` Michael S. Tsirkin
2016-04-07 17:30 ` Junio C Hamano
2016-04-07 17:52 ` Michael S. Tsirkin
2016-04-07 17:56 ` Junio C Hamano
2016-04-07 15:23 ` [PATCH 2/4] builtin/interpret-trailers: suppress blank line Michael S. Tsirkin
2016-04-07 17:00 ` Junio C Hamano
2016-04-07 17:21 ` Junio C Hamano
2016-04-07 17:21 ` Michael S. Tsirkin
2016-04-07 17:34 ` Junio C Hamano
2016-04-10 14:56 ` Michael S. Tsirkin
2016-04-07 17:35 ` Matthieu Moy
2016-04-07 15:23 ` [PATCH 3/4] builtin/am: read mailinfo from file Michael S. Tsirkin
2016-04-07 17:08 ` Junio C Hamano
2016-04-07 17:15 ` Michael S. Tsirkin
2016-04-07 17:36 ` Matthieu Moy
2016-04-07 15:23 ` Michael S. Tsirkin [this message]
2016-04-07 16:39 ` [PATCH 4/4] builtin/am: passthrough -t and --trailer flags Christian Couder
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=1460042563-32741-5-git-send-email-mst@redhat.com \
--to=mst@redhat.com \
--cc=Matthieu.Moy@grenoble-inp.fr \
--cc=christian.couder@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.