Subject: Preliminary patches to the diff.[hc] parseoptification

From: Pierre Habouzit <[email-masked]>
Date: Wed, 7 Nov 2007 11:20:25 +0100

I'm currently working on the very involved task of migrating diff
options to parseopts. It's quite involved because for many reasons I
won't detail here, it needs to migrate those _and_ revisions options at
the same time (most of the diff options users _also_ use the revisions
ones).

So I'm trying to see some preliminary patches that I need to make this
the less disruptive possible: my goal is that people can use those
preliminary series bit by bit, and not a whole 10 to 20 patches (I
believe it will really take this amount in the end) at once with
breakages hard to find in the mess.

So in the coming days I'll probably send my work bit by bit when I feel
it won't change anymore.

Summary:
~~~~~~~

The 3 series are completely independent.

  + this is a patch to fix an issue that begin to irritate me and
    prevents me to build with -Werror.

    [1/1] Make gcc warning about empty if body go away.

  + this series add new features that are needed for the diff options.
    commit 1 implements them (see commit log,
    commits 2 to 4 use them in some commands that benefit from those.

    [1/4] parse-options new features.
    [2/4] Use OPT_SET_INT and OPT_BIT in builtin-branch
    [3/4] Use OPT_BIT in builtin-for-each-ref
    [4/4] Use OPT_BIT in builtin-pack-refs

  + this series does some modifications on the diff_options structure
    and the diff_opt_parse functions. Those are not fundamentally needed
    without parseopt, but parseopt will need them.

    Basically, diff_options had bitfields (the C :1 kind). parseopt cannot
    grok that portably, so I've converted these into a single
    `unsigned flags` with explicit masks to use (and helper macros to
    avoid overlong lines).

    The obvious goal is that I can use the OPTION_BIT feature from the
    previous series to fill them from parse_options.

    [1/2] Make the diff_options bitfields be an unsigned with explicit masks.
    [2/2] Reorder diff_opt_parse options more logically per topics.

Those patches are available on my public repository in the
ph/parseopt-stable branch.

ph/parseopt is my WIP and has many many horrible commits right now, that
I rebase -i to cleanse them once the big picture pleases me enough,
though people may want to look at diff.h in that branch to see where it
goes. I'm pleased to say that it seems I'll only need 3 diff-specific
callbacks, which is not a lot:

    http://git.madism.org/?p=git.git;a=blobdiff;f=diff.h;h=0e44e5;hp=6ff2b0;hb=def4eb;hpb=bdc1ab

I suppose that the split of this big macro is explanatory enough for the
reason behind commit 2/2 of the third series...

Diff stats:
~~~~~~~~~~

  + gcc issue:
     builtin-diff.c |    2 +-
     1 file changed, 1 insertion(+), 1 deletion(-)

  + parseopt features:
     builtin-branch.c       |   44 ++++++++++++-----------------------
     builtin-for-each-ref.c |   19 ++++++++-------
     builtin-pack-refs.c    |   12 ++-------
     git-compat-util.h      |    1 
     parse-options.c        |   61 +++++++++++++++++++++++++++++++++++--------------
     parse-options.h        |   15 +++++++++++-
     6 files changed, 88 insertions(+), 64 deletions(-)

  + diff-cleanup:
     builtin-blame.c      |   10 +-
     builtin-diff-files.c |    4 +-
     builtin-diff-index.c |    4 +-
     builtin-diff-tree.c  |    9 +-
     builtin-diff.c       |   12 ++--
     builtin-log.c        |   24 +++---
     combine-diff.c       |   10 +-
     diff-lib.c           |   23 +++---
     diff.c               |  221 ++++++++++++++++++++++++++------------------------
     diff.h               |   40 ++++++----
     log-tree.c           |    6 +-
     merge-recursive.c    |    2 +-
     patch-ids.c          |    2 +-
     revision.c           |   22 +++---
     tree-diff.c          |   14 ++--
     15 files changed, 209 insertions(+), 194 deletions(-)

-- 
·O·  Pierre Habouzit
··O                                                [email-masked]
OOO                                                http://www.madism.org