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 wrote: > On Wed, Jun 24, 2015 at 11:10 PM, Johannes Schindelin > wrote: >>> + else if (l1.len && l2.len && l3.len && is_email(paths->items->string)) >>> + ret = PATCH_FORMAT_MBOX; >> >> Maybe we can do better than this by folding the `is_e

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 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 am_destroy(const struct am

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

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 wrote: > Paul Tan 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')) { >> +

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

2015-06-18 Thread Junio C Hamano
Paul Tan 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); Is