config API users: test for *_get_value_multi() segfaults

As we'll discuss in the subsequent commit these tests all show *_get_value_multi() API users unable to handle there being a value-less key in the config, which is represented with a "NULL" for that entry in the "string" member of the returned "struct string_list", causing a segfault. These added tests exhaustively test for that issue, as we'll see in a subsequent commit we'll need to change all of the API users of *_get_value_multi(). These cases were discovered by triggering each one individually, and then adding these tests. Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Ævar Arnfjörð Bjarmason committed Mar 28, 2023 at 16:04 UTC 1c7e239bd0bc91d6296835e30fa597b8c56e752d
5 files changed +74
t/t4202-log.sh
+11
@@ -835,6 +835,17 @@ test_expect_success 'log.decorate configuration' '
835
836 '
837
838 +test_expect_failure 'parse log.excludeDecoration with no value' '
839 + cp .git/config .git/config.orig &&
840 + test_when_finished mv .git/config.orig .git/config &&
841 +
842 + cat >>.git/config <<-\EOF &&
843 + [log]
844 + excludeDecoration
845 + EOF
846 + git log --decorate=short
847 +'
848 +
849 test_expect_success 'decorate-refs with glob' '
850 cat >expect.decorate <<-\EOF &&
851 Merge-tag-reach
t/t5310-pack-bitmaps.sh
+16
@@ -404,6 +404,22 @@ test_bitmap_cases () {
404 )
405 '
406
407 + test_expect_failure 'pack.preferBitmapTips' '
408 + git init repo &&
409 + test_when_finished "rm -rf repo" &&
410 + (
411 + cd repo &&
412 + git config pack.writeBitmapLookupTable '"$writeLookupTable"' &&
413 + test_commit_bulk --message="%s" 103 &&
414 +
415 + cat >>.git/config <<-\EOF &&
416 + [pack]
417 + preferBitmapTips
418 + EOF
419 + git repack -adb
420 + )
421 + '
422 +
423 test_expect_success 'complains about multiple pack bitmaps' '
424 rm -fr repo &&
425 git init repo &&
t/t7004-tag.sh
+12
@@ -1843,6 +1843,18 @@ test_expect_success 'invalid sort parameter in configuratoin' '
1843 test_must_fail git tag -l "foo*"
1844 '
1845
1846 +test_expect_failure 'version sort handles empty value for versionsort.{prereleaseSuffix,suffix}' '
1847 + cp .git/config .git/config.orig &&
1848 + test_when_finished mv .git/config.orig .git/config &&
1849 +
1850 + cat >>.git/config <<-\EOF &&
1851 + [versionsort]
1852 + prereleaseSuffix
1853 + suffix
1854 + EOF
1855 + git tag -l --sort=version:refname
1856 +'
1857 +
1858 test_expect_success 'version sort with prerelease reordering' '
1859 test_config versionsort.prereleaseSuffix -rc &&
1860 git tag foo1.6-rc1 &&
t/t7413-submodule-is-active.sh
+12
@@ -51,6 +51,18 @@ test_expect_success 'is-active works with submodule.<name>.active config' '
51 test-tool -C super submodule is-active sub1
52 '
53
54 +test_expect_failure 'is-active handles submodule.active config missing a value' '
55 + cp super/.git/config super/.git/config.orig &&
56 + test_when_finished mv super/.git/config.orig super/.git/config &&
57 +
58 + cat >>super/.git/config <<-\EOF &&
59 + [submodule]
60 + active
61 + EOF
62 +
63 + test-tool -C super submodule is-active sub1
64 +'
65 +
66 test_expect_success 'is-active works with basic submodule.active config' '
67 test_when_finished "git -C super config submodule.sub1.URL ../sub" &&
68 test_when_finished "git -C super config --unset-all submodule.active" &&
t/t7900-maintenance.sh
+23
@@ -524,6 +524,29 @@ test_expect_success 'register and unregister' '
524 git maintenance unregister --config-file ./other --force
525 '
526
527 +test_expect_failure 'register with no value for maintenance.repo' '
528 + cp .git/config .git/config.orig &&
529 + test_when_finished mv .git/config.orig .git/config &&
530 +
531 + cat >>.git/config <<-\EOF &&
532 + [maintenance]
533 + repo
534 + EOF
535 + git maintenance register
536 +'
537 +
538 +test_expect_failure 'unregister with no value for maintenance.repo' '
539 + cp .git/config .git/config.orig &&
540 + test_when_finished mv .git/config.orig .git/config &&
541 +
542 + cat >>.git/config <<-\EOF &&
543 + [maintenance]
544 + repo
545 + EOF
546 + git maintenance unregister &&
547 + git maintenance unregister --force
548 +'
549 +
550 test_expect_success !MINGW 'register and unregister with regex metacharacters' '
551 META="a+b*c" &&
552 git init "$META" &&