summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorTaylor Blau <me@ttaylorr.com>2018-04-09 22:46:54 (GMT)
committerJunio C Hamano <gitster@pobox.com>2018-04-10 01:22:29 (GMT)
commit0a8950be5d5d8699b4c1f31116bdf896278db484 (patch)
tree4daf908eef8bbe64cbaaa5842d6f4e765cf62664 /t
parent03df4959472e7d4b5117bb72ac86e1e2bcf21723 (diff)
downloadgit-0a8950be5d5d8699b4c1f31116bdf896278db484.zip
git-0a8950be5d5d8699b4c1f31116bdf896278db484.tar.gz
git-0a8950be5d5d8699b4c1f31116bdf896278db484.tar.bz2
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>
Diffstat (limited to 't')
-rwxr-xr-xt/t1300-repo-config.sh11
1 files changed, 11 insertions, 0 deletions
diff --git a/t/t1300-repo-config.sh b/t/t1300-repo-config.sh
index 4f8e6f5..24de37d 100755
--- a/t/t1300-repo-config.sh
+++ b/t/t1300-repo-config.sh
@@ -1611,4 +1611,15 @@ test_expect_success '--local requires a repo' '
test_expect_code 128 nongit git config --local foo.bar
'
+cat >.git/config <<-\EOF &&
+[core]
+number = 10
+EOF
+
+test_expect_success 'later legacy specifiers are given precedence' '
+ git config --bool --int core.number >actual &&
+ echo 10 >expect &&
+ test_cmp expect actual
+'
+
test_done