[DOC-WEB] [web-doc] master: Need to pass safe.directory to Git invocations

[email protected] (Jim Winstead) Tue, 22 Oct 2024 23:43:29 +0000
Newsgroups php.doc.web
Message-ID <[email protected]>
Author: Jim Winstead (jimwins)
Date: 2024-10-22T16:39:19-07:00

Commit: https://github.com/php/web-doc/commit/1f8d7bd1d82cc7a8f3635f1472ca9cdc053606b7
Raw diff: https://github.com/php/web-doc/commit/1f8d7bd1d82cc7a8f3635f1472ca9cdc053606b7.diff

Need to pass safe.directory to Git invocations

Original patch by @nilgun in #43

Changed paths:
  M  include/lib_revcheck.inc.php


Diff:

diff --git a/include/lib_revcheck.inc.php b/include/lib_revcheck.inc.php
index ad3f0db..ce534a0 100644
--- a/include/lib_revcheck.inc.php
+++ b/include/lib_revcheck.inc.php
@@ -249,13 +249,14 @@ function showdiff ()
         if (isset($_GET['c']))
             $c = $_GET['c'];
         $cwd = getcwd();
+        $safedir = 'safe.directory=' . GIT_DIR . 'en';
         chdir( GIT_DIR . 'en' );
         $arg_h = escapeshellarg($h);
         $arg_f = escapeshellarg($gitfile);
-        $file = `git diff --ignore-space-at-eol {$arg_h} -- {$arg_f}`;
+        $file = `git -c {$safedir} diff --ignore-space-at-eol {$arg_h} -- {$arg_f}`;
         if ($file == null)
-            $file = `git diff {$arg_h} -- {$arg_f}`;
-        $hash = `git log -n 1 --pretty=format:%H -- {$arg_f}`;
+            $file = `git -c {$safedir} diff {$arg_h} -- {$arg_f}`;
+        $hash = `git -c {$safedir} log -n 1 --pretty=format:%H -- {$arg_f}`;
         chdir( $cwd );
         if (!$file) return;
         $raw = htmlspecialchars( $file, ENT_XML1, 'UTF-8' );