Skip to content
Commits on May 8, 2012
  1. @pclouds @gitster

    i18n: parseopt: lookup help and argument translations when showing usage

    pclouds committed with gitster
    Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
Commits on Mar 5, 2012
  1. @gitster

    parse-options: typo check for unknown switches

    René Scharfe committed with gitster
    The user specifies a long option but forgets to type the second
    leading dash, we currently detect and report that fact if its first
    letter is a valid short option. This is done for safety, to avoid
    ambiguity between short options (and their arguments) and a long
    option with a missing dash.
    
    This diagnostic message is also helpful for long options whose first
    letter is not a valid short option, however. Print it in that case,
    too, as a courtesy.
    
    Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
Commits on Feb 28, 2012
  1. @gitster

    parse-options: remove PARSE_OPT_NEGHELP

    René Scharfe committed with gitster
    PARSE_OPT_NEGHELP is confusing because short options defined with that
    flag do the opposite of what the helptext says. It is also not needed
    anymore now that options starting with no- can be negated by removing
    that prefix. Convert its only two users to OPT_NEGBIT() and OPT_BOOL()
    and then remove support for PARSE_OPT_NEGHELP.
    
    Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>
    Acked-by: Jeff King <peff@peff.net>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
Commits on Feb 26, 2012
  1. @gitster

    parse-options: allow positivation of options starting, with no-

    René Scharfe committed with gitster
    Long options can be negated by adding no- right after the leading
    two dashes. This is useful e.g. to override options set by aliases.
    
    For options that are defined to start with no- already, this looks
    a bit funny. Allow such options to also be negated by removing the
    prefix.
    
    The following thirteen options are affected:
    
    	apply          --no-add
    	bisect--helper --no-checkout
    	checkout-index --no-create
    	clone          --no-checkout --no-hardlinks
    	commit         --no-verify   --no-post-rewrite
    	format-patch   --no-binary
    	hash-object    --no-filters
    	read-tree      --no-sparse-checkout
    	revert         --no-commit
    	show-branch    --no-name
    	update-ref     --no-deref
    
    The following five are NOT affected because they are defined with
    PARSE_OPT_NONEG or the non-negated version is defined as well:
    
    	branch       --no-merged
    	format-patch --no-stat             --no-numbered
    	update-index --no-assume-unchanged --no-skip-worktree
    
    Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
Commits on Sep 28, 2011
  1. @gitster

    parse-options: deprecate OPT_BOOLEAN

    gitster committed
    It is natural to expect that an option defined with OPT_BOOLEAN() could be
    used in this way:
    
    	int option = -1; /* unspecified */
    
    	struct option options[] = {
    		OPT_BOOLEAN(0, "option", &option, "set option"),
                    OPT_END()
    	};
    	parse_options(ac, av, prefix, options, usage, 0);
    
            if (option < 0)
            	... do the default thing ...
    	else if (!option)
    		... --no-option was given ...
    	else
    		... --option was given ...
    
    to easily tell three cases apart:
    
     - There is no mention of the `--option` on the command line;
     - The variable is positively set with `--option`; or
     - The variable is explicitly negated with `--no-option`.
    
    Unfortunately, this is not the case. OPT_BOOLEAN() increments the variable
    every time `--option` is given, and resets it to zero when `--no-option`
    is given.
    
    As a first step to remedy this, introduce a true boolean OPT_BOOL(), and
    rename OPT_BOOLEAN() to OPT_COUNTUP(). To help transitioning, OPT_BOOLEAN
    and OPTION_BOOLEAN are defined as deprecated synonyms to OPT_COUNTUP and
    OPTION_COUNTUP respectively.
    
    This is what db7244b (parse-options new features., 2007-11-07) from four
    years ago started by marking OPTION_BOOLEAN as "INCR would have been a
    better name".
    
    Some existing users do depend on the count-up semantics; for example,
    users of OPT__VERBOSE() could use it to raise the verbosity level with
    repeated use of `-v` on the command line, but they probably should be
    rewritten to use OPT__VERBOSITY() instead these days.  I suspect that some
    users of OPT__FORCE() may also use it to implement different level of
    forcibleness but I didn't check.
    
    On top of this patch, here are the remaining clean-up tasks that other
    people can help:
    
     - Look at each hit in "git grep -e OPT_BOOLEAN"; trace all uses of the
       value that is set to the underlying variable, and if it can proven that
       the variable is only used as a boolean, replace it with OPT_BOOL(). If
       the caller does depend on the count-up semantics, replace it with
       OPT_COUNTUP() instead.
    
     - Same for OPTION_BOOLEAN; replace it with OPTION_SET_INT and arrange to
       set 1 to the variable for a true boolean, and otherwise replace it with
       OPTION_COUNTUP.
    
     - Look at each hit in "git grep -e OPT__VERBOSE -e OPT__QUIET" and see if
       they can be replaced with OPT__VERBOSITY().
    
    I'll follow this message up with a separate patch as an example.
    
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
Commits on Aug 11, 2011
  1. @divanorama @gitster

    Reduce parse-options.o dependencies

    divanorama committed with gitster
    Currently parse-options.o pulls quite a big bunch of dependencies.
    his complicates it's usage in contrib/ because it pulls external
    dependencies and it also increases executables size.
    
    Split off less generic and more internal to git part of
    parse-options.c to parse-options-cb.c.
    
    Move prefix_filename function from setup.c to abspath.c. abspath.o
    and wrapper.o pull each other, so it's unlikely to increase the
    dependencies. It was a dependency of parse-options.o that pulled
    many others.
    
    Now parse-options.o pulls just abspath.o, ctype.o, strbuf.o, usage.o,
    wrapper.o, libc directly and strlcpy.o indirectly.
    
    Signed-off-by: Dmitry Ivankov <divanorama@gmail.com>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
  2. @divanorama @gitster

    parse-options: export opterr, optbug

    divanorama committed with gitster
    opterror and optbug functions are used by some of parsing routines
    in parse-options.c to report errors and bugs respectively.
    
    Export these functions to allow more custom parsing routines to use
    them in a uniform way.
    
    Signed-off-by: Dmitry Ivankov <divanorama@gmail.com>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
Commits on Jun 22, 2011
  1. @peff @gitster

    parse-options: add OPT_STRING_LIST helper

    peff committed with gitster
    This just adds repeated invocations of an option to a list
    of strings. Using the "--no-<var>" form will reset the list
    to empty.
    
    Signed-off-by: Jeff King <peff@peff.net>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
Commits on Mar 22, 2011
  1. @bebarino @gitster

    Fix sparse warnings

    bebarino committed with gitster
    Fix warnings from 'make check'.
    
     - These files don't include 'builtin.h' causing sparse to complain that
       cmd_* isn't declared:
    
       builtin/clone.c:364, builtin/fetch-pack.c:797,
       builtin/fmt-merge-msg.c:34, builtin/hash-object.c:78,
       builtin/merge-index.c:69, builtin/merge-recursive.c:22
       builtin/merge-tree.c:341, builtin/mktag.c:156, builtin/notes.c:426
       builtin/notes.c:822, builtin/pack-redundant.c:596,
       builtin/pack-refs.c:10, builtin/patch-id.c:60, builtin/patch-id.c:149,
       builtin/remote.c:1512, builtin/remote-ext.c:240,
       builtin/remote-fd.c:53, builtin/reset.c:236, builtin/send-pack.c:384,
       builtin/unpack-file.c:25, builtin/var.c:75
    
     - These files have symbols which should be marked static since they're
       only file scope:
    
       submodule.c:12, diff.c:631, replace_object.c:92, submodule.c:13,
       submodule.c:14, trace.c:78, transport.c:195, transport-helper.c:79,
       unpack-trees.c:19, url.c:3, url.c:18, url.c:104, url.c:117, url.c:123,
       url.c:129, url.c:136, thread-utils.c:21, thread-utils.c:48
    
     - These files redeclare symbols to be different types:
    
       builtin/index-pack.c:210, parse-options.c:564, parse-options.c:571,
       usage.c:49, usage.c:58, usage.c:63, usage.c:72
    
     - These files use a literal integer 0 when they really should use a NULL
       pointer:
    
       daemon.c:663, fast-import.c:2942, imap-send.c:1072, notes-merge.c:362
    
    While we're in the area, clean up some unused #includes in builtin files
    (mostly exec_cmd.h).
    
    Signed-off-by: Stephen Boyd <bebarino@gmail.com>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
Commits on Dec 7, 2010
  1. @jrn @gitster

    parse-options: make resuming easier after PARSE_OPT_STOP_AT_NON_OPTION

    jrn committed with gitster
    Introduce a PARSE_OPT_NON_OPTION state, so parse_option_step()
    callers can easily distinguish between non-options and other
    reasons for option parsing termination (like "--").
    
    Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
  2. @jrn @gitster

    parse-options: allow git commands to invent new option types

    jrn committed with gitster
    parse-options provides a variety of option behaviors, including
    OPTION_CALLBACK, which should take care of just about any sane
    behavior.  All supported behaviors obey the following constraint:
    
     A --foo option can only accept (and base its behavior on)
     one argument, which would be the following command-line
     argument in the "unsticked" form.
    
    Alas, some existing git commands have options that do not obey that
    constraint.  For example, update-index --cacheinfo takes three
    arguments, and update-index --resolve takes all later parameters as
    arguments.
    
    Introduces an OPTION_LOWLEVEL_CALLBACK backdoor to parse-options so
    such option types can be supported without tempting inventors of other
    commands through mention in the public API.  Commands can set the
    callback field to a function accepting three arguments: the option
    parsing context, the option itself, and a flag indicating whether the
    the option was negated.  When the option is encountered, that function
    is called to take over from get_value().  The return value should be
    zero for success, -1 for usage errors.
    
    Thanks to Stephen Boyd for API guidance.
    
    Improved-by: Stephen Boyd <bebarino@gmail.com>
    Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
  3. @jrn @gitster

    parse-options: never suppress arghelp if LITERAL_ARGHELP is set

    jrn committed with gitster
    The PARSE_OPT_LITERAL_ARGHELP flag allows a program to override the
    standard "<argument> for mandatory, [argument] for optional" markup in
    its help message.  Extend it to override the usual "no text for
    disallowed", too (for the PARSE_OPT_NOARG | PARSE_OPT_LITERAL_ARGHELP
    case, which was previously meaningless), to be more intuitive.
    
    The motivation is to allow update-index to correctly advertise
    
    	--cacheinfo <mode> <object> <path>
    	                      add the specified entry to the index
    
    while abusing PARSE_OPT_NOARG to disallow the "sticked form"
    
    	--cacheinfo=<mode> <object> <path>
    
    Noticed-by: Stephen Boyd <bebarino@gmail.com>
    Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
  4. @bebarino @gitster

    parse-options: do not infer PARSE_OPT_NOARG from option type

    bebarino committed with gitster
    Simplify the "takes no value" error path by relying on PARSE_OPT_NOARG
    being set correctly.  That is:
    
     - if the PARSE_OPT_NOARG flag is set, reject --opt=value
       regardless of the option type;
     - if the PARSE_OPT_NOARG flag is unset, accept --opt=value
       regardless of the option type.
    
    This way, the accepted usage more closely matches the usage advertised
    with --help-all.
    
    No functional change intended, since the NOARG flag is only used
    with "boolean-only" option types in existing parse_options callers.
    
    Signed-off-by: Stephen Boyd <bebarino@gmail.com>
    Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
  5. @jrn @gitster

    parse-options: sanity check PARSE_OPT_NOARG flag

    jrn committed with gitster
    Some option types cannot use an argument --- boolean options that
    would set a bit or flag or increment a counter, for example.  If
    configured in the flag word to accept an argument anyway, the result
    is an argument that is advertised in "program -h" output only to be
    rejected by parse-options::get_value.
    
    Luckily all current users of these option types use PARSE_OPT_NOARG
    and do not use PARSE_OPT_OPTARG.  Add a check to ensure that that
    remains true.  The check is run once for each invocation of
    parse_option_start().
    
    Improved-by: Stephen Boyd <bebarino@gmail.com>
    Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
  6. @jrn @gitster

    parse-options: move NODASH sanity checks to parse_options_check

    jrn committed with gitster
    A dashless switch (like '(' passed to 'git grep') cannot be negated,
    cannot be attached to an argument, and cannot have a long form.
    Currently parse-options runs the related sanity checks when the
    dashless option is used; better to always check them at the start of
    option parsing, so mistakes can be caught more quickly.
    
    The error message at the new call site is less specific about the
    nature of the error, for simplicity.  On the other hand, it prints
    which switch was problematic.  Before:
    
    	fatal: BUG: dashless options can't be long
    
    After:
    
    	error: BUG: switch '(' uses feature not supported for dashless options
    
    Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
  7. @jrn @gitster

    parse-options: clearer reporting of API misuse

    jrn committed with gitster
    The PARSE_OPT_LASTARG_DEFAULT flag is meant for options like
    --contains that (1) traditionally had a mandatory argument and
    (2) have some better behavior to use when appearing in the final
    position.  It makes no sense to combine this with OPTARG, so ever
    since v1.6.4-rc0~71 (parse-options: add parse_options_check to
    validate option specs, 2009-07-09) this mistake is flagged with
    
    	error: `--option` uses incompatible flags LASTARG_DEFAULT and OPTARG
    
    and an exit status representing an error in commandline usage.
    
    Unfortunately that which might confuse scripters calling such an
    erroneous program into thinking the _script_ contains an error.
    Clarify that it is an internal error by dying with a message beginning
    "error: BUG: ..." and status 128.
    
    While at it, clean up parse_options_check to prepare for more checks.
    
    Long term, it would be nicer to make such checks happen at compile
    time.
    
    Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
  8. @bebarino @gitster

    parse-options: Don't call parse_options_check() so much

    bebarino committed with gitster
    parse_options_check() is being called for each invocation of
    parse_options_step which can be quite a bit for some commands. The
    commit introducing this function cb9d398 (parse-options: add
    parse_options_check to validate option specs., 2009-06-09) had the
    correct motivation and explicitly states that parse_options_check()
    should be called from parse_options_start(). However, the implementation
    differs from the motivation. Fix it.
    
    Signed-off-by: Stephen Boyd <bebarino@gmail.com>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
Commits on Jun 13, 2010
  1. @trast @gitster

    parseopt: wrap rev-parse --parseopt usage for eval consumption

    trast committed with gitster
    9c7304e (print the usage string on stdout instead of stderr,
    2010-05-17) broke rev-parse --parseopt: when run with -h, the usage
    notice on stdout ended up in the shell eval.
    
    Wrap the usage in a cat <<\EOF ... EOF block when printing to stdout.
    I do not expect any usage lines to ever start with EOF so this
    shouldn't be an undue burden.
    
    Signed-off-by: Thomas Rast <trast@student.ethz.ch>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
Commits on Jun 1, 2010
  1. @giuseppe @gitster

    print the usage string on stdout instead of stderr

    giuseppe committed with gitster
    When -h is used, print usage messages on stdout.  If a command is invoked with
    wrong arguments then print the usage messages on stderr.
    
    Signed-off-by: Giuseppe Scrivano <gscrivano@gnu.org>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
Commits on Mar 7, 2010
  1. @gitster

    parse-options: add parse_options_concat() to concat options

    gitster committed
    Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
Commits on Feb 19, 2010
  1. @MarkLodato @gitster

    Add an optional argument for --color options

    MarkLodato committed with gitster
    Make git-branch, git-show-branch, git-grep, and all the diff-based
    programs accept an optional argument <when> for --color.  The argument
    is a colorbool: "always", "never", or "auto".  If no argument is given,
    "always" is used;  --no-color is an alias for --color=never.  This makes
    the command-line interface consistent with other GNU tools, such as `ls'
    and `grep', and with the git-config color options.  Note that, without
    an argument, --color and --no-color work exactly as before.
    
    To implement this, two internal changes were made:
    
    1. Allow the first argument of git_config_colorbool() to be NULL,
       in which case it returns -1 if the argument isn't "always", "never",
       or "auto".
    
    2. Add OPT_COLOR_FLAG(), OPT__COLOR(), and parse_opt_color_flag_cb()
       to the option parsing library.  The callback uses
       git_config_colorbool(), so color.h is now a dependency
       of parse-options.c.
    
    Signed-off-by: Mark Lodato <lodatom@gmail.com>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
Commits on Jan 20, 2010
  1. @gitster

    Merge branch 'jc/symbol-static'

    gitster committed
    * jc/symbol-static:
      date.c: mark file-local function static
      Replace parse_blob() with an explanatory comment
      symlinks.c: remove unused functions
      object.c: remove unused functions
      strbuf.c: remove unused function
      sha1_file.c: remove unused function
      mailmap.c: remove unused function
      utf8.c: mark file-local function static
      submodule.c: mark file-local function static
      quote.c: mark file-local function static
      remote-curl.c: mark file-local function static
      read-cache.c: mark file-local functions static
      parse-options.c: mark file-local function static
      entry.c: mark file-local function static
      http.c: mark file-local functions static
      pretty.c: mark file-local function static
      builtin-rev-list.c: mark file-local function static
      bisect.c: mark file-local function static
Commits on Jan 12, 2010
  1. @gitster

    parse-options.c: mark file-local function static

    gitster committed
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
Commits on Dec 4, 2009
  1. @gitster

    Teach --[no-]rerere-autoupdate option to merge, revert and friends

    gitster committed
    Introduce a command line option to override rerere.autoupdate configuration
    variable to make it more useful.
    
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
Commits on Sep 29, 2009
  1. @andreas-schwab @spearce

    parse-opt: ignore negation of OPT_NONEG for ambiguity checks

    andreas-schwab committed with spearce
    parse_long_opt always matches both --opt and --no-opt for any option
    "opt", and only get_value checks whether --no-opt is actually valid.
    Since the options for git branch contains both "no-merged" and "merged"
    there are two matches for --no-merge, but no exact match.  With this
    patch the negation of a NONEG option is rejected earlier, but it changes
    the error message from "option `no-opt' isn't available" to "unknown
    option `no-opt'".
    
    [jk: added test]
    
    Signed-off-by: Andreas Schwab <schwab@linux-m68k.org>
    Signed-off-by: Jeff King <peff@peff.net>
    Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Commits on Aug 22, 2009
  1. @gitster

    Merge branch 'cc/replace'

    gitster committed
    * cc/replace:
      t6050: check pushing something based on a replaced commit
      Documentation: add documentation for "git replace"
      Add git-replace to .gitignore
      builtin-replace: use "usage_msg_opt" to give better error messages
      parse-options: add new function "usage_msg_opt"
      builtin-replace: teach "git replace" to actually replace
      Add new "git replace" command
      environment: add global variable to disable replacement
      mktag: call "check_sha1_signature" with the replacement sha1
      replace_object: add a test case
      object: call "check_sha1_signature" with the replacement sha1
      sha1_file: add a "read_sha1_file_repl" function
      replace_object: add mechanism to replace objects found in "refs/replace/"
      refs: add a "for_each_replace_ref" function
Commits on Jul 31, 2009
  1. @dscho @gitster

    parse-opt: optionally show "--no-" option string

    dscho committed with gitster
    It is usually better to have positive options, to avoid confusing double
    negations.  However, sometimes it is desirable to show the negative option
    in the help.
    
    Introduce the flag PARSE_OPT_NEGHELP to do that.
    
    Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
Commits on Jun 21, 2009
  1. @torvalds @gitster

    Fix various sparse warnings in the git source code

    torvalds committed with gitster
    There are a few remaining ones, but this fixes the trivial ones. It boils
    down to two main issues that sparse complains about:
    
     - warning: Using plain integer as NULL pointer
    
       Sparse doesn't like you using '0' instead of 'NULL'. For various good
       reasons, not the least of which is just the visual confusion. A NULL
       pointer is not an integer, and that whole "0 works as NULL" is a
       historical accident and not very pretty.
    
       A few of these remain: zlib is a total mess, and Z_NULL is just a 0.
       I didn't touch those.
    
     - warning: symbol 'xyz' was not declared. Should it be static?
    
       Sparse wants to see declarations for any functions you export. A lack
       of a declaration tends to mean that you should either add one, or you
       should mark the function 'static' to show that it's in file scope.
    
       A few of these remain: I only did the ones that should obviously just
       be made static.
    
    That 'wt_status_submodule_summary' one is debatable. It has a few related
    flags (like 'wt_status_use_color') which _are_ declared, and are used by
    builtin-commit.c. So maybe we'd like to export it at some point, but it's
    not declared now, and not used outside of that file, so 'static' it is in
    this patch.
    
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
Commits on Jun 18, 2009
  1. @gitster

    Merge branch 'sb/parse-options-integer'

    gitster committed
    * sb/parse-options-integer:
      parse-options: simplify usage argh handling
      parse-options: make OPT_INTEGER's argh explicit
Commits on Jun 10, 2009
  1. @gitster

    parse-options: add parse_options_check to validate option specs.

    Pierre Habouzit committed with gitster
    It only searches for now for the dreaded LASTARG_DEFAULT | OPTARG
    combination, but can be extended to check for any other forbidden
    combination.
    
    Options are checked each time we call parse_options_start.
    
    Signed-off-by: Pierre Habouzit <madcoder@debian.org>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
Commits on Jun 6, 2009
  1. @bebarino @gitster

    parse-options: simplify usage argh handling

    bebarino committed with gitster
    Simplify the argh printing by simply calling usage_argh() if the option
    can take an argument. Update macros defined in parse-options.h to set
    the PARSE_OPT_NOARG flag.
    
    The only other user of custom non-argument taking options is git-apply
    (in this case OPTION_BOOLEAN for deprecated options). Update it to set
    the PARSE_OPT_NOARG flag.
    
    Thanks to Ren辿 Scharfe for the suggestion and starter patch.
    
    Signed-off-by: Stephen Boyd <bebarino@gmail.com>
    Reviewd-by: René Scharfe <rene.scharfe@lsrfire.ath.cx>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
  2. @bebarino @gitster

    parse-options: make OPT_INTEGER's argh explicit

    bebarino committed with gitster
    OPTION_INTEGER hardcodes its argh member to be "n", but the decision is
    hidden deep in usage_with_options_internal(). Make "n" the default argh
    for the OPT_INTEGER macro while leaving it undecided for the OPTION_INTEGER
    enum.
    
    This makes it less surprising to users that argh is "n" when using the
    OPT_INTEGER macro.
    
    Signed-off-by: Stephen Boyd <bebarino@gmail.com>
    Reviewed-by: René Scharfe <rene.scharfe@lsrfire.ath.cx>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
Commits on Jun 1, 2009
  1. @chriscool @gitster

    parse-options: add new function "usage_msg_opt"

    chriscool committed with gitster
    This function can be used instead of "usage_with_options" when you
    want to print an error message before the usage string.
    
    It may be useful because:
    
    if (condition)
    	usage_msg_opt("condition is false", usage, opts);
    
    is shorter than:
    
    if (condition) {
    	fprintf(stderr, "condition is false\n\n");
    	usage_with_options(usage, opts);
    }
    
    and may be more consistent.
    
    Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
Commits on May 25, 2009
  1. @bebarino @gitster

    parse-opts: add OPT_FILENAME and transition builtins

    bebarino committed with gitster
    Commit dbd0f5c (Files given on the command line are relative to $cwd,
    2008-08-06) introduced parse_options_fix_filename() as a minimal fix.
    OPT_FILENAME is intended to be a more robust fix for the same issue.
    OPT_FILENAME and its associated enum OPTION_FILENAME are used to
    represent filename options within the parse options API.
    
    This option is similar to OPTION_STRING. If --no is prefixed to the
    option the filename is unset. If no argument is given and the default
    value is set, the filename is set to the default value. The difference
    is that the filename is prefixed with the prefix passed to
    parse_options() (or parse_options_start()).
    
    Update git-apply, git-commit, git-fmt-merge-msg, and git-tag to use
    OPT_FILENAME with their filename options. Also, rename
    parse_options_fix_filename() to fix_filename() as it is no longer
    extern.
    
    Signed-off-by: Stephen Boyd <bebarino@gmail.com>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
  2. @bebarino @gitster

    parse-opts: prepare for OPT_FILENAME

    bebarino committed with gitster
    To give OPT_FILENAME the prefix, we pass the prefix to parse_options()
    which passes the prefix to parse_options_start() which sets the prefix
    member of parse_opts_ctx accordingly. If there isn't a prefix in the
    calling context, passing NULL will suffice.
    
    Signed-off-by: Stephen Boyd <bebarino@gmail.com>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
Something went wrong with that request. Please try again.