4

We have an Upstart service/job that uses a local clone of a git repo. After relocating the data folder using a symbolic link we now get the following error message:

Failed to run 'git fetch' for /var/company/service/src/program repo; Details: fatal: Not a git repository (or any parent up to mount point /data) Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).

How can I set GIT_DISCOVERY_ACROSS_FILESYSTEM for the service?

Greg Bray
  • 14,929
  • 12
  • 80
  • 104

3 Answers3

6

GIT_DISCOVERY_ACROSS_FILESYSTEM is an environmental variable that git looks for when trying to find the root of the repo. If that path exists on another filesystem, the command will produce the above error message to prevent git from crossing filesystem boundaries. You can set the value to true to allow this operation, and most init systems have ways to add environmental variables for a job/service.

For Upstart we just needed to update the /etc/init/servicename.conf file to include env and export keywords:

start on runlevel [2345]
stop on runlevel [^2345]
respawn
respawn limit 10 2
chdir /usr/local/servicename
setgid servicegroup
setuid servicename
limit nofile 1000000 1000000

env GIT_DISCOVERY_ACROSS_FILESYSTEM=true
export GIT_DISCOVERY_ACROSS_FILESYSTEM
exec /usr/local/servicename --cfg /etc/servicename.cfg >> /var/log/servicename.log 2>&1

After reloading the config and restarting the service, the git error message went away.

Greg Bray
  • 14,929
  • 12
  • 80
  • 104
2

Here's an alternative (if I've inferred all of the details of your problem correctly) that I prefer:

  • Delete the .git -> <location_on_other_filesystem>/ symlink in your clone's directory

  • Create, in its place, a plain-text file named .git, with the contents
    gitdir: <location_on_other_filesystem>.

For future reference, both git clone and git init support the
--separate-git-dir <git_dir>
option, which accomplishes the same thing when you set up the repo/clone.

Edward
  • 1,000
  • 5
  • 16
0

Type this on your terminal & press enter:-

git init

This will remove the error

Nitish Kumar Pal
  • 2,738
  • 3
  • 18
  • 23