Re: [PATCH 33/67] read_branches_file: replace strcpy with xstrdup

2015-09-17 Thread Junio C Hamano
Jeff King writes: > Yeah, that was my thinking. Since I _did_ end up doing the cleanup and > posted it earlier, please feel free to review and express an opinion on > the original versus the cleanup. > > I'm on the fence. I do think the cleaned-up version is much nicer, but > I always worry abou

Re: [PATCH 33/67] read_branches_file: replace strcpy with xstrdup

2015-09-17 Thread Jeff King
On Thu, Sep 17, 2015 at 08:38:32AM -0700, Junio C Hamano wrote: > > In some of the cases, as you've seen, I dug further in cleaning things > > up. But in others I did the minimal fix (especially in this case, the > > limitations are only about the deprecated "branches" and "remotes" > > file), mos

Re: [PATCH 33/67] read_branches_file: replace strcpy with xstrdup

2015-09-17 Thread Junio C Hamano
Jeff King writes: > On Wed, Sep 16, 2015 at 12:52:26PM -0700, Junio C Hamano wrote: > >> > diff --git a/remote.c b/remote.c >> > index 5ab0f7f..1b69751 100644 >> > --- a/remote.c >> > +++ b/remote.c >> > @@ -297,7 +297,6 @@ static void read_branches_file(struct remote *remote) >> >int n = 100

Re: [PATCH 33/67] read_branches_file: replace strcpy with xstrdup

2015-09-17 Thread Jeff King
On Thu, Sep 17, 2015 at 07:28:56AM -0400, Jeff King wrote: > Here is the patch I ended up with: > > -- >8 -- > Subject: [PATCH] read_branches_file: simplify string handling And here is the matching cleanup for read_remotes_file, which lets us drop the static global "buffer" entirely. -- >8 -- S

Re: [PATCH 33/67] read_branches_file: replace strcpy with xstrdup

2015-09-17 Thread Jeff King
On Thu, Sep 17, 2015 at 07:28:56AM -0400, Jeff King wrote: > /* >* The branches file would have URL and optionally >* #branch specified. The "master" (or specified) branch is > - * fetched and stored in the local branch of the same name. > + * fetched and stored in

Re: [PATCH 33/67] read_branches_file: replace strcpy with xstrdup

2015-09-17 Thread Jeff King
On Wed, Sep 16, 2015 at 04:42:26PM -0400, Jeff King wrote: > > We use buffer[BUFSIZ] to read various things in this file, not just > > $GIT_DIR/branches/* files, with fgets(), which may be better done if > > we switched to strbuf_getline(). Then we can also use trim family > > of calls from the s

Re: [PATCH 33/67] read_branches_file: replace strcpy with xstrdup

2015-09-16 Thread Jeff King
On Wed, Sep 16, 2015 at 12:52:26PM -0700, Junio C Hamano wrote: > > diff --git a/remote.c b/remote.c > > index 5ab0f7f..1b69751 100644 > > --- a/remote.c > > +++ b/remote.c > > @@ -297,7 +297,6 @@ static void read_branches_file(struct remote *remote) > > int n = 1000; > > FILE *f = fopen(g

Re: [PATCH 33/67] read_branches_file: replace strcpy with xstrdup

2015-09-16 Thread Junio C Hamano
Jeff King writes: > This code is exactly replicating strdup, so let's just use > that. It's shorter, and eliminates some confusion (such as > whether "p - s" is really enough to hold the result; it is, > because we write NULs as we shrink "p"). > > Signed-off-by: Jeff King > --- > remote.c | 5

[PATCH 33/67] read_branches_file: replace strcpy with xstrdup

2015-09-15 Thread Jeff King
This code is exactly replicating strdup, so let's just use that. It's shorter, and eliminates some confusion (such as whether "p - s" is really enough to hold the result; it is, because we write NULs as we shrink "p"). Signed-off-by: Jeff King --- remote.c | 5 + 1 file changed, 1 insertion(