| 139 | } |
| 140 | |
| 141 | static int parse_dirstat_params(struct diff_options *options, const char *params_string, |
| 142 | struct strbuf *errmsg) |
| 143 | { |
| 144 | char *params_copy = xstrdup(params_string); |
| 145 | struct string_list params = STRING_LIST_INIT_NODUP; |
| 146 | int ret = 0; |
| 147 | int i; |
| 148 | |
| 149 | if (*params_copy) |
| 150 | string_list_split_in_place(¶ms, params_copy, ",", -1); |
| 151 | for (i = 0; i < params.nr; i++) { |
| 152 | const char *p = params.items[i].string; |
| 153 | if (!strcmp(p, "changes")) { |
| 154 | options->flags.dirstat_by_line = 0; |
| 155 | options->flags.dirstat_by_file = 0; |
| 156 | } else if (!strcmp(p, "lines")) { |
| 157 | options->flags.dirstat_by_line = 1; |
| 158 | options->flags.dirstat_by_file = 0; |
| 159 | } else if (!strcmp(p, "files")) { |
| 160 | options->flags.dirstat_by_line = 0; |
| 161 | options->flags.dirstat_by_file = 1; |
| 162 | } else if (!strcmp(p, "noncumulative")) { |
| 163 | options->flags.dirstat_cumulative = 0; |
| 164 | } else if (!strcmp(p, "cumulative")) { |
| 165 | options->flags.dirstat_cumulative = 1; |
| 166 | } else if (isdigit(*p)) { |
| 167 | char *end; |
| 168 | int permille = strtoul(p, &end, 10) * 10; |
| 169 | if (*end == '.' && isdigit(*++end)) { |
| 170 | /* only use first digit */ |
| 171 | permille += *end - '0'; |
| 172 | /* .. and ignore any further digits */ |
| 173 | while (isdigit(*++end)) |
| 174 | ; /* nothing */ |
| 175 | } |
| 176 | if (!*end) |
| 177 | options->dirstat_permille = permille; |
| 178 | else { |
| 179 | strbuf_addf(errmsg, _(" Failed to parse dirstat cut-off percentage '%s'\n"), |
| 180 | p); |
| 181 | ret++; |
| 182 | } |
| 183 | } else { |
| 184 | strbuf_addf(errmsg, _(" Unknown dirstat parameter '%s'\n"), p); |
| 185 | ret++; |
| 186 | } |
| 187 | |
| 188 | } |
| 189 | string_list_clear(¶ms, 0); |
| 190 | free(params_copy); |
| 191 | return ret; |
| 192 | } |
| 193 | |
| 194 | static int parse_submodule_params(struct diff_options *options, const char *value) |
| 195 | { |
no test coverage detected