Skip to main content
1 of 4

Why is this path only sometimes not a git repository?

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 cd /home/git/bubblegum pwd 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:

/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.