Re: [PATCH 08/16] use skip_prefix to avoid magic numbers

2014-07-01 Thread Jeff King
On Mon, Jun 23, 2014 at 02:44:23PM -0700, Junio C Hamano wrote: > Jeff King writes: > > > diff --git a/connect.c b/connect.c > > index 94a6650..37ff018 100644 > > --- a/connect.c > > +++ b/connect.c > > @@ -140,12 +141,12 @@ struct ref **get_remote_heads(int in, char *src_buf, > > size_t src_le

Re: [PATCH 08/16] use skip_prefix to avoid magic numbers

2014-06-23 Thread Junio C Hamano
Jeff King writes: > diff --git a/connect.c b/connect.c > index 94a6650..37ff018 100644 > --- a/connect.c > +++ b/connect.c > @@ -140,12 +141,12 @@ struct ref **get_remote_heads(int in, char *src_buf, > size_t src_len, > if (!len) > break; > > - i

[PATCH 08/16] use skip_prefix to avoid magic numbers

2014-06-18 Thread Jeff King
It's a common idiom to match a prefix and then skip past it with a magic number, like: if (starts_with(foo, "bar")) foo += 3; This is easy to get wrong, since you have to count the prefix string yourself, and there's no compiler check if the string changes. We can use skip_prefix to