From 8a932d68b11de4a568f95691dadd9f4d7452016a Mon Sep 17 00:00:00 2001 From: Andreas Shimokawa Date: Thu, 18 Jun 2020 13:17:48 +0200 Subject: [PATCH] allow using codeberg pages without having a master branch use HEAD instad --- var/www/pages/index.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/var/www/pages/index.php b/var/www/pages/index.php index fbca7a2..c9ca209 100644 --- a/var/www/pages/index.php +++ b/var/www/pages/index.php @@ -54,7 +54,7 @@ if (substr($git_root, 0, strlen($git_prefix)) !== $git_prefix) { } # If this is a folder, we explicitly redirect to folder URL, otherwise browsers will construct invalid relative links: -$command = "sh -c \"cd '$git_root' && /usr/bin/git ls-tree 'master:$file_url' > /dev/null\""; +$command = "sh -c \"cd '$git_root' && /usr/bin/git ls-tree 'HEAD:$file_url' > /dev/null\""; exec($command, $output, $retval); if ($retval === 0) { if (substr($request_url, -1) !== "/") { @@ -101,17 +101,17 @@ if (array_key_exists($ext, $mime_types)) { ## We are executing command twice (first for send_response-checking, then for actual raw output to stream), ## which seems wasteful, but it seems exec+echo cannot do raw binary output? Is this true? -$command = "sh -c \"cd '$git_root' && /usr/bin/git show 'master:$file_url'\""; +$command = "sh -c \"cd '$git_root' && /usr/bin/git show 'HEAD:$file_url'\""; exec($command . " > /dev/null", $output, $retval); if ($retval != 0) { # Try adding '.html' suffix, if this does not work either, report error - $command = "sh -c \"cd '$git_root' && /usr/bin/git show 'master:$file_url.html'\""; + $command = "sh -c \"cd '$git_root' && /usr/bin/git show 'HEAD:$file_url.html'\""; exec($command . " > /dev/null", $output, $retval); header("Content-Type: text/html"); if ($retval != 0) { # Render user-provided 404.html if exists, generic 404 message if not: http_response_code(404); - $command = "sh -c \"cd '$git_root' && /usr/bin/git show 'master:404.html'\""; + $command = "sh -c \"cd '$git_root' && /usr/bin/git show 'HEAD:404.html'\""; exec($command . " > /dev/null", $output, $retval); if ($retval != 0) send_response(404 , "no such file in repo: '" . htmlspecialchars($file_url) . "'");