test-tool: retire "index-version"

As "git update-index --show-index-version" can do the same thing, the 'index-version' subcommand in the test-tool lost its reason to exist. Remove it and replace its use with the end-user facing 'git update-index --show-index-version'. Helped-by: Linus Arver <linusa@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Junio C Hamano committed Sep 12, 2023 at 12:32 UTC 83708f80fc5fc7202df0bf3c0951f85d31249fe3
7 files changed +5 -23
Makefile
-1
@@ -808,7 +808,6 @@ TEST_BUILTINS_OBJS += test-hash-speed.o
808 TEST_BUILTINS_OBJS += test-hash.o
809 TEST_BUILTINS_OBJS += test-hashmap.o
810 TEST_BUILTINS_OBJS += test-hexdump.o
811 -TEST_BUILTINS_OBJS += test-index-version.o
811 TEST_BUILTINS_OBJS += test-json-writer.o
812 TEST_BUILTINS_OBJS += test-lazy-init-name-hash.o
813 TEST_BUILTINS_OBJS += test-match-trees.o
t/helper/test-index-version.c deleted
-15
@@ -1,15 +0,0 @@
1 -#include "test-tool.h"
2 -#include "cache.h"
3 -
4 -int cmd__index_version(int argc UNUSED, const char **argv UNUSED)
5 -{
6 - struct cache_header hdr;
7 - int version;
8 -
9 - memset(&hdr,0,sizeof(hdr));
10 - if (read(0, &hdr, sizeof(hdr)) != sizeof(hdr))
11 - return 0;
12 - version = ntohl(hdr.hdr_version);
13 - printf("%d\n", version);
14 - return 0;
15 -}
t/helper/test-tool.c
-1
@@ -38,7 +38,6 @@ static struct test_cmd cmds[] = {
38 { "hashmap", cmd__hashmap },
39 { "hash-speed", cmd__hash_speed },
40 { "hexdump", cmd__hexdump },
41 - { "index-version", cmd__index_version },
41 { "json-writer", cmd__json_writer },
42 { "lazy-init-name-hash", cmd__lazy_init_name_hash },
43 { "match-trees", cmd__match_trees },
t/helper/test-tool.h
-1
@@ -32,7 +32,6 @@ int cmd__getcwd(int argc, const char **argv);
32 int cmd__hashmap(int argc, const char **argv);
33 int cmd__hash_speed(int argc, const char **argv);
34 int cmd__hexdump(int argc, const char **argv);
35 -int cmd__index_version(int argc, const char **argv);
35 int cmd__json_writer(int argc, const char **argv);
36 int cmd__lazy_init_name_hash(int argc, const char **argv);
37 int cmd__match_trees(int argc, const char **argv);
t/t1600-index.sh
+1 -1
@@ -118,7 +118,7 @@ test_index_version () {
118 fi &&
119 git add a &&
120 echo $EXPECTED_OUTPUT_VERSION >expect &&
121 - test-tool index-version <.git/index >actual &&
121 + git update-index --show-index-version >actual &&
122 test_cmp expect actual
123 )
124 }
t/t1700-split-index.sh
+1 -1
@@ -43,7 +43,7 @@ test_expect_success 'enable split index' '
43 git config splitIndex.maxPercentChange 100 &&
44 git update-index --split-index &&
45 test-tool dump-split-index .git/index >actual &&
46 - indexversion=$(test-tool index-version <.git/index) &&
46 + indexversion=$(git update-index --show-index-version) &&
47
48 # NEEDSWORK: Stop hard-coding checksums.
49 if test "$indexversion" = "4"
t/t2104-update-index-skip-worktree.sh
+3 -3
@@ -39,7 +39,7 @@ test_expect_success 'setup' '
39 '
40
41 test_expect_success 'index is at version 2' '
42 - test "$(test-tool index-version < .git/index)" = 2
42 + test "$(git update-index --show-index-version)" = 2
43 '
44
45 test_expect_success 'update-index --skip-worktree' '
@@ -48,7 +48,7 @@ test_expect_success 'update-index --skip-worktree' '
48 '
49
50 test_expect_success 'index is at version 3 after having some skip-worktree entries' '
51 - test "$(test-tool index-version < .git/index)" = 3
51 + test "$(git update-index --show-index-version)" = 3
52 '
53
54 test_expect_success 'ls-files -t' '
@@ -61,7 +61,7 @@ test_expect_success 'update-index --no-skip-worktree' '
61 '
62
63 test_expect_success 'index version is back to 2 when there is no skip-worktree entry' '
64 - test "$(test-tool index-version < .git/index)" = 2
64 + test "$(git update-index --show-index-version)" = 2
65 '
66
67 test_done