From 7ea51b6bb77baec1c2d15d98c99e708df9b676d1 Mon Sep 17 00:00:00 2001 From: epriestley Date: Tue, 10 Apr 2012 15:33:31 -0700 Subject: [PATCH] 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 --- src/repository/api/git/ArcanistGitAPI.php | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) 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(); -- 2.43.0