[ros-users] Yet another fix for vcstools + git

Top Page
Attachments:
Message as email
+ (text/plain)
+ fixup-git-checkout-with-submodule.patch (text/x-patch)
Delete this message
Reply to this message
Author: Peter Soetens
Date:  
To: User discussions
Subject: [ros-users] Yet another fix for vcstools + git
Ticket # 3251 attempted to fix a git submodules bug, but the proposed
patch was a hack which assumed submodules wouldn't change across
branches. In our case, they do and the patch breaks our build on
oneiric of the orocos_toolchain_ros package. This could easily break
other stacks as well as more git stacks with submodules are created.

The correct fix is to delay the checkout and then update the submodules.
Also, there was a bug in the current version that if version was empty,
the checkout would not necessarily use HEAD.

I fixed all these issues and tested on a rosinstall file containing:

- git: {local-name: ros-git-test, uri:
'http://git.mech.kuleuven.be/robotics/orocos_toolchain_ros.git' }

as above, with a version: master and with a version: oneiric item
The oneiric version is without submodules, the master is with submodules.

I can't retest the case of ticket #3251 since that repos no longer exists,
but I think I got all cases covered.

Please consider applying since this bug breaks our oneiric build:
http://build.willowgarage.com/job/prerelease_electric_orocos_toolchain_ros_oneiric_amd64/2/console

The alternative for us is to define orocos-toolchain-ros as a variant
in the rosdistro file, but I could not find documentation on how to
test or release a variant.

Peter
Index: vcstools/src/vcstools/git.py
===================================================================
--- vcstools/src/vcstools/git.py    (revision 15288)
+++ vcstools/src/vcstools/git.py    (working copy)
@@ -92,25 +92,25 @@
         if self.path_exists():
             sys.stderr.write("Error: cannot checkout into existing directory\n")
             return False
-            
-        cmd = "git clone %s %s"%(url, self._path)
+
+        # Clone but don't checkout yet:
+        cmd = "git clone -n %s %s"%(url, self._path)
         if not subprocess.call(cmd, shell=True) == 0:
             return False


-        # update submodules early to work around what appears to be a git bug noted in #3251
-        if not self.update_submodules():
-            return False
+        # Happens if version tag was omitted
+        if version == '':
+            version = 'HEAD'


+        # Analyse version and checkout accordingly:
         if self.get_branch_parent() == version:
-            # If already at the right version update submodules and return
-            return self.update_submodules()
+            cmd = "git checkout"
         elif self.is_remote_branch(version):  # remote branch
-            cmd = "git checkout remotes/origin/%s -b %s"%(version, version)
+            cmd = "git checkout remotes/origin/%s -b %s --track"%(version, version)
         else:  # tag or hash
             cmd = "git checkout %s -b %s"%(version, branch_name)
-        if not self.is_hash(version) and not self.is_tag(version):
-            cmd = cmd + " --track"
-        #print "Git Installing: %s"%cmd
+
+        print "Git Installing: %s"%cmd
         if not subprocess.call(cmd, cwd=self._path, shell=True) == 0:
             return False