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

Function format_config

builtin/config.c:406–471  ·  view source on GitHub ↗

* Format the configuration key-value pair (`key_`, `value_`) and * append it into strbuf `buf`. Returns a negative value on failure, * 0 on success, 1 on a missing optional value (i.e., telling the * caller to pretend that did not exist). * * Note: 'gently' is currently ignored, but will be implemented in * a future change. */

Source from the content-addressed store, hash-verified

404 * a future change.
405 */
406static int format_config(const struct config_display_options *opts,
407 struct strbuf *buf, const char *key_,
408 const char *value_, const struct key_value_info *kvi,
409 int gently)
410{
411 int res = 0;
412 if (opts->show_scope)
413 show_config_scope(opts, kvi, buf);
414 if (opts->show_origin)
415 show_config_origin(opts, kvi, buf);
416 if (opts->show_keys)
417 strbuf_addstr(buf, key_);
418
419 if (opts->omit_values)
420 goto terminator;
421
422 if (opts->show_keys)
423 strbuf_addch(buf, opts->key_delim);
424
425 switch (opts->type) {
426 case TYPE_INT:
427 res = format_config_int64(buf, key_, value_, kvi, gently);
428 break;
429
430 case TYPE_BOOL:
431 res = format_config_bool(buf, key_, value_, gently);
432 break;
433
434 case TYPE_BOOL_OR_INT:
435 res = format_config_bool_or_int(buf, key_, value_, kvi, gently);
436 break;
437
438 case TYPE_BOOL_OR_STR:
439 res = format_config_bool_or_str(buf, value_);
440 break;
441
442 case TYPE_PATH:
443 res = format_config_path(buf, key_, value_, gently);
444 break;
445
446 case TYPE_EXPIRY_DATE:
447 res = format_config_expiry_date(buf, key_, value_, gently);
448 break;
449
450 case TYPE_COLOR:
451 res = format_config_color(buf, key_, value_, gently);
452 break;
453
454 case TYPE_NONE:
455 if (value_) {
456 strbuf_addstr(buf, value_);
457 } else {
458 /* Just show the key name; back out delimiter */
459 if (opts->show_keys)
460 strbuf_setlen(buf, buf->len - 1);
461 }
462 break;
463

Callers 4

show_all_configFunction · 0.70
collect_configFunction · 0.70
get_valueFunction · 0.70
get_urlmatchFunction · 0.70

Calls 12

show_config_scopeFunction · 0.85
show_config_originFunction · 0.85
strbuf_addstrFunction · 0.85
strbuf_addchFunction · 0.85
format_config_int64Function · 0.85
format_config_boolFunction · 0.85
format_config_pathFunction · 0.85
format_config_colorFunction · 0.85
strbuf_setlenFunction · 0.85

Tested by

no test coverage detected