From: Kristian Høgsberg <hidden> Date: 2016-06-15 22:43:38
The option parser takes argc, argv, an array of struct option
and a usage string. Each of the struct option elements in the array
describes a valid option, its type and a pointer to the location where the
value is written. The entry point is parse_options(), which scans through
the given argv, and matches each option there against the list of valid
options. During the scan, argv is rewritten to only contain the
non-option command line arguments and the number of these is returned.
Signed-off-by: Kristian Høgsberg <redacted>
---
Makefile | 2 +-
parse-options.c | 106 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
parse-options.h | 33 +++++++++++++++++
3 files changed, 140 insertions(+), 1 deletions(-)
create mode 100644 parse-options.c
create mode 100644 parse-options.h
@@ -0,0 +1,33 @@+#ifndef PARSE_OPTIONS_H+#define PARSE_OPTIONS_H++enumoption_type{+OPTION_BOOLEAN,+OPTION_STRING,+OPTION_INTEGER,+OPTION_LAST,+};++structoption{+enumoption_typetype;+constchar*long_name;+charshort_name;+void*value;+};++/* Parse the given options against the list of known options. The+*orderoftheoptionstructsmatters,inthatambiguous+*abbreviations(eg,--incouldbeshortfor--includeor+*--interactive)arematchedbythefirstoptionthatsharethe+*prefix.+*+*parse_options()willfilterouttheprocessedoptionsandleavethe+*non-optionargmentsinargv[].Thereturnvalueisthenumberof+*argumentsleftinargv[].+*/++externintparse_options(intargc,constchar**argv,+structoption*options,intcount,+constchar*usage_string);++#endif
@@ -160,21 +161,30 @@ static struct lock_file lock_file;staticconstcharignore_error[]="The following paths are ignored by one of your .gitignore files:\n";+staticintverbose=0,show_only=0,ignored_too=0,refresh_only=0;+staticintadd_interactive=0;++staticstructoptionbuiltin_add_options[]={+{OPTION_BOOLEAN,"interactive",'i',&add_interactive},+{OPTION_BOOLEAN,NULL,'n',&show_only},+{OPTION_BOOLEAN,NULL,'f',&ignored_too},+{OPTION_BOOLEAN,NULL,'v',&verbose},+{OPTION_BOOLEAN,NULL,'u',&take_worktree_changes},+{OPTION_BOOLEAN,"refresh",0,&refresh_only}+};+intcmd_add(intargc,constchar**argv,constchar*prefix){inti,newfd;-intverbose=0,show_only=0,ignored_too=0,refresh_only=0;constchar**pathspec;structdir_structdir;-intadd_interactive=0;-for(i=1;i<argc;i++){-if(!strcmp("--interactive",argv[i])||-!strcmp("-i",argv[i]))-add_interactive++;-}+i=parse_options(argc,argv,builtin_add_options,+ARRAY_SIZE(builtin_add_options),+builtin_add_usage);+if(add_interactive){-if(argc!=2)+if(i>0)die("add --interactive does not take any parameters");exit(interactive_add());}
@@ -183,51 +193,19 @@ int cmd_add(int argc, const char **argv, const char *prefix)newfd=hold_locked_index(&lock_file,1);-for(i=1;i<argc;i++){-constchar*arg=argv[i];--if(arg[0]!='-')-break;-if(!strcmp(arg,"--")){-i++;-break;-}-if(!strcmp(arg,"-n")){-show_only=1;-continue;-}-if(!strcmp(arg,"-f")){-ignored_too=1;-continue;-}-if(!strcmp(arg,"-v")){-verbose=1;-continue;-}-if(!strcmp(arg,"-u")){-take_worktree_changes=1;-continue;-}-if(!strcmp(arg,"--refresh")){-refresh_only=1;-continue;-}-usage(builtin_add_usage);-}-if(take_worktree_changes){if(read_cache()<0)die("index file corrupt");-add_files_to_cache(verbose,prefix,argv+i);+add_files_to_cache(verbose,prefix,argv);gotofinish;}-if(argc<=i){+if(i==0){fprintf(stderr,"Nothing specified, nothing added.\n");fprintf(stderr,"Maybe you wanted to say 'git add .'?\n");return0;}-pathspec=get_pathspec(prefix,argv+i);+pathspec=get_pathspec(prefix,argv);if(refresh_only){refresh(verbose,pathspec);
From: Pierre Habouzit <hidden> Date: 2016-06-15 22:43:38
On Wed, Oct 03, 2007 at 09:45:01PM +0000, Kristian Høgsberg wrote:
The option parser takes argc, argv, an array of struct option
and a usage string. Each of the struct option elements in the array
describes a valid option, its type and a pointer to the location where the
value is written. The entry point is parse_options(), which scans through
the given argv, and matches each option there against the list of valid
options. During the scan, argv is rewritten to only contain the
non-option command line arguments and the number of these is returned.
if we are going in that direction (and I believe it's a good one), we
should be sure that the model fits with other commands as well. And as I
said on IRC, I believe the most "horrible" (as in complex) option parser
in git is the one from git-grep.
A migration of git-grep on that API should be tried first. If this
works well enough, I believe that the rest of the git commands will be
migrated easily enough. (with maybe small addition to parse-option.[hc]
but the hardcore things should have been met with git-grep already I
think).
--
·O· Pierre Habouzit
··O madcoder@debian.org
OOO http://www.madism.org
From: Kristian Høgsberg <hidden> Date: 2016-06-15 22:43:38
On Thu, 2007-10-04 at 01:11 +0200, Pierre Habouzit wrote:
On Wed, Oct 03, 2007 at 09:45:01PM +0000, Kristian Høgsberg wrote:
quoted
The option parser takes argc, argv, an array of struct option
and a usage string. Each of the struct option elements in the array
describes a valid option, its type and a pointer to the location where the
value is written. The entry point is parse_options(), which scans through
the given argv, and matches each option there against the list of valid
options. During the scan, argv is rewritten to only contain the
non-option command line arguments and the number of these is returned.
if we are going in that direction (and I believe it's a good one), we
should be sure that the model fits with other commands as well. And as I
said on IRC, I believe the most "horrible" (as in complex) option parser
in git is the one from git-grep.
A migration of git-grep on that API should be tried first. If this
works well enough, I believe that the rest of the git commands will be
migrated easily enough. (with maybe small addition to parse-option.[hc]
but the hardcore things should have been met with git-grep already I
think).
I'm not sure - we can go with the current proposal and add new options
types and probably the callback option type I suggested as we go. I
don't want to block builtin-commit on figuring out what the perfect
option parser should look like and what I sent out earlier work for
commit. I think the way you handled the strbuf rewrites worked pretty
well; extending and rewriting the API as you put it to use in more and
more places. We can do the same thing with parse_options().
cheers,
Kristian
From: Pierre Habouzit <hidden> Date: 2016-06-15 22:43:38
On Thu, Oct 04, 2007 at 02:57:58PM +0000, Kristian Høgsberg wrote:
On Thu, 2007-10-04 at 01:11 +0200, Pierre Habouzit wrote:
quoted
On Wed, Oct 03, 2007 at 09:45:01PM +0000, Kristian Høgsberg wrote:
quoted
The option parser takes argc, argv, an array of struct option
and a usage string. Each of the struct option elements in the array
describes a valid option, its type and a pointer to the location where the
value is written. The entry point is parse_options(), which scans through
the given argv, and matches each option there against the list of valid
options. During the scan, argv is rewritten to only contain the
non-option command line arguments and the number of these is returned.
if we are going in that direction (and I believe it's a good one), we
should be sure that the model fits with other commands as well. And as I
said on IRC, I believe the most "horrible" (as in complex) option parser
in git is the one from git-grep.
A migration of git-grep on that API should be tried first. If this
works well enough, I believe that the rest of the git commands will be
migrated easily enough. (with maybe small addition to parse-option.[hc]
but the hardcore things should have been met with git-grep already I
think).
I'm not sure - we can go with the current proposal and add new options
types and probably the callback option type I suggested as we go. I
don't want to block builtin-commit on figuring out what the perfect
option parser should look like and what I sent out earlier work for
commit. I think the way you handled the strbuf rewrites worked pretty
well; extending and rewriting the API as you put it to use in more and
more places. We can do the same thing with parse_options().
Of course we can do that, or junio said that some people talked about
popt some time ago. I understand that you don't want to block the
git-commit work, but doing things right from the beginning is often a
big win on the long term.
I don't know popt, and I don't know if it has sufficient expressivity.
For sure I don't like getopt_long APIs at all, so if popt is as
cumbersome, rolling our own based on the current parse_options you
propose is probably a good choice.
--
·O· Pierre Habouzit
··O madcoder@debian.org
OOO http://www.madism.org
From: Pierre Habouzit <hidden> Date: 2016-06-15 22:43:38
On jeu, oct 04, 2007 at 03:15:32 +0000, Pierre Habouzit wrote:
On Thu, Oct 04, 2007 at 02:57:58PM +0000, Kristian Høgsberg wrote:
quoted
I'm not sure - we can go with the current proposal and add new options
types and probably the callback option type I suggested as we go. I
don't want to block builtin-commit on figuring out what the perfect
option parser should look like and what I sent out earlier work for
commit. I think the way you handled the strbuf rewrites worked pretty
well; extending and rewriting the API as you put it to use in more and
more places. We can do the same thing with parse_options().
Of course we can do that, or junio said that some people talked about
popt some time ago. I understand that you don't want to block the
git-commit work, but doing things right from the beginning is often a
big win on the long term.
I don't know popt, and I don't know if it has sufficient expressivity.
For sure I don't like getopt_long APIs at all, so if popt is as
cumbersome, rolling our own based on the current parse_options you
propose is probably a good choice.
Okay, popt seems to be quite complicated, and depends upon gettext
(which we may require as per survey results, but right now it seems a
useless dependency). Don't get me wrong, I'm sure it's very powerful,
but again, I believe we can have a 200 line ad-hoc module that fits what
git really needs, the less cumbersome way.
So well, I'd be (I'm not in position to decide anything btw ;p) in
favor of pursuing the work into git-commit like you did, and ASAP it
gets merged into next, I'm definitely willing to pursue a refactoring to
use it (now that strbufs seems to have been used where needed).
--
·O· Pierre Habouzit
··O madcoder@debian.org
OOO http://www.madism.org
From: Johannes Schindelin <hidden> Date: 2016-06-15 22:43:38
Hi,
On Thu, 4 Oct 2007, Pierre Habouzit wrote:
Okay, popt seems to be quite complicated, and depends upon gettext
... which makes me vote against popt ...
(which we may require as per survey results, but right now it seems a
useless dependency).
Nope. git-gui got a script doing the job of msgfmt, which was the only
part of that beast known as gettext anyway.
So we will not require it for git-gui.
And I do not see core git being i18n'ised. Ever.
Ciao,
Dscho
From: Pierre Habouzit <hidden> Date: 2016-06-15 22:43:39
On Wed, Oct 03, 2007 at 09:45:01PM +0000, Kristian Høgsberg wrote:
+static int parse_one(const char **argv,
+ struct option *options, int count,
+ const char *usage_string)
+{
+ const char *eq, *arg, *value;
+ int i, processed;
gcc complains processed could be returned without being initialized
first, so should be processed = 0; Even if it cannot occurs, it avoid
raising eyebrows.
+ case OPTION_INTEGER:
+ if (value == NULL) {
+ error("option %s requires a value.", argv);
^^^
should probably be arg.
--
·O· Pierre Habouzit
··O madcoder@debian.org
OOO http://www.madism.org
From: Pierre Habouzit <hidden> Date: 2016-06-15 22:43:39
+/* Parse the given options against the list of known options. The
+ * order of the option structs matters, in that ambiguous
+ * abbreviations (eg, --in could be short for --include or
+ * --interactive) are matched by the first option that share the
+ * prefix.
Do we really want that ?
I do believe that it's a very bad idea, as it silently breaks. Most of
the command line switches people need to use have a short form, or their
shell will complete it properly.
A very interesting feature though, would be to finally be able to
parse aggregated switches (`git rm -rf` anyone ?).
I also believe that it's a pity that parse_options isn't able to
generate the usage by itself. But we can add that later.
I've though an alternate proposal, based on your work, for the first
patch.
--
·O· Pierre Habouzit
··O madcoder@debian.org
OOO http://www.madism.org
From: Pierre Habouzit <hidden> Date: 2016-06-15 22:43:39
The option parser takes argc, argv, an array of struct option
and a usage string. Each of the struct option elements in the array
describes a valid option, its type and a pointer to the location where the
value is written. The entry point is parse_options(), which scans through
the given argv, and matches each option there against the list of valid
options. During the scan, argv is rewritten to only contain the
non-option command line arguments and the number of these is returned.
Aggregation of single switches is allowed:
-rC0 is the same as -r -C 0 (supposing that -C wants an arg).
Boolean switches automatically support the option with the same name,
prefixed with 'no-' to disable the switch:
--no-color / --color only need to have an entry for "color".
Long options are supported either with '=' or without:
--some-option=foo is the same as --some-option foo
Signed-off-by: Kristian Høgsberg <redacted>
Signed-off-by: Pierre Habouzit <redacted>
---
I'm sorry about the "From" I don't intend to "steal" the patch in any
sense, it's just an alternate proposal.
oh and I don't grok what OPTION_LAST is for, so I left it apart, but
it seems unused ?
Makefile | 2 +-
parse-options.c | 154 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
parse-options.h | 29 ++++++++++
3 files changed, 184 insertions(+), 1 deletions(-)
create mode 100644 parse-options.c
create mode 100644 parse-options.h
@@ -0,0 +1,29 @@+#ifndef PARSE_OPTIONS_H+#define PARSE_OPTIONS_H++enumoption_type{+OPTION_BOOLEAN,+OPTION_STRING,+OPTION_INTEGER,+#if 0+OPTION_LAST,+#endif+};++structoption{+enumoption_typetype;+constchar*long_name;+charshort_name;+void*value;+};++/* parse_options() will filter out the processed options and leave the+*non-optionargmentsinargv[].Thereturnvalueisthenumberof+*argumentsleftinargv[].+*/++externintparse_options(intargc,constchar**argv,+structoption*options,intcount,+constchar*usage_string);++#endif
From: Mike Hommey <hidden> Date: 2016-06-15 22:43:39
On Fri, Oct 05, 2007 at 04:25:07PM +0200, Pierre Habouzit [off-list ref] wrote:
The option parser takes argc, argv, an array of struct option
and a usage string. Each of the struct option elements in the array
describes a valid option, its type and a pointer to the location where the
value is written. The entry point is parse_options(), which scans through
the given argv, and matches each option there against the list of valid
options. During the scan, argv is rewritten to only contain the
non-option command line arguments and the number of these is returned.
Aggregation of single switches is allowed:
-rC0 is the same as -r -C 0 (supposing that -C wants an arg).
I like options aggregation, but I'm not sure aggregating option arguments
is a good idea... I can't even think of an application that does it.
Mike
From: Pierre Habouzit <hidden> Date: 2016-06-15 22:43:39
On Fri, Oct 05, 2007 at 02:30:14PM +0000, Mike Hommey wrote:
On Fri, Oct 05, 2007 at 04:25:07PM +0200, Pierre Habouzit [off-list ref] wrote:
quoted
The option parser takes argc, argv, an array of struct option
and a usage string. Each of the struct option elements in the array
describes a valid option, its type and a pointer to the location where the
value is written. The entry point is parse_options(), which scans through
the given argv, and matches each option there against the list of valid
options. During the scan, argv is rewritten to only contain the
non-option command line arguments and the number of these is returned.
Aggregation of single switches is allowed:
-rC0 is the same as -r -C 0 (supposing that -C wants an arg).
I like options aggregation, but I'm not sure aggregating option arguments
is a good idea... I can't even think of an application that does it.
You mean like `grep -A1` or `diff -u3` or `ls -w10` ?
getopt does that by default as well, so you may not have aware of it,
but it's how things work in your system already.
btw `ls -rw10` works, though `ls -w10r` drops the 'r' silently. FWIW I
don't, in that case, the alternate patch I propose complains about "10r"
not being a valid integer, and that's because unlike getopt, the patch
krh proposed knows what an integer is ;)
--
·O· Pierre Habouzit
··O madcoder@debian.org
OOO http://www.madism.org
From: David Kastrup <hidden> Date: 2016-06-15 22:43:39
Mike Hommey [off-list ref] writes:
On Fri, Oct 05, 2007 at 04:25:07PM +0200, Pierre Habouzit [off-list ref] wrote:
quoted
The option parser takes argc, argv, an array of struct option
and a usage string. Each of the struct option elements in the array
describes a valid option, its type and a pointer to the location where the
value is written. The entry point is parse_options(), which scans through
the given argv, and matches each option there against the list of valid
options. During the scan, argv is rewritten to only contain the
non-option command line arguments and the number of these is returned.
Aggregation of single switches is allowed:
-rC0 is the same as -r -C 0 (supposing that -C wants an arg).
I like options aggregation, but I'm not sure aggregating option arguments
is a good idea... I can't even think of an application that does it.
I think most allow this for the last option in a row. Tar is somewhat
more perverse with its non-option command string:
tar xfzbv filename.tgz 40
uses filename.tgz as the option argument for "f" and 40 for "b".
Note that while tar accepts options instead of the initial command
string,
tar -xfzbv filename.tgz 40
will _not_ work, while
tar -xffilename.tgz -z -b40 -v
presumably would (have no time to test this right now).
--
David Kastrup
Hi,
You probably already considered and rejected the GNU argp parser. I used it before and I'd like to know reasons I should stay away from it.
Cheers,
Emil.
-----Original Message-----
From: git-owner@vger.kernel.org
[mailto:git-owner@vger.kernel.org] On Behalf Of Pierre Habouzit
Sent: Friday, October 05, 2007 9:46 AM
To: Mike Hommey
Cc: Kristian Høgsberg; git@vger.kernel.org; Junio C Hamano
Subject: Re: [ALTERNATE PATCH] Add a simple option parser.
On Fri, Oct 05, 2007 at 02:30:14PM +0000, Mike Hommey wrote:
quoted
On Fri, Oct 05, 2007 at 04:25:07PM +0200, Pierre Habouzit
[off-list ref] wrote:
quoted
quoted
The option parser takes argc, argv, an array of struct option
and a usage string. Each of the struct option elements
in the array
quoted
quoted
describes a valid option, its type and a pointer to the
location where the
quoted
quoted
value is written. The entry point is parse_options(),
which scans through
quoted
quoted
the given argv, and matches each option there against the
list of valid
quoted
quoted
options. During the scan, argv is rewritten to only contain the
non-option command line arguments and the number of these
is returned.
quoted
quoted
Aggregation of single switches is allowed:
-rC0 is the same as -r -C 0 (supposing that -C wants an arg).
I like options aggregation, but I'm not sure aggregating
option arguments
quoted
is a good idea... I can't even think of an application that does it.
You mean like `grep -A1` or `diff -u3` or `ls -w10` ?
getopt does that by default as well, so you may not have aware of it,
but it's how things work in your system already.
btw `ls -rw10` works, though `ls -w10r` drops the 'r'
silently. FWIW I
don't, in that case, the alternate patch I propose complains
about "10r"
not being a valid integer, and that's because unlike getopt, the patch
krh proposed knows what an integer is ;)
--
·O· Pierre Habouzit
··O madcoder@debian.org
OOO
http://www.madism.org
From: Kristian Høgsberg <hidden> Date: 2016-06-15 22:43:39
On Fri, 2007-10-05 at 16:25 +0200, Pierre Habouzit wrote:
The option parser takes argc, argv, an array of struct option
and a usage string. Each of the struct option elements in the array
describes a valid option, its type and a pointer to the location where the
value is written. The entry point is parse_options(), which scans through
the given argv, and matches each option there against the list of valid
options. During the scan, argv is rewritten to only contain the
non-option command line arguments and the number of these is returned.
Aggregation of single switches is allowed:
-rC0 is the same as -r -C 0 (supposing that -C wants an arg).
Boolean switches automatically support the option with the same name,
prefixed with 'no-' to disable the switch:
--no-color / --color only need to have an entry for "color".
Long options are supported either with '=' or without:
--some-option=foo is the same as --some-option foo
That looks great, works for me. One comment, though: it looks like
you're not sure whether to call these things "options" or "switches".
We should choose one and stick with it.
Acked-by: Kristian Høgsberg <redacted>
Signed-off-by: Pierre Habouzit <redacted>
---
I'm sorry about the "From" I don't intend to "steal" the patch in any
sense, it's just an alternate proposal.
No worries, I'm glad to see this move forward.
oh and I don't grok what OPTION_LAST is for, so I left it apart, but
it seems unused ?
Oh, kill that. I used that as the option array terminator before we
switched to ARRAY_SIZE().
@@ -0,0 +1,29 @@+#ifndef PARSE_OPTIONS_H+#define PARSE_OPTIONS_H++enumoption_type{+OPTION_BOOLEAN,+OPTION_STRING,+OPTION_INTEGER,+#if 0+OPTION_LAST,+#endif+};++structoption{+enumoption_typetype;+constchar*long_name;+charshort_name;+void*value;+};++/* parse_options() will filter out the processed options and leave the+*non-optionargmentsinargv[].Thereturnvalueisthenumberof+*argumentsleftinargv[].+*/++externintparse_options(intargc,constchar**argv,+structoption*options,intcount,+constchar*usage_string);++#endif
From: Pierre Habouzit <hidden> Date: 2016-06-15 22:43:39
On Fri, Oct 05, 2007 at 03:33:44PM +0000, Kristian Høgsberg wrote:
On Fri, 2007-10-05 at 16:25 +0200, Pierre Habouzit wrote:
quoted
The option parser takes argc, argv, an array of struct option
and a usage string. Each of the struct option elements in the array
describes a valid option, its type and a pointer to the location where the
value is written. The entry point is parse_options(), which scans through
the given argv, and matches each option there against the list of valid
options. During the scan, argv is rewritten to only contain the
non-option command line arguments and the number of these is returned.
Aggregation of single switches is allowed:
-rC0 is the same as -r -C 0 (supposing that -C wants an arg).
Boolean switches automatically support the option with the same name,
prefixed with 'no-' to disable the switch:
--no-color / --color only need to have an entry for "color".
Long options are supported either with '=' or without:
--some-option=foo is the same as --some-option foo
That looks great, works for me. One comment, though: it looks like
you're not sure whether to call these things "options" or "switches".
We should choose one and stick with it.
I use the word "switch" when it's a short_option, and "option" when
it's a long one. But maybe the distinction doesn't make sense, and it's
a non-native speaker glitch. I don't care that much btw.
quoted
oh and I don't grok what OPTION_LAST is for, so I left it apart, but
it seems unused ?
Oh, kill that. I used that as the option array terminator before we
switched to ARRAY_SIZE().
From: Pierre Habouzit <hidden> Date: 2016-06-15 22:43:39
On ven, oct 05, 2007 at 03:45:36 +0000, Medve Emilian-EMMEDVE1 wrote:
You probably already considered and rejected the GNU argp parser. I
used it before and I'd like to know reasons I should stay away from
it.
Because it's GNU and that it's a heavy dependency to begin with.
Moreover, getopt_long doesn't deal with argument types (like integers).
--
·O· Pierre Habouzit
··O madcoder@debian.org
OOO http://www.madism.org
-----Original Message-----
From: Pierre Habouzit [mailto:madcoder@debian.org]
Sent: Friday, October 05, 2007 10:57 AM
To: Medve Emilian-EMMEDVE1
Cc: Mike Hommey; Kristian Høgsberg; git@vger.kernel.org;
Junio C Hamano
Subject: Re: [ALTERNATE PATCH] Add a simple option parser.
On ven, oct 05, 2007 at 03:45:36 +0000, Medve Emilian-EMMEDVE1 wrote:
quoted
You probably already considered and rejected the GNU argp parser. I
used it before and I'd like to know reasons I should stay away from
it.
Because it's GNU and that it's a heavy dependency to begin with.
So it's more of a political decision then a technical one?
Moreover, getopt_long doesn't deal with argument types (like
integers).
From: David Kastrup <hidden> Date: 2016-06-15 22:43:39
"Medve Emilian-EMMEDVE1" [off-list ref] writes:
Hi Pierre,
quoted
-----Original Message-----
From: Pierre Habouzit [mailto:madcoder@debian.org]
Sent: Friday, October 05, 2007 10:57 AM
To: Medve Emilian-EMMEDVE1
Cc: Mike Hommey; Kristian Høgsberg; git@vger.kernel.org;
Junio C Hamano
Subject: Re: [ALTERNATE PATCH] Add a simple option parser.
On ven, oct 05, 2007 at 03:45:36 +0000, Medve Emilian-EMMEDVE1 wrote:
quoted
You probably already considered and rejected the GNU argp parser. I
used it before and I'd like to know reasons I should stay away from
it.
Because it's GNU and that it's a heavy dependency to begin with.
So it's more of a political decision then a technical one?
Well, if it is GNU then it is likely to mean GPLv3 (or GPLv3+) at some
point of time, though it should certainly be possible for now to still
secure a v2-licensed version (either GPL or LGPL).
GNU also means a different coding and indentation style.
Personally, I couldn't care less about both points (I prefer the GNU
coding style anyway), but that's for the maintainer to decide, and one
also has to take into account the effect on developer motivation.
And the typical git developer AFAICT prefers to consider themselves as
unaligned with GNU and the FSF as much as possible.
--
David Kastrup
Because it's GNU and that it's a heavy dependency to begin with.
So it's more of a political decision then a technical one?
I'd *strongly* argue against new dependencies unless they buy us
something major.
We've been good at cutting them down, including any required libraries
internally. We shouldn't add new ones.
So we'd have to include GNU getopt sources with the git tree, at which
point any advantage would be gone. Might as well include a private and
simpler version of our own.
Linus
From: Pierre Habouzit <hidden> Date: 2016-06-15 22:43:39
On Fri, Oct 05, 2007 at 04:20:33PM +0000, David Kastrup wrote:
"Medve Emilian-EMMEDVE1" [off-list ref] writes:
quoted
Hi Pierre,
quoted
-----Original Message-----
From: Pierre Habouzit [mailto:madcoder@debian.org]
Sent: Friday, October 05, 2007 10:57 AM
To: Medve Emilian-EMMEDVE1
Cc: Mike Hommey; Kristian Høgsberg; git@vger.kernel.org;
Junio C Hamano
Subject: Re: [ALTERNATE PATCH] Add a simple option parser.
On ven, oct 05, 2007 at 03:45:36 +0000, Medve Emilian-EMMEDVE1 wrote:
quoted
You probably already considered and rejected the GNU argp parser. I
used it before and I'd like to know reasons I should stay away from
it.
Because it's GNU and that it's a heavy dependency to begin with.
So it's more of a political decision then a technical one?
Well, if it is GNU then it is likely to mean GPLv3 (or GPLv3+) at some
point of time, though it should certainly be possible for now to still
secure a v2-licensed version (either GPL or LGPL).
That is an issue indeed.
And the typical git developer AFAICT prefers to consider themselves as
unaligned with GNU and the FSF as much as possible.
And is nothing near reality in my case.
The real issue is dependency and bloat. getopt_long would need the GNU
implementation, That I believe depends upon gettext, and argp is just
bloated, and I'm not even sure it's distributed outside from the glibc
anyways.
--
·O· Pierre Habouzit
··O madcoder@debian.org
OOO http://www.madism.org
Because it's GNU and that it's a heavy dependency to begin with.
So it's more of a political decision then a technical one?
I'd *strongly* argue against new dependencies unless they buy us
something major.
We've been good at cutting them down, including any required
libraries
internally. We shouldn't add new ones.
So we'd have to include GNU getopt sources with the git tree,
at which
point any advantage would be gone. Might as well include a
private and
simpler version of our own.
From: Pierre Habouzit <hidden> Date: 2016-06-15 22:43:39
On Fri, Oct 05, 2007 at 04:41:48PM +0000, Medve Emilian-EMMEDVE1 wrote:
Hello Linus,
quoted
On Fri, 5 Oct 2007, Medve Emilian-EMMEDVE1 wrote:
quoted
quoted
Because it's GNU and that it's a heavy dependency to begin with.
So it's more of a political decision then a technical one?
I'd *strongly* argue against new dependencies unless they buy us
something major.
We've been good at cutting them down, including any required
libraries internally. We shouldn't add new ones.
So we'd have to include GNU getopt sources with the git tree, at
which point any advantage would be gone. Might as well include a
private and simpler version of our own.
From what I understand argp is part of glibc.
And of course requiring the glibc would be a big step forward for the
msys (or AIX, or HP-UX, or …) port !
--
·O· Pierre Habouzit
··O madcoder@debian.org
OOO http://www.madism.org
From: Sven Verdoolaege <hidden> Date: 2016-06-15 22:43:39
On Fri, Oct 05, 2007 at 06:38:46PM +0200, Pierre Habouzit wrote:
The real issue is dependency and bloat. getopt_long would need the GNU
implementation, That I believe depends upon gettext, and argp is just
bloated, and I'm not even sure it's distributed outside from the glibc
anyways.
It's part of gnulib (http://savannah.gnu.org/git/?group=gnulib).
Including argp (and all its dependencies) is as easy as running some
gnulib command.
It does have some bloat, but for my project it was definitely more
convenient to include it than to write my own parser and the bloat
is still acceptable I suppose...
bash-3.00$ du lib m4
572 lib
208 m4
bash-3.00$ du -s .
20348 .
(In a source tree without the git repo.)
skimo
From: Pierre Habouzit <hidden> Date: 2016-06-15 22:43:39
FWIW this patch has some issues with long options parsing, I have a
fix, but am trying to migrate more builtins to this parser to see how
well it behaves.
--
·O· Pierre Habouzit
··O madcoder@debian.org
OOO http://www.madism.org