revision display support
[phorkie.git] / src / phorkie / Repository / Post.php
index f138491ac58735bc83eb61002aff455fdaf7e88c..96e5c1135153203a43eef3934024eb585a2f226e 100644 (file)
@@ -67,12 +67,17 @@ class Repository_Post
             } else if (isset($arFile['delete']) && $arFile['delete'] == 1) {
                 $bDelete = true;
             } else if ($orignalName != $name) {
-                //FIXME: what to do with overwrites?
-                $vc->getCommand('mv')
-                    ->addArgument($orignalName)
-                    ->addArgument($name)
-                    ->execute();
-                $bChanged = true;
+                if (strpos($name, '/') === false) {
+                    //ignore names with a slash in it, would be new directory
+                    //FIXME: what to do with overwrites?
+                    $vc->getCommand('mv')
+                        ->addArgument($orignalName)
+                        ->addArgument($name)
+                        ->execute();
+                    $bChanged = true;
+                } else {
+                    $name = $orignalName;
+                }
             }
 
             $file = $this->repo->getFileByName($name, false);
@@ -83,14 +88,14 @@ class Repository_Post
                 $bChanged = true;
             } else if ($bUpload) {
                 move_uploaded_file(
-                    $_FILES['files']['tmp_name'][$num]['upload'], $file->getPath()
+                    $_FILES['files']['tmp_name'][$num]['upload'], $file->getFullPath()
                 );
                 $command = $vc->getCommand('add')
                     ->addArgument($file->getFilename())
                     ->execute();
                 $bChanged = true;
-            } else if ($bNew || $file->getContent() != $arFile['content']) {
-                file_put_contents($file->getPath(), $arFile['content']);
+            } else if ($bNew || (isset($arFile['content']) && $file->getContent() != $arFile['content'])) {
+                file_put_contents($file->getFullPath(), $arFile['content']);
                 $command = $vc->getCommand('add')
                     ->addArgument($file->getFilename())
                     ->execute();
@@ -118,7 +123,7 @@ class Repository_Post
             //this should be setOption, but it fails with a = between name and value
             ->addArgument('--separate-git-dir')
             ->addArgument($GLOBALS['phorkie']['cfg']['gitdir'] . '/' . $repo->id . '.git')
-            ->addArgument($repo->workDir);
+            ->addArgument($repo->workDir)
             ->execute();
 
         foreach (glob($repo->gitDir . '/hooks/*') as $hookfile) {