| 2314 | } |
| 2315 | |
| 2316 | static int handle_revision_opt(struct rev_info *revs, int argc, const char **argv, |
| 2317 | int *unkc, const char **unkv, |
| 2318 | const struct setup_revision_opt* opt) |
| 2319 | { |
| 2320 | const char *arg = argv[0]; |
| 2321 | const char *optarg = NULL; |
| 2322 | int argcount; |
| 2323 | const unsigned hexsz = the_hash_algo->hexsz; |
| 2324 | |
| 2325 | /* pseudo revision arguments */ |
| 2326 | if (!strcmp(arg, "--all") || !strcmp(arg, "--branches") || |
| 2327 | !strcmp(arg, "--tags") || !strcmp(arg, "--remotes") || |
| 2328 | !strcmp(arg, "--reflog") || !strcmp(arg, "--not") || |
| 2329 | !strcmp(arg, "--no-walk") || !strcmp(arg, "--do-walk") || |
| 2330 | !strcmp(arg, "--bisect") || starts_with(arg, "--glob=") || |
| 2331 | !strcmp(arg, "--indexed-objects") || |
| 2332 | !strcmp(arg, "--alternate-refs") || |
| 2333 | starts_with(arg, "--exclude=") || starts_with(arg, "--exclude-hidden=") || |
| 2334 | starts_with(arg, "--branches=") || starts_with(arg, "--tags=") || |
| 2335 | starts_with(arg, "--remotes=") || starts_with(arg, "--no-walk=")) |
| 2336 | { |
| 2337 | overwrite_argv(unkc, unkv, &argv[0], opt); |
| 2338 | return 1; |
| 2339 | } |
| 2340 | |
| 2341 | if ((argcount = parse_long_opt("max-count", argv, &optarg))) { |
| 2342 | if (revs->max_count_type == 1) |
| 2343 | die_for_incompatible_opt2(1, "--max-count", 1, |
| 2344 | "--max-count-oldest"); |
| 2345 | revs->max_count = parse_count(optarg); |
| 2346 | revs->no_walk = 0; |
| 2347 | revs->max_count_type = 0; |
| 2348 | return argcount; |
| 2349 | } else if ((argcount = parse_long_opt("max-count-oldest", argv, &optarg))) { |
| 2350 | if (revs->max_count_type == 0 && revs->max_count != -1) |
| 2351 | die_for_incompatible_opt2(1, "--max-count", 1, |
| 2352 | "--max-count-oldest"); |
| 2353 | if (revs->skip_count > 0) |
| 2354 | die_for_incompatible_opt2(1, "--skip", 1, |
| 2355 | "--max-count-oldest"); |
| 2356 | revs->max_count = parse_count(optarg); |
| 2357 | revs->no_walk = 0; |
| 2358 | revs->max_count_type = 1; |
| 2359 | revs->max_count_stage = 0; |
| 2360 | } else if ((argcount = parse_long_opt("skip", argv, &optarg))) { |
| 2361 | if (revs->max_count_type == 1) |
| 2362 | die_for_incompatible_opt2(1, "--skip", 1, |
| 2363 | "--max-count-oldest"); |
| 2364 | revs->skip_count = parse_count(optarg); |
| 2365 | return argcount; |
| 2366 | } else if ((*arg == '-') && isdigit(arg[1])) { |
| 2367 | /* accept -<digit>, like traditional "head" */ |
| 2368 | revs->max_count = parse_count(arg + 1); |
| 2369 | revs->no_walk = 0; |
| 2370 | } else if (!strcmp(arg, "-n")) { |
| 2371 | if (argc <= 1) |
| 2372 | return error("-n requires an argument"); |
| 2373 | revs->max_count = parse_count(argv[1]); |
no test coverage detected