From d3374f09b980f59b32d84cedc7d9611286b99416 Mon Sep 17 00:00:00 2001 From: Jannis Pohlmann Date: Tue, 14 Feb 2012 14:28:07 +0000 Subject: 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. --- morphlib/git.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'morphlib/git.py') 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''' -- cgit v1.2.1