]> git.ipfire.org Git - thirdparty/git.git/commitdiff
Merge branch 'jc/update-index-show-index-version'
authorJunio C Hamano <gitster@pobox.com>
Wed, 20 Sep 2023 17:45:12 +0000 (10:45 -0700)
committerJunio C Hamano <gitster@pobox.com>
Wed, 20 Sep 2023 17:45:16 +0000 (10:45 -0700)
"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

1  2 
Makefile
builtin/update-index.c

diff --combined Makefile
index 5776309365357a5848c5f03214690e75d7deb57c,5323c76aa067ccb16db0db191773258d7d31a44e..003e63b792e39731e3baa771f3ff669917f98838
+++ b/Makefile
@@@ -808,7 -808,6 +808,6 @@@ TEST_BUILTINS_OBJS += test-hash-speed.
  TEST_BUILTINS_OBJS += test-hash.o
  TEST_BUILTINS_OBJS += test-hashmap.o
  TEST_BUILTINS_OBJS += test-hexdump.o
- TEST_BUILTINS_OBJS += test-index-version.o
  TEST_BUILTINS_OBJS += test-json-writer.o
  TEST_BUILTINS_OBJS += test-lazy-init-name-hash.o
  TEST_BUILTINS_OBJS += test-match-trees.o
@@@ -1051,6 -1050,7 +1050,6 @@@ LIB_OBJS += linear-assignment.
  LIB_OBJS += list-objects-filter-options.o
  LIB_OBJS += list-objects-filter.o
  LIB_OBJS += list-objects.o
 -LIB_OBJS += ll-merge.o
  LIB_OBJS += lockfile.o
  LIB_OBJS += log-tree.o
  LIB_OBJS += ls-refs.o
@@@ -1059,7 -1059,6 +1058,7 @@@ LIB_OBJS += mailmap.
  LIB_OBJS += match-trees.o
  LIB_OBJS += mem-pool.o
  LIB_OBJS += merge-blobs.o
 +LIB_OBJS += merge-ll.o
  LIB_OBJS += merge-ort.o
  LIB_OBJS += merge-ort-wrappers.o
  LIB_OBJS += merge-recursive.o
@@@ -1142,7 -1141,6 +1141,7 @@@ LIB_OBJS += sigchain.
  LIB_OBJS += sparse-index.o
  LIB_OBJS += split-index.o
  LIB_OBJS += stable-qsort.o
 +LIB_OBJS += statinfo.o
  LIB_OBJS += strbuf.o
  LIB_OBJS += streaming.o
  LIB_OBJS += string-list.o
@@@ -1952,7 -1950,7 +1951,7 @@@ endi
        BASIC_CFLAGS += \
                -DSHA1DC_NO_STANDARD_INCLUDES \
                -DSHA1DC_INIT_SAFE_HASH_DEFAULT=0 \
 -              -DSHA1DC_CUSTOM_INCLUDE_SHA1_C="\"cache.h\"" \
 +              -DSHA1DC_CUSTOM_INCLUDE_SHA1_C="\"git-compat-util.h\"" \
                -DSHA1DC_CUSTOM_INCLUDE_UBC_CHECK_C="\"git-compat-util.h\""
  endif
  endif
@@@ -2743,8 -2741,8 +2742,8 @@@ exec-cmd.sp exec-cmd.s exec-cmd.o: EXTR
        '-DBINDIR="$(bindir_relative_SQ)"' \
        '-DFALLBACK_RUNTIME_PREFIX="$(prefix_SQ)"'
  
 -builtin/init-db.sp builtin/init-db.s builtin/init-db.o: GIT-PREFIX
 -builtin/init-db.sp builtin/init-db.s builtin/init-db.o: EXTRA_CPPFLAGS = \
 +setup.sp setup.s setup.o: GIT-PREFIX
 +setup.sp setup.s setup.o: EXTRA_CPPFLAGS = \
        -DDEFAULT_GIT_TEMPLATE_DIR='"$(template_dir_SQ)"'
  
  config.sp config.s config.o: GIT-PREFIX
@@@ -2779,13 -2777,6 +2778,13 @@@ compat/nedmalloc/nedmalloc.sp compat/ne
  compat/nedmalloc/nedmalloc.sp: SP_EXTRA_FLAGS += -Wno-non-pointer-null
  endif
  
 +headless-git.o: compat/win32/headless.c GIT-CFLAGS
 +      $(QUIET_CC)$(CC) $(ALL_CFLAGS) $(COMPAT_CFLAGS) \
 +              -fno-stack-protector -o $@ -c -Wall -Wwrite-strings $<
 +
 +headless-git$X: headless-git.o git.res GIT-LDFLAGS
 +      $(QUIET_LINK)$(CC) $(ALL_CFLAGS) $(ALL_LDFLAGS) -mwindows -o $@ $< git.res
 +
  git-%$X: %.o GIT-LDFLAGS $(GITLIBS)
        $(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(LIBS)
  
@@@ -3223,12 -3214,6 +3222,12 @@@ $(SP_OBJ): %.sp: %.c %.
  sparse: $(SP_OBJ)
  
  EXCEPT_HDRS := $(GENERATED_H) unicode-width.h compat/% xdiff/%
 +ifndef OPENSSL_SHA1
 +      EXCEPT_HDRS += sha1/openssl.h
 +endif
 +ifndef OPENSSL_SHA256
 +      EXCEPT_HDRS += sha256/openssl.h
 +endif
  ifndef NETTLE_SHA256
        EXCEPT_HDRS += sha256/nettle.h
  endif
@@@ -3665,7 -3650,6 +3664,7 @@@ clean: profile-clean coverage-clean coc
        $(RM) po/git.pot po/git-core.pot
        $(RM) git.res
        $(RM) $(OBJECTS)
 +      $(RM) headless-git.o
        $(RM) $(LIB_FILE) $(XDIFF_LIB) $(REFTABLE_LIB) $(REFTABLE_TEST_LIB)
        $(RM) $(ALL_PROGRAMS) $(SCRIPT_LIB) $(BUILT_INS) $(OTHER_PROGRAMS)
        $(RM) $(TEST_PROGRAMS)
@@@ -3694,7 -3678,6 +3693,7 @@@ endi
        $(RM) GIT-SCRIPT-DEFINES GIT-PERL-DEFINES GIT-PERL-HEADER GIT-PYTHON-VARS
  ifdef MSVC
        $(RM) $(patsubst %.o,%.o.pdb,$(OBJECTS))
 +      $(RM) headless-git.o.pdb
        $(RM) $(patsubst %.exe,%.pdb,$(OTHER_PROGRAMS))
        $(RM) $(patsubst %.exe,%.iobj,$(OTHER_PROGRAMS))
        $(RM) $(patsubst %.exe,%.ipdb,$(OTHER_PROGRAMS))
diff --combined builtin/update-index.c
index 59acae333612a4e27dca7a0809961ac7b74ce994,8c3454c1c161c295461adbe46e83b385f5b5d332..97617c587e251562720d326e9961a986fdf387a2
@@@ -4,7 -4,7 +4,7 @@@
   * Copyright (C) Linus Torvalds, 2005
   */
  #define USE_THE_INDEX_VARIABLE
 -#include "cache.h"
 +#include "builtin.h"
  #include "bulk-checkin.h"
  #include "config.h"
  #include "environment.h"
  #include "quote.h"
  #include "cache-tree.h"
  #include "tree-walk.h"
 -#include "builtin.h"
  #include "object-file.h"
  #include "refs.h"
  #include "resolve-undo.h"
  #include "parse-options.h"
  #include "pathspec.h"
  #include "dir.h"
 +#include "read-cache.h"
  #include "repository.h"
  #include "setup.h"
 +#include "sparse-index.h"
  #include "split-index.h"
  #include "symlinks.h"
  #include "fsmonitor.h"
@@@ -856,7 -855,7 +856,7 @@@ static int chmod_callback(const struct 
        return 0;
  }
  
 -static int resolve_undo_clear_callback(const struct option *opt,
 +static int resolve_undo_clear_callback(const struct option *opt UNUSED,
                                const char *arg, int unset)
  {
        BUG_ON_OPT_NEG(unset);
@@@ -890,7 -889,7 +890,7 @@@ static int parse_new_style_cacheinfo(co
  }
  
  static enum parse_opt_result cacheinfo_callback(
 -      struct parse_opt_ctx_t *ctx, const struct option *opt,
 +      struct parse_opt_ctx_t *ctx, const struct option *opt UNUSED,
        const char *arg, int unset)
  {
        struct object_id oid;
@@@ -1090,6 -1089,8 +1090,8 @@@ int cmd_update_index(int argc, const ch
                        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,
  
        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) {