Fix: typos in clone commands were creating empty repos
authorSteve McIntyre <smcintyre@aminocom.com>
Tue, 2 Mar 2010 11:53:15 +0000 (11:53 +0000)
committerSteve McIntyre <smcintyre@aminocom.com>
Tue, 2 Mar 2010 11:53:15 +0000 (11:53 +0000)
Changes to the logic in serve() made it possible for code flow to fall
through further than initially expected. ONLY attempt to init a new
repo if we are trying to WRITE to a non-existent repo. That way,
trying to read from a non-existent repo will fail as it should.

gitosis/serve.py

index 732a0e4..904bb2e 100644 (file)
@@ -139,10 +139,14 @@ def serve(
            'git extension should have been stripped: %r' % relpath
     repopath = '%s.git' % relpath
     fullpath = os.path.join(topdir, repopath)
-    if not os.path.exists(fullpath):
-        # it doesn't exist on the filesystem, but the configuration
-        # refers to it, we're serving a write request, and the user is
-        # authorized to do that: create the repository on the fly
+    if verb in COMMANDS_WRITE and not os.path.exists(fullpath):
+        # IFF:
+        # 1. it doesn't exist on the filesystem
+        # 2. the configuration refers to it
+        # 3. we're serving a write request
+        # 4. and the user is authorized to do that:
+        # THEN:
+        # create the repository on the fly
 
         # create leading directories
         p = topdir