Bug 1246998 - Take worktrees into account in git mozreview draft
authorMike Hommey <mh@glandium.org>
Thu, 11 Feb 2016 12:51:03 +0900
changeset 7220 155eab8851d408dc29a5f20a45c5e199ac27c424
parent 7219 02b77aaee9659140196f5cfbe5f3d6bee0d22e97
push id616
push userbmo:mh+mozilla@glandium.org
push dateThu, 11 Feb 2016 03:51:15 +0000
bugs1246998
Bug 1246998 - Take worktrees into account in git mozreview
git/commands/git-mozreview
--- a/git/commands/git-mozreview
+++ b/git/commands/git-mozreview
@@ -53,17 +53,24 @@ CLIENT_CAPABILITIES = {
     'bzapikeys',
     'jsonproto',
     'commitid',
 }
 
 MAX_REVIEW_COMMITS = 100
 
 
-git_dir = os.environ.get('GIT_DIR')
+git_dir = os.environ.get('GIT_COMMON_DIR')
+if not git_dir:
+    git_dir = os.environ.get('GIT_DIR')
+if not git_dir:
+    git_dir = subprocess.check_output(
+            ['git', 'rev-parse', '--no-flags', '--git-common-dir']).rstrip('\n')
+# git versions before 2.5 don't support --git-common-dir, so fallback to
+# --git-dir
 if not git_dir:
     git_dir = subprocess.check_output(
             ['git', 'rev-parse', '--git-dir']).rstrip('\n')
 
 
 def gethgui():
     """Obtain a Mercurial ui instance.