From ec160ae12b0ae938ed5076b9f604e88976fc429c Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Sun, 23 Mar 2014 16:57:28 -0700 Subject: update-index: teach --cacheinfo a new syntax "mode,sha1,path" 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 --- t/t2107-update-index-basic.sh | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 't') diff --git a/t/t2107-update-index-basic.sh b/t/t2107-update-index-basic.sh index a6405d318..fe2fb1710 100755 --- a/t/t2107-update-index-basic.sh +++ b/t/t2107-update-index-basic.sh @@ -48,4 +48,17 @@ test_expect_success '--cacheinfo does not accept gitlink null sha1' ' test_cmp expect actual ' +test_expect_success '--cacheinfo mode,sha1,path (new syntax)' ' + echo content >file && + git hash-object -w --stdin 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 -- cgit v1.2.1