提交 ef7ee16d 编写于 作者: P Paul Tan 提交者: Junio C Hamano

builtin-am: implement -u/--utf8

Since d1c5f2a4 (Add git-am, applymbox replacement., 2005-10-07),
git-am.sh supported the -u,--utf8 option. If set, the -u option will be
passed to git-mailinfo to re-code the commit log message and authorship
in the charset specified by i18n.commitencoding. If unset, the -n option
will be passed to git-mailinfo, which disables the re-encoding.

Since d84029b6 (--utf8 is now default for 'git-am', 2007-01-08), --utf8
is specified by default in git-am.sh.

Re-implement the above in builtin/am.c.
Signed-off-by: NPaul Tan <pyokagan@gmail.com>
Signed-off-by: NJunio C Hamano <gitster@pobox.com>
上级 6d42ac29
...@@ -90,6 +90,7 @@ struct am_state { ...@@ -90,6 +90,7 @@ struct am_state {
int threeway; int threeway;
int quiet; int quiet;
int signoff; int signoff;
int utf8;
const char *resolvemsg; const char *resolvemsg;
int rebasing; int rebasing;
}; };
...@@ -106,6 +107,8 @@ static void am_state_init(struct am_state *state, const char *dir) ...@@ -106,6 +107,8 @@ static void am_state_init(struct am_state *state, const char *dir)
state->dir = xstrdup(dir); state->dir = xstrdup(dir);
state->prec = 4; state->prec = 4;
state->utf8 = 1;
} }
/** /**
...@@ -367,6 +370,9 @@ static void am_load(struct am_state *state) ...@@ -367,6 +370,9 @@ static void am_load(struct am_state *state)
read_state_file(&sb, state, "sign", 1); read_state_file(&sb, state, "sign", 1);
state->signoff = !strcmp(sb.buf, "t"); state->signoff = !strcmp(sb.buf, "t");
read_state_file(&sb, state, "utf8", 1);
state->utf8 = !strcmp(sb.buf, "t");
state->rebasing = !!file_exists(am_path(state, "rebasing")); state->rebasing = !!file_exists(am_path(state, "rebasing"));
strbuf_release(&sb); strbuf_release(&sb);
...@@ -556,6 +562,8 @@ static void am_setup(struct am_state *state, enum patch_format patch_format, ...@@ -556,6 +562,8 @@ static void am_setup(struct am_state *state, enum patch_format patch_format,
write_file(am_path(state, "sign"), 1, state->signoff ? "t" : "f"); write_file(am_path(state, "sign"), 1, state->signoff ? "t" : "f");
write_file(am_path(state, "utf8"), 1, state->utf8 ? "t" : "f");
if (state->rebasing) if (state->rebasing)
write_file(am_path(state, "rebasing"), 1, "%s", ""); write_file(am_path(state, "rebasing"), 1, "%s", "");
else else
...@@ -722,6 +730,7 @@ static int parse_mail(struct am_state *state, const char *mail) ...@@ -722,6 +730,7 @@ static int parse_mail(struct am_state *state, const char *mail)
cp.out = xopen(am_path(state, "info"), O_WRONLY | O_CREAT, 0777); cp.out = xopen(am_path(state, "info"), O_WRONLY | O_CREAT, 0777);
argv_array_push(&cp.args, "mailinfo"); argv_array_push(&cp.args, "mailinfo");
argv_array_push(&cp.args, state->utf8 ? "-u" : "-n");
argv_array_push(&cp.args, am_path(state, "msg")); argv_array_push(&cp.args, am_path(state, "msg"));
argv_array_push(&cp.args, am_path(state, "patch")); argv_array_push(&cp.args, am_path(state, "patch"));
...@@ -1460,6 +1469,8 @@ int cmd_am(int argc, const char **argv, const char *prefix) ...@@ -1460,6 +1469,8 @@ int cmd_am(int argc, const char **argv, const char *prefix)
OPT__QUIET(&state.quiet, N_("be quiet")), OPT__QUIET(&state.quiet, N_("be quiet")),
OPT_BOOL('s', "signoff", &state.signoff, OPT_BOOL('s', "signoff", &state.signoff,
N_("add a Signed-off-by line to the commit message")), N_("add a Signed-off-by line to the commit message")),
OPT_BOOL('u', "utf8", &state.utf8,
N_("recode into utf8 (default)")),
OPT_CALLBACK(0, "patch-format", &patch_format, N_("format"), OPT_CALLBACK(0, "patch-format", &patch_format, N_("format"),
N_("format the patch(es) are in"), N_("format the patch(es) are in"),
parse_opt_patchformat), parse_opt_patchformat),
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册