Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitaly.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Steinhardt <psteinhardt@gitlab.com>2021-11-18 17:46:34 +0300
committerPatrick Steinhardt <psteinhardt@gitlab.com>2021-11-18 17:52:16 +0300
commitdf40494541216b4a8d0c4437c75bb7540b5c5f72 (patch)
treeadec41052ebc6a50e5edc59f5a2144983f9ee4e4
parente135e17c377f1dbbf7b428a1fdefeea8f0319ce5 (diff)
commit: Do not raise error when listing tree entries for nonexistent ref
The GetTreeEntries RPC has weird calling semantics: when the caller requests entries for a nonexisteng revision or path, then it won't error but instead just returns an empty set. While the rewrite for recursive listings introduced via 08507b227 (commit: Convert GetTreeEntries to use git-ls-tree(1), 2021-11-08) correctly honors the case when trying to list entries for an object which is not a treeish, it fails to do the same when using an invalid revision. As a result, the new code returns errors where we previously just silently failed. Fix this by swallowing `lstree.ErrNotExist` errors. Changelog: fixed
-rw-r--r--internal/gitaly/service/commit/tree_entries.go5
-rw-r--r--internal/gitaly/service/commit/tree_entries_test.go7
2 files changed, 12 insertions, 0 deletions
diff --git a/internal/gitaly/service/commit/tree_entries.go b/internal/gitaly/service/commit/tree_entries.go
index 98eb0b7f9..897d93f05 100644
--- a/internal/gitaly/service/commit/tree_entries.go
+++ b/internal/gitaly/service/commit/tree_entries.go
@@ -108,6 +108,11 @@ func (s *server) sendTreeEntries(
return nil
}
+ // Same if we try to list tree entries of a revision which doesn't exist.
+ if errors.Is(err, lstree.ErrNotExist) {
+ return nil
+ }
+
return fmt.Errorf("listing tree entries: %w", err)
}
diff --git a/internal/gitaly/service/commit/tree_entries_test.go b/internal/gitaly/service/commit/tree_entries_test.go
index a1ca7b750..b5371dbeb 100644
--- a/internal/gitaly/service/commit/tree_entries_test.go
+++ b/internal/gitaly/service/commit/tree_entries_test.go
@@ -378,6 +378,13 @@ func testGetTreeEntriesSuccessful(t *testing.T, ctx context.Context) {
entries: nil,
},
{
+ description: "with a non-existing path",
+ revision: []byte(commitID),
+ path: []byte("i-dont/exist"),
+ recursive: true,
+ entries: nil,
+ },
+ {
description: "with root path and sorted by trees first",
revision: []byte(commitID),
path: []byte("."),