Skip to content

Commit 98564d8

Browse files
delphijgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 01bbbbd commit 98564d8

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

builtin/sparse-checkout.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,8 @@ static int set_config(enum sparse_checkout_mode mode)
249249
{
250250
const char *config_path;
251251

252+
if (upgrade_repository_format(1) < 0)
253+
die(_("unable to upgrade repository format to enable worktreeConfig"));
252254
if (git_config_set_gently("extensions.worktreeConfig", "true")) {
253255
error(_("failed to set extensions.worktreeConfig setting"));
254256
return 1;

t/t2404-worktree-config.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,10 @@ test_expect_success 'config --worktree without extension' '
2323
'
2424

2525
test_expect_success 'enable worktreeConfig extension' '
26+
git config core.repositoryformatversion 1 &&
2627
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
2830
'
2931

3032
test_expect_success 'config is shared as before' '

0 commit comments

Comments
 (0)