{"thread":{"id":"60041","subject":"[PATCH] bundle: use OPT_PASSTHRU_ARGV","startedAt":"2023-07-29T20:40:34Z","lastAt":"2023-07-29T20:40:34Z","messageCount":1,"participants":["René Scharfe"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"479983","messageId":"2dcb915f-b926-e024-6394-23aff200955c@web.de","threadId":"60041","inReplyTo":null,"subject":"[PATCH] bundle: use OPT_PASSTHRU_ARGV","fromName":"René Scharfe","fromEmail":"l.s.r@web.de","sentAt":"2023-07-29T20:40:27Z","receivedAt":"2023-07-29T20:40:34Z","isPatch":true,"sender":{"key":"l.s.r@web.de","avatar":"https://avatars.githubusercontent.com/u/26122331?v=4"},"body":"\"git bundle\" passes the progress control options to \"git pack-objects\"\nby parsing and then recreating them explicitly.  Simplify that process\nby using OPT_PASSTHRU_ARGV instead.\n\nThis also fixes --no-quiet, which has been doing the same as --quiet\nsince its introduction by 79862b6b77 (bundle-create: progress output\ncontrol, 2019-11-10) because it had been defined using OPT_SET_INT with\na value of 0, which sets 0 when negated as well.\n\nSigned-off-by: René Scharfe <l.s.r@web.de>\n---\n builtin/bundle.c       | 40 +++++++++++++++++-----------------------\n t/t6020-bundle-misc.sh |  6 ++++++\n 2 files changed, 23 insertions(+), 23 deletions(-)\n\ndiff --git a/builtin/bundle.c b/builtin/bundle.c\nindex 3f63631c03..3ad11dc5d0 100644\n--- a/builtin/bundle.c\n+++ b/builtin/bundle.c\n@@ -68,42 +68,36 @@ static int parse_options_cmd_bundle(int argc,\n }\n\n static int cmd_bundle_create(int argc, const char **argv, const char *prefix) {\n-\tint all_progress_implied = 1;\n-\tint progress = isatty(STDERR_FILENO);\n-\tstruct strvec pack_opts;\n+\tstruct strvec pack_opts = STRVEC_INIT;\n \tint version = -1;\n \tint ret;\n \tstruct option options[] = {\n-\t\tOPT_SET_INT('q', \"quiet\", &progress,\n-\t\t\t    N_(\"do not show progress meter\"), 0),\n-\t\tOPT_SET_INT(0, \"progress\", &progress,\n-\t\t\t    N_(\"show progress meter\"), 1),\n-\t\tOPT_SET_INT_F(0, \"all-progress\", &progress,\n-\t\t\t      N_(\"historical; same as --progress\"), 2,\n-\t\t\t      PARSE_OPT_HIDDEN),\n-\t\tOPT_HIDDEN_BOOL(0, \"all-progress-implied\",\n-\t\t\t\t&all_progress_implied,\n-\t\t\t\tN_(\"historical; does nothing\")),\n+\t\tOPT_PASSTHRU_ARGV('q', \"quiet\", &pack_opts, NULL,\n+\t\t\t\t  N_(\"do not show progress meter\"),\n+\t\t\t\t  PARSE_OPT_NOARG),\n+\t\tOPT_PASSTHRU_ARGV(0, \"progress\", &pack_opts, NULL,\n+\t\t\t\t  N_(\"show progress meter\"),\n+\t\t\t\t  PARSE_OPT_NOARG),\n+\t\tOPT_PASSTHRU_ARGV(0, \"all-progress\", &pack_opts, NULL,\n+\t\t\t\t  N_(\"historical; same as --progress\"),\n+\t\t\t\t  PARSE_OPT_NOARG | PARSE_OPT_HIDDEN),\n+\t\tOPT_PASSTHRU_ARGV(0, \"all-progress-implied\", &pack_opts, NULL,\n+\t\t\t\t  N_(\"historical; does nothing\"),\n+\t\t\t\t  PARSE_OPT_NOARG | PARSE_OPT_HIDDEN),\n \t\tOPT_INTEGER(0, \"version\", &version,\n \t\t\t    N_(\"specify bundle format version\")),\n \t\tOPT_END()\n \t};\n \tchar *bundle_file;\n\n+\tif (isatty(STDERR_FILENO))\n+\t\tstrvec_push(&pack_opts, \"--progress\");\n+\tstrvec_push(&pack_opts, \"--all-progress-implied\");\n+\n \targc = parse_options_cmd_bundle(argc, argv, prefix,\n \t\t\tbuiltin_bundle_create_usage, options, &bundle_file);\n \t/* bundle internals use argv[1] as further parameters */\n\n-\tstrvec_init(&pack_opts);\n-\tif (progress == 0)\n-\t\tstrvec_push(&pack_opts, \"--quiet\");\n-\telse if (progress == 1)\n-\t\tstrvec_push(&pack_opts, \"--progress\");\n-\telse if (progress == 2)\n-\t\tstrvec_push(&pack_opts, \"--all-progress\");\n-\tif (progress && all_progress_implied)\n-\t\tstrvec_push(&pack_opts, \"--all-progress-implied\");\n-\n \tif (!startup_info->have_repository)\n \t\tdie(_(\"Need a repository to create a bundle.\"));\n \tret = !!create_bundle(the_repository, bundle_file, argc, argv, &pack_opts, version);\ndiff --git a/t/t6020-bundle-misc.sh b/t/t6020-bundle-misc.sh\nindex dface8bcfe..3e6bcbf30c 100755\n--- a/t/t6020-bundle-misc.sh\n+++ b/t/t6020-bundle-misc.sh\n@@ -619,6 +619,12 @@ test_expect_success TTY 'create --quiet disables all bundle progress' '\n \ttest_must_be_empty err\n '\n\n+test_expect_success 'bundle progress with --no-quiet' '\n+\tGIT_PROGRESS_DELAY=0 \\\n+\t\tgit bundle create --no-quiet out.bundle --all 2>err &&\n+\tgrep \"%\" err\n+'\n+\n test_expect_success 'read bundle over stdin' '\n \tgit bundle create some.bundle HEAD &&\n\n--\n2.41.0\n"}]}