| File: | builtin/prune-packed.c |
| Location: | line 62, column 2 |
| Description: | Value stored to 'argc' is never read |
| 1 | #include "builtin.h" |
| 2 | #include "cache.h" |
| 3 | #include "progress.h" |
| 4 | #include "parse-options.h" |
| 5 | |
| 6 | static const char * const prune_packed_usage[] = { |
| 7 | N_("git prune-packed [-n | --dry-run] [-q | --quiet]")("git prune-packed [-n | --dry-run] [-q | --quiet]"), |
| 8 | NULL((void*)0) |
| 9 | }; |
| 10 | |
| 11 | static struct progress *progress; |
| 12 | |
| 13 | static int prune_subdir(int nr, const char *path, void *data) |
| 14 | { |
| 15 | int *opts = data; |
| 16 | display_progress(progress, nr + 1); |
| 17 | if (!(*opts & PRUNE_PACKED_DRY_RUN01)) |
| 18 | rmdir(path); |
| 19 | return 0; |
| 20 | } |
| 21 | |
| 22 | static int prune_object(const unsigned char *sha1, const char *path, |
| 23 | void *data) |
| 24 | { |
| 25 | int *opts = data; |
| 26 | |
| 27 | if (!has_sha1_pack(sha1)) |
| 28 | return 0; |
| 29 | |
| 30 | if (*opts & PRUNE_PACKED_DRY_RUN01) |
| 31 | printf("rm -f %s\n", path); |
| 32 | else |
| 33 | unlink_or_warn(path); |
| 34 | return 0; |
| 35 | } |
| 36 | |
| 37 | void prune_packed_objects(int opts) |
| 38 | { |
| 39 | if (opts & PRUNE_PACKED_VERBOSE02) |
| 40 | progress = start_progress_delay(_("Removing duplicate objects"), |
| 41 | 256, 95, 2); |
| 42 | |
| 43 | for_each_loose_file_in_objdir(get_object_directory(), |
| 44 | prune_object, NULL((void*)0), prune_subdir, &opts); |
| 45 | |
| 46 | /* Ensure we show 100% before finishing progress */ |
| 47 | display_progress(progress, 256); |
| 48 | stop_progress(&progress); |
| 49 | } |
| 50 | |
| 51 | int cmd_prune_packed(int argc, const char **argv, const char *prefix) |
| 52 | { |
| 53 | int opts = isatty(2) ? PRUNE_PACKED_VERBOSE02 : 0; |
| 54 | const struct option prune_packed_options[] = { |
| 55 | OPT_BIT('n', "dry-run", &opts, N_("dry run"),{ OPTION_BIT, ('n'), ("dry-run"), (&opts), ((void*)0), (( "dry run")), PARSE_OPT_NOARG, ((void*)0), (01) } |
| 56 | PRUNE_PACKED_DRY_RUN){ OPTION_BIT, ('n'), ("dry-run"), (&opts), ((void*)0), (( "dry run")), PARSE_OPT_NOARG, ((void*)0), (01) }, |
| 57 | OPT_NEGBIT('q', "quiet", &opts, N_("be quiet"),{ OPTION_NEGBIT, ('q'), ("quiet"), (&opts), ((void*)0), ( ("be quiet")), PARSE_OPT_NOARG, ((void*)0), (02) } |
| 58 | PRUNE_PACKED_VERBOSE){ OPTION_NEGBIT, ('q'), ("quiet"), (&opts), ((void*)0), ( ("be quiet")), PARSE_OPT_NOARG, ((void*)0), (02) }, |
| 59 | OPT_END(){ OPTION_END } |
| 60 | }; |
| 61 | |
| 62 | argc = parse_options(argc, argv, prefix, prune_packed_options, |
Value stored to 'argc' is never read | |
| 63 | prune_packed_usage, 0); |
| 64 | |
| 65 | prune_packed_objects(opts); |
| 66 | return 0; |
| 67 | } |