]> khamidou — GitHub mirrors - arcanist.git/commitdiff
If a Git upstream is configured for the current branch, always use that as the defaul...
authorepriestley <git@epriestley.com>
Tue, 10 Apr 2012 22:33:31 +0000 (15:33 -0700)
committerepriestley <git@epriestley.com>
Tue, 10 Apr 2012 22:33:31 +0000 (15:33 -0700)
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

index 9a0ca790fadae556e45e629fd7a0825de62c73b6..271822358b1889f93e6c6b68502efdf5b060efeb 100644 (file)
@@ -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();