summaryrefslogtreecommitdiff
path: root/morphlib/morphologyfinder_tests.py
diff options
context:
space:
mode:
authorRichard Maw <richard.maw@codethink.co.uk>2014-08-21 12:58:46 +0000
committerRichard Maw <richard.maw@codethink.co.uk>2014-08-21 16:04:41 +0000
commit23e86c643a82731aba6561321b8bb5b168e80598 (patch)
tree4e50e39d30b775d3e911cfd375ec4bbcfa793eb4 /morphlib/morphologyfinder_tests.py
parent35f3a8779a316ed6a44ce5bb62bea9e2d7c67a16 (diff)
downloadmorph-23e86c643a82731aba6561321b8bb5b168e80598.tar.gz
Prevent git-replace refs affecting git operations
We assumed that the sha1 of the tree of the commit of the ref we care about was sufficient to cache, but `git replace` means that you need to know the state of other branches too, since anything in refs/replace can completely change what the tree you check-out is. This behaviour can be disabled globally by setting GIT_NO_REPLACE_OBJECTS, so we're going to do that. If we need to integrate a project that uses git-replace to change the contents of their git trees then we could support that by: if any(refs/replace/*): potentially_replacable_objects = [ `git rev-parse HEAD`, `git rev-parse HEAD^{commit}`, `git rev-parse HEAD^{tree}`] potentially_replacable_objects.extend( `git ls-tree -r HEAD | awk '{print $3}'`) # NOTE: doesn't handle submodules, and you'd need to expand this # set whenever you process a replacement for object in refs/replace/*: if basename(object) not in potentially_replacable_objects: continue cache_key['replacements'][basename(object)] = `git rev-parse $object` If we were to support this would need to traverse the tree anyway, doing replacements, so we may as well use libgit to do the checkout anyway, and list which replacements were used. However, since the expected use-case of `git replace` is as a better way to do history grafting, we're unlikely to need it, as it would only have any effect if it replaced the commit we were using with a different one. Rubber-stamped-by: Daniel Silverstone
Diffstat (limited to 'morphlib/morphologyfinder_tests.py')
-rw-r--r--morphlib/morphologyfinder_tests.py7
1 files changed, 4 insertions, 3 deletions
diff --git a/morphlib/morphologyfinder_tests.py b/morphlib/morphologyfinder_tests.py
index b07b2613..67161f9b 100644
--- a/morphlib/morphologyfinder_tests.py
+++ b/morphlib/morphologyfinder_tests.py
@@ -34,8 +34,8 @@ class MorphologyFinderTests(unittest.TestCase):
for fn in ('foo', 'bar.morph', 'baz.morph', 'quux'):
with open(os.path.join(self.dirname, fn), "w") as f:
f.write('dummy morphology text')
- gd._runcmd(['git', 'add', '.'])
- gd._runcmd(['git', 'commit', '-m', 'Initial commit'])
+ morphlib.git.gitcmd(gd._runcmd, 'add', '.')
+ morphlib.git.gitcmd(gd._runcmd, 'commit', '-m', 'Initial commit')
# Changes for difference between commited and work tree
newmorphpath = os.path.join(self.dirname, 'foo.morph')
@@ -45,7 +45,8 @@ class MorphologyFinderTests(unittest.TestCase):
# Changes for bare repository
self.mirror = os.path.join(self.tempdir, 'mirror')
- gd._runcmd(['git', 'clone', '--mirror', self.dirname, self.mirror])
+ morphlib.git.gitcmd(gd._runcmd, 'clone', '--mirror', self.dirname,
+ self.mirror)
def tearDown(self):
shutil.rmtree(self.tempdir)