subrepo: bare git repos considered dirty
authorPaul Molodowitch <pm@stanfordalumni.org>
Wed, 25 May 2011 08:38:58 -0700
changeset 14440 96f1c1b14154
parent 14439 80c599eee3f3
child 14441 39e81b9377e6
subrepo: bare git repos considered dirty Currently, if there is a bare git subrepo, but it is at the "right" revision, calling dirty() will error because diff-index does not work on bare repos. This patch makes it so bare subrepos are always considered dirty.
mercurial/subrepo.py
--- a/mercurial/subrepo.py	Thu May 26 00:53:23 2011 +0300
+++ b/mercurial/subrepo.py	Wed May 25 08:38:58 2011 -0700
@@ -761,6 +761,9 @@
         base = self._gitcommand(['merge-base', r1, r2])
         return base == r1
 
+    def _gitisbare(self):
+        return self._gitcommand(['config', '--bool', 'core.bare']) == 'true'
+
     def _gitbranchmap(self):
         '''returns 2 things:
         a map from git branch to revision
@@ -823,6 +826,8 @@
     def dirty(self, ignoreupdate=False):
         if self._gitmissing():
             return True
+        if self._gitisbare():
+            return True
         if not ignoreupdate and self._state[1] != self._gitstate():
             # different version checked out
             return True
@@ -834,7 +839,7 @@
         source, revision, kind = state
         self._fetch(source, revision)
         # if the repo was set to be bare, unbare it
-        if self._gitcommand(['config', '--bool', 'core.bare']) == 'true':
+        if self._gitisbare():
             self._gitcommand(['config', 'core.bare', 'false'])
             if self._gitstate() == revision:
                 self._gitcommand(['reset', '--hard', 'HEAD'])