# HG changeset patch # User Paul Molodowitch # Date 2011-05-25 15:38:58 # Node ID 96f1c1b141549be3671e567f00d9e228a49069d6 # Parent 80c599eee3f3b867cdd2a10cf62d3da19f8f2d32 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. diff --git a/mercurial/subrepo.py b/mercurial/subrepo.py --- a/mercurial/subrepo.py +++ b/mercurial/subrepo.py @@ -761,6 +761,9 @@ class gitsubrepo(abstractsubrepo): 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 @@ class gitsubrepo(abstractsubrepo): 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 @@ class gitsubrepo(abstractsubrepo): 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'])