Bots: Checkout failure in git projects that have submodules with a detached HEAD

Originator:inbox
Number:rdar://15184702 Date Originated:2013-10-09
Status:Open Resolved:
Product:Developer Tools Product Version:5.0.1
Classification:Serious Bug Reproducible:Always
 
When creating Bots that check out git repositories, if any submodules are in a detached HEAD state, checkouts will always fail.

Steps to reproduce: 

1. Install Xcode 5.0 on your machine, and set up 10.9 Server on another with the Xcode service running.

2. Open a project in Xcode that contains a git submodule checked out to an arbitrary commit, and is thus in a detached HEAD state.

3. Create a Bot with this project and attempt to Integrate it.

Expected behaviour:

The Xcode service on the server machine should check out the project and build it.

Actual behaviour:

During the checkout process, checkout fails and the integration fails.

Notes:

This can be worked around by ensuring that you always have the HEAD of a branch checked out in your submodules. However, having a detached HEAD in submodules is a very common case.

Comments

Background:

If you are working with submodules it is quite common to have a detached HEAD.

Workaround:

This can be easily resolved by rejoining the submodules to the main branch (this not only resolves the Xcode bug but also makes it much easier to resync to HEAD any time in the future).

Commands:

To rejoin the particular checkout with the main branch:

git submodule foreach --recursive git checkout master

To update all the submodules (at some point in the future):

git submodule foreach 'git pull || :'

--

prkoat


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!