]> git.ipfire.org Git - thirdparty/git.git/commitdiff
quote: simplify internals of dequoting
authorJeff King <peff@peff.net>
Tue, 19 May 2026 01:20:59 +0000 (21:20 -0400)
committerJunio C Hamano <gitster@pobox.com>
Tue, 19 May 2026 03:14:03 +0000 (12:14 +0900)
Our sq_dequote_to_argv_internal() helper was wrapped by the to_argv()
and to_strvec() forms. Now that we have only the latter, we can stop
wrapping it and drop the argv-only bits.

Note that in theory sq_dequote_to_strvec() could take a const input
string, which would be friendlier to its callers. We couldn't do that
with the to_argv() form because it reused the input string to hold the
output elements. But since we're built on sq_dequote_step(), which
munges the input, we'd have to rework the parser. Since no callers care
about it currently, we'll leave that for another day.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
quote.c

diff --git a/quote.c b/quote.c
index cff78af3a4d7db5c7acd8bc8df35f747f133e178..235fac8e47093f606f20a77812c02e491d698833 100644 (file)
--- a/quote.c
+++ b/quote.c
@@ -171,9 +171,7 @@ char *sq_dequote(char *arg)
        return sq_dequote_step(arg, NULL);
 }
 
-static int sq_dequote_to_argv_internal(char *arg,
-                                      const char ***argv, int *nr, int *alloc,
-                                      struct strvec *array)
+int sq_dequote_to_strvec(char *arg, struct strvec *array)
 {
        char *next = arg;
 
@@ -191,22 +189,12 @@ static int sq_dequote_to_argv_internal(char *arg,
                                c = *++next;
                        } while (isspace(c));
                }
-               if (argv) {
-                       ALLOC_GROW(*argv, *nr + 1, *alloc);
-                       (*argv)[(*nr)++] = dequoted;
-               }
-               if (array)
-                       strvec_push(array, dequoted);
+               strvec_push(array, dequoted);
        } while (next);
 
        return 0;
 }
 
-int sq_dequote_to_strvec(char *arg, struct strvec *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