From: "Johannes Schindelin via GitGitGadget" <gitgitgadget@gmail.com>
To: git@vger.kernel.org
Cc: Johannes Schindelin <johannes.schindelin@gmx.de>,
Johannes Schindelin <johannes.schindelin@gmx.de>
Subject: [PATCH] setup: warn about un-enabled extensions
Date: Mon, 13 Jul 2020 21:55:20 +0000 [thread overview]
Message-ID: <pull.675.git.1594677321039.gitgitgadget@gmail.com> (raw)
From: Johannes Schindelin <johannes.schindelin@gmx.de>
When any `extensions.*` setting is configured, we newly ignore it unless
`core.repositoryFormatVersion` is set to a positive value.
This might be quite surprising, e.g. when calling `git config --worktree
[...]` elicits a warning that it requires
`extensions.worktreeConfig = true` when that setting _is_ configured
(but ignored because `core.repositoryFormatVersion` is unset).
Let's warn about this situation specifically, especially because there
might be already setups out there that configured a sparse worktree
using Git v2.27.0 (which does set `extensions.worktreeConfig` but not
`core.repositoryFormatVersion`) and users might want to work in those
setups with Git v2.28.0, too.
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
Warn when extensions.* is ignored
I did actually run into this today. One of my pipelines is configured to
clone a bare repository, then set up a sparse secondary worktree. This
used to work, but all of a sudden, the git config --worktree
core.sparseCheckout true call failed because I'm now using v2.28.0-rc0.
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-675%2Fdscho%2Frepo-format-version-advice-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-675/dscho/repo-format-version-advice-v1
Pull-Request: https://github.com/gitgitgadget/git/pull/675
cache.h | 2 +-
setup.c | 16 +++++++++++++++-
t/t2404-worktree-config.sh | 15 +++++++++++++++
3 files changed, 31 insertions(+), 2 deletions(-)
diff --git a/cache.h b/cache.h
index 126ec56c7f..da2c71f366 100644
--- a/cache.h
+++ b/cache.h
@@ -1042,7 +1042,7 @@ struct repository_format {
int worktree_config;
int is_bare;
int hash_algo;
- int has_extensions;
+ int has_extensions, saw_extensions;
char *work_tree;
struct string_list unknown_extensions;
};
diff --git a/setup.c b/setup.c
index dbac2eabe8..0f45e2e174 100644
--- a/setup.c
+++ b/setup.c
@@ -489,6 +489,15 @@ static int check_repository_format_gently(const char *gitdir, struct repository_
read_repository_format(candidate, sb.buf);
strbuf_release(&sb);
+ if (candidate->version < 1 &&
+ (candidate->saw_extensions || candidate->has_extensions))
+ advise(_("extensions.* settings require a positive repository "
+ "format version greater than zero.\n"
+ "\n"
+ "Please use the following call to enable extensions.* "
+ "config settings:\n"
+ "\"git config core.repositoryFormatVersion 1\""));
+
/*
* For historical use of check_repository_format() in git-init,
* we treat a missing config as a silent "ok", even when nongit_ok
@@ -584,8 +593,13 @@ int read_repository_format(struct repository_format *format, const char *path)
{
clear_repository_format(format);
git_config_from_file(check_repo_format, path, format);
- if (format->version == -1)
+ if (format->version == -1) {
+ int saw_extensions = format->has_extensions;
+
clear_repository_format(format);
+
+ format->saw_extensions = saw_extensions;
+ }
return format->version;
}
diff --git a/t/t2404-worktree-config.sh b/t/t2404-worktree-config.sh
index 9536d10919..1c08a45177 100755
--- a/t/t2404-worktree-config.sh
+++ b/t/t2404-worktree-config.sh
@@ -78,4 +78,19 @@ test_expect_success 'config.worktree no longer read without extension' '
test_cmp_config -C wt2 shared this.is
'
+test_expect_success 'show advice when extensions.* are not enabled' '
+ test_config core.repositoryformatversion 1 &&
+ test_config extensions.worktreeConfig true &&
+ git status 2>err &&
+ test_i18ngrep ! "git config core.repositoryFormatVersion 1" err &&
+
+ test_config core.repositoryformatversion 0 &&
+ git status 2>err &&
+ test_i18ngrep "git config core.repositoryFormatVersion 1" err &&
+
+ git config --unset core.repositoryformatversion &&
+ git status 2>err &&
+ test_i18ngrep "git config core.repositoryFormatVersion 1" err
+'
+
test_done
base-commit: bd42bbe1a46c0fe486fc33e82969275e27e4dc19
--
gitgitgadget
next reply other threads:[~2020-07-13 21:55 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-13 21:55 Johannes Schindelin via GitGitGadget [this message]
2020-07-13 22:48 ` [PATCH] setup: warn about un-enabled extensions Junio C Hamano
2020-07-14 0:24 ` Derrick Stolee
2020-07-14 12:21 ` Johannes Schindelin
2020-07-14 15:27 ` Junio C Hamano
2020-07-14 15:40 ` Derrick Stolee
2020-07-14 20:30 ` Johannes Schindelin
2020-07-14 20:47 ` Junio C Hamano
2020-07-15 16:09 ` Junio C Hamano
2020-07-15 17:01 ` Junio C Hamano
2020-07-15 18:00 ` Derrick Stolee
2020-07-15 18:09 ` Junio C Hamano
2020-07-15 18:40 ` Derrick Stolee
2020-07-15 19:16 ` Johannes Schindelin
2020-07-15 18:15 ` Junio C Hamano
2020-07-15 19:21 ` Johannes Schindelin
2020-07-15 18:20 ` Jonathan Nieder
2020-07-16 2:06 ` Junio C Hamano
2020-07-16 6:20 ` [PATCH 0/2] extensions.* fixes for 2.28 (Re: [PATCH] setup: warn about un-enabled extensions) Jonathan Nieder
2020-07-16 6:24 ` [PATCH 1/2] Revert "check_repository_format_gently(): refuse extensions for old repositories" Jonathan Nieder
2020-07-16 10:56 ` Jeff King
2020-07-16 6:28 ` [PATCH 2/2] repository: allow repository format upgrade with extensions Jonathan Nieder
2020-07-16 7:01 ` Junio C Hamano
2020-07-16 11:00 ` Jeff King
2020-07-16 12:25 ` Jeff King
2020-07-16 12:53 ` Derrick Stolee
2020-07-16 16:32 ` Junio C Hamano
2020-07-16 16:53 ` Jeff King
2020-07-16 20:27 ` Junio C Hamano
2020-07-16 16:49 ` Junio C Hamano
2020-07-16 16:56 ` Jeff King
2020-07-16 16:10 ` Junio C Hamano
2020-07-16 22:37 ` Jonathan Nieder
2020-07-16 23:50 ` Junio C Hamano
2020-07-17 15:27 ` Jeff King
2020-07-17 17:07 ` Junio C Hamano
2020-07-17 15:22 ` Jeff King
2020-07-16 8:13 ` [PATCH 0/2] extensions.* fixes for 2.28 (Re: [PATCH] setup: warn about un-enabled extensions) Johannes Schindelin
2020-07-16 12:17 ` Derrick Stolee
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=pull.675.git.1594677321039.gitgitgadget@gmail.com \
--to=gitgitgadget@gmail.com \
--cc=git@vger.kernel.org \
--cc=johannes.schindelin@gmx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).