t6024: move "git reset" to prepare for a test inside the test itself
[git] / t / t5303-hash-object.sh
1 #!/bin/sh
2
3 test_description=git-hash-object
4
5 . ./test-lib.sh
6
7 test_expect_success \
8     'git hash-object -w --stdin saves the object' \
9     'obname=$(echo foo | git hash-object -w --stdin) &&
10     obpath=$(echo $obname | sed -e "s/\(..\)/\1\//") &&
11     test -r .git/objects/"$obpath" &&
12     rm -f .git/objects/"$obpath"'
13     
14 test_expect_success \
15     'git hash-object --stdin -w saves the object' \
16     'obname=$(echo foo | git hash-object --stdin -w) &&
17     obpath=$(echo $obname | sed -e "s/\(..\)/\1\//") &&
18     test -r .git/objects/"$obpath" &&
19     rm -f .git/objects/"$obpath"'    
20
21 test_expect_success \
22     'git hash-object --stdin file1 <file0 first operates on file0, then file1' \
23     'echo foo > file1 &&
24     obname0=$(echo bar | git hash-object --stdin) &&
25     obname1=$(git hash-object file1) &&
26     obname0new=$(echo bar | git hash-object --stdin file1 | sed -n -e 1p) &&
27     obname1new=$(echo bar | git hash-object --stdin file1 | sed -n -e 2p) &&
28     test "$obname0" = "$obname0new" &&
29     test "$obname1" = "$obname1new"'
30
31 test_expect_success \
32     'git hash-object refuses multiple --stdin arguments' \
33     '! git hash-object --stdin --stdin < file1'
34
35 test_done