summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Maw <richard.maw@codethink.co.uk>2013-02-11 16:52:53 +0000
committerRichard Maw <richard.maw@codethink.co.uk>2013-02-11 17:36:51 +0000
commit282b737dd74c0b96d24a707903b437075fdef0fc (patch)
tree3ad4249d9c4e906570922fe912ee578716c49d38
parent2bc4e93f6c29ebdc7c63c1388dc579b0e1d1b081 (diff)
downloadmorph-282b737dd74c0b96d24a707903b437075fdef0fc.tar.gz
git: clone then checkout instead of clone -b
Newer versions of git have changed the behaviour when cloning with --branch=$sha1. It used to be nearly synonamous with clone then checkout. The clone then checkout logic is different to the clone with branch logic, since they have different behaviour with regard to the branches that are checked out in the workspace.
-rw-r--r--morphlib/git.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/morphlib/git.py b/morphlib/git.py
index 9ac9e292..c63c21b2 100644
--- a/morphlib/git.py
+++ b/morphlib/git.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2011-2012 Codethink Limited
+# Copyright (C) 2011-2013 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
@@ -256,8 +256,12 @@ def reset_workdir(runcmd, gitdir):
def clone_into(runcmd, srcpath, targetpath, ref=None):
'''Clones a repo in srcpath into targetpath, optionally directly at ref.'''
+
if ref is None:
runcmd(['git', 'clone', srcpath, targetpath])
+ elif is_valid_sha1(ref):
+ runcmd(['git', 'clone', srcpath, targetpath])
+ runcmd(['git', 'checkout', ref], cwd=targetpath)
else:
runcmd(['git', 'clone', '-b', ref, srcpath, targetpath])