Skip to content

Adjust example for running git-fsck repository check to run as the git user

What does this MR do and why?

The example command given for running git-fsck on the Gitaly server executes the command as the root user. Based on the path to the git executable in the example, it appears this example is based on the Omnibus installation, wherein the git repos on-disk are owned by the "git" user. Running git as root against "git"-owned files will result in an error from git about dubious ownership. By altering the example shown to run the git command as user "git", the user will have a working command that produces no errors. And in case the user alters the command to run git-gc or another writing git command, then permissions will remain corrected (any new files will be owned by "git").

The error:

brycec@gitlab:~$ sudo /opt/gitlab/embedded/bin/git -C  /var/opt/gitlab/git-data/repositories/@hashed/85/27/8527a891e224136950ff32ca212b45bc93f69fbb801c3b1ebedac52775f99e61.git show 37e2cd62463e99bbd8728aefc0cef4429ce7d2cc
fatal: detected dubious ownership in repository at '/var/opt/gitlab/git-data/repositories/@hashed/85/27/8527a891e224136950ff32ca212b45bc93f69fbb801c3b1ebedac52775f99e61.git'
To add an exception for this directory, call:

        git config --global --add safe.directory /var/opt/gitlab/git-data/repositories/@hashed/85/27/8527a891e224136950ff32ca212b45bc93f69fbb801c3b1ebedac52775f99e61.git

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Bryce Chidester

Merge request reports