aboutsummaryrefslogtreecommitdiff
path: root/t/t1007-hash-object.sh
diff options
context:
space:
mode:
authorDmitry Potapov <dpotapov@gmail.com>2008-08-03 18:36:21 +0400
committerJunio C Hamano <gitster@pobox.com>2008-08-03 13:33:06 -0700
commit39702431500b76425f047209c9e9b2aae7e92b00 (patch)
treeff5326506a125c988f8010c826e7a355bb72525d /t/t1007-hash-object.sh
parent548601adcc638d96486e0f2a3dd399d4ca215eca (diff)
downloadgit-39702431500b76425f047209c9e9b2aae7e92b00.tar.gz
git-39702431500b76425f047209c9e9b2aae7e92b00.tar.xz
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-xt/t1007-hash-object.sh24
1 files changed, 24 insertions, 0 deletions
diff --git a/t/t1007-hash-object.sh b/t/t1007-hash-object.sh
index 6d505fafe..f3972a79a 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