From 7ad2783be18ba8a3b88f78d8b9177bef11602731 Mon Sep 17 00:00:00 2001
From: hanyixuanten <105723997+hanyixuanten@users.noreply.github.com>
Date: Fri, 14 Aug 2026 17:55:21 +0800
Subject: [PATCH] remove git excuteable need
---
README.md | 16 +--
config.php.sample | 5 -
index.php | 9 +-
install.php | 11 --
lib/git_service.php | 317 ++------------------------------------------
lib/i18n.php | 10 --
usage.md | 45 +++----
7 files changed, 37 insertions(+), 376 deletions(-)
diff --git a/README.md b/README.md
index 8d649cd..88b7edd 100644
--- a/README.md
+++ b/README.md
@@ -21,7 +21,7 @@ This project serves configured Git repositories through PHP. It supports:
`index.php` is the application entry point. Protocol responsibilities are split
into `operations/clone.php`, `operations/pull.php`, `operations/push.php`,
`operations/branch.php` and `operations/tag.php`; shared routing, repository,
-HTTP and Git process code is under `lib/`.
+HTTP and pure-PHP Git protocol code is under `lib/`.
Requirements
------------
@@ -30,23 +30,21 @@ Requirements
- Apache with `mod_rewrite` and `.htaccess` enabled for normal deployment.
- MySQL 5.7+/MariaDB 10.2+ and PHP PDO MySQL (`pdo_mysql`) when account
authentication is enabled.
-- PHP zlib and hash extensions for the native Git protocol implementation.
-- Git and PHP `proc_open` are optional; when available, Git remains the Smart
- HTTP backend for full protocol and hook compatibility.
+- PHP zlib and hash extensions are required for the Smart HTTP implementation.
- Read access to published repositories; write access is also required for push
and for the managed repository directory when home-page creation is enabled.
-If Git or `proc_open` is unavailable, the native PHP backend supports ordinary
-SHA-1 clone, fetch, pull and push, including deltas, branches and tags. It does
-not currently support SHA-256 repositories, shallow or filtered fetches, signed
-push certificates, Git hooks or protocol v2-only features.
+The pure-PHP backend supports ordinary SHA-1 clone, fetch, pull and push,
+including deltas, branches and tags. It does not currently support SHA-256
+repositories, shallow or filtered fetches, signed push certificates, Git hooks
+or protocol v2-only features.
Push is disabled by default and should be enabled only behind HTTPS.
Configuration
-------------
Copy `config.php.sample` to `config.php`, import `schema.mysql.sql`, then
-configure `$url_base`, `$git_executable`, `$auth`, `$repos` and optionally
+configure `$url_base`, `$auth`, `$repos` and optionally
`$managed_repositories`. A writable repository can be configured as:
```php
diff --git a/config.php.sample b/config.php.sample
index 96e06c7..2ac7c85 100644
--- a/config.php.sample
+++ b/config.php.sample
@@ -6,11 +6,6 @@
$url_base = '';
-/* Git executable used by Smart HTTP when available. If it is unavailable,
- * supported SHA-1 Smart HTTP operations run through the native PHP backend. */
-
-$git_executable = 'git';
-
/* Interface language: 'en', 'zh', or empty to follow the browser. */
$language = '';
diff --git a/index.php b/index.php
index ceaa70b..d6963a1 100644
--- a/index.php
+++ b/index.php
@@ -242,7 +242,6 @@ function home_creation_result_notice($result) {
case 'already_exists': return array(409, 'error', t('notice.repository_exists', array('name' => $name)));
case 'create_busy': return array(409, 'error', t('notice.repository_create_busy'));
case 'root_unavailable': return array(503, 'error', t('notice.repository_root_unavailable'));
- case 'git_unavailable': return array(503, 'error', t('notice.repository_git_unavailable'));
case 'metadata_unavailable': return array(503, 'error', t('notice.repository_metadata_unsaved'));
default: return array(500, 'error', t('notice.repository_create_failed'));
}
@@ -297,7 +296,6 @@ function home_create_repository(
$result = array('status' => 'already_exists', 'name' => $name);
} else {
$result = git_service_create_managed_repository(
- $application,
$configuration,
$value,
$owner['id'],
@@ -918,9 +916,6 @@ if (!isset($repos) || !is_array($repos)) {
send_error(500, 'Internal Server Error', 'The repository configuration is invalid.');
}
-if (!isset($git_executable)) {
- $git_executable = 'git';
-}
if (!isset($auth)) {
$auth = array();
@@ -938,9 +933,7 @@ if (!is_array($managed_repositories)) {
send_error(500, 'Internal Server Error', 'The managed repository configuration is invalid.');
}
-$application = array(
- 'git_executable' => $git_executable,
- 'push_ref_rules' => array());
+$application = array('push_ref_rules' => array());
$services = array();
register_branch_operation($application);
diff --git a/install.php b/install.php
index fd6552b..ff6eba4 100644
--- a/install.php
+++ b/install.php
@@ -121,10 +121,6 @@ function install_validate($input) {
&& !preg_match('~^/[A-Za-z0-9._~/-]*[A-Za-z0-9._~-]$~D', $input['url_base'])) {
$errors[] = t('install.error_url_base');
}
- if ($input['git_executable'] === '' || strlen($input['git_executable']) > 255
- || preg_match('~[\x00-\x1F\x7F]~', $input['git_executable'])) {
- $errors[] = t('install.error_git_executable');
- }
if (!install_host_is_valid($input['db_host'])) {
$errors[] = t('install.error_db_host');
}
@@ -223,7 +219,6 @@ function install_config_contents($input) {
return " TRUE,\n"
@@ -382,10 +377,6 @@ function install_send_form($input, $errors) {
.''
.'
'.t('install.hint_url_base').'
' ."\n";
- echo ''
- .'
'
- .'
'.t('install.hint_git_executable').'
' ."\n";
echo ''
.'