summaryrefslogtreecommitdiff
path: root/morphlib/git.py
diff options
context:
space:
mode:
authorJannis Pohlmann <jannis.pohlmann@codethink.co.uk>2012-02-14 14:28:07 +0000
committerJannis Pohlmann <jannis.pohlmann@codethink.co.uk>2012-02-14 15:25:55 +0000
commitd3374f09b980f59b32d84cedc7d9611286b99416 (patch)
treeca1e76b31d7f0ed5330e80c8ab57604809f6be0a /morphlib/git.py
parent2c1fb6748a746b2a0796cd26fef6cd4cb4ae7123 (diff)
downloadmorph-d3374f09b980f59b32d84cedc7d9611286b99416.tar.gz
Switch to caching repos without checking them out.
This is almost as good as --bare. But unlike --bare, it properly sets up the 'origin' remote and creates the 'refs/remotes/origin/...' branches. When cloning with --bare, and you end up with "refs/heads/master", not "/refs/remotes/origin/master". You can re-add the remote 'origin', still no "refs/remotes/origin/master". Only after you update the remote (after re-adding it), the bare clone has "refs/remotes/origin/master"... and a "refs/heads/master" that is out of sync. An ugly mix, basically. So maybe this approach is better.
Diffstat (limited to 'morphlib/git.py')
-rw-r--r--morphlib/git.py11
1 files changed, 6 insertions, 5 deletions
diff --git a/morphlib/git.py b/morphlib/git.py
index 5000cd21..5563d625 100644
--- a/morphlib/git.py
+++ b/morphlib/git.py
@@ -70,7 +70,7 @@ class Treeish(object):
try:
refs = ex.runv(['git', 'show-ref', ref]).split('\n')
- # drop the refs that are not from origin
+ # split each ref line into an array, drop non-origin branches
refs = [x.split() for x in refs if 'origin' in x]
binascii.unhexlify(refs[0][0]) #Valid hex?
@@ -189,7 +189,7 @@ class Submodules(object):
# fail if the commit hash is invalid
if len(submodule.commit) != 40:
raise MissingSubmoduleCommitError(self.treeish,
- submodule.name)
+ submodule.name)
# add a submodule object to the list
self.submodules.append(submodule)
@@ -198,7 +198,8 @@ class Submodules(object):
'a non-commit object for it' %
(submodule.name, self.treeish))
except morphlib.execute.CommandFailure:
- raise MissingSubmoduleCommitError(self.treeish, submodule.name)
+ raise MissingSubmoduleCommitError(self.treeish,
+ submodule.name)
else:
raise InvalidSectionError(self.treeish, section)
@@ -225,12 +226,12 @@ def get_morph_text(treeish, filename, msg=logging.debug):
def extract_bundle(location, bundle, msg=logging.debug):
'''Extract a bundle into git at location'''
ex = morphlib.execute.Execute(location, msg=msg)
- return ex.runv(['git', 'clone', bundle, '.'])
+ return ex.runv(['git', 'clone', '-n', bundle, '.'])
def clone(location, repo, msg=logging.debug):
'''clone at git repo into location'''
ex = morphlib.execute.Execute('.', msg=msg)
- return ex.runv(['git', 'clone', '-l', repo, location])
+ return ex.runv(['git', 'clone', '-n', '-l', repo, location])
def init(location, msg=logging.debug):
'''initialise git repo at location'''