argv-array: return the pushed string from argv_push*()
authorJunio C Hamano <gitster@pobox.com>
Mon, 21 May 2018 14:54:27 +0000 (16:54 +0200)
committerJunio C Hamano <gitster@pobox.com>
Tue, 22 May 2018 02:58:50 +0000 (11:58 +0900)
Such an API change allows us to use an argv_array this way:

struct argv_array to_free = ARGV_ARRAY_INIT;
const char *msg;

if (some condition) {
msg = "constant string message";
... other logic ...
} else {
msg = argv_array_pushf(&to_free, "format %s", var);
}
... use "msg" ...
... do other things ...
argv_array_clear(&to_free);

Note that argv_array_pushl() and argv_array_pushv() are used to push
one or more strings with a single call, so we do not return any one
of these strings from these two functions in order to reduce the
chance to misuse the API.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Martin Ă…gren <martin.agren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
No differences found