MCPcopy Index your code
hub / github.com/git/git / git_config_prepare_comment_string

Function git_config_prepare_comment_string

config.c:2921–2952  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2919}
2920
2921char *git_config_prepare_comment_string(const char *comment)
2922{
2923 size_t leading_blanks;
2924 char *prepared;
2925
2926 if (!comment)
2927 return NULL;
2928
2929 if (strchr(comment, '\n'))
2930 die(_("no multi-line comment allowed: '%s'"), comment);
2931
2932 /*
2933 * If it begins with one or more leading whitespace characters
2934 * followed by '#", the comment string is used as-is.
2935 *
2936 * If it begins with '#', a SP is inserted between the comment
2937 * and the value the comment is about.
2938 *
2939 * Otherwise, the value is followed by a SP followed by '#'
2940 * followed by SP and then the comment string comes.
2941 */
2942
2943 leading_blanks = strspn(comment, " \t");
2944 if (leading_blanks && comment[leading_blanks] == '#')
2945 prepared = xstrdup(comment); /* use it as-is */
2946 else if (comment[0] == '#')
2947 prepared = xstrfmt(" %s", comment);
2948 else
2949 prepared = xstrfmt(" # %s", comment);
2950
2951 return prepared;
2952}
2953
2954static void validate_comment_string(const char *comment)
2955{

Callers 2

cmd_config_setFunction · 0.85
cmd_config_actionsFunction · 0.85

Calls 3

xstrdupFunction · 0.85
xstrfmtFunction · 0.85
dieFunction · 0.70

Tested by

no test coverage detected