]> git.ipfire.org Git - thirdparty/git.git/blobdiff - t/t0060-path-utils.sh
git_path(): be aware of file relocation in $GIT_DIR
[thirdparty/git.git] / t / t0060-path-utils.sh
index c0143a0a70b7d3dc213b691aecea6b3fffbc5844..33d2818d02b5d887814c63c55c63ad5ac7b15719 100755 (executable)
@@ -19,6 +19,14 @@ relative_path() {
        "test \"\$(test-path-utils relative_path '$1' '$2')\" = '$expected'"
 }
 
+test_git_path() {
+       test_expect_success "git-path $1 $2 => $3" "
+               $1 git rev-parse --git-path $2 >actual &&
+               echo $3 >expect &&
+               test_cmp expect actual
+       "
+}
+
 # On Windows, we are using MSYS's bash, which mangles the paths.
 # Absolute paths are anchored at the MSYS installation directory,
 # which means that the path / accounts for this many characters:
@@ -244,4 +252,15 @@ relative_path "<null>"             "<empty>"       ./
 relative_path "<null>"         "<null>"        ./
 relative_path "<null>"         /foo/a/b        ./
 
+test_git_path A=B                info/grafts .git/info/grafts
+test_git_path GIT_GRAFT_FILE=foo info/grafts foo
+test_git_path GIT_GRAFT_FILE=foo info/////grafts foo
+test_git_path GIT_INDEX_FILE=foo index foo
+test_git_path GIT_INDEX_FILE=foo index/foo .git/index/foo
+test_git_path GIT_INDEX_FILE=foo index2 .git/index2
+test_expect_success 'setup fake objects directory foo' 'mkdir foo'
+test_git_path GIT_OBJECT_DIRECTORY=foo objects foo
+test_git_path GIT_OBJECT_DIRECTORY=foo objects/foo foo/foo
+test_git_path GIT_OBJECT_DIRECTORY=foo objects2 .git/objects2
+
 test_done