Skip to content
Commits on Jun 20, 2014
  1. @peff @gitster

    refactor skip_prefix to return a boolean

    peff committed with gitster Jun 18, 2014
    The skip_prefix() function returns a pointer to the content
    past the prefix, or NULL if the prefix was not found. While
    this is nice and simple, in practice it makes it hard to use
    for two reasons:
    
      1. When you want to conditionally skip or keep the string
         as-is, you have to introduce a temporary variable.
         For example:
    
           tmp = skip_prefix(buf, "foo");
           if (tmp)
    	       buf = tmp;
    
      2. It is verbose to check the outcome in a conditional, as
         you need extra parentheses to silence compiler
         warnings. For example:
    
           if ((cp = skip_prefix(buf, "foo"))
    	       /* do something with cp */
    
    Both of these make it harder to use for long if-chains, and
    we tend to use starts_with() instead. However, the first line
    of "do something" is often to then skip forward in buf past
    the prefix, either using a magic constant or with an extra
    strlen(3) (which is generally computed at compile time, but
    means we are repeating ourselves).
    
    This patch refactors skip_prefix() to return a simple boolean,
    and to provide the pointer value as an out-parameter. If the
    prefix is not found, the out-parameter is untouched. This
    lets you write:
    
      if (skip_prefix(arg, "foo ", &arg))
    	  do_foo(arg);
      else if (skip_prefix(arg, "bar ", &arg))
    	  do_bar(arg);
    
    Signed-off-by: Jeff King <peff@peff.net>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
Commits on Apr 8, 2014
  1. @gitster

    Merge branch 'mr/opt-set-ptr'

    gitster committed Apr 8, 2014
    OPT_SET_PTR() implementation was broken on IL32P64 platforms;
    it turns out that the macro is not used by any real user.
    
    * mr/opt-set-ptr:
      parse-options: remove unused OPT_SET_PTR
      parse-options: add cast to correct pointer type to OPT_SET_PTR
      MSVC: fix t0040-parse-options crash
Commits on Mar 31, 2014
  1. @slonopotamus @gitster

    parse-options: remove unused OPT_SET_PTR

    slonopotamus committed with gitster Mar 30, 2014
    OPT_SET_PTR was never used since its creation at db7244b
    (parse-options new features., 2007-11-07).
    
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
Commits on Mar 24, 2014
  1. @gitster

    parse-options: make sure argh string does not have SP or _

    gitster committed Mar 23, 2014
    We encourage to spell an argument hint that consists of multiple
    words as a single-token separated with dashes.  In order to help
    catching violations added by new callers of parse-options, make sure
    argh does not contain SP or _ when the code validates the option
    definitions.
    
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
Commits on Mar 10, 2014
  1. @RohitMani @gitster

    use strchrnul() in place of strchr() and strlen()

    RohitMani committed with gitster Mar 7, 2014
    Avoid scanning strings twice, once with strchr() and then with
    strlen(), by using strchrnul().
    
    Helped-by: Junio C Hamano <gitster@pobox.com>
    Signed-off-by: Rohit Mani <rohit.mani@outlook.com>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
Commits on Dec 5, 2013
  1. @chriscool @gitster

    replace {pre,suf}fixcmp() with {starts,ends}_with()

    chriscool committed with gitster Nov 30, 2013
    Leaving only the function definitions and declarations so that any
    new topic in flight can still make use of the old functions, replace
    existing uses of the prefixcmp() and suffixcmp() with new API
    functions.
    
    The change can be recreated by mechanically applying this:
    
        $ git grep -l -e prefixcmp -e suffixcmp -- \*.c |
          grep -v strbuf\\.c |
          xargs perl -pi -e '
            s|!prefixcmp\(|starts_with\(|g;
            s|prefixcmp\(|!starts_with\(|g;
            s|!suffixcmp\(|ends_with\(|g;
            s|suffixcmp\(|!ends_with\(|g;
          '
    
    on the result of preparatory changes in this series.
    
    Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
Commits on Jul 30, 2013
  1. @gitster

    parse-options: add OPT_CMDMODE()

    gitster committed Jul 30, 2013
    This can be used to define a set of mutually exclusive "command
    mode" options, and automatically catch use of more than one from
    that set as an error.
    
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
Commits on Feb 15, 2013
  1. @gitster

    Merge branch 'ef/non-ascii-parse-options-error-diag'

    gitster committed Feb 14, 2013
    * ef/non-ascii-parse-options-error-diag:
      parse-options: report uncorrupted multi-byte options
Commits on Feb 14, 2013
  1. @gitster

    Merge branch 'jx/utf8-printf-width'

    gitster committed Feb 14, 2013
    Use a new helper that prints a message and counts its display width
    to align the help messages parse-options produces.
    
    * jx/utf8-printf-width:
      Add utf8_fprintf helper that returns correct number of columns
Commits on Feb 11, 2013
  1. @kusma @gitster

    parse-options: report uncorrupted multi-byte options

    kusma committed with gitster Feb 12, 2013
    Because our command-line parser considers only one byte at the time
    for short-options, we incorrectly report only the first byte when
    multi-byte input was provided. This makes user-errors slightly
    awkward to diagnose for instance under UTF-8 locale and non-English
    keyboard layouts.
    
    Report the whole argument-string when a non-ASCII short-option is
    detected.
    
    Signed-off-by: Erik Faye-Lund <kusmabite@gmail.com>
    Improved-by: Jeff King <peff@peff.net>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
  2. @jiangxin @gitster

    Add utf8_fprintf helper that returns correct number of columns

    jiangxin committed with gitster Feb 9, 2013
    Since command usages can be translated, they may include utf-8
    encoded strings, and the output in console may not align well any
    more. This is because strlen() is different from strwidth() on utf-8
    strings.
    
    A wrapper utf8_fprintf() can help to return the correct number of
    columns required.
    
    Signed-off-by: Jiang Xin <worldhello.net@gmail.com>
    Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
    Reviewed-by: Torsten Bögershausen <tboegi@web.de>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
Commits on Dec 15, 2012
  1. @peff @gitster

    silence some -Wuninitialized false positives

    peff committed with gitster Dec 15, 2012
    There are a few error functions that simply wrap error() and
    provide a standardized message text. Like error(), they
    always return -1; knowing that can help the compiler silence
    some false positive -Wuninitialized warnings.
    
    One strategy would be to just declare these as inline in the
    header file so that the compiler can see that they always
    return -1. However, gcc does not always inline them (e.g.,
    it will not inline opterror, even with -O3), which renders
    our change pointless.
    
    Instead, let's follow the same route we did with error() in
    the last patch, and define a macro that makes the constant
    return value obvious to the compiler.
    
    Signed-off-by: Jeff King <peff@peff.net>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
Commits on Jul 9, 2012
  1. @tboegi @gitster

    git on Mac OS and precomposed unicode

    tboegi committed with gitster Jul 8, 2012
    Mac OS X mangles file names containing unicode on file systems HFS+,
    VFAT or SAMBA.  When a file using unicode code points outside ASCII
    is created on a HFS+ drive, the file name is converted into
    decomposed unicode and written to disk. No conversion is done if
    the file name is already decomposed unicode.
    
    Calling open("\xc3\x84", ...) with a precomposed "Ä" yields the same
    result as open("\x41\xcc\x88",...) with a decomposed "Ä".
    
    As a consequence, readdir() returns the file names in decomposed
    unicode, even if the user expects precomposed unicode.  Unlike on
    HFS+, Mac OS X stores files on a VFAT drive (e.g. an USB drive) in
    precomposed unicode, but readdir() still returns file names in
    decomposed unicode.  When a git repository is stored on a network
    share using SAMBA, file names are send over the wire and written to
    disk on the remote system in precomposed unicode, but Mac OS X
    readdir() returns decomposed unicode to be compatible with its
    behaviour on HFS+ and VFAT.
    
    The unicode decomposition causes many problems:
    
    - The names "git add" and other commands get from the end user may
      often be precomposed form (the decomposed form is not easily input
      from the keyboard), but when the commands read from the filesystem
      to see what it is going to update the index with already is on the
      filesystem, readdir() will give decomposed form, which is different.
    
    - Similarly "git log", "git mv" and all other commands that need to
      compare pathnames found on the command line (often but not always
      precomposed form; a command line input resulting from globbing may
      be in decomposed) with pathnames found in the tree objects (should
      be precomposed form to be compatible with other systems and for
      consistency in general).
    
    - The same for names stored in the index, which should be
      precomposed, that may need to be compared with the names read from
      readdir().
    
    NFS mounted from Linux is fully transparent and does not suffer from
    the above.
    
    As Mac OS X treats precomposed and decomposed file names as equal,
    we can
    
     - wrap readdir() on Mac OS X to return the precomposed form, and
    
     - normalize decomposed form given from the command line also to the
       precomposed form,
    
    to ensure that all pathnames used in Git are always in the
    precomposed form.  This behaviour can be requested by setting
    "core.precomposedunicode" configuration variable to true.
    
    The code in compat/precomposed_utf8.c implements basically 4 new
    functions: precomposed_utf8_opendir(), precomposed_utf8_readdir(),
    precomposed_utf8_closedir() and precompose_argv().  The first three
    are to wrap opendir(3), readdir(3), and closedir(3) functions.
    
    The argv[] conversion allows to use the TAB filename completion done
    by the shell on command line.  It tolerates other tools which use
    readdir() to feed decomposed file names into git.
    
    When creating a new git repository with "git init" or "git clone",
    "core.precomposedunicode" will be set "false".
    
    The user needs to activate this feature manually.  She typically
    sets core.precomposedunicode to "true" on HFS and VFAT, or file
    systems mounted via SAMBA.
    
    Helped-by: Junio C Hamano <gitster@pobox.com>
    Signed-off-by: Torsten Bögershausen <tboegi@web.de>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
Commits on May 8, 2012
  1. @pclouds @gitster

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

    pclouds committed with gitster May 6, 2012
    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 Mar 3, 2012
    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 Feb 28, 2012
    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 Feb 25, 2012
    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 Sep 27, 2011
    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 Aug 11, 2011
    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 Aug 11, 2011
    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 Jun 9, 2011
    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 Mar 22, 2011
    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 Dec 1, 2010
    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 Dec 1, 2010
    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 Dec 1, 2010
    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 Dec 1, 2010
    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 Dec 2, 2010
    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 Dec 2, 2010
    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 Dec 2, 2010
    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 Dec 5, 2010
    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 Jun 12, 2010
    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 May 17, 2010
    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 Mar 6, 2010
    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 Feb 16, 2010
    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 Jan 20, 2010
    * 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
Something went wrong with that request. Please try again.