aboutsummaryrefslogtreecommitdiff
path: root/quote.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2011-10-05 12:36:24 -0700
committerJunio C Hamano <gitster@pobox.com>2011-10-05 12:36:24 -0700
commit7a95d1be03d3fdd571bd36ea5b8bc5c59b063249 (patch)
tree6d0430818f4ec0a5938c38788b3f98865c051f4b /quote.c
parentb5b6521645ed41353e88c443ebaf124b214f25b1 (diff)
parent5d40a179855a39ae9e8ac22e1874720f2b98a91c (diff)
downloadgit-7a95d1be03d3fdd571bd36ea5b8bc5c59b063249.tar.gz
git-7a95d1be03d3fdd571bd36ea5b8bc5c59b063249.tar.xz
Merge branch 'jk/argv-array'
* jk/argv-array: run_hook: use argv_array API checkout: use argv_array API bisect: use argv_array API quote: provide sq_dequote_to_argv_array refactor argv_array into generic code quote.h: fix bogus comment add sha1_array API docs
Diffstat (limited to 'quote.c')
-rw-r--r--quote.c23
1 files changed, 20 insertions, 3 deletions
diff --git a/quote.c b/quote.c
index 532fd3b7b..911229fdf 100644
--- a/quote.c
+++ b/quote.c
@@ -1,5 +1,6 @@
#include "cache.h"
#include "quote.h"
+#include "argv-array.h"
int quote_path_fully = 1;
@@ -120,7 +121,9 @@ char *sq_dequote(char *arg)
return sq_dequote_step(arg, NULL);
}
-int sq_dequote_to_argv(char *arg, const char ***argv, int *nr, int *alloc)
+static int sq_dequote_to_argv_internal(char *arg,
+ const char ***argv, int *nr, int *alloc,
+ struct argv_array *array)
{
char *next = arg;
@@ -130,13 +133,27 @@ int sq_dequote_to_argv(char *arg, const char ***argv, int *nr, int *alloc)
char *dequoted = sq_dequote_step(next, &next);
if (!dequoted)
return -1;
- ALLOC_GROW(*argv, *nr + 1, *alloc);
- (*argv)[(*nr)++] = dequoted;
+ if (argv) {
+ ALLOC_GROW(*argv, *nr + 1, *alloc);
+ (*argv)[(*nr)++] = dequoted;
+ }
+ if (array)
+ argv_array_push(array, dequoted);
} while (next);
return 0;
}
+int sq_dequote_to_argv(char *arg, const char ***argv, int *nr, int *alloc)
+{
+ return sq_dequote_to_argv_internal(arg, argv, nr, alloc, NULL);
+}
+
+int sq_dequote_to_argv_array(char *arg, struct argv_array *array)
+{
+ return sq_dequote_to_argv_internal(arg, NULL, NULL, NULL, array);
+}
+
/* 1 means: quote as octal
* 0 means: quote as octal if (quote_path_fully)
* -1 means: never quote