From 6fcd2db646805b9eb59957ed23021207a29c4e98 Mon Sep 17 00:00:00 2001 From: Nick Harper Date: Sun, 6 May 2012 17:03:32 -0700 Subject: [PATCH] Always use git.default-relative-commit, if present Summary: Always use the value in git.default-relative-commit when getting the relative commit in git. Test Plan: Ran arc diff in a repo with git.default-relative-commit set to HEAD^ on a branch tracking a remote (that is different from HEAD^), and checked that the diff against HEAD^, not the remote, was published. Reviewers: jungejason, epriestley, vrana Reviewed By: epriestley CC: aran, Koolvin Differential Revision: https://secure.phabricator.com/D2409 --- src/repository/api/git/ArcanistGitAPI.php | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/src/repository/api/git/ArcanistGitAPI.php b/src/repository/api/git/ArcanistGitAPI.php index 611a3e5b..92ea13fa 100644 --- a/src/repository/api/git/ArcanistGitAPI.php +++ b/src/repository/api/git/ArcanistGitAPI.php @@ -130,12 +130,19 @@ final class ArcanistGitAPI extends ArcanistRepositoryAPI { $do_write = false; $default_relative = null; + $working_copy = $this->getWorkingCopyIdentity(); + if ($working_copy) { + $default_relative = $working_copy->getConfig( + 'git.default-relative-commit'); + } - list($err, $upstream) = $this->execManualLocal( - "rev-parse --abbrev-ref --symbolic-full-name '@{upstream}'"); + if (!$default_relative) { + list($err, $upstream) = $this->execManualLocal( + "rev-parse --abbrev-ref --symbolic-full-name '@{upstream}'"); - if (!$err) { - $default_relative = trim($upstream); + if (!$err) { + $default_relative = trim($upstream); + } } if (!$default_relative) { @@ -143,14 +150,6 @@ final class ArcanistGitAPI extends ArcanistRepositoryAPI { $default_relative = trim($default_relative); } - if (!$default_relative) { - $working_copy = $this->getWorkingCopyIdentity(); - if ($working_copy) { - $default_relative = $working_copy->getConfig( - 'git.default-relative-commit'); - } - } - if (!$default_relative) { // TODO: Remove the history lesson soon. -- 2.43.0