]> khamidou — GitHub mirrors - arcanist.git/commitdiff
Allow `arc diff` and similar to run on systems with no `git`
authorepriestley <git@epriestley.com>
Mon, 4 Feb 2013 19:34:53 +0000 (11:34 -0800)
committerepriestley <git@epriestley.com>
Mon, 4 Feb 2013 19:34:53 +0000 (11:34 -0800)
Summary:
We assume `git` is available now, but should not. Specifically, if a user runs a working copy operation like `arc list` in an SVN working copy without `git` available, they get this error: P707

We interpret git errors very narrowly; be more liberal in how we interpret them. This assumes users working with `git` will have a functional `git`, but this seems like a reasonable assumption and lets us remove some error text matching code.

Test Plan: Changed `git` to `girt`, ran `arc list`, saw a reasonable exception. Changed back to `git`, saw git detected.

Reviewers: btrahan, vrana

Reviewed By: vrana

CC: svemir, aran
Differential Revision: https://secure.phabricator.com/D4804

src/repository/api/ArcanistRepositoryAPI.php

index 4501dc4cecdbf7bc111833c6224f8536a62dac48..0a170fa780c13b63e71a2ffb27f2ada3d6129899 100644 (file)
@@ -288,10 +288,11 @@ abstract class ArcanistRepositoryAPI {
 
       return Filesystem::resolvePath(rtrim($stdout, "\n"), $root);
     } catch (CommandException $ex) {
-      if (preg_match('/^fatal: Not a git repository/', $ex->getStdErr())) {
-        return null;
-      }
-      throw $ex;
+      // This might be because the $root isn't a Git working copy, or the user
+      // might not have Git installed at all so the `git` command fails. Assume
+      // that users trying to work with git working copies will have a working
+      // `git` binary.
+      return null;
     }
   }