summaryrefslogtreecommitdiff
path: root/t/test-lib-functions.sh
diff options
context:
space:
mode:
authorJohannes Sixt <j6t@kdbg.org>2013-06-07 20:53:27 (GMT)
committerJunio C Hamano <gitster@pobox.com>2013-06-07 22:01:16 (GMT)
commit9ce415d972a04df4bfceaad0fab8eaea9a66997e (patch)
tree84abd364d506aa9c4983f109b9babc1680a3674b /t/test-lib-functions.sh
parentcb648689b9456a1131b494065d7888c925265ddd (diff)
downloadgit-9ce415d972a04df4bfceaad0fab8eaea9a66997e.zip
git-9ce415d972a04df4bfceaad0fab8eaea9a66997e.tar.gz
git-9ce415d972a04df4bfceaad0fab8eaea9a66997e.tar.bz2
tests: introduce test_ln_s_add
Add a new function that creates a symbolic link and adds it to the index to be used in cases where a symbolic link is not required on the file system. We will use it to remove many SYMLINKS prerequisites from test cases. Signed-off-by: Johannes Sixt <j6t@kdbg.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/test-lib-functions.sh')
-rw-r--r--t/test-lib-functions.sh17
1 files changed, 17 insertions, 0 deletions
diff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh
index 5251009..fac9234 100644
--- a/t/test-lib-functions.sh
+++ b/t/test-lib-functions.sh
@@ -679,3 +679,20 @@ test_create_repo () {
mv .git/hooks .git/hooks-disabled
) || exit
}
+
+# This function helps on symlink challenged file systems when it is not
+# important that the file system entry is a symbolic link.
+# Use test_ln_s_add instead of "ln -s x y && git add y" to add a
+# symbolic link entry y to the index.
+
+test_ln_s_add () {
+ if test_have_prereq SYMLINKS
+ then
+ ln -s "$1" "$2" &&
+ git update-index --add "$2"
+ else
+ printf '%s' "$1" >"$2" &&
+ ln_s_obj=$(git hash-object -w "$2") &&
+ git update-index --add --cacheinfo 120000 $ln_s_obj "$2"
+ fi
+}