From 9a718f210acb74a87ee31ba7a32feb3110658a57 Mon Sep 17 00:00:00 2001 From: Marke Hallowell Date: Wed, 2 May 2012 12:39:12 -0700 Subject: [PATCH] Using a temp file for git commit --amend instead of passing multi-line message to the shell. Avoids escaping issue on windows. Test Plan: Run arc diff locally, verify via git log that the commit is amended afterwards (using the mutable history paradigm) Reviewers: epriestley Reviewed By: epriestley CC: aran, Koolvin Differential Revision: https://secure.phabricator.com/D2369 --- src/repository/api/git/ArcanistGitAPI.php | 6 ++++-- src/repository/api/git/__init__.php | 2 ++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/repository/api/git/ArcanistGitAPI.php b/src/repository/api/git/ArcanistGitAPI.php index b47c0b0a..611a3e5b 100644 --- a/src/repository/api/git/ArcanistGitAPI.php +++ b/src/repository/api/git/ArcanistGitAPI.php @@ -412,9 +412,11 @@ final class ArcanistGitAPI extends ArcanistRepositoryAPI { } public function amendGitHeadCommit($message) { + $tmp_file = new TempFile(); + Filesystem::writeFile($tmp_file, $message); $this->execxLocal( - 'commit --amend --allow-empty --message %s', - $message); + 'commit --amend --allow-empty -F %s', + $tmp_file); } public function getPreReceiveHookStatus($old_ref, $new_ref) { diff --git a/src/repository/api/git/__init__.php b/src/repository/api/git/__init__.php index e57f8047..64fcef4d 100644 --- a/src/repository/api/git/__init__.php +++ b/src/repository/api/git/__init__.php @@ -12,6 +12,8 @@ phutil_require_module('arcanist', 'parser/diff'); phutil_require_module('arcanist', 'repository/api/base'); phutil_require_module('phutil', 'console'); +phutil_require_module('phutil', 'filesystem'); +phutil_require_module('phutil', 'filesystem/tempfile'); phutil_require_module('phutil', 'future'); phutil_require_module('phutil', 'future/exec'); phutil_require_module('phutil', 'utils'); -- 2.43.0