@matheusbsbs / matheus-bagliano / commits / d054680c7d
Fork 0

Reorder diff_opt_parse options more logically per topics.

This is a line reordering patch _only_. Signed-off-by: Pierre Habouzit <madcoder@debian.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Pierre Habouzit committed Nov 7, 2007 at 11:20 UTC d054680c7d245b71ebba0dd030fd13dce213559a
1 file changed +63 -53
diff.c
+63 -53
@@ -2185,6 +2185,8 @@ static int diff_scoreopt_parse(const char *opt);
2185 int diff_opt_parse(struct diff_options *options, const char **av, int ac)
2186 {
2187 const char *arg = av[0];
2188 +
2189 + /* Output format options */
2190 if (!strcmp(arg, "-p") || !strcmp(arg, "-u"))
2191 options->output_format |= DIFF_FORMAT_PATCH;
2192 else if (opt_arg(arg, 'U', "unified", &options->context))
@@ -2197,6 +2199,18 @@ int diff_opt_parse(struct diff_options *options, const char **av, int ac)
2199 options->output_format |= DIFF_FORMAT_NUMSTAT;
2200 else if (!strcmp(arg, "--shortstat"))
2201 options->output_format |= DIFF_FORMAT_SHORTSTAT;
2202 + else if (!strcmp(arg, "--check"))
2203 + options->output_format |= DIFF_FORMAT_CHECKDIFF;
2204 + else if (!strcmp(arg, "--summary"))
2205 + options->output_format |= DIFF_FORMAT_SUMMARY;
2206 + else if (!strcmp(arg, "--patch-with-stat"))
2207 + options->output_format |= DIFF_FORMAT_PATCH | DIFF_FORMAT_DIFFSTAT;
2208 + else if (!strcmp(arg, "--name-only"))
2209 + options->output_format |= DIFF_FORMAT_NAME;
2210 + else if (!strcmp(arg, "--name-status"))
2211 + options->output_format |= DIFF_FORMAT_NAME_STATUS;
2212 + else if (!strcmp(arg, "-s"))
2213 + options->output_format |= DIFF_FORMAT_NO_OUTPUT;
2214 else if (!prefixcmp(arg, "--stat")) {
2215 char *end;
2216 int width = options->stat_width;
@@ -2224,42 +2238,8 @@ int diff_opt_parse(struct diff_options *options, const char **av, int ac)
2238 options->stat_name_width = name_width;
2239 options->stat_width = width;
2240 }
2227 - else if (!strcmp(arg, "--check"))
2228 - options->output_format |= DIFF_FORMAT_CHECKDIFF;
2229 - else if (!strcmp(arg, "--summary"))
2230 - options->output_format |= DIFF_FORMAT_SUMMARY;
2231 - else if (!strcmp(arg, "--patch-with-stat"))
2232 - options->output_format |= DIFF_FORMAT_PATCH | DIFF_FORMAT_DIFFSTAT;
2233 - else if (!strcmp(arg, "-z"))
2234 - options->line_termination = 0;
2235 - else if (!prefixcmp(arg, "-l"))
2236 - options->rename_limit = strtoul(arg+2, NULL, 10);
2237 - else if (!strcmp(arg, "--full-index"))
2238 - DIFF_OPT_SET(options, FULL_INDEX);
2239 - else if (!strcmp(arg, "--binary")) {
2240 - options->output_format |= DIFF_FORMAT_PATCH;
2241 - DIFF_OPT_SET(options, BINARY);
2242 - }
2243 - else if (!strcmp(arg, "-a") || !strcmp(arg, "--text"))
2244 - DIFF_OPT_SET(options, TEXT);
2245 - else if (!strcmp(arg, "--name-only"))
2246 - options->output_format |= DIFF_FORMAT_NAME;
2247 - else if (!strcmp(arg, "--name-status"))
2248 - options->output_format |= DIFF_FORMAT_NAME_STATUS;
2249 - else if (!strcmp(arg, "-R"))
2250 - DIFF_OPT_SET(options, REVERSE_DIFF);
2251 - else if (!prefixcmp(arg, "-S"))
2252 - options->pickaxe = arg + 2;
2253 - else if (!strcmp(arg, "-s"))
2254 - options->output_format |= DIFF_FORMAT_NO_OUTPUT;
2255 - else if (!prefixcmp(arg, "-O"))
2256 - options->orderfile = arg + 2;
2257 - else if (!prefixcmp(arg, "--diff-filter="))
2258 - options->filter = arg + 14;
2259 - else if (!strcmp(arg, "--pickaxe-all"))
2260 - options->pickaxe_opts = DIFF_PICKAXE_ALL;
2261 - else if (!strcmp(arg, "--pickaxe-regex"))
2262 - options->pickaxe_opts = DIFF_PICKAXE_REGEX;
2241 +
2242 + /* renames options */
2243 else if (!prefixcmp(arg, "-B")) {
2244 if ((options->break_opt = diff_scoreopt_parse(arg)) == -1)
2245 return -1;
@@ -2276,33 +2256,38 @@ int diff_opt_parse(struct diff_options *options, const char **av, int ac)
2256 return -1;
2257 options->detect_rename = DIFF_DETECT_COPY;
2258 }
2259 + else if (!strcmp(arg, "--no-renames"))
2260 + options->detect_rename = 0;
2261 +
2262 + /* xdiff options */
2263 + else if (!strcmp(arg, "-w") || !strcmp(arg, "--ignore-all-space"))
2264 + options->xdl_opts |= XDF_IGNORE_WHITESPACE;
2265 + else if (!strcmp(arg, "-b") || !strcmp(arg, "--ignore-space-change"))
2266 + options->xdl_opts |= XDF_IGNORE_WHITESPACE_CHANGE;
2267 + else if (!strcmp(arg, "--ignore-space-at-eol"))
2268 + options->xdl_opts |= XDF_IGNORE_WHITESPACE_AT_EOL;
2269 +
2270 + /* flags options */
2271 + else if (!strcmp(arg, "--binary")) {
2272 + options->output_format |= DIFF_FORMAT_PATCH;
2273 + DIFF_OPT_SET(options, BINARY);
2274 + }
2275 + else if (!strcmp(arg, "--full-index"))
2276 + DIFF_OPT_SET(options, FULL_INDEX);
2277 + else if (!strcmp(arg, "-a") || !strcmp(arg, "--text"))
2278 + DIFF_OPT_SET(options, TEXT);
2279 + else if (!strcmp(arg, "-R"))
2280 + DIFF_OPT_SET(options, REVERSE_DIFF);
2281 else if (!strcmp(arg, "--find-copies-harder"))
2282 DIFF_OPT_SET(options, FIND_COPIES_HARDER);
2283 else if (!strcmp(arg, "--follow"))
2284 DIFF_OPT_SET(options, FOLLOW_RENAMES);
2283 - else if (!strcmp(arg, "--abbrev"))
2284 - options->abbrev = DEFAULT_ABBREV;
2285 - else if (!prefixcmp(arg, "--abbrev=")) {
2286 - options->abbrev = strtoul(arg + 9, NULL, 10);
2287 - if (options->abbrev < MINIMUM_ABBREV)
2288 - options->abbrev = MINIMUM_ABBREV;
2289 - else if (40 < options->abbrev)
2290 - options->abbrev = 40;
2291 - }
2285 else if (!strcmp(arg, "--color"))
2286 DIFF_OPT_SET(options, COLOR_DIFF);
2287 else if (!strcmp(arg, "--no-color"))
2288 DIFF_OPT_CLR(options, COLOR_DIFF);
2296 - else if (!strcmp(arg, "-w") || !strcmp(arg, "--ignore-all-space"))
2297 - options->xdl_opts |= XDF_IGNORE_WHITESPACE;
2298 - else if (!strcmp(arg, "-b") || !strcmp(arg, "--ignore-space-change"))
2299 - options->xdl_opts |= XDF_IGNORE_WHITESPACE_CHANGE;
2300 - else if (!strcmp(arg, "--ignore-space-at-eol"))
2301 - options->xdl_opts |= XDF_IGNORE_WHITESPACE_AT_EOL;
2289 else if (!strcmp(arg, "--color-words"))
2290 options->flags |= DIFF_OPT_COLOR_DIFF | DIFF_OPT_COLOR_DIFF_WORDS;
2304 - else if (!strcmp(arg, "--no-renames"))
2305 - options->detect_rename = 0;
2291 else if (!strcmp(arg, "--exit-code"))
2292 DIFF_OPT_SET(options, EXIT_WITH_STATUS);
2293 else if (!strcmp(arg, "--quiet"))
@@ -2311,6 +2296,31 @@ int diff_opt_parse(struct diff_options *options, const char **av, int ac)
2296 DIFF_OPT_SET(options, ALLOW_EXTERNAL);
2297 else if (!strcmp(arg, "--no-ext-diff"))
2298 DIFF_OPT_CLR(options, ALLOW_EXTERNAL);
2299 +
2300 + /* misc options */
2301 + else if (!strcmp(arg, "-z"))
2302 + options->line_termination = 0;
2303 + else if (!prefixcmp(arg, "-l"))
2304 + options->rename_limit = strtoul(arg+2, NULL, 10);
2305 + else if (!prefixcmp(arg, "-S"))
2306 + options->pickaxe = arg + 2;
2307 + else if (!strcmp(arg, "--pickaxe-all"))
2308 + options->pickaxe_opts = DIFF_PICKAXE_ALL;
2309 + else if (!strcmp(arg, "--pickaxe-regex"))
2310 + options->pickaxe_opts = DIFF_PICKAXE_REGEX;
2311 + else if (!prefixcmp(arg, "-O"))
2312 + options->orderfile = arg + 2;
2313 + else if (!prefixcmp(arg, "--diff-filter="))
2314 + options->filter = arg + 14;
2315 + else if (!strcmp(arg, "--abbrev"))
2316 + options->abbrev = DEFAULT_ABBREV;
2317 + else if (!prefixcmp(arg, "--abbrev=")) {
2318 + options->abbrev = strtoul(arg + 9, NULL, 10);
2319 + if (options->abbrev < MINIMUM_ABBREV)
2320 + options->abbrev = MINIMUM_ABBREV;
2321 + else if (40 < options->abbrev)
2322 + options->abbrev = 40;
2323 + }
2324 else
2325 return 0;
2326 return 1;