summaryrefslogtreecommitdiff
path: root/argv-array.c
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2012-09-01 07:25:27 -0400
committerJunio C Hamano <gitster@pobox.com>2012-09-02 21:10:01 -0700
commitfe4a0a288842e225f99254b3e6ce14ff98875501 (patch)
treec8bb6378525ac176e76472dcc58666a708845d78 /argv-array.c
parent9e234af281107d44116ecf31eef65de145c46d15 (diff)
downloadgit-fe4a0a288842e225f99254b3e6ce14ff98875501.tar.gz
argv-array: add pop function
Sometimes we build a set of similar command lines, differing only in the final arguments (e.g., "fetch --multiple"). To use argv_array for this, you have to either push the same set of elements repeatedly, or break the abstraction by manually manipulating the array's internal members. Instead, let's provide a sanctioned "pop" function to remove elements from the end. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'argv-array.c')
-rw-r--r--argv-array.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/argv-array.c b/argv-array.c
index 0b5f8898a1..55e8443ff9 100644
--- a/argv-array.c
+++ b/argv-array.c
@@ -49,6 +49,15 @@ void argv_array_pushl(struct argv_array *array, ...)
va_end(ap);
}
+void argv_array_pop(struct argv_array *array)
+{
+ if (!array->argc)
+ return;
+ free((char *)array->argv[array->argc - 1]);
+ array->argv[array->argc - 1] = NULL;
+ array->argc--;
+}
+
void argv_array_clear(struct argv_array *array)
{
if (array->argv != empty_argv) {