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

Re: [PATCH] remote-http: use argv-array

From
Bert Wesarg <bert.wesarg@googlemail.com>
Date
Jul 9, 2013, 06:05 UTC
Message-ID
<CAKPyHN0DG0c2vxWtybYtDmFKMo369PZcbqCfDJaXeiRV+PP8pQ@mail.gmail.com>
In-Reply-To
<7vfvvoxqdw.fsf@alter.siamese.dyndns.org>
On Tue, Jul 9, 2013 at 7:18 AM, Junio C Hamano <gitster@pobox.com> wrote:
Show 31 quoted lines
> Instead of using a hand-managed argument array, use argv-array API
> to manage dynamically formulated command line.
>
> Signed-off-by: Junio C Hamano <gitster@pobox.com>
> ---
>  remote-curl.c | 31 +++++++++++++++----------------
>  1 file changed, 15 insertions(+), 16 deletions(-)
>
> diff --git a/remote-curl.c b/remote-curl.c
> index 60eda63..884b3a3 100644
> --- a/remote-curl.c
> +++ b/remote-curl.c
> @@ -7,6 +7,7 @@
>  #include "run-command.h"
>  #include "pkt-line.h"
>  #include "sideband.h"
> +#include "argv-array.h"
>
>  static struct remote *remote;
>  static const char *url; /* always ends with a trailing slash */
> @@ -787,36 +788,34 @@ static int push_dav(int nr_spec, char **specs)
>  static int push_git(struct discovery *heads, int nr_spec, char **specs)
>  {
>         struct rpc_state rpc;
> -       const char **argv;
> -       int argc = 0, i, err;
> +       int i, err;
> +       struct argv_array args;
> +
> +       argv_array_init(&args);
> +       argv_array_pushl(&args, "send-pack", "--stateless-rpc", "--helper-status");

missing NULL sentinel. GCC has the 'sentinel' [1] attribute to catch such errors. Or use macro magic:

void argv_array_pushl_(struct argv_array *array, ...); #define argv_array_pushl(array, ...) argv_array_pushl_(array, __VA_ARGS__, NULL)

Bert
[1] http://gcc.gnu.org/onlinedocs/gcc/Function-Attributes.html#index-g_t_0040code_007bsentinel_007d-function-attribute-2708
Previous: Junio C HamanoNext: Jeff King
Message 2 of 17 in “remote-http: use argv-array”
  1. remote-http: use argv-arrayJunio C Hamano, Jul 9, 2013
  2. Bert WesargJul 9, 2013
  3. Jeff KingJul 9, 2013
  4. Matt KraaiJul 9, 2013
  5. Jeff KingJul 10, 2013
  6. 1/3 add missing "format" function attributesJeff King, Jul 10, 2013
  7. 2/3 use "sentinel" function attribute for variadic listsJeff King, Jul 10, 2013
  8. 3/3 wt-status: use "format" function attribute for status_printfJeff King, Jul 10, 2013
  9. Junio C HamanoJul 10, 2013
  10. Jeff KingJul 10, 2013
  11. Junio C HamanoJul 10, 2013
  12. Jeff KingJul 10, 2013
  13. Junio C HamanoJul 10, 2013
  14. Jeff KingJul 10, 2013
  15. Junio C HamanoJul 10, 2013
  16. Junio C HamanoJul 12, 2013
  17. Jeff KingJul 12, 2013

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.