diff mbox

clone: make it possible to clone bare/mirror for a specific branch

Message ID 1400010964-32177-1-git-send-email-kim.hansen@prevas.dk
State Accepted
Delegated to: Esben Haabendal
Headers show

Commit Message

kim.hansen@prevas.dk May 13, 2014, 7:56 p.m. UTC
From: Kim Højgaard-Hansen <kiho@prevas.dk>

Without this it is not possible to correctly mirror a repository
that previously had more submodules than in current master since
these would not be cloned.
---
 oebakery/cmd/clone.py | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

Comments

Esben Haabendal May 14, 2014, 8:52 a.m. UTC | #1
Hi Kim

Merged to master, thanks.

I don't see what is wrong with your mail, but for some reason patchwork
did not pick it up...

/Esben
kim.hansen@prevas.dk May 14, 2014, 9:01 a.m. UTC | #2
ok, I think there is some problem with git send-email though, I set it to "in-reply-to" the previous thread, but it just use the subject from the patch instead

/Kim
Esben Haabendal May 14, 2014, 9:03 a.m. UTC | #3
Esben Haabendal <esben.haabendal@dev.prevas.dk> writes:

> I don't see what is wrong with your mail, but for some reason patchwork
> did not pick it up...

My bad, patchwork picked it up just nicely :)

/Esben
diff mbox

Patch

diff --git a/oebakery/cmd/clone.py b/oebakery/cmd/clone.py
index 0d9ac5b..ffb8386 100644
--- a/oebakery/cmd/clone.py
+++ b/oebakery/cmd/clone.py
@@ -78,14 +78,20 @@  def clone_checkout(options):
 
 def clone_bare(options):
     global clone_cmd
-    clone_cmd = 'git clone %s %%s %%s'%(
+    clone_cmd = 'git clone %s %%s %%s %%s'%(
         ['--bare', '--mirror'][int(options.mirror)])
-    failed = clone_bare_recursive(options.repository, options.directory)
+    failed = clone_bare_recursive(options.repository, options.directory, branch=options.branch)
     if failed:
         return "failed repositories: %s"%(', '.join(failed))
 
-def clone_bare_recursive(repository, directory):
-    if not oebakery.call(clone_cmd%(repository, directory)):
+def clone_bare_recursive(repository, directory, branch=None):
+    if branch:
+        #only clone using branch on the top level repository
+        #to get the wanted state of submodules
+        cmd = clone_cmd%('--branch %s'%(branch),repository, directory)
+    else:
+        cmd = clone_cmd%("",repository, directory)
+    if not oebakery.call(cmd):
         logger.error("bare clone of module %s failed", directory)
         return [directory]
     gitmodules = oebakery.call(