{"thread":{"id":"65655","subject":"[PATCH 0/3] small quote.[ch] cleanup","startedAt":"2026-05-19T01:18:39Z","lastAt":"2026-05-21T11:39:48Z","messageCount":6,"participants":["Jeff King","Junio C Hamano","Patrick Steinhardt"],"isPatch":true,"patchVersion":1,"patchTotal":3},"messages":[{"id":"543576","messageId":"20260519011837.GA1615637@coredump.intra.peff.net","threadId":"65655","inReplyTo":null,"subject":"[PATCH 0/3] small quote.[ch] cleanup","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2026-05-19T01:18:37Z","receivedAt":"2026-05-19T01:18:39Z","isPatch":true,"body":"I noticed some unused code while looking at an unrelated topic. So\nhere's a small cleanup.\n\n  [1/3]: quote.h: bump strvec forward declaration to the top\n  [2/3]: quote: drop sq_dequote_to_argv()\n  [3/3]: quote: simplify internals of dequoting\n\n quote.c | 21 ++-------------------\n quote.h | 14 ++++----------\n 2 files changed, 6 insertions(+), 29 deletions(-)\n\n-Peff\n"},{"id":"543577","messageId":"20260519011901.GA1615870@coredump.intra.peff.net","threadId":"65655","inReplyTo":"20260519011837.GA1615637@coredump.intra.peff.net","subject":"[PATCH 1/3] quote.h: bump strvec forward declaration to the top","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2026-05-19T01:19:01Z","receivedAt":"2026-05-19T01:19:03Z","isPatch":true,"body":"We usually put forward declarations at the top of header files, rather\nthan next to the functions that need them. In theory placing it next to\nthe function has some explanatory value, but it's also just as likely to\nbecome stale if other uses are added.\n\nSigned-off-by: Jeff King <peff@peff.net>\n---\n quote.h | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/quote.h b/quote.h\nindex 0300c29104..400397b11a 100644\n--- a/quote.h\n+++ b/quote.h\n@@ -2,6 +2,7 @@\n #define QUOTE_H\n \n struct strbuf;\n+struct strvec;\n \n extern int quote_path_fully;\n \n@@ -77,7 +78,6 @@ int sq_dequote_to_argv(char *arg, const char ***argv, int *nr, int *alloc);\n  * still modify arg in place, but unlike sq_dequote_to_argv, the strvec\n  * will duplicate and take ownership of the strings.\n  */\n-struct strvec;\n int sq_dequote_to_strvec(char *arg, struct strvec *);\n \n int unquote_c_style(struct strbuf *, const char *quoted, const char **endp);\n-- \n2.54.0.524.g198262df96\n\n"},{"id":"543578","messageId":"20260519011934.GB1615870@coredump.intra.peff.net","threadId":"65655","inReplyTo":"20260519011837.GA1615637@coredump.intra.peff.net","subject":"[PATCH 2/3] quote: drop sq_dequote_to_argv()","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2026-05-19T01:19:34Z","receivedAt":"2026-05-19T01:19:36Z","isPatch":true,"body":"The last caller went away in f9dbb64fad (config: parse more robust\nformat in GIT_CONFIG_PARAMETERS, 2021-01-12), when we switched to using\nsq_dequote_step().\n\nThe \"to_argv()\" form is not a great interface. If you care about raw\nspeed, then sq_dequote_step() lets you work incrementally without extra\nallocations. If you care about simplicity, then sq_dequote_to_strvec()\nputs the result in an encapsulated data structure. With sq_dequote_to_argv(),\nyou have a data dependency on the original string but still have to\nremember to manually free the argv array itself (but not its elements).\n\nSo it's sort of a worst-of-both-worlds middle ground. Let's get rid of\nit.\n\nSigned-off-by: Jeff King <peff@peff.net>\n---\n quote.c |  5 -----\n quote.h | 12 +++---------\n 2 files changed, 3 insertions(+), 14 deletions(-)\n\ndiff --git a/quote.c b/quote.c\nindex b9f6bdc775..cff78af3a4 100644\n--- a/quote.c\n+++ b/quote.c\n@@ -202,11 +202,6 @@ static int sq_dequote_to_argv_internal(char *arg,\n \treturn 0;\n }\n \n-int sq_dequote_to_argv(char *arg, const char ***argv, int *nr, int *alloc)\n-{\n-\treturn sq_dequote_to_argv_internal(arg, argv, nr, alloc, NULL);\n-}\n-\n int sq_dequote_to_strvec(char *arg, struct strvec *array)\n {\n \treturn sq_dequote_to_argv_internal(arg, NULL, NULL, NULL, array);\ndiff --git a/quote.h b/quote.h\nindex 400397b11a..989f2388c0 100644\n--- a/quote.h\n+++ b/quote.h\n@@ -68,15 +68,9 @@ char *sq_dequote_step(char *src, char **next);\n \n /*\n  * Same as the above, but can be used to unwrap many arguments in the\n- * same string separated by space. Like sq_quote, it works in place,\n- * modifying arg and appending pointers into it to argv.\n- */\n-int sq_dequote_to_argv(char *arg, const char ***argv, int *nr, int *alloc);\n-\n-/*\n- * Same as above, but store the unquoted strings in a strvec. We will\n- * still modify arg in place, but unlike sq_dequote_to_argv, the strvec\n- * will duplicate and take ownership of the strings.\n+ * same string separated by space. The strvec will duplicate and take\n+ * ownership of the strings, but note that \"arg\" is still modified in-place\n+ * during parsing.\n  */\n int sq_dequote_to_strvec(char *arg, struct strvec *);\n \n-- \n2.54.0.524.g198262df96\n\n"},{"id":"543579","messageId":"20260519012059.GC1615870@coredump.intra.peff.net","threadId":"65655","inReplyTo":"20260519011837.GA1615637@coredump.intra.peff.net","subject":"[PATCH 3/3] quote: simplify internals of dequoting","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2026-05-19T01:20:59Z","receivedAt":"2026-05-19T01:21:01Z","isPatch":true,"body":"Our sq_dequote_to_argv_internal() helper was wrapped by the to_argv()\nand to_strvec() forms. Now that we have only the latter, we can stop\nwrapping it and drop the argv-only bits.\n\nNote that in theory sq_dequote_to_strvec() could take a const input\nstring, which would be friendlier to its callers. We couldn't do that\nwith the to_argv() form because it reused the input string to hold the\noutput elements. But since we're built on sq_dequote_step(), which\nmunges the input, we'd have to rework the parser. Since no callers care\nabout it currently, we'll leave that for another day.\n\nSigned-off-by: Jeff King <peff@peff.net>\n---\n quote.c | 16 ++--------------\n 1 file changed, 2 insertions(+), 14 deletions(-)\n\ndiff --git a/quote.c b/quote.c\nindex cff78af3a4..235fac8e47 100644\n--- a/quote.c\n+++ b/quote.c\n@@ -171,9 +171,7 @@ char *sq_dequote(char *arg)\n \treturn sq_dequote_step(arg, NULL);\n }\n \n-static int sq_dequote_to_argv_internal(char *arg,\n-\t\t\t\t       const char ***argv, int *nr, int *alloc,\n-\t\t\t\t       struct strvec *array)\n+int sq_dequote_to_strvec(char *arg, struct strvec *array)\n {\n \tchar *next = arg;\n \n@@ -191,22 +189,12 @@ static int sq_dequote_to_argv_internal(char *arg,\n \t\t\t\tc = *++next;\n \t\t\t} while (isspace(c));\n \t\t}\n-\t\tif (argv) {\n-\t\t\tALLOC_GROW(*argv, *nr + 1, *alloc);\n-\t\t\t(*argv)[(*nr)++] = dequoted;\n-\t\t}\n-\t\tif (array)\n-\t\t\tstrvec_push(array, dequoted);\n+\t\tstrvec_push(array, dequoted);\n \t} while (next);\n \n \treturn 0;\n }\n \n-int sq_dequote_to_strvec(char *arg, struct strvec *array)\n-{\n-\treturn sq_dequote_to_argv_internal(arg, NULL, NULL, NULL, array);\n-}\n-\n /* 1 means: quote as octal\n  * 0 means: quote as octal if (quote_path_fully)\n  * -1 means: never quote\n-- \n2.54.0.524.g198262df96\n"},{"id":"543584","messageId":"xmqqjyt084sn.fsf@gitster.g","threadId":"65655","inReplyTo":"20260519011837.GA1615637@coredump.intra.peff.net","subject":"Re: [PATCH 0/3] small quote.[ch] cleanup","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2026-05-19T03:19:20Z","receivedAt":"2026-05-19T03:19:22Z","isPatch":true,"body":"Jeff King <peff@peff.net> writes:\n\n> I noticed some unused code while looking at an unrelated topic. So\n> here's a small cleanup.\n>\n>   [1/3]: quote.h: bump strvec forward declaration to the top\n>   [2/3]: quote: drop sq_dequote_to_argv()\n>   [3/3]: quote: simplify internals of dequoting\n>\n>  quote.c | 21 ++-------------------\n>  quote.h | 14 ++++----------\n>  2 files changed, 6 insertions(+), 29 deletions(-)\n>\n> -Peff\n\nThese were very straight-forward and pleasant to read.  Queued.\nThanks.\n"},{"id":"543821","messageId":"ag7u-LkIyYvnhtfX@pks.im","threadId":"65655","inReplyTo":"xmqqjyt084sn.fsf@gitster.g","subject":"Re: [PATCH 0/3] small quote.[ch] cleanup","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2026-05-21T11:39:36Z","receivedAt":"2026-05-21T11:39:48Z","isPatch":true,"body":"On Tue, May 19, 2026 at 12:19:20PM +0900, Junio C Hamano wrote:\n> Jeff King <peff@peff.net> writes:\n> \n> > I noticed some unused code while looking at an unrelated topic. So\n> > here's a small cleanup.\n> >\n> >   [1/3]: quote.h: bump strvec forward declaration to the top\n> >   [2/3]: quote: drop sq_dequote_to_argv()\n> >   [3/3]: quote: simplify internals of dequoting\n> >\n> >  quote.c | 21 ++-------------------\n> >  quote.h | 14 ++++----------\n> >  2 files changed, 6 insertions(+), 29 deletions(-)\n> >\n> > -Peff\n> \n> These were very straight-forward and pleasant to read.  Queued.\n> Thanks.\n\nIndeed, all of these steps make sense to me. Thanks!\n\nPatrick\n"}]}