summaryrefslogtreecommitdiff
path: root/argv-array.c
diff options
context:
space:
mode:
authorLibravatar Junio C Hamano <gitster@pobox.com>2012-05-11 11:16:45 -0700
committerLibravatar Junio C Hamano <gitster@pobox.com>2012-05-11 11:16:45 -0700
commit285005c8c405fb1ea2226cff06aa6ac1029b9db1 (patch)
tree3c8d996b50264478361f30043ea29f2e3df4f277 /argv-array.c
parentMerge branch 'ah/maint-grep-double-init' into maint (diff)
parentgc: use argv-array for sub-commands (diff)
downloadtgif-285005c8c405fb1ea2226cff06aa6ac1029b9db1.tar.xz
Merge branch 'jk/repack-no-explode-objects-from-old-pack' into maint
"git repack" used to write out unreachable objects as loose objects when repacking, even if such loose objects will immediately pruned due to its age. By Jeff King * jk/repack-no-explode-objects-from-old-pack: gc: use argv-array for sub-commands argv-array: add a new "pushl" method argv-array: refactor empty_argv initialization gc: do not explode objects which will be immediately pruned
Diffstat (limited to 'argv-array.c')
-rw-r--r--argv-array.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/argv-array.c b/argv-array.c
index a4e04201e6..0b5f8898a1 100644
--- a/argv-array.c
+++ b/argv-array.c
@@ -2,8 +2,7 @@
#include "argv-array.h"
#include "strbuf.h"
-static const char *empty_argv_storage = NULL;
-const char **empty_argv = &empty_argv_storage;
+const char *empty_argv[] = { NULL };
void argv_array_init(struct argv_array *array)
{
@@ -39,6 +38,17 @@ void argv_array_pushf(struct argv_array *array, const char *fmt, ...)
argv_array_push_nodup(array, strbuf_detach(&v, NULL));
}
+void argv_array_pushl(struct argv_array *array, ...)
+{
+ va_list ap;
+ const char *arg;
+
+ va_start(ap, array);
+ while((arg = va_arg(ap, const char *)))
+ argv_array_push(array, arg);
+ va_end(ap);
+}
+
void argv_array_clear(struct argv_array *array)
{
if (array->argv != empty_argv) {