nim-lang/nimble — pull request #70 by gradha (2014-12-05 15:48:25+00:00)
Title: Manually checks out the branch/tag after git clone.

It seems that certain git versions fail to check out the requested branch/tag during a clone operation. This can be reproduced using the Vagrant setup files at https://gist.github.com/gradha/6a7332126968a71e7530 (revision 2) which create a linux box with Nimrod 0.9.6 and nimble 0.4.0. After the machine has been set up manually running ``nimble install nake`` will fail. After adding some logging I got:
```
…
Going to run 'git clone --recursive --depth 1 -b v1.2 git://github.com/fowlmouth/nake/ /tmp/nimble_3061/nake'
Cloning into '/tmp/nimble_3061/nake'...
remote: Counting objects: 35, done.
remote: Compressing objects: 100% (28/28), done.
remote: Total 35 (delta 13), reused 20 (delta 7)
Receiving objects: 100% (35/35), 14.62 KiB, done.
Resolving deltas: 100% (13/13), done.
warning: Remote branch v1.2 not found in upstream origin, using HEAD instead
FAILURE: Only one .nimble file should be present in /tmp/nimble_3061/nake
…
```
Despite the ``-b v1.2`` the git command is failing to checkout that branch and instead gets HEAD, which fails for unrelated reasons. I verified this with other modules too, for instance running ``nimble install midnight_dynamite`` will end up installing development version 0.2.5 rather than the latest tag 0.2.4. After the following patch has been applied the clone works again as expected. Log extract:
```
…
Found tags...
Cloning latest tagged version: v1.2
Going to run 'git clone --recursive --depth 1 -b v1.2 git://github.com/fowlmouth/nake/ /tmp/nimble_3451/nake'
Cloning into '/tmp/nimble_3451/nake'...
remote: Counting objects: 35, done.
remote: Compressing objects: 100% (28/28), done.
Receiving objects: 100% (35/35), 14.62 KiB, done.
remote: Total 35 (delta 13), reused 20 (delta 7)
Resolving deltas: 100% (13/13), done.
warning: Remote branch v1.2 not found in upstream origin, using HEAD instead
Going to run 'git checkout --force v1.2'
Note: checking out 'v1.2'.

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by performing another checkout.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -b with the checkout command again. Example:

git checkout -b new_branch_name

HEAD is now at 46ce719... Bumped version numbers for v1.2 release.
Installing nake-1.2
…
```
It think it is kind of flaky to try to check out a branch/tag after a ``--depth 1`` clone (will the depth include this tag/branch?) but it seems to work with the few cases I've tried.