Skip to content

Commit ef7ee16

Browse files
pyokagangitster
authored andcommitted
builtin-am: implement -u/--utf8
Since d1c5f2a (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 d84029b (--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: Paul Tan <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 6d42ac2 commit ef7ee16

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

builtin/am.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ struct am_state {
9090
int threeway;
9191
int quiet;
9292
int signoff;
93+
int utf8;
9394
const char *resolvemsg;
9495
int rebasing;
9596
};
@@ -106,6 +107,8 @@ static void am_state_init(struct am_state *state, const char *dir)
106107
state->dir = xstrdup(dir);
107108

108109
state->prec = 4;
110+
111+
state->utf8 = 1;
109112
}
110113

111114
/**
@@ -367,6 +370,9 @@ static void am_load(struct am_state *state)
367370
read_state_file(&sb, state, "sign", 1);
368371
state->signoff = !strcmp(sb.buf, "t");
369372

373+
read_state_file(&sb, state, "utf8", 1);
374+
state->utf8 = !strcmp(sb.buf, "t");
375+
370376
state->rebasing = !!file_exists(am_path(state, "rebasing"));
371377

372378
strbuf_release(&sb);
@@ -556,6 +562,8 @@ static void am_setup(struct am_state *state, enum patch_format patch_format,
556562

557563
write_file(am_path(state, "sign"), 1, state->signoff ? "t" : "f");
558564

565+
write_file(am_path(state, "utf8"), 1, state->utf8 ? "t" : "f");
566+
559567
if (state->rebasing)
560568
write_file(am_path(state, "rebasing"), 1, "%s", "");
561569
else
@@ -722,6 +730,7 @@ static int parse_mail(struct am_state *state, const char *mail)
722730
cp.out = xopen(am_path(state, "info"), O_WRONLY | O_CREAT, 0777);
723731

724732
argv_array_push(&cp.args, "mailinfo");
733+
argv_array_push(&cp.args, state->utf8 ? "-u" : "-n");
725734
argv_array_push(&cp.args, am_path(state, "msg"));
726735
argv_array_push(&cp.args, am_path(state, "patch"));
727736

@@ -1460,6 +1469,8 @@ int cmd_am(int argc, const char **argv, const char *prefix)
14601469
OPT__QUIET(&state.quiet, N_("be quiet")),
14611470
OPT_BOOL('s', "signoff", &state.signoff,
14621471
N_("add a Signed-off-by line to the commit message")),
1472+
OPT_BOOL('u', "utf8", &state.utf8,
1473+
N_("recode into utf8 (default)")),
14631474
OPT_CALLBACK(0, "patch-format", &patch_format, N_("format"),
14641475
N_("format the patch(es) are in"),
14651476
parse_opt_patchformat),

0 commit comments

Comments
 (0)