From: epriestley Date: Tue, 10 Apr 2012 22:33:31 +0000 (-0700) Subject: If a Git upstream is configured for the current branch, always use that as the defaul... X-Git-Tag: conduit-4~49 X-Git-Url: http://git.khamidou.com/?a=commitdiff_plain;h=7ea51b6bb77baec1c2d15d98c99e708df9b676d1;p=arcanist.git If a Git upstream is configured for the current branch, always use that as the default relative commit Summary: See discussion in D1861. Test Plan: Ran "arc diff" on master, got an upstream-based relative commit. Ran "arc diff" on a feature branch, got a config-based relative commit. Ran "arc diff x", got an argument-based relative commit. Reviewers: btrahan, vrana, davidreuss, elgenie Reviewed By: davidreuss CC: aran Differential Revision: https://secure.phabricator.com/D2192 --- diff --git a/src/repository/api/git/ArcanistGitAPI.php b/src/repository/api/git/ArcanistGitAPI.php index 9a0ca790..27182235 100644 --- a/src/repository/api/git/ArcanistGitAPI.php +++ b/src/repository/api/git/ArcanistGitAPI.php @@ -128,8 +128,19 @@ final class ArcanistGitAPI extends ArcanistRepositoryAPI { return $this->relativeCommit; } - $default_relative = $this->readScratchFile('default-relative-commit'); $do_write = false; + $default_relative = null; + + list($err, $upstream) = $this->execManualLocal( + "rev-parse --abbrev-ref --symbolic-full-name '@{upstream}'"); + + if (!$err) { + $default_relative = trim($upstream); + } + + if (!$default_relative) { + $default_relative = $this->readScratchFile('default-relative-commit'); + } if (!$default_relative) { $working_copy = $this->getWorkingCopyIdentity();