builtin/config.c: treat type specifiers singularly
commit0a8950be5d5d8699b4c1f31116bdf896278db484
authorTaylor Blau <me@ttaylorr.com>
Mon, 9 Apr 2018 22:46:54 +0000 (9 15:46 -0700)
committerJunio C Hamano <gitster@pobox.com>
Tue, 10 Apr 2018 01:22:29 +0000 (10 10:22 +0900)
tree4daf908eef8bbe64cbaaa5842d6f4e765cf62664
parent03df4959472e7d4b5117bb72ac86e1e2bcf21723
builtin/config.c: treat type specifiers singularly

Internally, we represent `git config`'s type specifiers as a bitset
using OPT_BIT. 'bool' is 1<<0, 'int' is 1<<1, and so on. This technique
allows for the representation of multiple type specifiers in the `int
types` field, but this multi-representation is left unused.

In fact, `git config` will not accept multiple type specifiers at a
time, as indicated by:

  $ git config --int --bool some.section
  error: only one type at a time.

This patch uses `OPT_SET_INT` to prefer the _last_ mentioned type
specifier, so that the above command would instead be valid, and a
synonym of:

  $ git config --bool some.section

This change is motivated by two urges: (1) it does not make sense to
represent a singular type specifier internally as a bitset, only to
complain when there are multiple bits in the set. `OPT_SET_INT` is more
well-suited to this task than `OPT_BIT` is. (2) a future patch will
introduce `--type=<type>`, and we would like not to complain in the
following situation:

  $ git config --int --type=int

Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/config.c
t/t1300-repo-config.sh