From: Junio C Hamano <gitster@pobox.com>
To: Shourya Shukla <shouryashukla.oo@gmail.com>
Cc: git@vger.kernel.org, christian.couder@gmail.com, liu.denton@gmail.com
Subject: Re: [PATCH v3] submodule: port subcommand 'set-url' from shell to C
Date: Mon, 04 May 2020 12:14:01 -0700 [thread overview]
Message-ID: <xmqq368fh5s6.fsf@gitster.c.googlers.com> (raw)
In-Reply-To: <20200504173936.GA8919@konoha> (Shourya Shukla's message of "Mon, 4 May 2020 23:09:36 +0530")
Shourya Shukla <shouryashukla.oo@gmail.com> writes:
> On 04/05 08:55, Junio C Hamano wrote:
>> > + argc = parse_options(argc, argv, prefix, set_url_options,
>> > + usage, 0);
>> > +
>> > + if (quiet)
>> > + quiet |= OPT_QUIET;
>>
>> This is bogus. "command --quiet --quiet" would count-up quiet twice
>> and would make it 2, and you or OPT_QUIET==1 in to make it 3, but
>> your intention is quite clear that you want to pass 1 to
>> sync_submodule() in such a case.
>
> This is a grave mistake from my side. Though I do not understand how
> will `quiet` be counted twice.
The way I read the definition of OPT__QUIET()
#define OPT__QUIET(var, h) OPT_COUNTUP('q', "quiet", (var), (h))
is that it is OPT_COUNTUP() in disguise, and that is designed to
yield increased quietness when "-q" is given more than once.
> The fix you suggested (quiet ? OPT_QUIET : 0), we use this because we
> want to ensure `quiet` goes into sync as either 1/0 right? Not any other
> non-zero positive integer right?
The "if (quiet) quiet |= OPT_QUIET" does not make *any* sense, if
you are expecting quiet to be set to 1 or left as 0 as initialized
by parse_options() API. You are defeating the whole point of using
preprocessor macro OPT_QUIET, as the correctness of the construct
heavily rely on OPT_QUIET defined to be 1. If for any reason the
preprocessor macro gets redefined to 8, writing
quiet ? OPT_QUIET : 0
would need *no* adjustment, while "if (quiet) quiet |= OPT_QUIET"
would require fixing.
prev parent reply other threads:[~2020-05-04 19:14 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-04 7:27 [PATCH v3] submodule: port subcommand 'set-url' from shell to C Shourya Shukla
2020-05-04 15:55 ` Junio C Hamano
2020-05-04 17:39 ` Shourya Shukla
2020-05-04 19:14 ` Junio C Hamano [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xmqq368fh5s6.fsf@gitster.c.googlers.com \
--to=gitster@pobox.com \
--cc=christian.couder@gmail.com \
--cc=git@vger.kernel.org \
--cc=liu.denton@gmail.com \
--cc=shouryashukla.oo@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).