git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Duy Nguyen <pclouds@gmail.com>
To: Yuxuan Shui <yshuiv7@gmail.com>
Cc: Git Mailing List <git@vger.kernel.org>
Subject: Re: [PATCH][GSoC] parse-options: Add OPT_SET_INT_NONEG.
Date: Wed, 12 Mar 2014 17:47:19 +0700	[thread overview]
Message-ID: <CACsJy8Dq5QyZdzCtew0qF37qThH8+05iTrD-ZOeBgbEukmCY5Q@mail.gmail.com> (raw)
In-Reply-To: <1394535016-9424-1-git-send-email-yshuiv7@gmail.com>

By convention, no full stop in the subject line. The subject should
summarize your changes and "add ..NONEG" is just one part of it. The
other is "convert to use ...NONEG". So I suggest "parse-options:
convert to use new macro OPT_SET_INT_NONEG()" or something like that.

You should also explain in the message body (before Signed-off-by:)
why this is a good thing to do. My guess is better readability and
harder to make mistakes in the future when you have to declare new
options with noneg.

On Tue, Mar 11, 2014 at 5:50 PM, Yuxuan Shui <yshuiv7@gmail.com> wrote:
> Reference: http://git.github.io/SoC-2014-Microprojects.html

I think this project is actually two: one is convert current
{OPTION_SET_INT, ... _NONEG} to the new macro, which is truly a micro
project. The other is to find OPT_...(..) that should have NONEG but
does not. This one may need more time because you need to check what
those options do and if it makes sense to have --no- form.

I think we can focus on the {OPTION_..., _NONEG} conversion, which
should be enough get you familiar with git community.

> diff --git a/parse-options.h b/parse-options.h
> index d670cb9..7d20cf9 100644
> --- a/parse-options.h
> +++ b/parse-options.h
> @@ -125,6 +125,10 @@ struct option {
>                                       (h), PARSE_OPT_NOARG }
>  #define OPT_SET_INT(s, l, v, h, i)  { OPTION_SET_INT, (s), (l), (v), NULL, \
>                                       (h), PARSE_OPT_NOARG, NULL, (i) }
> +#define OPT_SET_INT_NONEG(s, l, v, h, i)  \
> +                                     { OPTION_SET_INT, (s), (l), (v), NULL, \
> +                                     (h), PARSE_OPT_NOARG | PARSE_OPT_NONEG, \
> +                                     NULL, (i) }
>  #define OPT_BOOL(s, l, v, h)        OPT_SET_INT(s, l, v, h, 1)
>  #define OPT_HIDDEN_BOOL(s, l, v, h) { OPTION_SET_INT, (s), (l), (v), NULL, \
>                                       (h), PARSE_OPT_NOARG | PARSE_OPT_HIDDEN, NULL, 1}

To avoid the proliferation of similar macros in future, I think we
should make a macro that takes any flags, e.g.

#define OPT_SET_INT_X(s, l, v, h, i, flags) {  ....., PARSE_OPT_NOARG
| PARSE_OPT_ ## flags, NULL, (i) }

and we can use it for NONEG like "OPT_SET_INT_X(...., NONEG)". We
could even redefine OPT_SET_INT() to use OPT_SET_INT_X() to reduce
duplication.

While we're at NONEG, I see that builtin/grep.c has this construct "{
OPTION_INTEGER...NONEG}" and builtin/read-tree.c has "{
OPTION_STRING..NONEG}". It would be great if you could look at them
and see if NONEG is really needed there, or simpler forms
OPT_INTEGER(...) and OPT_STRING(...) are enough.

You might need to read parse-options.c to understand these options.
Documentation/technical/api-parse-options.txt should give you a good
overview.

You could also think if we could transform "{ OPTION_CALLBACK.... }"
to OPT_CALLBACK(...). But if you do and decide to do it, please make
it a separate patch (one patch deals with one thing).

That remaining of your patch looks good.
-- 
Duy

  reply	other threads:[~2014-03-12 10:47 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-11 10:50 [PATCH][GSoC] parse-options: Add OPT_SET_INT_NONEG Yuxuan Shui
2014-03-12 10:47 ` Duy Nguyen [this message]
2014-03-12 17:25   ` Yuxuan Shui
2014-03-12 18:30   ` Junio C Hamano
2014-03-12 18:33     ` Yuxuan Shui
2014-03-12 19:02       ` Junio C Hamano

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

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CACsJy8Dq5QyZdzCtew0qF37qThH8+05iTrD-ZOeBgbEukmCY5Q@mail.gmail.com \
    --to=pclouds@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=yshuiv7@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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).