Browse Source

Merge branch 'jc/maint-format-patch-encoding' into maint

* jc/maint-format-patch-encoding:
  test format-patch -s: make sure MIME content type is shown as needed
  format-patch -s: add MIME encoding header if signer's name requires so
maint
Junio C Hamano 17 years ago
parent
commit
d1c7cd13dc
  1. 2
      builtin-branch.c
  2. 2
      builtin-log.c
  3. 2
      builtin-rev-list.c
  4. 2
      builtin-show-branch.c
  5. 6
      commit.c
  6. 3
      commit.h
  7. 15
      log-tree.c
  8. 42
      t/t4021-format-patch-signer-mime.sh

2
builtin-branch.c

@ -276,7 +276,7 @@ static void print_ref_item(struct ref_item *item, int maxwidth, int verbose, @@ -276,7 +276,7 @@ static void print_ref_item(struct ref_item *item, int maxwidth, int verbose,
if (commit && !parse_commit(commit)) {
pretty_print_commit(CMIT_FMT_ONELINE, commit, ~0,
&subject, &subject_len, 0,
NULL, NULL, 0);
NULL, NULL, 0, 0);
sub = subject;
}
printf("%c %s%-*s%s %s %s\n", c, branch_get_color(color),

2
builtin-log.c

@ -795,7 +795,7 @@ int cmd_cherry(int argc, const char **argv, const char *prefix) @@ -795,7 +795,7 @@ int cmd_cherry(int argc, const char **argv, const char *prefix)
char *buf = NULL;
unsigned long buflen = 0;
pretty_print_commit(CMIT_FMT_ONELINE, commit, ~0,
&buf, &buflen, 0, NULL, NULL, 0);
&buf, &buflen, 0, NULL, NULL, 0, 0);
printf("%c %s %s\n", sign,
sha1_to_hex(commit->object.sha1), buf);
free(buf);

2
builtin-rev-list.c

@ -84,7 +84,7 @@ static void show_commit(struct commit *commit) @@ -84,7 +84,7 @@ static void show_commit(struct commit *commit)
unsigned long buflen = 0;
pretty_print_commit(revs.commit_format, commit, ~0,
&buf, &buflen,
revs.abbrev, NULL, NULL, revs.date_mode);
revs.abbrev, NULL, NULL, revs.date_mode, 0);
printf("%s%c", buf, hdr_termination);
free(buf);
}

2
builtin-show-branch.c

@ -267,7 +267,7 @@ static void show_one_commit(struct commit *commit, int no_name) @@ -267,7 +267,7 @@ static void show_one_commit(struct commit *commit, int no_name)
if (commit->object.parsed) {
pretty_print_commit(CMIT_FMT_ONELINE, commit, ~0,
&pretty, &pretty_len,
0, NULL, NULL, 0);
0, NULL, NULL, 0, 0);
pretty_str = pretty;
}
if (!prefixcmp(pretty_str, "[PATCH] "))

6
commit.c

@ -479,7 +479,7 @@ static int get_one_line(const char *msg, unsigned long len) @@ -479,7 +479,7 @@ static int get_one_line(const char *msg, unsigned long len)
}

/* High bit set, or ISO-2022-INT */
static int non_ascii(int ch)
int non_ascii(int ch)
{
ch = (ch & 0xff);
return ((ch & 0x80) || (ch == 0x1b));
@ -1158,13 +1158,13 @@ unsigned long pretty_print_commit(enum cmit_fmt fmt, @@ -1158,13 +1158,13 @@ unsigned long pretty_print_commit(enum cmit_fmt fmt,
char **buf_p, unsigned long *space_p,
int abbrev, const char *subject,
const char *after_subject,
enum date_mode dmode)
enum date_mode dmode,
int plain_non_ascii)
{
unsigned long offset = 0;
unsigned long beginning_of_body;
int indent = 4;
const char *msg = commit->buffer;
int plain_non_ascii = 0;
char *reencoded;
const char *encoding;
char *buf;

3
commit.h

@ -60,8 +60,9 @@ enum cmit_fmt { @@ -60,8 +60,9 @@ enum cmit_fmt {
CMIT_FMT_UNSPECIFIED,
};

extern int non_ascii(int);
extern enum cmit_fmt get_commit_format(const char *arg);
extern unsigned long pretty_print_commit(enum cmit_fmt fmt, const struct commit *, unsigned long len, char **buf_p, unsigned long *space_p, int abbrev, const char *subject, const char *after_subject, enum date_mode dmode);
extern unsigned long pretty_print_commit(enum cmit_fmt fmt, const struct commit *, unsigned long len, char **buf_p, unsigned long *space_p, int abbrev, const char *subject, const char *after_subject, enum date_mode dmode, int non_ascii_present);

/** Removes the first commit from a list sorted by date, and adds all
* of its parents.

15
log-tree.c

@ -140,6 +140,18 @@ static unsigned int digits_in_number(unsigned int number) @@ -140,6 +140,18 @@ static unsigned int digits_in_number(unsigned int number)
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)
{
char *msgbuf = NULL;
@ -290,7 +302,8 @@ void show_log(struct rev_info *opt, const char *sep) @@ -290,7 +302,8 @@ void show_log(struct rev_info *opt, const char *sep)
*/
len = pretty_print_commit(opt->commit_format, commit, ~0u,
&msgbuf, &msgbuf_len, abbrev, subject,
extra_headers, opt->date_mode);
extra_headers, opt->date_mode,
has_non_ascii(opt->add_signoff));

if (opt->add_signoff)
len = append_signoff(&msgbuf, &msgbuf_len, len,

42
t/t4021-format-patch-signer-mime.sh

@ -0,0 +1,42 @@ @@ -0,0 +1,42 @@
#!/bin/sh

test_description='format-patch -s should force MIME encoding as needed'

. ./test-lib.sh

test_expect_success setup '

>F &&
git add F &&
git commit -m initial &&
echo new line >F &&

test_tick &&
git commit -m "This adds some lines to F" F

'

test_expect_success 'format normally' '

git format-patch --stdout -1 >output &&
! grep Content-Type output

'

test_expect_success 'format with signoff without funny signer name' '

git format-patch -s --stdout -1 >output &&
! grep Content-Type output

'

test_expect_success 'format with non ASCII signer name' '

GIT_COMMITTER_NAME="$B$O$^$N(B $B$U$K$*$&(B" \
git format-patch -s --stdout -1 >output &&
grep Content-Type output

'

test_done

Loading…
Cancel
Save