diff options
author | Junio C Hamano <gitster@pobox.com> | 2023-09-12 22:32:34 +0300 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2023-09-13 02:21:53 +0300 |
commit | 606e088d5d9af2393b4b05a8a180162c129cd734 (patch) | |
tree | 6684eaf70d5ce0a78944896aaae3a3e1f2c23405 /t/t2107-update-index-basic.sh | |
parent | 764b2330db42d07ed8c7d4f6c66a1d1203fb95de (diff) |
update-index: add --show-index-version
"git update-index --index-version N" is used to set the index format
version to a specific version, but there was no way to query the
current version used in the on-disk index file.
Teach the command a new "--show-index-version" option, and also
teach the "--index-version N" option to report what the version was
when run with the "--verbose" option.
Helped-by: Linus Arver <linusa@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t2107-update-index-basic.sh')
-rwxr-xr-x | t/t2107-update-index-basic.sh | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/t/t2107-update-index-basic.sh b/t/t2107-update-index-basic.sh index 89b285fa3a..22f4c92399 100755 --- a/t/t2107-update-index-basic.sh +++ b/t/t2107-update-index-basic.sh @@ -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 |