-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add platform-independent .git "symlink"
This patch allows .git to be a regular textfile containing the path of the real git directory (prefixed with "gitdir: "), which can be useful on platforms lacking support for real symlinks. Signed-off-by: Lars Hjemli <hjemli@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
- Loading branch information
Lars Hjemli
authored and
Junio C Hamano
committed
Apr 9, 2008
1 parent
2a5fe25
commit b44ebb1
Showing
5 changed files
with
157 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
#!/bin/sh | ||
|
||
test_description='.git file | ||
Verify that plumbing commands work when .git is a file | ||
' | ||
. ./test-lib.sh | ||
|
||
objpath() { | ||
echo "$1" | sed -e 's|\(..\)|\1/|' | ||
} | ||
|
||
objck() { | ||
p=$(objpath "$1") | ||
if test ! -f "$REAL/objects/$p" | ||
then | ||
echo "Object not found: $REAL/objects/$p" | ||
false | ||
fi | ||
} | ||
|
||
|
||
test_expect_success 'initial setup' ' | ||
REAL="$(pwd)/.real" && | ||
mv .git "$REAL" | ||
' | ||
|
||
test_expect_success 'bad setup: invalid .git file format' ' | ||
echo "gitdir $REAL" >.git && | ||
if git rev-parse 2>.err | ||
then | ||
echo "git rev-parse accepted an invalid .git file" | ||
false | ||
fi && | ||
if ! grep -qe "Invalid gitfile format" .err | ||
then | ||
echo "git rev-parse returned wrong error" | ||
false | ||
fi | ||
' | ||
|
||
test_expect_success 'bad setup: invalid .git file path' ' | ||
echo "gitdir: $REAL.not" >.git && | ||
if git rev-parse 2>.err | ||
then | ||
echo "git rev-parse accepted an invalid .git file path" | ||
false | ||
fi && | ||
if ! grep -qe "Not a git repository" .err | ||
then | ||
echo "git rev-parse returned wrong error" | ||
false | ||
fi | ||
' | ||
|
||
test_expect_success 'final setup + check rev-parse --git-dir' ' | ||
echo "gitdir: $REAL" >.git && | ||
test "$REAL" = "$(git rev-parse --git-dir)" | ||
' | ||
|
||
test_expect_success 'check hash-object' ' | ||
echo "foo" >bar && | ||
SHA=$(cat bar | git hash-object -w --stdin) && | ||
objck $SHA | ||
' | ||
|
||
test_expect_success 'check cat-file' ' | ||
git cat-file blob $SHA >actual && | ||
diff -u bar actual | ||
' | ||
|
||
test_expect_success 'check update-index' ' | ||
if test -f "$REAL/index" | ||
then | ||
echo "Hmm, $REAL/index exists?" | ||
false | ||
fi && | ||
rm -f "$REAL/objects/$(objpath $SHA)" && | ||
git update-index --add bar && | ||
if ! test -f "$REAL/index" | ||
then | ||
echo "$REAL/index not found" | ||
false | ||
fi && | ||
objck $SHA | ||
' | ||
|
||
test_expect_success 'check write-tree' ' | ||
SHA=$(git write-tree) && | ||
objck $SHA | ||
' | ||
|
||
test_expect_success 'check commit-tree' ' | ||
SHA=$(echo "commit bar" | git commit-tree $SHA) && | ||
objck $SHA | ||
' | ||
|
||
test_expect_success 'check rev-list' ' | ||
echo $SHA >"$REAL/HEAD" && | ||
test "$SHA" = "$(git rev-list HEAD)" | ||
' | ||
|
||
test_done |