Skip to content

Commit 1d2a7e0

Browse files
committed
Merge branch 'js/maint-cover-letter-non-ascii' into maint
* js/maint-cover-letter-non-ascii: Correctly mark cover letters' encodings if they are not pure ASCII Expose the has_non_ascii() function
2 parents b813234 + 0a7f448 commit 1d2a7e0

File tree

4 files changed

+17
-12
lines changed

4 files changed

+17
-12
lines changed

builtin-log.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -664,6 +664,10 @@ static void make_cover_letter(struct rev_info *rev, int use_stdout,
664664
log_write_email_headers(rev, head, &subject_start, &extra_headers,
665665
&need_8bit_cte);
666666

667+
for (i = 0; !need_8bit_cte && i < nr; i++)
668+
if (has_non_ascii(list[i]->buffer))
669+
need_8bit_cte = 1;
670+
667671
msg = body;
668672
pp_user_info(NULL, CMIT_FMT_EMAIL, &sb, committer, DATE_RFC2822,
669673
encoding);

commit.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ enum cmit_fmt {
6464
};
6565

6666
extern int non_ascii(int);
67+
extern int has_non_ascii(const char *text);
6768
struct rev_info; /* in revision.h, it circularly uses enum cmit_fmt */
6869
extern char *reencode_commit_message(const struct commit *commit,
6970
const char **encoding_p);

log-tree.c

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -168,18 +168,6 @@ static unsigned int digits_in_number(unsigned int number)
168168
return result;
169169
}
170170

171-
static int has_non_ascii(const char *s)
172-
{
173-
int ch;
174-
if (!s)
175-
return 0;
176-
while ((ch = *s++) != '\0') {
177-
if (non_ascii(ch))
178-
return 1;
179-
}
180-
return 0;
181-
}
182-
183171
void get_patch_filename(struct commit *commit, int nr, const char *suffix,
184172
struct strbuf *buf)
185173
{

pretty.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,18 @@ int non_ascii(int ch)
8686
return !isascii(ch) || ch == '\033';
8787
}
8888

89+
int has_non_ascii(const char *s)
90+
{
91+
int ch;
92+
if (!s)
93+
return 0;
94+
while ((ch = *s++) != '\0') {
95+
if (non_ascii(ch))
96+
return 1;
97+
}
98+
return 0;
99+
}
100+
89101
static int is_rfc2047_special(char ch)
90102
{
91103
return (non_ascii(ch) || (ch == '=') || (ch == '?') || (ch == '_'));

0 commit comments

Comments
 (0)