pack-objects: fix --no-quiet

Since 99fb6e04cb (pack-objects: convert to use parse_options(), 2012-02-01) git pack-objects has accepted the option --no-quiet, but it does the same as --quiet. That's because it's defined using OPT_SET_INT with a value of 0, which sets 0 when negated, too. Make --no-quiet equivalent to --progress and ignore it if --all-progress was given. Signed-off-by: René Scharfe <l.s.r@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>

René Scharfe committed Jul 21, 2023 at 14:41 UTC 36f76d2a253a0346491cc127de5ca4b9f7895d60
1 file changed +15 -2
builtin/pack-objects.c
+15 -2
@@ -4118,6 +4118,18 @@ static void add_extra_kept_packs(const struct string_list *names)
4118 }
4119 }
4120
4121 +static int option_parse_quiet(const struct option *opt, const char *arg,
4122 + int unset)
4123 +{
4124 + BUG_ON_OPT_ARG(arg);
4125 +
4126 + if (!unset)
4127 + progress = 0;
4128 + else if (!progress)
4129 + progress = 1;
4130 + return 0;
4131 +}
4132 +
4133 static int option_parse_index_version(const struct option *opt,
4134 const char *arg, int unset)
4135 {
@@ -4179,8 +4191,9 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix)
4191 LIST_OBJECTS_FILTER_INIT;
4192
4193 struct option pack_objects_options[] = {
4182 - OPT_SET_INT('q', "quiet", &progress,
4183 - N_("do not show progress meter"), 0),
4194 + OPT_CALLBACK_F('q', "quiet", NULL, NULL,
4195 + N_("do not show progress meter"),
4196 + PARSE_OPT_NOARG, option_parse_quiet),
4197 OPT_SET_INT(0, "progress", &progress,
4198 N_("show progress meter"), 1),
4199 OPT_SET_INT(0, "all-progress", &progress,