summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2020-07-17 00:58:42 (GMT)
committerJunio C Hamano <gitster@pobox.com>2020-07-17 00:58:42 (GMT)
commitd13b7f21989335c0ac14e3a0c7eaaee0bc30ea70 (patch)
treebef23ee949b0c34d0bc9d4ee908e26b116cc62b8
parentb6a658bd00c9c29e07f833cabfc0ef12224e277a (diff)
parent62f2eca6065d0c27b0ea3b7806a590466ea04960 (diff)
downloadgit-d13b7f21989335c0ac14e3a0c7eaaee0bc30ea70.zip
git-d13b7f21989335c0ac14e3a0c7eaaee0bc30ea70.tar.gz
git-d13b7f21989335c0ac14e3a0c7eaaee0bc30ea70.tar.bz2
Merge branch 'jn/v0-with-extensions-fix' into master
In 2.28-rc0, we corrected a bug that some repository extensions are honored by mistake even in a version 0 repositories (these configuration variables in extensions.* namespace were supposed to have special meaning in repositories whose version numbers are 1 or higher), but this was a bit too big a change. * jn/v0-with-extensions-fix: repository: allow repository format upgrade with extensions Revert "check_repository_format_gently(): refuse extensions for old repositories"
-rw-r--r--cache.h1
-rw-r--r--setup.c24
-rwxr-xr-xt/t0410-partial-clone.sh15
3 files changed, 23 insertions, 17 deletions
diff --git a/cache.h b/cache.h
index 126ec56..6544264 100644
--- a/cache.h
+++ b/cache.h
@@ -1042,7 +1042,6 @@ struct repository_format {
int worktree_config;
int is_bare;
int hash_algo;
- int has_extensions;
char *work_tree;
struct string_list unknown_extensions;
};
diff --git a/setup.c b/setup.c
index dbac2ea..3a81307 100644
--- a/setup.c
+++ b/setup.c
@@ -455,7 +455,6 @@ static int check_repo_format(const char *var, const char *value, void *vdata)
if (strcmp(var, "core.repositoryformatversion") == 0)
data->version = git_config_int(var, value);
else if (skip_prefix(var, "extensions.", &ext)) {
- data->has_extensions = 1;
/*
* record any known extensions here; otherwise,
* we fall through to recording it as unknown, and
@@ -507,15 +506,9 @@ static int check_repository_format_gently(const char *gitdir, struct repository_
die("%s", err.buf);
}
- if (candidate->version >= 1) {
- repository_format_precious_objects = candidate->precious_objects;
- set_repository_format_partial_clone(candidate->partial_clone);
- repository_format_worktree_config = candidate->worktree_config;
- } else {
- repository_format_precious_objects = 0;
- set_repository_format_partial_clone(NULL);
- repository_format_worktree_config = 0;
- }
+ repository_format_precious_objects = candidate->precious_objects;
+ set_repository_format_partial_clone(candidate->partial_clone);
+ repository_format_worktree_config = candidate->worktree_config;
string_list_clear(&candidate->unknown_extensions, 0);
if (repository_format_worktree_config) {
@@ -559,13 +552,16 @@ int upgrade_repository_format(int target_version)
if (repo_fmt.version >= target_version)
return 0;
- if (verify_repository_format(&repo_fmt, &err) < 0 ||
- (!repo_fmt.version && repo_fmt.has_extensions)) {
- warning("unable to upgrade repository format from %d to %d: %s",
- repo_fmt.version, target_version, err.buf);
+ if (verify_repository_format(&repo_fmt, &err) < 0) {
+ error("cannot upgrade repository format from %d to %d: %s",
+ repo_fmt.version, target_version, err.buf);
strbuf_release(&err);
return -1;
}
+ if (!repo_fmt.version && repo_fmt.unknown_extensions.nr)
+ return error("cannot upgrade repository format: "
+ "unknown extension %s",
+ repo_fmt.unknown_extensions.items[0].string);
strbuf_addf(&repo_version, "%d", target_version);
git_config_set("core.repositoryformatversion", repo_version.buf);
diff --git a/t/t0410-partial-clone.sh b/t/t0410-partial-clone.sh
index 463dc3a..6aa0f31 100755
--- a/t/t0410-partial-clone.sh
+++ b/t/t0410-partial-clone.sh
@@ -42,14 +42,25 @@ test_expect_success 'convert shallow clone to partial clone' '
test_cmp_config -C client 1 core.repositoryformatversion
'
-test_expect_success 'convert shallow clone to partial clone must fail with any extension' '
+test_expect_success 'convert to partial clone with noop extension' '
rm -fr server client &&
test_create_repo server &&
test_commit -C server my_commit 1 &&
test_commit -C server my_commit2 1 &&
git clone --depth=1 "file://$(pwd)/server" client &&
test_cmp_config -C client 0 core.repositoryformatversion &&
- git -C client config extensions.partialclone origin &&
+ git -C client config extensions.noop true &&
+ git -C client fetch --unshallow --filter="blob:none"
+'
+
+test_expect_success 'converting to partial clone fails with unrecognized extension' '
+ rm -fr server client &&
+ test_create_repo server &&
+ test_commit -C server my_commit 1 &&
+ test_commit -C server my_commit2 1 &&
+ git clone --depth=1 "file://$(pwd)/server" client &&
+ test_cmp_config -C client 0 core.repositoryformatversion &&
+ git -C client config extensions.nonsense true &&
test_must_fail git -C client fetch --unshallow --filter="blob:none"
'