changeset 15531:0810ccc51f0a stable

subrepo: fix git status false positive (issue3109) It turns out there's a separate command to force git to look at file contents if the stat has changed.
author Eric Roshan Eisner <ede@alum.mit.edu>
date Fri, 11 Nov 2011 11:11:11 +1111
parents 8b011ededfb2
children 5edaf47cd462
files mercurial/subrepo.py tests/test-subrepo-git.t
diffstat 2 files changed, 18 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/subrepo.py	Wed Nov 16 08:34:36 2011 +0100
+++ b/mercurial/subrepo.py	Fri Nov 11 11:11:11 2011 +1111
@@ -807,6 +807,12 @@
     def _gitisbare(self):
         return self._gitcommand(['config', '--bool', 'core.bare']) == 'true'
 
+    def _gitupdatestat(self):
+        """This must be run before git diff-index.
+        diff-index only looks at changes to file stat;
+        this command looks at file contents and updates the stat."""
+        self._gitcommand(['update-index', '-q', '--refresh'])
+
     def _gitbranchmap(self):
         '''returns 2 things:
         a map from git branch to revision
@@ -876,6 +882,7 @@
             # different version checked out
             return True
         # check for staged changes or modified files; ignore untracked files
+        self._gitupdatestat()
         out, code = self._gitdir(['diff-index', '--quiet', 'HEAD'])
         return code == 1
 
@@ -983,6 +990,7 @@
         source, revision, kind = state
         self._fetch(source, revision)
         base = self._gitcommand(['merge-base', revision, self._state[1]])
+        self._gitupdatestat()
         out, code = self._gitdir(['diff-index', '--quiet', 'HEAD'])
 
         def mergefunc():
@@ -1090,6 +1098,7 @@
             # if the repo is missing, return no results
             return [], [], [], [], [], [], []
         modified, added, removed = [], [], []
+        self._gitupdatestat()
         if rev2:
             command = ['diff-tree', rev1, rev2]
         else:
--- a/tests/test-subrepo-git.t	Wed Nov 16 08:34:36 2011 +0100
+++ b/tests/test-subrepo-git.t	Fri Nov 11 11:11:11 2011 +1111
@@ -361,6 +361,15 @@
   $ hg update -qC nosubstate
   $ ls s
 
+issue3109: false positives in git diff-index
+
+  $ hg update -q
+  $ touch -t 200001010000 s/g
+  $ hg status --subrepos
+  $ touch -t 200001010000 s/g
+  $ hg sum | grep commit
+  commit: (clean)
+
 Check hg update --clean
   $ cd $TESTTMP/ta
   $ echo  > s/g