]> khamidou — GitHub mirrors - arcanist.git/commitdiff
Always use git.default-relative-commit, if present
authorNick Harper <nharper@fb.com>
Mon, 7 May 2012 00:03:32 +0000 (17:03 -0700)
committerNick Harper <nharper@fb.com>
Mon, 7 May 2012 16:54:47 +0000 (09:54 -0700)
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

index 611a3e5b568aca0a245db8c95117401d6960ba70..92ea13faf543b0057df7ef7c3dbbfee0326c5adb 100644 (file)
@@ -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.