summaryrefslogtreecommitdiff
path: root/parse-options.h
Commit message (Collapse)AuthorAgeFilesLines
* parse-options: move unsigned long option parsing out of pack-objects.ccb/parse-magnitudeCharles Bailey2015-06-221-0/+3
| | | | | | | | | | | | | | | | | | | The unsigned long option parsing (including 'k'/'m'/'g' suffix parsing) is more widely applicable. Add support for OPT_MAGNITUDE to parse-options.h and change pack-objects.c use this support. The error behavior on parse errors follows that of OPT_INTEGER. The name of the option that failed to parse is reported with a brief message describing the expect format for the option argument and then the full usage message for the command invoked. This differs from the previous behavior for OPT_ULONG used in pack-objects for --max-pack-size and --window-memory which used to display the value supplied in the error message and did not display the full usage message. Signed-off-by: Charles Bailey <cbailey32@bloomberg.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* Merge branch 'iu/fix-parse-options-h-comment'Junio C Hamano2015-04-141-2/+1
|\ | | | | | | | | * iu/fix-parse-options-h-comment: parse-options.h: OPTION_{BIT,SET_INT} do not store pointer to defval
| * parse-options.h: OPTION_{BIT,SET_INT} do not store pointer to defvaliu/fix-parse-options-h-commentIvan Ukhov2015-03-291-2/+1
| | | | | | | | | | | | | | | | | | | | When 20d1c652 (parse-options: remove unused OPT_SET_PTR, 2014-03-30) removed OPT_SET_PTR, the comment in the header that describes what the option did to defval field was left behind by mistake. Remove it. Signed-off-by: Ivan Ukhov <ivan.ukhov@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* | Merge branch 'jk/squelch-compiler-warning-from-funny-error-macro'Junio C Hamano2014-06-061-2/+2
|\ \ | | | | | | | | | | | | | | | * jk/squelch-compiler-warning-from-funny-error-macro: let clang use the constant-return error() macro inline constant return from error() function
| * | let clang use the constant-return error() macrojk/squelch-compiler-warning-from-funny-error-macroJeff King2014-05-061-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Commit e208f9c converted error() into a macro to make its constant return value more apparent to calling code. Commit 5ded807 prevents us using this macro with clang, since clang's -Wunused-value is smart enough to realize that the constant "-1" is useless in some contexts. However, since the last commit puts the constant behind an inline function call, this is enough to prevent the -Wunused-value warning on both modern gcc and clang. So we can now re-enable the macro when compiling with clang. Tested with clang 3.3, 3.4, and 3.5. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
| * | inline constant return from error() functionJeff King2014-05-061-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Commit e208f9c introduced a macro to turn error() calls into: (error(), -1) to make the constant return value more visible to the calling code (and thus let the compiler make better decisions about the code). This works well for code like: return error(...); but the "-1" is superfluous in code that just calls error() without caring about the return value. In older versions of gcc, that was fine, but gcc 4.9 complains with -Wunused-value. We can work around this by encapsulating the constant return value in a static inline function, as gcc specifically avoids complaining about unused function returns unless the function has been specifically marked with the warn_unused_result attribute. We also use the same trick for config_error_nonbool and opterror, which learned the same error technique in a469a10. Reported-by: Felipe Contreras <felipe.contreras@gmail.com> Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* | | Merge branch 'mr/opt-set-ptr'Junio C Hamano2014-04-081-4/+1
|\ \ \ | | |/ | |/| | | | | | | | | | | | | | | | | | | | | | 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
| * | parse-options: remove unused OPT_SET_PTRmr/opt-set-ptrMarat Radchenko2014-03-311-4/+1
| | | | | | | | | | | | | | | | | | | | | OPT_SET_PTR was never used since its creation at db7244bd (parse-options new features., 2007-11-07). Signed-off-by: Junio C Hamano <gitster@pobox.com>
| * | parse-options: add cast to correct pointer type to OPT_SET_PTRJunio C Hamano2014-03-311-1/+1
| |/ | | | | | | | | | | | | | | | | | | Do not force users of OPT_SET_PTR to cast pointer to correct underlying pointer type by integrating cast into OPT_SET_PTR macro. Cast is required to prevent 'initialization makes integer from pointer without a cast' compiler warning. Signed-off-by: Junio C Hamano <gitster@pobox.com>
* | parse-options: multi-word argh should use dash to separate wordsJunio C Hamano2014-03-241-1/+1
|/ | | | | | | | | | | | | | | | | | "When you need to use space, use dash" is a strange way to say that you must not use a space. Because it is more common for the command line descriptions to use dashed-multi-words, you do not even want to use spaces in these places. Rephrase the documentation to avoid this strangeness. Fix a few existing multi-word argument help strings, i.e. - GPG key-ids given to -S/--gpg-sign are "key-id"; - Refs used for storing notes are "notes-ref"; and - Expiry timestamps given to --expire are "expiry-date". and update the corresponding documentation pages. Signed-off-by: Junio C Hamano <gitster@pobox.com>
* parse-options: remove OPT_BOOLEANnd/remove-opt-booleanNguyễn Thái Ngọc Duy2013-12-091-7/+4
| | | | | | | | | | | | | | | After a86a8b9 (sb/parseopt-boolean-removal), the deprecated OPT_BOOLEAN is not used anywhere except by OPT__* macros. Kill OPT_BOOLEAN and make OPT__* use OPT_COUNTUP directly instead. This should stop OPT_BOOLEAN from entering the tree again in new patches. OPT__DRY_RUN() is converted to use OPT_BOOL though because it does not make sense to increase the level of dryness. All OPT__DRY_RUN call sites have been checked and they look safe for OPT_BOOL. Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Reviewed-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* Merge branch 'sb/parseopt-boolean-removal'Junio C Hamano2013-09-041-3/+2
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Convert most uses of OPT_BOOLEAN/OPTION_BOOLEAN that can use OPT_BOOL/OPTION_BOOLEAN which have much saner semantics, and turn remaining ones into OPT_SET_INT, OPT_COUNTUP, etc. as necessary. * sb/parseopt-boolean-removal: revert: use the OPT_CMDMODE for parsing, reducing code checkout-index: fix negations of even numbers of -n config parsing options: allow one flag multiple times hash-object: replace stdin parsing OPT_BOOLEAN by OPT_COUNTUP branch, commit, name-rev: ease up boolean conditions checkout: remove superfluous local variable log, format-patch: parsing uses OPT__QUIET Replace deprecated OPT_BOOLEAN by OPT_BOOL Remove deprecated OPTION_BOOLEAN for parsing arguments
| * Remove deprecated OPTION_BOOLEAN for parsing argumentsStefan Beller2013-08-051-3/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | As of b04ba2bb4 OPTION_BOOLEAN was deprecated. This commit removes all occurrences of OPTION_BOOLEAN. In b04ba2bb4 Junio suggested to replace it with either OPTION_SET_INT or OPTION_COUNTUP instead. However a pattern, which occurred often with the OPTION_BOOLEAN was a hidden boolean parameter. So I defined OPT_HIDDEN_BOOL as an additional possible parse option in parse-options.h to make life easy. The OPT_HIDDEN_BOOL was used in checkout, clone, commit, show-ref. The only exception, where there was need to fiddle with OPTION_SET_INT was log and notes. However in these two files there is also a pattern, so we could think of introducing OPT_NONEG_BOOL. Signed-off-by: Stefan Beller <stefanbeller@googlemail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* | Merge branch 'jc/parseopt-command-modes'Junio C Hamano2013-09-041-0/+3
|\ \ | |/ | | | | | | | | | | | | | | | | | | | | Many commands use --dashed-option as a operation mode selector (e.g. "git tag --delete") that the user can use at most one (e.g. "git tag --delete --verify" is a nonsense) and you cannot negate (e.g. "git tag --no-delete" is a nonsense). Make it easier for users of parse_options() to enforce these restrictions. * jc/parseopt-command-modes: tag: use OPT_CMDMODE parse-options: add OPT_CMDMODE()
| * parse-options: add OPT_CMDMODE()Junio C Hamano2013-07-301-0/+3
| | | | | | | | | | | | | | | | 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>
* | Merge branch 'maint'Junio C Hamano2013-08-091-1/+1
|\ \ | |/ |/| | | | | * maint: parse-options: fix clang opterror() -Wunused-value warning
| * parse-options: fix clang opterror() -Wunused-value warningEric Sunshine2013-08-091-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | a469a1019352b8ef (silence some -Wuninitialized false positives; 2012-12-15) triggered "unused value" warnings when the return value of opterror() and several other error-related functions was not used. 5ded807f7c0be10e (fix clang -Wunused-value warnings for error functions; 2013-01-16) applied a fix by adding #if !defined(__clang__) in cache.h and git-compat-util.h, but misspelled it as #if !defined(clang) in parse-options.h. Fix this. This mistake went unnoticed because existing callers of opterror() utilize its return value. 1158826394e162c5 (parse-options: add OPT_CMDMODE(); 2013-07-30), however, adds a new invocation of opterror() which ignores the return value, thus triggering the "unused value" warning. Signed-off-by: Eric Sunshine <sunshine@sunshineco.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* | Merge branch 'jc/prune-all'Junio C Hamano2013-05-291-0/+4
|\ \ | |/ |/| | | | | | | | | | | | | | | | | | | | | | | We used the approxidate() parser for "--expire=<timestamp>" options of various commands, but it is better to treat --expire=all and --expire=now a bit more specially than using the current timestamp. Update "git gc" and "git reflog" with a new parsing function for expiry dates. * jc/prune-all: prune: introduce OPT_EXPIRY_DATE() and use it api-parse-options.txt: document "no-" for non-boolean options git-gc.txt, git-reflog.txt: document new expiry options date.c: add parse_expiry_date()
| * prune: introduce OPT_EXPIRY_DATE() and use itJunio C Hamano2013-04-251-0/+4
| | | | | | | | | | | | | | | | | | | | | | Earlier we added support for --expire=all (or --expire=now) that considers all crufts, regardless of their age, as eligible for garbage collection by turning command argument parsers that use approxidate() to use parse_expiry_date(), but "git prune" used a built-in parse-options facility OPT_DATE() and did not benefit from the new function. Signed-off-by: Junio C Hamano <gitster@pobox.com>
* | fix clang -Wunused-value warnings for error functionsMax Horn2013-01-161-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Commit a469a10 wraps some error calls in macros to give the compiler a chance to do more static analysis on their constant -1 return value. We limit the use of these macros to __GNUC__, since gcc is the primary beneficiary of the new information, and because we use GNU features for handling variadic macros. However, clang also defines __GNUC__, but generates warnings with -Wunused-value when these macros are used in a void context, because the constant "-1" ends up being useless. Gcc does not complain about this case (though it is unclear if it is because it is smart enough to see what we are doing, or too dumb to realize that the -1 is unused). We can squelch the warning by just disabling these macros when clang is in use. Signed-off-by: Max Horn <max@quendi.de> Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* | silence some -Wuninitialized false positivesJeff King2012-12-151-0/+4
|/ | | | | | | | | | | | | | | | | | | | 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>
* i18n: mark "style" in OPT_COLUMN() for translationNguyễn Thái Ngọc Duy2012-08-201-1/+1
| | | | | Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* i18n: parseopt: lookup help and argument translations when showing usageNguyễn Thái Ngọc Duy2012-05-081-11/+14
| | | | | Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* Merge branch 'nd/columns'Junio C Hamano2012-05-031-0/+2
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | A couple of commands learn --column option to produce columnar output. By Nguyễn Thái Ngọc Duy (9) and Zbigniew Jędrzejewski-Szmek (1) * nd/columns: tag: add --column column: support piping stdout to external git-column process status: add --column branch: add --column help: reuse print_columns() for help -a column: add dense layout support t9002: work around shells that are unable to set COLUMNS to 1 column: add columnar layout Stop starting pager recursively Add column layout skeleton and git-column
| * Add column layout skeleton and git-columnNguyễn Thái Ngọc Duy2012-04-271-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | A column option string consists of many token separated by either a space or a comma. A token belongs to one of three groups: - enabling: always, never and auto - layout mode: currently plain (which does not layout at all) - other future tuning flags git-column can be used to pipe output to from a command that wants column layout, but not to mess with its own output code. Simpler output code can be changed to use column layout code directly. Thanks-to: Ramsay Jones <ramsay@ramsay1.demon.co.uk> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* | parse-options: remove PARSE_OPT_NEGHELPrs/no-no-no-parseoptRené Scharfe2012-02-281-4/+0
|/ | | | | | | | | | | | 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>
* parseopt: add OPT_NOOP_NOARGRené Scharfe2011-09-281-0/+6
| | | | | | | | | | | | Add OPT_NOOP_NOARG, a helper macro to define deprecated options in a standard way. The help text is taken from the no-op option -r of git revert. The callback could be made to emit a (conditional?) warning later. And we could also add OPT_NOOP (requiring an argument) etc. as needed. Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* parse-options: deprecate OPT_BOOLEANJunio C Hamano2011-09-271-2/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* parse-options: export opterr, optbugDmitry Ivankov2011-08-111-0/+2
| | | | | | | | | | | 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>
* parse-options: add OPT_STRING_LIST helperJeff King2011-06-221-0/+4
| | | | | | | | | 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>
* Make <identifier> lowercase as per CodingGuidelinesMichael J Gruber2011-02-151-1/+1
| | | | | | | parse-options part Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* Merge branch 'jn/parse-options-extra'Junio C Hamano2010-12-121-2/+9
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | * jn/parse-options-extra: update-index: migrate to parse-options API setup: save prefix (original cwd relative to toplevel) in startup_info parse-options: make resuming easier after PARSE_OPT_STOP_AT_NON_OPTION parse-options: allow git commands to invent new option types parse-options: never suppress arghelp if LITERAL_ARGHELP is set parse-options: do not infer PARSE_OPT_NOARG from option type parse-options: sanity check PARSE_OPT_NOARG flag parse-options: move NODASH sanity checks to parse_options_check parse-options: clearer reporting of API misuse parse-options: Don't call parse_options_check() so much
| * parse-options: make resuming easier after PARSE_OPT_STOP_AT_NON_OPTIONJonathan Nieder2010-12-071-0/+1
| | | | | | | | | | | | | | | | | | 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>
| * parse-options: allow git commands to invent new option typesJonathan Nieder2010-12-071-1/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
| * parse-options: Don't call parse_options_check() so muchStephen Boyd2010-12-061-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* | add OPT__FORCERené Scharfe2010-11-151-0/+1
| | | | | | | | | | | | | | | | Add OPT__FORCE as a helper macro in the same spirit as OPT__VERBOSE et.al. to simplify defining -f/--force options. Signed-off-by: Rene Scharfe <rene.scharfe@lstfire.ath.cx> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* | add description parameter to OPT__QUIETRené Scharfe2010-11-151-1/+1
| | | | | | | | | | | | | | | | | | Allows better help text to be defined than "be quiet". Also make use of the macro in a place that already had a different description. No object code changes intended. Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* | add description parameter to OPT__DRY_RUNRené Scharfe2010-11-151-1/+1
| | | | | | | | | | | | | | | | | | Allows better help text to be defined than "dry run". Also make use of the macro in places that already had a different description. No object code changes intended. Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* | add description parameter to OPT__VERBOSERené Scharfe2010-11-151-1/+1
|/ | | | | | | | | Allows better help text to be defined than "be verbose". Also make use of the macro in places that already had a different description. No object code changes intended. Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* parse-options: clarify PARSE_OPT_NOARG descriptionJonathan Nieder2010-08-241-1/+1
| | | | | | | | | | | Here "takes no argument" means "does not take an argument". The latter phrasing might make it clearer that PARSE_OPT_NOARG does not make an option with an argument that can optionally be left off. Noticed-by: Ramkumar Ramachandra <artagnon@gmail.com> Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* Merge branch 'gs/usage-to-stdout'Junio C Hamano2010-06-211-1/+2
|\ | | | | | | | | | | | | | | | | * gs/usage-to-stdout: parseopt: wrap rev-parse --parseopt usage for eval consumption print the usage string on stdout instead of stderr Conflicts: parse-options.h
| * parseopt: wrap rev-parse --parseopt usage for eval consumptionThomas Rast2010-06-131-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* | enums: omit trailing comma for portabilityGary V. Vaughan2010-05-311-3/+3
|/ | | | | | | | | | | | | | | | | | | Without this patch at least IBM VisualAge C 5.0 (I have 5.0.2) on AIX 5.1 fails to compile git. enum style is inconsistent already, with some enums declared on one line, some over 3 lines with the enum values all on the middle line, sometimes with 1 enum value per line... and independently of that the trailing comma is sometimes present and other times absent, often mixing with/without trailing comma styles in a single file, and sometimes in consecutive enum declarations. Clearly, omitting the comma is the more portable style, and this patch changes all enum declarations to use the portable omitted dangling comma style consistently. Signed-off-by: Gary V. Vaughan <gary@thewrittenword.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* parse-options: add parse_options_concat() to concat optionsJunio C Hamano2010-03-061-0/+1
| | | | | Signed-off-by: Christian Couder <chriscool@tuxfamily.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* Add an optional argument for --color optionsMark Lodato2010-02-181-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | 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>
* Merge branch 'jc/symbol-static'Junio C Hamano2010-01-201-3/+0
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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
| * parse-options.c: mark file-local function staticJunio C Hamano2010-01-121-3/+0
| | | | | | | | Signed-off-by: Junio C Hamano <gitster@pobox.com>
* | Teach --[no-]rerere-autoupdate option to merge, revert and friendsJunio C Hamano2009-12-041-0/+3
|/ | | | | | | 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>
* Merge branch 'cc/replace'Junio C Hamano2009-08-211-0/+4
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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
| * parse-options: add new function "usage_msg_opt"Christian Couder2009-05-311-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>