Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2023-09-20 20:45:12 +0300
committerJunio C Hamano <gitster@pobox.com>2023-09-20 20:45:16 +0300
commit3c2af826a35ecba8533748db5bd0a4dbda2d33db (patch)
tree22eb0337f8113684e786a42a395c574ffb286355 /builtin/update-index.c
parent767e4d68c7dab58e55c4f43ee8a490c946e480b8 (diff)
parent83708f80fc5fc7202df0bf3c0951f85d31249fe3 (diff)
Merge branch 'jc/update-index-show-index-version'
"git update-index" learns "--show-index-version" to inspect the index format version used by the on-disk index file. * jc/update-index-show-index-version: test-tool: retire "index-version" update-index: add --show-index-version update-index doc: v4 is OK with JGit and libgit2
Diffstat (limited to 'builtin/update-index.c')
-rw-r--r--builtin/update-index.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/builtin/update-index.c b/builtin/update-index.c
index 59acae3336..97617c587e 100644
--- a/builtin/update-index.c
+++ b/builtin/update-index.c
@@ -1090,6 +1090,8 @@ int cmd_update_index(int argc, const char **argv, const char *prefix)
resolve_undo_clear_callback),
OPT_INTEGER(0, "index-version", &preferred_index_format,
N_("write index in this format")),
+ OPT_SET_INT(0, "show-index-version", &preferred_index_format,
+ N_("report on-disk index format version"), -1),
OPT_BOOL(0, "split-index", &split_index,
N_("enable or disable split index")),
OPT_BOOL(0, "untracked-cache", &untracked_cache,
@@ -1182,15 +1184,20 @@ int cmd_update_index(int argc, const char **argv, const char *prefix)
getline_fn = nul_term_line ? strbuf_getline_nul : strbuf_getline_lf;
if (preferred_index_format) {
- if (preferred_index_format < INDEX_FORMAT_LB ||
- INDEX_FORMAT_UB < preferred_index_format)
+ if (preferred_index_format < 0) {
+ printf(_("%d\n"), the_index.version);
+ } else if (preferred_index_format < INDEX_FORMAT_LB ||
+ INDEX_FORMAT_UB < preferred_index_format) {
die("index-version %d not in range: %d..%d",
preferred_index_format,
INDEX_FORMAT_LB, INDEX_FORMAT_UB);
-
- if (the_index.version != preferred_index_format)
- the_index.cache_changed |= SOMETHING_CHANGED;
- the_index.version = preferred_index_format;
+ } else {
+ if (the_index.version != preferred_index_format)
+ the_index.cache_changed |= SOMETHING_CHANGED;
+ report(_("index-version: was %d, set to %d"),
+ the_index.version, preferred_index_format);
+ the_index.version = preferred_index_format;
+ }
}
if (read_from_stdin) {