[PATCH 1/2] diff: simplify quote_two()
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Sep 15, 2021, 22:33 UTC
- Message-ID
- <20210915223316.1653443-2-gitster@pobox.com>
- In-Reply-To
- <20210915223316.1653443-1-gitster@pobox.com>
Reimplement the function as a mere thin wrapper around quote_two_c_style().
Signed-off-by: Junio C Hamano <gitster@pobox.com> --- diff.c | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-)
diff --git a/diff.c b/diff.c index a8113f1707..8143b737b7 100644 --- a/diff.c +++ b/diff.c @@ -482,19 +482,9 @@ int git_diff_basic_config(const char *var, const char *value, void *cb) static char *quote_two(const char *one, const char *two) { - int need_one = quote_c_style(one, NULL, NULL, CQUOTE_NODQ); - int need_two = quote_c_style(two, NULL, NULL, CQUOTE_NODQ); struct strbuf res = STRBUF_INIT; - if (need_one + need_two) { - strbuf_addch(&res, '"'); - quote_c_style(one, &res, NULL, CQUOTE_NODQ); - quote_c_style(two, &res, NULL, CQUOTE_NODQ); - strbuf_addch(&res, '"'); - } else { - strbuf_addstr(&res, one); - strbuf_addstr(&res, two); - } + quote_two_c_style(&res, one, two, 0); return strbuf_detach(&res, NULL); }
-- 2.33.0-649-gd4f4107c2b