format-patch -s: add MIME encoding header if signer's name requires so
When the body of the commit log message contains a non-ASCII character, format-patch correctly emitted the encoding header to mark the resulting message as such. However, if the original message was fully ASCII, the command line switch "-s" was given to add a new sign-off, and the signer's name was not ASCII only, the resulting message would have contained non-ASCII character but was not marked as such. Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
3e4bb087a1
commit
4593fb8405
@ -276,7 +276,7 @@ static void print_ref_item(struct ref_item *item, int maxwidth, int verbose,
|
|||||||
commit = lookup_commit(item->sha1);
|
commit = lookup_commit(item->sha1);
|
||||||
if (commit && !parse_commit(commit)) {
|
if (commit && !parse_commit(commit)) {
|
||||||
pretty_print_commit(CMIT_FMT_ONELINE, commit,
|
pretty_print_commit(CMIT_FMT_ONELINE, commit,
|
||||||
&subject, 0, NULL, NULL, 0);
|
&subject, 0, NULL, NULL, 0, 0);
|
||||||
sub = subject.buf;
|
sub = subject.buf;
|
||||||
}
|
}
|
||||||
printf("%c %s%-*s%s %s %s\n", c, branch_get_color(color),
|
printf("%c %s%-*s%s %s %s\n", c, branch_get_color(color),
|
||||||
|
@ -787,7 +787,7 @@ int cmd_cherry(int argc, const char **argv, const char *prefix)
|
|||||||
struct strbuf buf;
|
struct strbuf buf;
|
||||||
strbuf_init(&buf, 0);
|
strbuf_init(&buf, 0);
|
||||||
pretty_print_commit(CMIT_FMT_ONELINE, commit,
|
pretty_print_commit(CMIT_FMT_ONELINE, commit,
|
||||||
&buf, 0, NULL, NULL, 0);
|
&buf, 0, NULL, NULL, 0, 0);
|
||||||
printf("%c %s %s\n", sign,
|
printf("%c %s %s\n", sign,
|
||||||
sha1_to_hex(commit->object.sha1), buf.buf);
|
sha1_to_hex(commit->object.sha1), buf.buf);
|
||||||
strbuf_release(&buf);
|
strbuf_release(&buf);
|
||||||
|
@ -86,7 +86,8 @@ static void show_commit(struct commit *commit)
|
|||||||
struct strbuf buf;
|
struct strbuf buf;
|
||||||
strbuf_init(&buf, 0);
|
strbuf_init(&buf, 0);
|
||||||
pretty_print_commit(revs.commit_format, commit,
|
pretty_print_commit(revs.commit_format, commit,
|
||||||
&buf, revs.abbrev, NULL, NULL, revs.date_mode);
|
&buf, revs.abbrev, NULL, NULL,
|
||||||
|
revs.date_mode, 0);
|
||||||
if (buf.len)
|
if (buf.len)
|
||||||
printf("%s%c", buf.buf, hdr_termination);
|
printf("%s%c", buf.buf, hdr_termination);
|
||||||
strbuf_release(&buf);
|
strbuf_release(&buf);
|
||||||
|
@ -266,7 +266,7 @@ static void show_one_commit(struct commit *commit, int no_name)
|
|||||||
strbuf_init(&pretty, 0);
|
strbuf_init(&pretty, 0);
|
||||||
if (commit->object.parsed) {
|
if (commit->object.parsed) {
|
||||||
pretty_print_commit(CMIT_FMT_ONELINE, commit,
|
pretty_print_commit(CMIT_FMT_ONELINE, commit,
|
||||||
&pretty, 0, NULL, NULL, 0);
|
&pretty, 0, NULL, NULL, 0, 0);
|
||||||
pretty_str = pretty.buf;
|
pretty_str = pretty.buf;
|
||||||
}
|
}
|
||||||
if (!prefixcmp(pretty_str, "[PATCH] "))
|
if (!prefixcmp(pretty_str, "[PATCH] "))
|
||||||
|
5
commit.c
5
commit.c
@ -479,7 +479,7 @@ static int get_one_line(const char *msg)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* High bit set, or ISO-2022-INT */
|
/* High bit set, or ISO-2022-INT */
|
||||||
static int non_ascii(int ch)
|
int non_ascii(int ch)
|
||||||
{
|
{
|
||||||
ch = (ch & 0xff);
|
ch = (ch & 0xff);
|
||||||
return ((ch & 0x80) || (ch == 0x1b));
|
return ((ch & 0x80) || (ch == 0x1b));
|
||||||
@ -1046,12 +1046,11 @@ static void pp_remainder(enum cmit_fmt fmt,
|
|||||||
void pretty_print_commit(enum cmit_fmt fmt, const struct commit *commit,
|
void pretty_print_commit(enum cmit_fmt fmt, const struct commit *commit,
|
||||||
struct strbuf *sb, int abbrev,
|
struct strbuf *sb, int abbrev,
|
||||||
const char *subject, const char *after_subject,
|
const char *subject, const char *after_subject,
|
||||||
enum date_mode dmode)
|
enum date_mode dmode, int plain_non_ascii)
|
||||||
{
|
{
|
||||||
unsigned long beginning_of_body;
|
unsigned long beginning_of_body;
|
||||||
int indent = 4;
|
int indent = 4;
|
||||||
const char *msg = commit->buffer;
|
const char *msg = commit->buffer;
|
||||||
int plain_non_ascii = 0;
|
|
||||||
char *reencoded;
|
char *reencoded;
|
||||||
const char *encoding;
|
const char *encoding;
|
||||||
|
|
||||||
|
4
commit.h
4
commit.h
@ -61,13 +61,15 @@ enum cmit_fmt {
|
|||||||
CMIT_FMT_UNSPECIFIED,
|
CMIT_FMT_UNSPECIFIED,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
extern int non_ascii(int);
|
||||||
extern enum cmit_fmt get_commit_format(const char *arg);
|
extern enum cmit_fmt get_commit_format(const char *arg);
|
||||||
extern void format_commit_message(const struct commit *commit,
|
extern void format_commit_message(const struct commit *commit,
|
||||||
const void *format, struct strbuf *sb);
|
const void *format, struct strbuf *sb);
|
||||||
extern void pretty_print_commit(enum cmit_fmt fmt, const struct commit*,
|
extern void pretty_print_commit(enum cmit_fmt fmt, const struct commit*,
|
||||||
struct strbuf *,
|
struct strbuf *,
|
||||||
int abbrev, const char *subject,
|
int abbrev, const char *subject,
|
||||||
const char *after_subject, enum date_mode);
|
const char *after_subject, enum date_mode,
|
||||||
|
int non_ascii_present);
|
||||||
|
|
||||||
/** Removes the first commit from a list sorted by date, and adds all
|
/** Removes the first commit from a list sorted by date, and adds all
|
||||||
* of its parents.
|
* of its parents.
|
||||||
|
15
log-tree.c
15
log-tree.c
@ -125,6 +125,18 @@ static unsigned int digits_in_number(unsigned int number)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int has_non_ascii(const char *s)
|
||||||
|
{
|
||||||
|
int ch;
|
||||||
|
if (!s)
|
||||||
|
return 0;
|
||||||
|
while ((ch = *s++) != '\0') {
|
||||||
|
if (non_ascii(ch))
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
void show_log(struct rev_info *opt, const char *sep)
|
void show_log(struct rev_info *opt, const char *sep)
|
||||||
{
|
{
|
||||||
struct strbuf msgbuf;
|
struct strbuf msgbuf;
|
||||||
@ -273,7 +285,8 @@ void show_log(struct rev_info *opt, const char *sep)
|
|||||||
*/
|
*/
|
||||||
strbuf_init(&msgbuf, 0);
|
strbuf_init(&msgbuf, 0);
|
||||||
pretty_print_commit(opt->commit_format, commit, &msgbuf,
|
pretty_print_commit(opt->commit_format, commit, &msgbuf,
|
||||||
abbrev, subject, extra_headers, opt->date_mode);
|
abbrev, subject, extra_headers, opt->date_mode,
|
||||||
|
has_non_ascii(opt->add_signoff));
|
||||||
|
|
||||||
if (opt->add_signoff)
|
if (opt->add_signoff)
|
||||||
append_signoff(&msgbuf, opt->add_signoff);
|
append_signoff(&msgbuf, opt->add_signoff);
|
||||||
|
Loading…
Reference in New Issue
Block a user