chiark / gitweb /
git-cache-proxy: postpone chdir so Housekeeping lock and stamp and up in the right...
[chiark-utils.git] / scripts / git-cache-proxy
index 4d55233a5f1a70d9cddd8efee5022e5ce3357a9c..d12bdb3a3c1c7de8c30d9a14a46883a7c52b0942 100755 (executable)
@@ -370,10 +370,10 @@ sub clonefetch () {
     servinfo "sharing";
     lockfile \*LOCK, $lock, LOCK_SH; # NB releases and relocks
 
-    if (chdir $gitd) {
+    if (stat $gitd) {
        return 1;
     }
-    $!==ENOENT or fail "chdir $gitd: $!";
+    $!==ENOENT or fail "stat $gitd: $!";
 
     # Well, err, someone must have taken the lock in between
     # and garbage collected it.  How annoying.
@@ -457,6 +457,9 @@ sub housekeepingcheck ($$) {
 
 sub runcommand () {
     servinfo "serving";
+
+    chdir $gitd or fail "chdir $gitd: $!";
+
     exec qw(git-upload-pack --strict --timeout=1000 .)
        or fail "exec git-upload-pack: $!";
 }