git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
Jeff King <peff@peff.net>
Date
Feb 26, 2016, 10:59 UTC
Message-ID
<20160226105926.GB12472@sigill.intra.peff.net>
In-Reply-To
<CAPig+cRSKFsO+ygnQGxj+HjO+9Y_7YdubvqscNH7X1A6gM8OtQ@mail.gmail.com>
On Thu, Feb 25, 2016 at 09:14:01PM -0500, Eric Sunshine wrote:
Show 30 quoted lines
> On Thu, Feb 25, 2016 at 7:13 AM, Michael Procter <michael@procter.org.uk> 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@procter.org.uk>
> > ---
> > 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
Previous: Eric Sunshine
Message 3 of 3 in “upload-pack: use argv_array for pack_objects”
  1. upload-pack: use argv_array for pack_objectsMichael Procter, Feb 25, 2016
  2. Eric SunshineFeb 26, 2016
  3. Jeff KingFeb 26, 2016

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.