@matheusbsbs / matheus-bagliano / commits / 98564d8059
Fork 0

sparse-checkout: upgrade repository to version 1 when enabling extension

The 'extensions' configuration variable gets special meaning in the new repository version, so when enabling the extension we should upgrade the repository to version 1. Signed-off-by: Xin Li <delphij@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Xin Li committed Jun 5, 2020 at 02:10 UTC 98564d805938cae8b72687a9e39d65b00ac7ad27
2 files changed +5 -1
builtin/sparse-checkout.c
+2
@@ -249,6 +249,8 @@ static int set_config(enum sparse_checkout_mode mode)
249 {
250 const char *config_path;
251
252 + if (upgrade_repository_format(1) < 0)
253 + die(_("unable to upgrade repository format to enable worktreeConfig"));
254 if (git_config_set_gently("extensions.worktreeConfig", "true")) {
255 error(_("failed to set extensions.worktreeConfig setting"));
256 return 1;
t/t2404-worktree-config.sh
+3 -1
@@ -23,8 +23,10 @@ test_expect_success 'config --worktree without extension' '
23 '
24
25 test_expect_success 'enable worktreeConfig extension' '
26 + git config core.repositoryformatversion 1 &&
27 git config extensions.worktreeConfig true &&
27 - test_cmp_config true extensions.worktreeConfig
28 + test_cmp_config true extensions.worktreeConfig &&
29 + test_cmp_config 1 core.repositoryformatversion
30 '
31
32 test_expect_success 'config is shared as before' '