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

Re: [PATCH] http: use internal argv_array of struct child_process

From
Eric Sunshine <sunshine@sunshineco.com>
Date
Dec 22, 2017, 08:59 UTC
Message-ID
<CAPig+cQaQ9ae1e4eMfJMG4wykXe2tTgtvpxB1_Z=3XbitYeQyw@mail.gmail.com>
In-Reply-To
<504cafe3-2960-af2d-10fe-51e8ba3d2213@web.de>
On Fri, Dec 22, 2017 at 3:14 AM, René Scharfe <l.s.r@web.de> wrote:
Show 20 quoted lines
> Avoid a strangely magic array size (it's slightly too big) and explicit
> index numbers by building the command line for index-pack using the
> embedded argv_array of the child_process.  The resulting code is shorter
> and easier to extend.
>
> Signed-off-by: Rene Scharfe <l.s.r@web.de>
> ---
> diff --git a/http.c b/http.c
> @@ -2041,13 +2040,10 @@ int finish_http_pack_request(struct http_pack_request *preq)
> -       ip_argv[0] = "index-pack";
> -       ip_argv[1] = "-o";
> -       ip_argv[2] = tmp_idx;
> -       ip_argv[3] = preq->tmpfile;
> -       ip_argv[4] = NULL;
> -
> -       ip.argv = ip_argv;
> +       argv_array_push(&ip.args, "index-pack");
> +       argv_array_push(&ip.args, "-o");
> +       argv_array_push(&ip.args, tmp_idx);
> +       argv_array_push(&ip.args, preq->tmpfile);

Not necessarily worth a re-roll, but using the "pushl" variant would make it clear that "-o" and tmp_idx are related and would ensure that they don't accidentally get split up if someone inserts a new "push" in the sequence in the future.

    argv_array_push(&ip.args, "index-pack");
    argv_array_pushl(&ip.args, "-o", tmp_idx, NULL);
    argv_array_push(&ip.args, preq->tmpfile);
Previous: René ScharfeNext: René Scharfe
Message 2 of 3 in “http: use internal argv_array of struct child_process”
  1. http: use internal argv_array of struct child_processRené Scharfe, Dec 22, 2017
  2. Eric SunshineDec 22, 2017
  3. http: use internal argv_array of struct child_processRené Scharfe, Dec 22, 2017

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.