Subject: [PATCH v6] json-writer: fixups for V5

From: [email-masked]
Date: Wed, 28 Mar 2018 13:09:40 +0000

From: Jeff Hostetler <[email-masked]>

Please squash this onto the top of jh/json-writer.

Fix leading whitespace in t0019 using tricked suggested by Junio.
Fix unnecessary cast for intmax_t suggested by Wink.

Signed-off-by: Jeff Hostetler <[email-masked]>
---
 json-writer.c          |  4 ++--
 t/t0019-json-writer.sh | 36 ++++++++++++++++++------------------
 2 files changed, 20 insertions(+), 20 deletions(-)

diff --git a/json-writer.c b/json-writer.c
index 1b49158..dbfcf70 100644
--- a/json-writer.c
+++ b/json-writer.c
@@ -165,7 +165,7 @@ void jw_object_string(struct json_writer *jw, const char *key, const char *value
 void jw_object_intmax(struct json_writer *jw, const char *key, intmax_t value)
 {
 	object_common(jw, key);
-	strbuf_addf(&jw->json, "%"PRIdMAX, (intmax_t)value);
+	strbuf_addf(&jw->json, "%"PRIdMAX, value);
 }
 
 void jw_object_double(struct json_writer *jw, const char *key, int precision,
@@ -303,7 +303,7 @@ void jw_array_string(struct json_writer *jw, const char *value)
 void jw_array_intmax(struct json_writer *jw, intmax_t value)
 {
 	array_common(jw);
-	strbuf_addf(&jw->json, "%"PRIdMAX, (intmax_t)value);
+	strbuf_addf(&jw->json, "%"PRIdMAX, value);
 }
 
 void jw_array_double(struct json_writer *jw, int precision, double value)
diff --git a/t/t0019-json-writer.sh b/t/t0019-json-writer.sh
index a04c055..bd6d474 100755
--- a/t/t0019-json-writer.sh
+++ b/t/t0019-json-writer.sh
@@ -166,24 +166,24 @@ test_expect_success 'nested inline object and array 2' '
 '
 
 test_expect_success 'pretty nested inline object and array 2' '
-	cat >expect <<EOF &&
-{
-  "a": "abc",
-  "b": 42,
-  "sub1": {
-    "c": 3.14,
-    "d": true,
-    "sub2": [
-      false,
-      {
-        "g": 0,
-        "h": 1
-      },
-      null
-    ]
-  }
-}
-EOF
+	sed -e "s/^|//" >expect <<-\EOF &&
+	|{
+	|  "a": "abc",
+	|  "b": 42,
+	|  "sub1": {
+	|    "c": 3.14,
+	|    "d": true,
+	|    "sub2": [
+	|      false,
+	|      {
+	|        "g": 0,
+	|        "h": 1
+	|      },
+	|      null
+	|    ]
+	|  }
+	|}
+	EOF
 	test-json-writer >actual \
 		--pretty \
 		@object \
-- 
2.9.3