From: Yuxuan Shui <yshuiv7@gmail.com>
To: git@vger.kernel.org
Cc: Yuxuan Shui <yshuiv7@gmail.com>
Subject: [PATCH][GSoC] parse-options: Add OPT_SET_INT_NONEG.
Date: Tue, 11 Mar 2014 10:50:16 +0000 [thread overview]
Message-ID: <1394535016-9424-1-git-send-email-yshuiv7@gmail.com> (raw)
Reference: http://git.github.io/SoC-2014-Microprojects.html
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
---
builtin/fetch.c | 5 ++---
builtin/merge.c | 5 ++---
builtin/notes.c | 10 ++++------
builtin/pack-objects.c | 15 ++++++---------
builtin/update-index.c | 20 ++++++++------------
parse-options.h | 4 ++++
6 files changed, 26 insertions(+), 33 deletions(-)
diff --git a/builtin/fetch.c b/builtin/fetch.c
index 55f457c..37c2a9d 100644
--- a/builtin/fetch.c
+++ b/builtin/fetch.c
@@ -97,9 +97,8 @@ static struct option builtin_fetch_options[] = {
OPT_BOOL(0, "progress", &progress, N_("force progress reporting")),
OPT_STRING(0, "depth", &depth, N_("depth"),
N_("deepen history of shallow clone")),
- { OPTION_SET_INT, 0, "unshallow", &unshallow, NULL,
- N_("convert to a complete repository"),
- PARSE_OPT_NONEG | PARSE_OPT_NOARG, NULL, 1 },
+ OPT_SET_INT_NONEG(0, "unshallow", &unshallow,
+ N_("convert to a complete repository"), 1),
{ OPTION_STRING, 0, "submodule-prefix", &submodule_prefix, N_("dir"),
N_("prepend this to submodule path output"), PARSE_OPT_HIDDEN },
{ OPTION_STRING, 0, "recurse-submodules-default",
diff --git a/builtin/merge.c b/builtin/merge.c
index f0cf120..cf9a157 100644
--- a/builtin/merge.c
+++ b/builtin/merge.c
@@ -203,9 +203,8 @@ static struct option builtin_merge_options[] = {
OPT_BOOL('e', "edit", &option_edit,
N_("edit message before committing")),
OPT_SET_INT(0, "ff", &fast_forward, N_("allow fast-forward (default)"), FF_ALLOW),
- { OPTION_SET_INT, 0, "ff-only", &fast_forward, NULL,
- N_("abort if fast-forward is not possible"),
- PARSE_OPT_NOARG | PARSE_OPT_NONEG, NULL, FF_ONLY },
+ OPT_SET_INT_NONEG(0, "ff-only", &fast_forward,
+ N_("abort if fast-forward is not possible"), FF_ONLY),
OPT_RERERE_AUTOUPDATE(&allow_rerere_auto),
OPT_BOOL(0, "verify-signatures", &verify_signatures,
N_("Verify that the named commit has a valid GPG signature")),
diff --git a/builtin/notes.c b/builtin/notes.c
index 2b24d05..02a554d 100644
--- a/builtin/notes.c
+++ b/builtin/notes.c
@@ -739,13 +739,11 @@ static int merge(int argc, const char **argv, const char *prefix)
N_("resolve notes conflicts using the given strategy "
"(manual/ours/theirs/union/cat_sort_uniq)")),
OPT_GROUP(N_("Committing unmerged notes")),
- { OPTION_SET_INT, 0, "commit", &do_commit, NULL,
- N_("finalize notes merge by committing unmerged notes"),
- PARSE_OPT_NOARG | PARSE_OPT_NONEG, NULL, 1},
+ OPT_SET_INT_NONEG(0, "commit", &do_commit,
+ N_("finalize notes merge by committing unmerged notes"), 1),
OPT_GROUP(N_("Aborting notes merge resolution")),
- { OPTION_SET_INT, 0, "abort", &do_abort, NULL,
- N_("abort notes merge"),
- PARSE_OPT_NOARG | PARSE_OPT_NONEG, NULL, 1},
+ OPT_SET_INT_NONEG(0, "abort", &do_abort,
+ N_("abort notes merge"), 1),
OPT_END()
};
diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c
index c733379..2e2b12a 100644
--- a/builtin/pack-objects.c
+++ b/builtin/pack-objects.c
@@ -2579,15 +2579,12 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix)
N_("do not create an empty pack output")),
OPT_BOOL(0, "revs", &use_internal_rev_list,
N_("read revision arguments from standard input")),
- { OPTION_SET_INT, 0, "unpacked", &rev_list_unpacked, NULL,
- N_("limit the objects to those that are not yet packed"),
- PARSE_OPT_NOARG | PARSE_OPT_NONEG, NULL, 1 },
- { OPTION_SET_INT, 0, "all", &rev_list_all, NULL,
- N_("include objects reachable from any reference"),
- PARSE_OPT_NOARG | PARSE_OPT_NONEG, NULL, 1 },
- { OPTION_SET_INT, 0, "reflog", &rev_list_reflog, NULL,
- N_("include objects referred by reflog entries"),
- PARSE_OPT_NOARG | PARSE_OPT_NONEG, NULL, 1 },
+ OPT_SET_INT_NONEG(0, "unpacked", &rev_list_unpacked,
+ N_("limit the objects to those that are not yet packed"), 1),
+ OPT_SET_INT_NONEG(0, "all", &rev_list_all,
+ N_("include objects reachable from any reference"), 1),
+ OPT_SET_INT_NONEG(0, "reflog", &rev_list_reflog,
+ N_("include objects referred by reflog entries"), 1),
OPT_BOOL(0, "stdout", &pack_to_stdout,
N_("output pack to stdout")),
OPT_BOOL(0, "include-tag", &include_tag,
diff --git a/builtin/update-index.c b/builtin/update-index.c
index d12ad95..807e853 100644
--- a/builtin/update-index.c
+++ b/builtin/update-index.c
@@ -749,18 +749,14 @@ int cmd_update_index(int argc, const char **argv, const char *prefix)
N_("override the executable bit of the listed files"),
PARSE_OPT_NONEG | PARSE_OPT_LITERAL_ARGHELP,
chmod_callback},
- {OPTION_SET_INT, 0, "assume-unchanged", &mark_valid_only, NULL,
- N_("mark files as \"not changing\""),
- PARSE_OPT_NOARG | PARSE_OPT_NONEG, NULL, MARK_FLAG},
- {OPTION_SET_INT, 0, "no-assume-unchanged", &mark_valid_only, NULL,
- N_("clear assumed-unchanged bit"),
- PARSE_OPT_NOARG | PARSE_OPT_NONEG, NULL, UNMARK_FLAG},
- {OPTION_SET_INT, 0, "skip-worktree", &mark_skip_worktree_only, NULL,
- N_("mark files as \"index-only\""),
- PARSE_OPT_NOARG | PARSE_OPT_NONEG, NULL, MARK_FLAG},
- {OPTION_SET_INT, 0, "no-skip-worktree", &mark_skip_worktree_only, NULL,
- N_("clear skip-worktree bit"),
- PARSE_OPT_NOARG | PARSE_OPT_NONEG, NULL, UNMARK_FLAG},
+ OPT_SET_INT_NONEG(0, "assume-unchanged", &mark_valid_only,
+ N_("mark files as \"not changing\""), MARK_FLAG),
+ OPT_SET_INT_NONEG(0, "no-assume-unchanged", &mark_valid_only,
+ N_("clear assumed-unchanged bit"), UNMARK_FLAG),
+ OPT_SET_INT_NONEG(0, "skip-worktree", &mark_skip_worktree_only,
+ N_("mark files as \"index-only\""), MARK_FLAG),
+ OPT_SET_INT_NONEG(0, "no-skip-worktree", &mark_skip_worktree_only,
+ N_("clear skip-worktree bit"), UNMARK_FLAG),
OPT_SET_INT(0, "info-only", &info_only,
N_("add to index only; do not add content to object database"), 1),
OPT_SET_INT(0, "force-remove", &force_remove,
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}
--
1.9.0
next reply other threads:[~2014-03-11 10:50 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-03-11 10:50 Yuxuan Shui [this message]
2014-03-12 10:47 ` [PATCH][GSoC] parse-options: Add OPT_SET_INT_NONEG Duy Nguyen
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=1394535016-9424-1-git-send-email-yshuiv7@gmail.com \
--to=yshuiv7@gmail.com \
--cc=git@vger.kernel.org \
/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).