Re: [PATCH/WIP v3 06/31] am: detect mbox patches

2015-06-26 Thread Paul Tan
On Thu, Jun 25, 2015 at 9:40 PM, Paul Tan pyoka...@gmail.com wrote: On Wed, Jun 24, 2015 at 11:10 PM, Johannes Schindelin johannes.schinde...@gmx.de wrote: + else if (l1.len l2.len l3.len is_email(paths-items-string)) + ret = PATCH_FORMAT_MBOX; Maybe we can do better than

Re: [PATCH/WIP v3 06/31] am: detect mbox patches

2015-06-25 Thread Paul Tan
On Wed, Jun 24, 2015 at 11:10 PM, Johannes Schindelin johannes.schinde...@gmx.de wrote: Hi Paul, On 2015-06-18 13:25, Paul Tan wrote: diff --git a/builtin/am.c b/builtin/am.c index e9a3687..7b97ea8 100644 --- a/builtin/am.c +++ b/builtin/am.c @@ -121,6 +121,96 @@ static void

Re: [PATCH/WIP v3 06/31] am: detect mbox patches

2015-06-24 Thread Paul Tan
On Fri, Jun 19, 2015 at 5:02 AM, Junio C Hamano gits...@pobox.com wrote: Paul Tan pyoka...@gmail.com writes: +static int is_email(const char *filename) +{ + struct strbuf sb = STRBUF_INIT; + FILE *fp = xfopen(filename, r); + int ret = 1; + + while (!strbuf_getline(sb, fp,

Re: [PATCH/WIP v3 06/31] am: detect mbox patches

2015-06-24 Thread Johannes Schindelin
Hi Paul, On 2015-06-18 13:25, Paul Tan wrote: diff --git a/builtin/am.c b/builtin/am.c index e9a3687..7b97ea8 100644 --- a/builtin/am.c +++ b/builtin/am.c @@ -121,6 +121,96 @@ static void am_destroy(const struct am_state *state) strbuf_release(sb); } +/* + * Returns 1 if the

[PATCH/WIP v3 06/31] am: detect mbox patches

2015-06-18 Thread Paul Tan
Since 15ced75 (git-am foreign patch support: autodetect some patch formats, 2009-05-27), git-am.sh is able to autodetect mbox, stgit and mercurial patches through heuristics. Re-implement support for autodetecting mbox/maildir files. Helped-by: Eric Sunshine sunsh...@sunshineco.com

Re: [PATCH/WIP v3 06/31] am: detect mbox patches

2015-06-18 Thread Junio C Hamano
Paul Tan pyoka...@gmail.com writes: +static int is_email(const char *filename) +{ + struct strbuf sb = STRBUF_INIT; + FILE *fp = xfopen(filename, r); + int ret = 1; + + while (!strbuf_getline(sb, fp, '\n')) { + const char *x; + + strbuf_rtrim(sb);