diff mbox series

[1/2] diff: simplify quote_two()

Message ID 20210915223316.1653443-2-gitster@pobox.com (mailing list archive)
State New, archived
Headers show
Series (experimental) diff --quote-path-with-sp | expand

Commit Message

Junio C Hamano Sept. 15, 2021, 10:33 p.m. UTC
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 mbox series

Patch

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);
 }