[PATCH stable] subrepo: fix git status false positive (issue3109)
Eric Roshan Eisner
ede at alum.mit.edu
Fri Nov 18 10:17:43 CST 2011
# HG changeset patch
# User Eric Roshan Eisner <ede at alum.mit.edu>
# Date 1320969611 -40260
# Branch stable
# Node ID b305f153dac07ae6d9a8ac4508913188493906e2
# Parent 6eff984d8e76811f1ce129a424236abf0afaa191
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.
diff --git a/mercurial/subrepo.py b/mercurial/subrepo.py
--- a/mercurial/subrepo.py
+++ b/mercurial/subrepo.py
@@ -807,6 +807,12 @@ class gitsubrepo(abstractsubrepo):
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 @@ class gitsubrepo(abstractsubrepo):
# 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 @@ class gitsubrepo(abstractsubrepo):
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 @@ class gitsubrepo(abstractsubrepo):
# if the repo is missing, return no results
return [], [], [], [], [], [], []
modified, added, removed = [], [], []
+ self._gitupdatestat()
if rev2:
command = ['diff-tree', rev1, rev2]
else:
diff --git a/tests/test-subrepo-git.t b/tests/test-subrepo-git.t
--- a/tests/test-subrepo-git.t
+++ b/tests/test-subrepo-git.t
@@ -361,6 +361,15 @@ Don't crash if the .hgsubstate entry is
$ hg update -qC nosubstate
$ ls s
+issue3109: false positives in git diff-index
+
+ $ hg update -q
+ $ touch -d 0 s/g
+ $ hg status --subrepos
+ $ touch -d 0 s/g
+ $ hg sum | grep commit
+ commit: (clean)
+
Check hg update --clean
$ cd $TESTTMP/ta
$ echo > s/g
More information about the Mercurial-devel
mailing list