I have a git hook (`post-receive`) to update the documentation, run the unit-tests etc. etc., but the thing is sometimes not working.

Here are the contents of the `post-receive` hook:

```
#!/usr/bin/bash
~/bubblegum_ci > /tmp/bubblegum_ci_log 2>&1 &
```

That's not hard to understand, just launch a script in the background and pipe stdout and stderr to a logfile.

Here are the contents of bubblegum_ci:

```
#!/usr/bin/bash
id
cd /home/git/bubblegum
pwd
GIT_CURL_VERBOSE=1 GIT_TRACE=1 git pull -v .
make genhtml doxygen
```
This one is also very simple; just cd to another repository, pull any changes, and invoke `make` to take care of the actual work. Sometimes it works just fine. Sometimes, the script gives the following output:

```
uid=1001(git) gid=1001(git) groups=1001(git),1002(www)
/home/git/bubblegum
fatal: not a git repository: '.'
make genhtml doxygen
<the output from make showing that the commits I just pushed have not been pulled>
```

That first line, `/home/git/bubblegum` obviously is the output from `pwd`, but then git fails to pull, saying it's not a git repo. I'm confused by the fact that this sometimes works and sometimes doesn't. Can anyone here shed any light on the issue? Is there a race condition I haven't spotted? Otherwise I would be interested to see if there's a better way to handle this kind of thing.

Here are the permissions for /home/git/bubblegum/.git:

```
git@fancy-server:~$ ls /home/git/bubblegum -al | grep \\.git
drwxr-xr-x 8 git git 4096 Sep 2 09:58 .git
```

here is the output of `ls -l /home/git/bubblegum/.git/`:

```
$ ls -l .git
total 52
-rw-r--r-- 1 git git 84 Sep 2 09:58 FETCH_HEAD
-rw-r--r-- 1 git git 23 Aug 31 15:42 HEAD
-rw-r--r-- 1 git git 41 Sep 2 09:58 ORIG_HEAD
drwxr-xr-x 2 git git 4096 Aug 31 15:42 branches
-rw-r--r-- 1 git git 251 Aug 31 15:42 config
-rw-r--r-- 1 git git 73 Aug 31 15:42 description
drwxr-xr-x 2 git git 4096 Aug 31 15:42 hooks
-rw-r--r-- 1 git git 1875 Sep 2 09:52 index
drwxr-xr-x 2 git git 4096 Aug 31 15:42 info
drwxr-xr-x 3 git git 4096 Aug 31 15:42 logs
drwxr-xr-x 151 git git 4096 Sep 2 09:52 objects
-rw-r--r-- 1 git git 114 Aug 31 15:42 packed-refs
drwxr-xr-x 5 git git 4096 Aug 31 15:42 refs
```

Here si the output of `mount | grep home`:

 /dev/sda6 on /home type ext4 (rw,relatime)