diff options
author | Dmitry Potapov <dpotapov@gmail.com> | 2008-08-03 18:36:21 +0400 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2008-08-03 13:33:06 -0700 |
commit | 39702431500b76425f047209c9e9b2aae7e92b00 (patch) | |
tree | ff5326506a125c988f8010c826e7a355bb72525d /t/t1007-hash-object.sh | |
parent | 548601adcc638d96486e0f2a3dd399d4ca215eca (diff) | |
download | git-39702431500b76425f047209c9e9b2aae7e92b00.tar.gz |
add --path option to git hash-object
The --path option allows us to pretend as if the contents being hashed
came from the specified path, and affects which input filter is used via
the attributes mechanism. This is useful for hashing a temporary file
whose name is different from the path that is meant to have the hashed
contents.
Signed-off-by: Dmitry Potapov <dpotapov@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t1007-hash-object.sh')
-rwxr-xr-x | t/t1007-hash-object.sh | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/t/t1007-hash-object.sh b/t/t1007-hash-object.sh index 6d505fafeb..f3972a79af 100755 --- a/t/t1007-hash-object.sh +++ b/t/t1007-hash-object.sh @@ -61,6 +61,10 @@ test_expect_success "Can't pass filenames as arguments with --stdin-paths" ' echo example | test_must_fail git hash-object --stdin-paths hello ' +test_expect_success "Can't use --path with --stdin-paths" ' + echo example | test_must_fail git hash-object --stdin-paths --path=foo +' + # Behavior push_repo @@ -93,6 +97,26 @@ test_expect_success 'git hash-object --stdin file1 <file0 first operates on file test "$obname1" = "$obname1new" ' +test_expect_success 'check that appropriate filter is invoke when --path is used' ' + echo fooQ | tr Q "\\015" >file0 && + cp file0 file1 && + echo "file0 -crlf" >.gitattributes && + echo "file1 crlf" >>.gitattributes && + git config core.autocrlf true && + file0_sha=$(git hash-object file0) && + file1_sha=$(git hash-object file1) && + test "$file0_sha" != "$file1_sha" && + path1_sha=$(git hash-object --path=file1 file0) && + path0_sha=$(git hash-object --path=file0 file1) && + test "$file0_sha" = "$path0_sha" && + test "$file1_sha" = "$path1_sha" && + path1_sha=$(cat file0 | git hash-object --path=file1 --stdin) && + path0_sha=$(cat file1 | git hash-object --path=file0 --stdin) && + test "$file0_sha" = "$path0_sha" && + test "$file1_sha" = "$path1_sha" && + git config --unset core.autocrlf +' + pop_repo for args in "-w --stdin" "--stdin -w"; do |