MCPcopy Create free account
hub / github.com/git/git / append_sub_jw

Function append_sub_jw

json-writer.c:237–269  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

235}
236
237static void append_sub_jw(struct json_writer *jw,
238 const struct json_writer *value)
239{
240 /*
241 * If both are pretty, increase the indentation of the sub_jw
242 * to better fit under the super.
243 *
244 * If the super is pretty, but the sub_jw is compact, leave the
245 * sub_jw compact. (We don't want to parse and rebuild the sub_jw
246 * for this debug-ish feature.)
247 *
248 * If the super is compact, and the sub_jw is pretty, convert
249 * the sub_jw to compact.
250 *
251 * If both are compact, keep the sub_jw compact.
252 */
253 if (jw->pretty && jw->open_stack.len && value->pretty) {
254 struct strbuf sb = STRBUF_INIT;
255 increase_indent(&sb, value, jw->open_stack.len * 2);
256 strbuf_addbuf(&jw->json, &sb);
257 strbuf_release(&sb);
258 return;
259 }
260 if (!jw->pretty && value->pretty) {
261 struct strbuf sb = STRBUF_INIT;
262 kill_indent(&sb, value);
263 strbuf_addbuf(&jw->json, &sb);
264 strbuf_release(&sb);
265 return;
266 }
267
268 strbuf_addbuf(&jw->json, &value->json);
269}
270
271void jw_object_sub_jw(struct json_writer *jw, const char *key,
272 const struct json_writer *value)

Callers 2

jw_object_sub_jwFunction · 0.85
jw_array_sub_jwFunction · 0.85

Calls 4

increase_indentFunction · 0.85
strbuf_addbufFunction · 0.85
strbuf_releaseFunction · 0.85
kill_indentFunction · 0.85

Tested by

no test coverage detected