• Junio C Hamano's avatar
    argv-array: return the pushed string from argv_push*() · 342c513a
    Junio C Hamano authored
    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 ...
    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: 's avatarJunio C Hamano <gitster@pobox.com>
    Signed-off-by: 's avatarMartin Ågren <martin.agren@gmail.com>
    Signed-off-by: 's avatarJunio C Hamano <gitster@pobox.com>
argv-array.c 1.83 KB