From: Nick Harper Date: Mon, 7 May 2012 00:03:32 +0000 (-0700) Subject: Always use git.default-relative-commit, if present X-Git-Tag: conduit-4~17 X-Git-Url: http://git.khamidou.com/?a=commitdiff_plain;h=6fcd2db646805b9eb59957ed23021207a29c4e98;p=arcanist.git 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 --- 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.