summaryrefslogtreecommitdiff
path: root/morphlib/localrepocache.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/localrepocache.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/localrepocache.py')
-rw-r--r--morphlib/localrepocache.py4
1 files changed, 2 insertions, 2 deletions
diff --git a/morphlib/localrepocache.py b/morphlib/localrepocache.py
index 9c20e4bc..8d2030c4 100644
--- a/morphlib/localrepocache.py
+++ b/morphlib/localrepocache.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2012-2013 Codethink Limited
+# Copyright (C) 2012-2014 Codethink Limited
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -110,7 +110,7 @@ class LocalRepoCache(object):
'''
- self._app.runcmd(['git'] + args, cwd=cwd)
+ morphlib.git.gitcmd(self._app.runcmd, *args, cwd=cwd)
def _fetch(self, url, path): # pragma: no cover
'''Fetch contents of url into a file.