mirror of
https://github.com/git/git.git
synced 2024-11-15 21:53:44 +01:00
ec160ae12b
The "--cacheinfo" option is unusual in that it takes three option parameters. An option with an optional parameter is bad enough. An option with multiple parameters is simply insane. Introduce a new syntax that takes these three things concatenated together with a comma, which makes the command line syntax more uniform across subcommands, while retaining the traditional syntax for backward compatiblity. If we were designing the "update-index" subcommand from scratch today, it may probably have made sense to make this option (and possibly others) a command mode option that does not take any option parameter (hence no need for arg-help). But we do not live in such an ideal world, and as far as I can tell, the command still supports (and must support) mixed command modes in a single invocation, e.g. $ git update-index path1 --add path2 \ --cacheinfo 100644 $(git hash-object --stdin -w <path3) path3 \ path4 must make sure path1 is already in the index and update all of these four paths. So this is probably as far as we can go to fix this issue without risking to break people's existing scripts. Signed-off-by: Junio C Hamano <gitster@pobox.com>
64 lines
1.6 KiB
Bash
Executable file
64 lines
1.6 KiB
Bash
Executable file
#!/bin/sh
|
|
|
|
test_description='basic update-index tests
|
|
|
|
Tests for command-line parsing and basic operation.
|
|
'
|
|
|
|
. ./test-lib.sh
|
|
|
|
test_expect_success 'update-index --nonsense fails' '
|
|
test_must_fail git update-index --nonsense 2>msg &&
|
|
cat msg &&
|
|
test -s msg
|
|
'
|
|
|
|
test_expect_success 'update-index --nonsense dumps usage' '
|
|
test_expect_code 129 git update-index --nonsense 2>err &&
|
|
test_i18ngrep "[Uu]sage: git update-index" err
|
|
'
|
|
|
|
test_expect_success 'update-index -h with corrupt index' '
|
|
mkdir broken &&
|
|
(
|
|
cd broken &&
|
|
git init &&
|
|
>.git/index &&
|
|
test_expect_code 129 git update-index -h >usage 2>&1
|
|
) &&
|
|
test_i18ngrep "[Uu]sage: git update-index" broken/usage
|
|
'
|
|
|
|
test_expect_success '--cacheinfo does not accept blob null sha1' '
|
|
echo content >file &&
|
|
git add file &&
|
|
git rev-parse :file >expect &&
|
|
test_must_fail git update-index --cacheinfo 100644 $_z40 file &&
|
|
git rev-parse :file >actual &&
|
|
test_cmp expect actual
|
|
'
|
|
|
|
test_expect_success '--cacheinfo does not accept gitlink null sha1' '
|
|
git init submodule &&
|
|
(cd submodule && test_commit foo) &&
|
|
git add submodule &&
|
|
git rev-parse :submodule >expect &&
|
|
test_must_fail git update-index --cacheinfo 160000 $_z40 submodule &&
|
|
git rev-parse :submodule >actual &&
|
|
test_cmp expect actual
|
|
'
|
|
|
|
test_expect_success '--cacheinfo mode,sha1,path (new syntax)' '
|
|
echo content >file &&
|
|
git hash-object -w --stdin <file >expect &&
|
|
|
|
git update-index --add --cacheinfo 100644 "$(cat expect)" file &&
|
|
git rev-parse :file >actual &&
|
|
test_cmp expect actual &&
|
|
|
|
git update-index --add --cacheinfo "100644,$(cat expect),elif" &&
|
|
git rev-parse :elif >actual &&
|
|
test_cmp expect actual
|
|
'
|
|
|
|
test_done
|