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