]> khamidou — GitHub mirrors - arcanist.git/commitdiff
Use `git diff a b` for ranges, not `git diff a..b`
authorepriestley <git@epriestley.com>
Fri, 11 Jul 2014 17:45:11 +0000 (10:45 -0700)
committerepriestley <git@epriestley.com>
Fri, 11 Jul 2014 17:45:11 +0000 (10:45 -0700)
Summary:
These are documented as being identical, but `git diff a b` works if `a` is a tree (for example, `4b825d...`, the empty tree hash), but `git diff a..b` does not.

Particularly, with the `a..b` form, `arc diff --base arc:empty` does not work. With the `a b` form, it does.

Test Plan: Ran `arc diff --base arc:empty` in a repository and got a diff.

Reviewers: btrahan, talshiri

Reviewed By: talshiri

Subscribers: epriestley

Differential Revision: https://secure.phabricator.com/D9898

src/repository/api/ArcanistGitAPI.php

index e9f05f588d31817b68aa4d1787d2e72d49ea690d..514f6068003afdead5f058f0267996d6162ff41c 100644 (file)
@@ -429,17 +429,20 @@ final class ArcanistGitAPI extends ArcanistRepositoryAPI {
    * @param head revision. If this is null, the generated diff will include the
    * working copy
    */
-  public function getFullGitDiff($base, $head=null) {
+  public function getFullGitDiff($base, $head = null) {
     $options = $this->getDiffFullOptions();
 
-    $diff_revision = $base;
-    if ($head) {
-      $diff_revision .= '..'.$head;
+    if ($head !== null) {
+      list($stdout) = $this->execxLocal(
+        "diff {$options} %s %s --",
+        $base,
+        $head);
+    } else {
+      list($stdout) = $this->execxLocal(
+        "diff {$options} %s --",
+        $base);
     }
 
-    list($stdout) = $this->execxLocal(
-      "diff {$options} %s --",
-      $diff_revision);
     return $stdout;
   }