[PR #114] [MERGED] Added FollowLink() method to TreeEntry #120

Closed
opened 2026-02-16 10:24:10 -05:00 by yindo · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/go-gitea/git/pull/114
Author: @tf198
Created: 4/18/2018
Status: Merged
Merged: 4/19/2018
Merged by: @lafriks

Base: masterHead: follow_links


📝 Commits (3)

📊 Changes

16 files changed (+92 additions, -1 deletions)

View changed files

📝 error.go (+10 -0)
tests/repos/repo1_bare/objects/21/6bf54c2f2e2916b830ebe09e8c58a6ed52d86b (+0 -0)
tests/repos/repo1_bare/objects/50/13716a9da8e66ea21059a84f1b4311424d2b7f (+0 -0)
tests/repos/repo1_bare/objects/59/dfb0bb505a601006e31fed53d2e24e44fca9ca (+0 -0)
tests/repos/repo1_bare/objects/62/d735f9efa9cf5b7df6bac9917b80e4779f4315 (+0 -0)
tests/repos/repo1_bare/objects/64/3a35374408002fcf2f0e8d42d262a1e0e2f80e (+0 -0)
tests/repos/repo1_bare/objects/6f/bd69e9823458e6c4a2fc5c0f6bc022b2f2acd1 (+1 -0)
tests/repos/repo1_bare/objects/80/06ff9adbf0cb94da7dad9e537e53817f9fa5c0 (+0 -0)
tests/repos/repo1_bare/objects/82/26f571dcc2d2f33a7179d929b10b9c39faa631 (+0 -0)
tests/repos/repo1_bare/objects/98/1ff127cc331753bba28e1377c35934f1ca9b56 (+0 -0)
tests/repos/repo1_bare/objects/b1/4df6442ea5a1b382985a6549b85d435376c351 (+0 -0)
tests/repos/repo1_bare/objects/c8/c90111bdc18b3afd2b2906007059e95ac8fdc3 (+0 -0)
tests/repos/repo1_bare/objects/d0/845fe2f85710b50d673dafe98236bf9f2023da (+0 -0)
📝 tests/repos/repo1_bare/refs/heads/master (+1 -1)
📝 tree_entry.go (+40 -0)
📝 tree_entry_test.go (+40 -0)

📄 Description

Solution for #63.

As symlinks are all mode 120000 we have to traverse the tree which is more expensive than a straight check so I've implemented it as a FollowLink() method and the caller can determine the type

if entry.IsLink() {
  target, err = entry.FollowLink()
  // err: on broken symlinks and targets outside repo
  if target.IsDir() {
    // isDirectorySymlink action
  } else {
    // isFileSymlink action (or a link, but would need to detect loops in recursive calls)
  }
}

Have a patch ready for go-gitea/gitea#1416 if this is accepted...

For testing I had to add files directly to the tests/repo1_bare and include them in the commit. If there is a cleaner way to do this I'm happy to resubmit.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/go-gitea/git/pull/114 **Author:** [@tf198](https://github.com/tf198) **Created:** 4/18/2018 **Status:** ✅ Merged **Merged:** 4/19/2018 **Merged by:** [@lafriks](https://github.com/lafriks) **Base:** `master` ← **Head:** `follow_links` --- ### 📝 Commits (3) - [`9b09ca2`](https://github.com/go-gitea/git/commit/9b09ca2aad6b86fa5482ce9073556e2773c76e85) Added FollowLink() method to TreeEntry - [`46f8f2f`](https://github.com/go-gitea/git/commit/46f8f2f90283aef1978450163e0d11caf6620b30) Fixed lint warning - [`b439e76`](https://github.com/go-gitea/git/commit/b439e76ee4c5cf31e072b143adf191c3d349b88f) Comment cleanup ### 📊 Changes **16 files changed** (+92 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `error.go` (+10 -0) ➕ `tests/repos/repo1_bare/objects/21/6bf54c2f2e2916b830ebe09e8c58a6ed52d86b` (+0 -0) ➕ `tests/repos/repo1_bare/objects/50/13716a9da8e66ea21059a84f1b4311424d2b7f` (+0 -0) ➕ `tests/repos/repo1_bare/objects/59/dfb0bb505a601006e31fed53d2e24e44fca9ca` (+0 -0) ➕ `tests/repos/repo1_bare/objects/62/d735f9efa9cf5b7df6bac9917b80e4779f4315` (+0 -0) ➕ `tests/repos/repo1_bare/objects/64/3a35374408002fcf2f0e8d42d262a1e0e2f80e` (+0 -0) ➕ `tests/repos/repo1_bare/objects/6f/bd69e9823458e6c4a2fc5c0f6bc022b2f2acd1` (+1 -0) ➕ `tests/repos/repo1_bare/objects/80/06ff9adbf0cb94da7dad9e537e53817f9fa5c0` (+0 -0) ➕ `tests/repos/repo1_bare/objects/82/26f571dcc2d2f33a7179d929b10b9c39faa631` (+0 -0) ➕ `tests/repos/repo1_bare/objects/98/1ff127cc331753bba28e1377c35934f1ca9b56` (+0 -0) ➕ `tests/repos/repo1_bare/objects/b1/4df6442ea5a1b382985a6549b85d435376c351` (+0 -0) ➕ `tests/repos/repo1_bare/objects/c8/c90111bdc18b3afd2b2906007059e95ac8fdc3` (+0 -0) ➕ `tests/repos/repo1_bare/objects/d0/845fe2f85710b50d673dafe98236bf9f2023da` (+0 -0) 📝 `tests/repos/repo1_bare/refs/heads/master` (+1 -1) 📝 `tree_entry.go` (+40 -0) 📝 `tree_entry_test.go` (+40 -0) </details> ### 📄 Description Solution for #63. As symlinks are all mode 120000 we have to traverse the tree which is more expensive than a straight check so I've implemented it as a FollowLink() method and the caller can determine the type ```go if entry.IsLink() { target, err = entry.FollowLink() // err: on broken symlinks and targets outside repo if target.IsDir() { // isDirectorySymlink action } else { // isFileSymlink action (or a link, but would need to detect loops in recursive calls) } } ``` Have a patch ready for go-gitea/gitea#1416 if this is accepted... For testing I had to add files directly to the tests/repo1_bare and include them in the commit. If there is a cleaner way to do this I'm happy to resubmit. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
yindo added the pull-request label 2026-02-16 10:24:10 -05:00
yindo closed this issue 2026-02-16 10:24:10 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: go-gitea/git#120