Git fork

Merge branch 'rs/bundle-parseopt-cleanup'

Code clean-up.

* rs/bundle-parseopt-cleanup:
bundle: use OPT_PASSTHRU_ARGV

+23 -23
+17 -23
builtin/bundle.c
··· 68 68 } 69 69 70 70 static int cmd_bundle_create(int argc, const char **argv, const char *prefix) { 71 - int all_progress_implied = 1; 72 - int progress = isatty(STDERR_FILENO); 73 - struct strvec pack_opts; 71 + struct strvec pack_opts = STRVEC_INIT; 74 72 int version = -1; 75 73 int ret; 76 74 struct option options[] = { 77 - OPT_SET_INT('q', "quiet", &progress, 78 - N_("do not show progress meter"), 0), 79 - OPT_SET_INT(0, "progress", &progress, 80 - N_("show progress meter"), 1), 81 - OPT_SET_INT_F(0, "all-progress", &progress, 82 - N_("historical; same as --progress"), 2, 83 - PARSE_OPT_HIDDEN), 84 - OPT_HIDDEN_BOOL(0, "all-progress-implied", 85 - &all_progress_implied, 86 - N_("historical; does nothing")), 75 + OPT_PASSTHRU_ARGV('q', "quiet", &pack_opts, NULL, 76 + N_("do not show progress meter"), 77 + PARSE_OPT_NOARG), 78 + OPT_PASSTHRU_ARGV(0, "progress", &pack_opts, NULL, 79 + N_("show progress meter"), 80 + PARSE_OPT_NOARG), 81 + OPT_PASSTHRU_ARGV(0, "all-progress", &pack_opts, NULL, 82 + N_("historical; same as --progress"), 83 + PARSE_OPT_NOARG | PARSE_OPT_HIDDEN), 84 + OPT_PASSTHRU_ARGV(0, "all-progress-implied", &pack_opts, NULL, 85 + N_("historical; does nothing"), 86 + PARSE_OPT_NOARG | PARSE_OPT_HIDDEN), 87 87 OPT_INTEGER(0, "version", &version, 88 88 N_("specify bundle format version")), 89 89 OPT_END() 90 90 }; 91 91 char *bundle_file; 92 + 93 + if (isatty(STDERR_FILENO)) 94 + strvec_push(&pack_opts, "--progress"); 95 + strvec_push(&pack_opts, "--all-progress-implied"); 92 96 93 97 argc = parse_options_cmd_bundle(argc, argv, prefix, 94 98 builtin_bundle_create_usage, options, &bundle_file); 95 99 /* bundle internals use argv[1] as further parameters */ 96 - 97 - strvec_init(&pack_opts); 98 - if (progress == 0) 99 - strvec_push(&pack_opts, "--quiet"); 100 - else if (progress == 1) 101 - strvec_push(&pack_opts, "--progress"); 102 - else if (progress == 2) 103 - strvec_push(&pack_opts, "--all-progress"); 104 - if (progress && all_progress_implied) 105 - strvec_push(&pack_opts, "--all-progress-implied"); 106 100 107 101 if (!startup_info->have_repository) 108 102 die(_("Need a repository to create a bundle."));
+6
t/t6020-bundle-misc.sh
··· 619 619 test_must_be_empty err 620 620 ' 621 621 622 + test_expect_success 'bundle progress with --no-quiet' ' 623 + GIT_PROGRESS_DELAY=0 \ 624 + git bundle create --no-quiet out.bundle --all 2>err && 625 + grep "%" err 626 + ' 627 + 622 628 test_expect_success 'read bundle over stdin' ' 623 629 git bundle create some.bundle HEAD && 624 630