From: Jeff King <peff@peff•net>
To: git@vger•kernel.org
Subject: [PATCH 3/3] quote: simplify internals of dequoting
Date: Mon, 18 May 2026 21:20:59 -0400 [thread overview]
Message-ID: <20260519012059.GC1615870@coredump.intra.peff.net> (raw)
In-Reply-To: <20260519011837.GA1615637@coredump.intra.peff.net>
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>
---
quote.c | 16 ++--------------
1 file changed, 2 insertions(+), 14 deletions(-)
diff --git a/quote.c b/quote.c
index cff78af3a4..235fac8e47 100644
--- 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
--
2.54.0.524.g198262df96
next prev parent reply other threads:[~2026-05-19 1:21 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-19 1:18 [PATCH 0/3] small quote.[ch] cleanup Jeff King
2026-05-19 1:19 ` [PATCH 1/3] quote.h: bump strvec forward declaration to the top Jeff King
2026-05-19 1:19 ` [PATCH 2/3] quote: drop sq_dequote_to_argv() Jeff King
2026-05-19 1:20 ` Jeff King [this message]
2026-05-19 3:19 ` [PATCH 0/3] small quote.[ch] cleanup Junio C Hamano
2026-05-21 11:39 ` Patrick Steinhardt
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260519012059.GC1615870@coredump.intra.peff.net \
--to=peff@peff$(echo .)net \
--cc=git@vger$(echo .)kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox