@@ -964,4 +964,70 @@ test_expect_success 'cat-file --batch-all-objects --batch-check ignores replace'
964
964
test_cmp expect actual
965
965
'
966
966
967
+ F=' %s\0'
968
+
969
+ test_expect_sucess ' stdin-cmd not enough arguments' '
970
+ echo ' object ' >cmd &&
971
+ test_expect_code 128 git cat-file --batch --stdin-cmd < cmd 2>err &&
972
+ grep -E "^fatal:.*too few arguments for object" err
973
+ '
974
+
975
+ test_expect_success ' stdin-cmd unknown command' '
976
+ echo unknown_command >cmd &&
977
+ test_expect_code 128 git cat-file --batch --stdin-cmd < cmd 2>err &&
978
+ grep -E "^fatal:.*unknown command.*" err &&
979
+ test_expect_code 128 git cat-file --batch --stdin-cmd -z < cmd 2>err &&
980
+ grep -E "^fatal:.*unknown command.*" err
981
+ '
982
+
983
+ test_expect_success ' setup object data' '
984
+ content="Object Data" &&
985
+ size=$(strlen "$content") &&
986
+ sha1=$(echo_without_newline "$content" | git hash-object -w --stdin)
987
+ '
988
+
989
+ test_expect_success ' stdin-cmd calling object works' '
990
+ echo "object $sha1" | git cat-file --batch --stdin-cmd >actual &&
991
+ echo "$sha1 blob $size" >expect &&
992
+ echo `git cat-file -p "$sha1"` >>expect &&
993
+ test_cmp expect actual
994
+ '
995
+
996
+ test_expect_success ' stdin-cmd -z calling object works' '
997
+ printf $F "object $sha1" | git cat-file --batch --stdin-cmd -z >actual &&
998
+ echo "$sha1 blob $size" >expect &&
999
+ echo `git cat-file -p "$sha1"` >>expect &&
1000
+ test_cmp expect actual
1001
+ '
1002
+
1003
+ test_expect_success ' setup object data' '
1004
+ content="Object Data" &&
1005
+ size=$(strlen "$content") &&
1006
+ sha1=$(echo_without_newline "$content" | git hash-object -w --stdin)
1007
+ '
1008
+
1009
+ test_expect_success ' stdin-cmd calling object works' '
1010
+ echo "object $sha1" | git cat-file --batch --stdin-cmd >actual &&
1011
+ echo "$sha1 blob $size" >expect &&
1012
+ echo `git cat-file -p "$sha1"` >>expect &&
1013
+ test_cmp expect actual
1014
+ '
1015
+
1016
+ test_expect_success ' stdin-cmd -z calling object works' '
1017
+ printf $F "object $sha1" | git cat-file --batch --stdin-cmd -z >actual &&
1018
+ echo "$sha1 blob $size" >expect &&
1019
+ echo `git cat-file -p "$sha1"` >>expect &&
1020
+ test_cmp expect actual
1021
+ '
1022
+
1023
+ test_expect_success ' stdin-cmd fflush works' '
1024
+ printf "fflush\n" > cmd &&
1025
+ test_expect_code 0 git cat-file --batch --stdin-cmd < cmd 2>err
1026
+ '
1027
+
1028
+ test_expect_success ' stdin-cmd -z fflush works' '
1029
+ printf $F ' fflush' > cmd &&
1030
+ test_expect_code 0 git cat-file --batch --stdin-cmd -z < cmd 2>err
1031
+ '
1032
+
967
1033
test_done
0 commit comments