diff options
author | Johannes Schindelin <johannes.schindelin@gmx.de> | 2019-03-14 04:25:04 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2019-03-18 11:44:14 +0900 |
commit | 1a85b49b87af0e17a503b94df10d0b39472ad5b8 (patch) | |
tree | 134e30676e6d083164858ce3bb7d40b914509f27 /Documentation/technical/api-parse-options.txt | |
parent | difftool: remove obsolete (and misleading) comment (diff) | |
download | tgif-1a85b49b87af0e17a503b94df10d0b39472ad5b8.tar.xz |
parse-options: make OPT_ARGUMENT() more useful
`OPT_ARGUMENT()` is intended to keep the specified long option in `argv`
and not to do anything else.
However, it would make a lot of sense for the caller to know whether
this option was seen at all or not. For example, we want to teach `git
difftool` to work outside of any Git worktree, but only when
`--no-index` was specified.
Note: nothing in Git uses OPT_ARGUMENT(). Even worse, looking through
the commit history, one can easily see that nothing even
ever used it, apart from the regression test.
So not only do we make `OPT_ARGUMENT()` more useful, we are also about
to introduce its first real user!
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'Documentation/technical/api-parse-options.txt')
-rw-r--r-- | Documentation/technical/api-parse-options.txt | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/Documentation/technical/api-parse-options.txt b/Documentation/technical/api-parse-options.txt index 2b036d7838..2e2e7c10c6 100644 --- a/Documentation/technical/api-parse-options.txt +++ b/Documentation/technical/api-parse-options.txt @@ -198,8 +198,10 @@ There are some macros to easily define options: The filename will be prefixed by passing the filename along with the prefix argument of `parse_options()` to `prefix_filename()`. -`OPT_ARGUMENT(long, description)`:: +`OPT_ARGUMENT(long, &int_var, description)`:: Introduce a long-option argument that will be kept in `argv[]`. + If this option was seen, `int_var` will be set to one (except + if a `NULL` pointer was passed). `OPT_NUMBER_CALLBACK(&var, description, func_ptr)`:: Recognize numerical options like -123 and feed the integer as |