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>2023-01-03 15:00:21 +0300
committerPatrick Steinhardt <psteinhardt@gitlab.com>2023-01-03 17:55:21 +0300
commitfb830f5f01311609c01590ddf04a22a3d33cd36d (patch)
tree399a9adfa4c6c4c93bfa74baaa52977582e96af1
parentaa9f210c73eea36dba5561477932c08b7c855578 (diff)
repository: Disable misleading dangling checks in git-fsck(1)
The `Fsck` RPC uses git-fsck(1) to inform the user about repository corruption. In case the Git command returns with a non-zero exit code the RPC will return both its stdout and stderr to the caller via the `Error` field that is part of the `FsckResponse`. By default, git-fsck(1) will not only print information about repository corruption though, but also about dangling objects that aren't reachable via any reference. But as it is totally expected that repositories have dangling objects, it is only distracting from the actual error messages that the repository owner would care about. Stop git-fsck(1) from checking for dangling objects to improve the signal to noise ratio. While at it, let's also explicitly ask it to not print any progress -- while it wouldn't do that anyway because it is not printing to a TTY, it stops the next reader of the code from wondering whether it would ever do that. Changelog: improved
-rw-r--r--internal/gitaly/service/repository/fsck.go12
-rw-r--r--internal/gitaly/service/repository/fsck_test.go7
2 files changed, 12 insertions, 7 deletions
diff --git a/internal/gitaly/service/repository/fsck.go b/internal/gitaly/service/repository/fsck.go
index 6ccd7499b..9561339a7 100644
--- a/internal/gitaly/service/repository/fsck.go
+++ b/internal/gitaly/service/repository/fsck.go
@@ -18,7 +18,17 @@ func (s *server) Fsck(ctx context.Context, req *gitalypb.FsckRequest) (*gitalypb
var output strings.Builder
cmd, err := s.gitCmdFactory.New(ctx, repository,
- git.Command{Name: "fsck"},
+ git.Command{
+ Name: "fsck",
+ Flags: []git.Option{
+ // We don't care about any progress bars.
+ git.Flag{Name: "--no-progress"},
+ // We don't want to get warning about dangling objects. It is
+ // expected that repositories have these and makes the signal to
+ // noise ratio a lot worse.
+ git.Flag{Name: "--no-dangling"},
+ },
+ },
git.WithStdout(&output),
git.WithStderr(&output),
)
diff --git a/internal/gitaly/service/repository/fsck_test.go b/internal/gitaly/service/repository/fsck_test.go
index 303ad8934..6bf337388 100644
--- a/internal/gitaly/service/repository/fsck_test.go
+++ b/internal/gitaly/service/repository/fsck_test.go
@@ -150,12 +150,7 @@ func TestFsck(t *testing.T) {
{Path: "duplicate", Mode: "100644", Content: "bar"},
})
- expectedErr := strings.Join([]string{
- "error in tree " + treeID.String() + ": duplicateEntries: contains duplicate file entries",
- // This error is a bug: we shouldn't complain about the
- // dangling tree.
- "dangling tree " + treeID.String(),
- }, "\n") + "\n"
+ expectedErr := "error in tree " + treeID.String() + ": duplicateEntries: contains duplicate file entries\n"
return setupData{
repo: repo,