Re: [PATCH] upload-pack: use argv_array for pack_objects

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Feb 25, 2016 at 09:14:01PM -0500, Eric Sunshine wrote:

> On Thu, Feb 25, 2016 at 7:13 AM, Michael Procter <michael@xxxxxxxxxxxxxx> wrote:
> > Use the argv_array in the child_process structure, to avoid having to
> > manually maintain an array size.
> >
> > Signed-off-by: Michael Procter <michael@xxxxxxxxxxxxxx>
> > ---
> > diff --git a/upload-pack.c b/upload-pack.c
> > @@ -90,35 +90,32 @@ static void create_pack_file(void)
> >                 "corruption on the remote side.";
> >         int buffered = -1;
> >         ssize_t sz;
> > -       const char *argv[13];
> > -       int i, arg = 0;
> > +       int i;
> >         FILE *pipe_fd;
> >
> >         if (shallow_nr) {
> > -               argv[arg++] = "--shallow-file";
> > -               argv[arg++] = "";
> > +               argv_array_push(&pack_objects.args, "--shallow-file");
> > +               argv_array_push(&pack_objects.args, "");
> >         }
> 
> Not worth a re-roll, but:
> 
>     if (shallow_nr)
>         argv_array_pushv(..., "--shallow-file", "", NULL);
> 
> would have made it clearer that the two arguments are related (and
> allowed you to drop the braces).

This same pattern repeats in a few places, and I always want to say:

  argv_array_pushf(..., "--shallow-file=%s", file);

but the parsing side is lazy. It wouldn't be too hard to fix (and would
make the option nicer for users, too!), but perhaps it would be better
still to convert git.c to use the standard parse-options.

That is more work, though. Maybe it would be good for the
low-hanging-fruit list.

Other than that, Michael's patch looks fine to me (unsurprising, since I
already saw it off-list and offered my commentary :) ). I agree it's not
worth a re-roll for just this point.

-Peff
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]