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
This commit is contained in:
@@ -1,15 +0,0 @@
|
||||
#include "test-tool.h"
|
||||
#include "read-cache-ll.h"
|
||||
|
||||
int cmd__index_version(int argc UNUSED, const char **argv UNUSED)
|
||||
{
|
||||
struct cache_header hdr;
|
||||
int version;
|
||||
|
||||
memset(&hdr,0,sizeof(hdr));
|
||||
if (read(0, &hdr, sizeof(hdr)) != sizeof(hdr))
|
||||
return 0;
|
||||
version = ntohl(hdr.hdr_version);
|
||||
printf("%d\n", version);
|
||||
return 0;
|
||||
}
|
||||
@@ -38,7 +38,6 @@ static struct test_cmd cmds[] = {
|
||||
{ "hashmap", cmd__hashmap },
|
||||
{ "hash-speed", cmd__hash_speed },
|
||||
{ "hexdump", cmd__hexdump },
|
||||
{ "index-version", cmd__index_version },
|
||||
{ "json-writer", cmd__json_writer },
|
||||
{ "lazy-init-name-hash", cmd__lazy_init_name_hash },
|
||||
{ "match-trees", cmd__match_trees },
|
||||
|
||||
@@ -32,7 +32,6 @@ int cmd__getcwd(int argc, const char **argv);
|
||||
int cmd__hashmap(int argc, const char **argv);
|
||||
int cmd__hash_speed(int argc, const char **argv);
|
||||
int cmd__hexdump(int argc, const char **argv);
|
||||
int cmd__index_version(int argc, const char **argv);
|
||||
int cmd__json_writer(int argc, const char **argv);
|
||||
int cmd__lazy_init_name_hash(int argc, const char **argv);
|
||||
int cmd__match_trees(int argc, const char **argv);
|
||||
|
||||
@@ -118,7 +118,7 @@ test_index_version () {
|
||||
fi &&
|
||||
git add a &&
|
||||
echo $EXPECTED_OUTPUT_VERSION >expect &&
|
||||
test-tool index-version <.git/index >actual &&
|
||||
git update-index --show-index-version >actual &&
|
||||
test_cmp expect actual
|
||||
)
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ test_expect_success 'enable split index' '
|
||||
git config splitIndex.maxPercentChange 100 &&
|
||||
git update-index --split-index &&
|
||||
test-tool dump-split-index .git/index >actual &&
|
||||
indexversion=$(test-tool index-version <.git/index) &&
|
||||
indexversion=$(git update-index --show-index-version) &&
|
||||
|
||||
# NEEDSWORK: Stop hard-coding checksums.
|
||||
if test "$indexversion" = "4"
|
||||
|
||||
@@ -39,7 +39,7 @@ test_expect_success 'setup' '
|
||||
'
|
||||
|
||||
test_expect_success 'index is at version 2' '
|
||||
test "$(test-tool index-version < .git/index)" = 2
|
||||
test "$(git update-index --show-index-version)" = 2
|
||||
'
|
||||
|
||||
test_expect_success 'update-index --skip-worktree' '
|
||||
@@ -48,7 +48,7 @@ test_expect_success 'update-index --skip-worktree' '
|
||||
'
|
||||
|
||||
test_expect_success 'index is at version 3 after having some skip-worktree entries' '
|
||||
test "$(test-tool index-version < .git/index)" = 3
|
||||
test "$(git update-index --show-index-version)" = 3
|
||||
'
|
||||
|
||||
test_expect_success 'ls-files -t' '
|
||||
@@ -61,7 +61,7 @@ test_expect_success 'update-index --no-skip-worktree' '
|
||||
'
|
||||
|
||||
test_expect_success 'index version is back to 2 when there is no skip-worktree entry' '
|
||||
test "$(test-tool index-version < .git/index)" = 2
|
||||
test "$(git update-index --show-index-version)" = 2
|
||||
'
|
||||
|
||||
test_done
|
||||
|
||||
@@ -111,4 +111,35 @@ test_expect_success '--chmod=+x and chmod=-x in the same argument list' '
|
||||
test_cmp expect actual
|
||||
'
|
||||
|
||||
test_expect_success '--index-version' '
|
||||
git commit --allow-empty -m snap &&
|
||||
git reset --hard &&
|
||||
git rm -f -r --cached . &&
|
||||
|
||||
# The default index version is 2 --- update this test
|
||||
# when you change it in the code
|
||||
git update-index --show-index-version >actual &&
|
||||
echo 2 >expect &&
|
||||
test_cmp expect actual &&
|
||||
|
||||
# The next test wants us to be using version 2
|
||||
git update-index --index-version 2 &&
|
||||
|
||||
git update-index --index-version 4 --verbose >actual &&
|
||||
echo "index-version: was 2, set to 4" >expect &&
|
||||
test_cmp expect actual &&
|
||||
|
||||
git update-index --index-version 4 --verbose >actual &&
|
||||
echo "index-version: was 4, set to 4" >expect &&
|
||||
test_cmp expect actual &&
|
||||
|
||||
git update-index --index-version 2 --verbose >actual &&
|
||||
echo "index-version: was 4, set to 2" >expect &&
|
||||
test_cmp expect actual &&
|
||||
|
||||
# non-verbose should be silent
|
||||
git update-index --index-version 4 >actual &&
|
||||
test_must_be_empty actual
|
||||
'
|
||||
|
||||
test_done
|
||||
|
||||
Reference in New Issue
Block a user