Re: GSoC proposal: port pack bitmap support to libgit2.

2014-03-20 Thread Yuxuan Shui
Hi,

Sorry for this late reply, I was busy for past few days.

On Fri, Mar 14, 2014 at 12:34 PM, Jeff King p...@peff.net wrote:
 On Wed, Mar 12, 2014 at 04:19:23PM +0800, Yuxuan Shui wrote:

 I'm Yuxuan Shui, a undergraduate student from China. I'm applying for
 GSoC 2014, and here is my proposal:

 I found this idea on the ideas page, and did some research about it.
 The pack bitmap patchset add a new .bitmap file for every pack file
 which contains the reachability information of selected commits. This
 information is used to speed up git fetching and cloning, and produce
 a very convincing results.

 The goal of my project is to port the pack bitmap implementation in
 core git to libgit2, so users of libgit2 could benefit from this
 optimization as well.

 Please let me know if my proposal makes sense, thanks.

 You'd want to flesh it out a bit more to show how you're thinking about
 tackling the problem:

   - What are the areas of libgit2 that you will need to touch? Be
 specific. What's the current state of the packing code? What
 files and functions will you need to touch?

Firstly I will need to implement bitmap creation in libgit2's
git_packbuilder_* functions (probably also git_odb_write_pack), so
libgit2 could support bitmap creation. Then I will need to change
git_revwalk_* functions to make them use bitmap. Since the operations
that can benefit from bitmap is, if my understanding is correct, all
using the git_revwalk_* functions, having bitmap support in revwalk
functions should be enough.

Files I need to touch probably are: revwalk.c pack-objects.c
If I need to change the API of packbuilder or revwalk functions I will
have to change the callers as well: push.c fetch.c and
transport/smart_protocol.c

I haven't read all the code to put together a list of functions I need
to change, but I think the list will be long.


   - What are the challenges you expect to encounter in porting the code?

The architecture differences between git and libgit2 will probably be
a challenge.


   - Can you give a detailed schedule of the summer's work? What will you
 work on in each week? What milestones do you expect to hit, and
 when?

I don't really have a plan, but I'll try to provide a rough schedule.

I'll read the code and try to understand the code, to the point where
I can start to add new code. This will probably take a week. For next
three or four weeks I should be implementing bitmap creation in
packbuilder. Then for the rest of time I will be optimizing revwalk
using bitmap.


 -Peff

--

Regards
Yuxuan Shui
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: GSoC proposal: port pack bitmap support to libgit2.

2014-03-13 Thread Yuxuan Shui
Hi,

On Wed, Mar 12, 2014 at 4:19 PM, Yuxuan Shui yshu...@gmail.com wrote:
 Hi,

 I'm Yuxuan Shui, a undergraduate student from China. I'm applying for
 GSoC 2014, and here is my proposal:

 I found this idea on the ideas page, and did some research about it.
 The pack bitmap patchset add a new .bitmap file for every pack file
 which contains the reachability information of selected commits. This
 information is used to speed up git fetching and cloning, and produce
 a very convincing results.

 The goal of my project is to port the pack bitmap implementation in
 core git to libgit2, so users of libgit2 could benefit from this
 optimization as well.

 Please let me know if my proposal makes sense, thanks.

 P.S. I've submitted by microproject patch[1], but haven't received any
 response yet.

 [1]: http://thread.gmane.org/gmane.comp.version-control.git/243854

 --
 Regards
 Yuxuan Shui

Could anyone please review my proposal a little bit? Is this project
helpful and worth doing? Did I get anything wrong in my proposal?

Thanks.

-- 

Regards
Yuxuan Shui
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


GSoC proposal: port pack bitmap support to libgit2.

2014-03-12 Thread Yuxuan Shui
Hi,

I'm Yuxuan Shui, a undergraduate student from China. I'm applying for
GSoC 2014, and here is my proposal:

I found this idea on the ideas page, and did some research about it.
The pack bitmap patchset add a new .bitmap file for every pack file
which contains the reachability information of selected commits. This
information is used to speed up git fetching and cloning, and produce
a very convincing results.

The goal of my project is to port the pack bitmap implementation in
core git to libgit2, so users of libgit2 could benefit from this
optimization as well.

Please let me know if my proposal makes sense, thanks.

P.S. I've submitted by microproject patch[1], but haven't received any
response yet.

[1]: http://thread.gmane.org/gmane.comp.version-control.git/243854

-- 
Regards
Yuxuan Shui
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH][GSoC] parse-options: Add OPT_SET_INT_NONEG.

2014-03-12 Thread Yuxuan Shui
On Wed, Mar 12, 2014 at 6:47 PM, Duy Nguyen pclo...@gmail.com wrote:
 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.

Thanks for pointing that out, I'll do as you suggested.


 On Tue, Mar 11, 2014 at 5:50 PM, Yuxuan Shui yshu...@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.

Hmm, this microproject has been striked from the ideas page, maybe I
should switch to another one...


 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.

I could do that, but it seems only the NONEG flag is used in the code.


 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.

I've grep'd through the source code, and most of the manually filled
option structures don't seems to have a pattern. And I think writing a
overly generalized macro won't help much.


 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.

Thanks for reviewing my patch.

 --
 Duy
-- 

Regards
Yuxuan Shui
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 0/2] GSoC micro project, use skip_prefix() in fsck_commit()

2014-03-12 Thread Yuxuan Shui

Yuxuan Shui (2):
  fsck.c: Change the type of fsck_ident()'s first argument
  fsck.c: Rewrite fsck_commit() to use skip_prefix()

 fsck.c | 26 ++
 1 file changed, 14 insertions(+), 12 deletions(-)

-- 
1.9.0

--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/2] fsck.c: Change the type of fsck_ident()'s first argument

2014-03-12 Thread Yuxuan Shui
Since fsck_ident doesn't change the content of **ident, the type of
ident could be const char **.

This change is required to rewrite fsck_commit() to use skip_prefix().
---
 fsck.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fsck.c b/fsck.c
index 99c0497..1789c34 100644
--- a/fsck.c
+++ b/fsck.c
@@ -243,7 +243,7 @@ static int fsck_tree(struct tree *item, int strict, 
fsck_error error_func)
return retval;
 }
 
-static int fsck_ident(char **ident, struct object *obj, fsck_error error_func)
+static int fsck_ident(const char **ident, struct object *obj, fsck_error 
error_func)
 {
if (**ident == '')
return error_func(obj, FSCK_ERROR, invalid author/committer 
line - missing space before email);
-- 
1.9.0

--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/2] fsck.c: Rewrite fsck_commit() to use skip_prefix()

2014-03-12 Thread Yuxuan Shui
The purpose of skip_prefix() is much clearer than memcmp(). Also
skip_prefix() takes one less argument and its return value makes more
sense.
---
 fsck.c | 24 +---
 1 file changed, 13 insertions(+), 11 deletions(-)

diff --git a/fsck.c b/fsck.c
index 1789c34..7e6b829 100644
--- a/fsck.c
+++ b/fsck.c
@@ -281,7 +281,7 @@ static int fsck_ident(const char **ident, struct object 
*obj, fsck_error error_f
 
 static int fsck_commit(struct commit *commit, fsck_error error_func)
 {
-   char *buffer = commit-buffer;
+   const char *buffer = commit-buffer, *tmp;
unsigned char tree_sha1[20], sha1[20];
struct commit_graft *graft;
int parents = 0;
@@ -290,15 +290,17 @@ static int fsck_commit(struct commit *commit, fsck_error 
error_func)
if (commit-date == ULONG_MAX)
return error_func(commit-object, FSCK_ERROR, invalid 
author/committer line);
 
-   if (memcmp(buffer, tree , 5))
+   buffer = skip_prefix(buffer, tree );
+   if (buffer == NULL)
return error_func(commit-object, FSCK_ERROR, invalid format 
- expected 'tree' line);
-   if (get_sha1_hex(buffer+5, tree_sha1) || buffer[45] != '\n')
+   if (get_sha1_hex(buffer, tree_sha1) || buffer[40] != '\n')
return error_func(commit-object, FSCK_ERROR, invalid 'tree' 
line format - bad sha1);
-   buffer += 46;
-   while (!memcmp(buffer, parent , 7)) {
-   if (get_sha1_hex(buffer+7, sha1) || buffer[47] != '\n')
+   buffer += 41;
+   while ((tmp = skip_prefix(buffer, parent ))) {
+   buffer = tmp;
+   if (get_sha1_hex(buffer, sha1) || buffer[40] != '\n')
return error_func(commit-object, FSCK_ERROR, invalid 
'parent' line format - bad sha1);
-   buffer += 48;
+   buffer += 41;
parents++;
}
graft = lookup_commit_graft(commit-object.sha1);
@@ -322,15 +324,15 @@ static int fsck_commit(struct commit *commit, fsck_error 
error_func)
if (p || parents)
return error_func(commit-object, FSCK_ERROR, parent 
objects missing);
}
-   if (memcmp(buffer, author , 7))
+   buffer = skip_prefix(buffer, author );
+   if (buffer == NULL)
return error_func(commit-object, FSCK_ERROR, invalid format 
- expected 'author' line);
-   buffer += 7;
err = fsck_ident(buffer, commit-object, error_func);
if (err)
return err;
-   if (memcmp(buffer, committer , strlen(committer )))
+   buffer = skip_prefix(buffer, committer );
+   if (buffer == NULL)
return error_func(commit-object, FSCK_ERROR, invalid format 
- expected 'committer' line);
-   buffer += strlen(committer );
err = fsck_ident(buffer, commit-object, error_func);
if (err)
return err;
-- 
1.9.0

--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH][GSoC] parse-options: Add OPT_SET_INT_NONEG.

2014-03-12 Thread Yuxuan Shui
Hi,

On Thu, Mar 13, 2014 at 2:30 AM, Junio C Hamano gits...@pobox.com wrote:
 Duy Nguyen pclo...@gmail.com writes:

 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.

 As I said elsewhere, I am not sure if doubling the number of
 OPT_type macros as your micro suggestion proposes is the right
 solution to the problem.

 What are we trying to solve?

OK, I'll switch to another micro project.

-- 

Regards
Yuxuan Shui
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 0/2] GSoC micro project, use skip_prefix() in fsck_commit()

2014-03-12 Thread Yuxuan Shui
I'm sorry for resending these patches, but the previous ones miss the sign-offs.

Yuxuan Shui (2):
  fsck.c: Change the type of fsck_ident()'s first argument
  fsck.c: Rewrite fsck_commit() to use skip_prefix()

 fsck.c | 26 ++
 1 file changed, 14 insertions(+), 12 deletions(-)

-- 
1.9.0

--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 2/2] fsck.c: Rewrite fsck_commit() to use skip_prefix()

2014-03-12 Thread Yuxuan Shui
The purpose of skip_prefix() is much clearer than memcmp(). Also
skip_prefix() takes one less argument and its return value makes more
sense.

Signed-off-by: Yuxuan Shui yshu...@gmail.com
---
 fsck.c | 24 +---
 1 file changed, 13 insertions(+), 11 deletions(-)

diff --git a/fsck.c b/fsck.c
index 1789c34..7e6b829 100644
--- a/fsck.c
+++ b/fsck.c
@@ -281,7 +281,7 @@ static int fsck_ident(const char **ident, struct object 
*obj, fsck_error error_f
 
 static int fsck_commit(struct commit *commit, fsck_error error_func)
 {
-   char *buffer = commit-buffer;
+   const char *buffer = commit-buffer, *tmp;
unsigned char tree_sha1[20], sha1[20];
struct commit_graft *graft;
int parents = 0;
@@ -290,15 +290,17 @@ static int fsck_commit(struct commit *commit, fsck_error 
error_func)
if (commit-date == ULONG_MAX)
return error_func(commit-object, FSCK_ERROR, invalid 
author/committer line);
 
-   if (memcmp(buffer, tree , 5))
+   buffer = skip_prefix(buffer, tree );
+   if (buffer == NULL)
return error_func(commit-object, FSCK_ERROR, invalid format 
- expected 'tree' line);
-   if (get_sha1_hex(buffer+5, tree_sha1) || buffer[45] != '\n')
+   if (get_sha1_hex(buffer, tree_sha1) || buffer[40] != '\n')
return error_func(commit-object, FSCK_ERROR, invalid 'tree' 
line format - bad sha1);
-   buffer += 46;
-   while (!memcmp(buffer, parent , 7)) {
-   if (get_sha1_hex(buffer+7, sha1) || buffer[47] != '\n')
+   buffer += 41;
+   while ((tmp = skip_prefix(buffer, parent ))) {
+   buffer = tmp;
+   if (get_sha1_hex(buffer, sha1) || buffer[40] != '\n')
return error_func(commit-object, FSCK_ERROR, invalid 
'parent' line format - bad sha1);
-   buffer += 48;
+   buffer += 41;
parents++;
}
graft = lookup_commit_graft(commit-object.sha1);
@@ -322,15 +324,15 @@ static int fsck_commit(struct commit *commit, fsck_error 
error_func)
if (p || parents)
return error_func(commit-object, FSCK_ERROR, parent 
objects missing);
}
-   if (memcmp(buffer, author , 7))
+   buffer = skip_prefix(buffer, author );
+   if (buffer == NULL)
return error_func(commit-object, FSCK_ERROR, invalid format 
- expected 'author' line);
-   buffer += 7;
err = fsck_ident(buffer, commit-object, error_func);
if (err)
return err;
-   if (memcmp(buffer, committer , strlen(committer )))
+   buffer = skip_prefix(buffer, committer );
+   if (buffer == NULL)
return error_func(commit-object, FSCK_ERROR, invalid format 
- expected 'committer' line);
-   buffer += strlen(committer );
err = fsck_ident(buffer, commit-object, error_func);
if (err)
return err;
-- 
1.9.0

--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 1/2] fsck.c: Change the type of fsck_ident()'s first argument

2014-03-12 Thread Yuxuan Shui
Since fsck_ident doesn't change the content of **ident, the type of
ident could be const char **.

This change is required to rewrite fsck_commit() to use skip_prefix().

Signed-off-by: Yuxuan Shui yshu...@gmail.com
---
 fsck.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fsck.c b/fsck.c
index 99c0497..1789c34 100644
--- a/fsck.c
+++ b/fsck.c
@@ -243,7 +243,7 @@ static int fsck_tree(struct tree *item, int strict, 
fsck_error error_func)
return retval;
 }
 
-static int fsck_ident(char **ident, struct object *obj, fsck_error error_func)
+static int fsck_ident(const char **ident, struct object *obj, fsck_error 
error_func)
 {
if (**ident == '')
return error_func(obj, FSCK_ERROR, invalid author/committer 
line - missing space before email);
-- 
1.9.0

--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v2 1/2] fsck.c: Change the type of fsck_ident()'s first argument

2014-03-12 Thread Yuxuan Shui
Hi,

On Thu, Mar 13, 2014 at 4:22 AM, Jeff King p...@peff.net wrote:
 On Thu, Mar 13, 2014 at 02:51:29AM +0800, Yuxuan Shui wrote:

 Since fsck_ident doesn't change the content of **ident, the type of
 ident could be const char **.

 Unfortunately, const double-pointers in C are a bit tricky, and a
 pointer to char * cannot automatically be passed as a pointer to
 const char *.

Thanks for pointing this out, I split the changes in a wrong way. I'll
fix this in next version of this patch.


 I think you want this on top:

 diff --git a/fsck.c b/fsck.c
 index 1789c34..7776660 100644
 --- a/fsck.c
 +++ b/fsck.c
 @@ -281,7 +281,7 @@ static int fsck_ident(const char **ident, struct object 
 *obj, fsck_error error_f

  static int fsck_commit(struct commit *commit, fsck_error error_func)
  {
 -   char *buffer = commit-buffer;
 +   const char *buffer = commit-buffer;
 unsigned char tree_sha1[20], sha1[20];
 struct commit_graft *graft;
 int parents = 0;

 Otherwise, gcc will complain about incompatible pointer types.

 -Peff

-- 

Regards
Yuxuan Shui
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v3 0/2] GSoC micro project, rewrite fsck_commit() to use skip_prefix()

2014-03-12 Thread Yuxuan Shui
Improved commit message, and added a missing hunk to the second commit.

Yuxuan Shui (2):
  fsck.c: Change the type of fsck_ident()'s first argument
  fsck.c: Rewrite fsck_commit() to use skip_prefix()

 fsck.c | 26 ++
 1 file changed, 14 insertions(+), 12 deletions(-)

-- 
1.9.0

--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v3 1/2] fsck.c: Change the type of fsck_ident()'s first argument

2014-03-12 Thread Yuxuan Shui
Since fsck_ident doesn't change the content of **ident, the type of
ident could be const char **.

This change is required to rewrite fsck_commit() to use skip_prefix().

Signed-off-by: Yuxuan Shui yshu...@gmail.com
---
 fsck.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/fsck.c b/fsck.c
index 99c0497..7776660 100644
--- a/fsck.c
+++ b/fsck.c
@@ -243,7 +243,7 @@ static int fsck_tree(struct tree *item, int strict, 
fsck_error error_func)
return retval;
 }
 
-static int fsck_ident(char **ident, struct object *obj, fsck_error error_func)
+static int fsck_ident(const char **ident, struct object *obj, fsck_error 
error_func)
 {
if (**ident == '')
return error_func(obj, FSCK_ERROR, invalid author/committer 
line - missing space before email);
@@ -281,7 +281,7 @@ static int fsck_ident(char **ident, struct object *obj, 
fsck_error error_func)
 
 static int fsck_commit(struct commit *commit, fsck_error error_func)
 {
-   char *buffer = commit-buffer;
+   const char *buffer = commit-buffer;
unsigned char tree_sha1[20], sha1[20];
struct commit_graft *graft;
int parents = 0;
-- 
1.9.0

--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH][GSoC] parse-options: Add OPT_SET_INT_NONEG.

2014-03-11 Thread Yuxuan Shui
Reference: http://git.github.io/SoC-2014-Microprojects.html
Signed-off-by: Yuxuan Shui yshu...@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