Skip to content
This repository was archived by the owner on Apr 12, 2019. It is now read-only.

Commit f1ecc13

Browse files
tf198lunny
authored andcommitted
Fix for short symlinks (#115)
Signed-off-by: Tris Forster <[email protected]>
1 parent 288aede commit f1ecc13

File tree

7 files changed

+10
-3
lines changed

7 files changed

+10
-3
lines changed
Binary file not shown.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
x��KN1 Y��#��3 !�p.���L��J����,k����}5�Pl�B�5sK�H|>�d�K�Kl k�%���S7�ܛ�e�Ӣ�c�Ή���H��Se�~�uLx��oc����e���:D�7�Ә�g���_B�=":�����S�^ET����u�p?�6M^
Binary file not shown.
Binary file not shown.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
6fbd69e9823458e6c4a2fc5c0f6bc022b2f2acd1
1+
37991dec2c8e592043f47155ce4808d4580f9123

tree_entry.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ func (te *TreeEntry) FollowLink() (*TreeEntry, error) {
112112
t := te.ptree
113113

114114
// traverse up directories
115-
for ; t != nil && lnk[:3] == "../"; lnk = lnk[3:] {
115+
for ; t != nil && strings.HasPrefix(lnk, "../"); lnk = lnk[3:] {
116116
t = t.ptree
117117
}
118118

tree_entry_test.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ func TestFollowLink(t *testing.T) {
5555
r, err := OpenRepository("tests/repos/repo1_bare")
5656
assert.NoError(t, err)
5757

58-
commit, err := r.GetCommit("6fbd69e9823458e6c4a2fc5c0f6bc022b2f2acd1")
58+
commit, err := r.GetCommit("37991dec2c8e592043f47155ce4808d4580f9123")
5959
assert.NoError(t, err)
6060

6161
// get the symlink
@@ -89,4 +89,10 @@ func TestFollowLink(t *testing.T) {
8989
assert.True(t, target.IsLink())
9090
_, err = target.FollowLink()
9191
assert.Equal(t, err.Error(), "outside_repo: points outside of repo")
92+
93+
// testing fix for short link bug
94+
target, err = commit.Tree.GetTreeEntryByPath("foo/link_short")
95+
assert.NoError(t, err)
96+
_, err = target.FollowLink()
97+
assert.Equal(t, err.Error(), "link_short: broken link")
9298
}

0 commit comments

Comments
 (0)