I've looked around for a report of this bug and didn't see anything, but I've no idea how popular this feature of drush make is. I have a project specified with a branch to be checked out in my .make file, like so:

projects[myproject][type] = "module"
projects[myproject][download][type] = "git"
projects[myproject][download][url] = "git@projects.example.com:myproject.git"
projects[myproject][download][branch] = "somebranch"

When I run the make file, drush happily clones the repository, and then attempts to checkout the 'somebranch' branch, hitting the first if condition in the "branch" section of make_download_git(). When I run this series of commands manually, the same thing happens- git silently fails to check out the branch, apparently because the origin/ branch it's tracking hasn't been mentioned yet. To fix this, I need the second version of the command to run: git checkout -b origin/

I'm not sure if this is particular to my version of git, but it's unclear to me what's the best fix- I'm not sure if there is ever a case where this first condition on line 310 works properly, or if the second form fails on some (older?) versions of git, perhaps. In any case, I've got a simple patch forthcoming which strengthens the check on the first if condition, checking for empty output (it seems that when the command works, it says so).

CommentFileSizeAuthor
#1 branch-checkout-fails-1989280.patch773 bytesspiderman
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

spiderman’s picture

I should have mentioned: I'm running Drush 5.9, but a quick peek at the make.download.inc on the 8.x-6.x branch indicates this logic is unchanged, so this one-liner should apply wherever.

lslinnet’s picture

I ran into the same issue, tested your patch and seems to fixed the issue.

➜  ~  git --version
git version 1.7.6
➜  ~  drush --version
drush version 5.9
➜  green-devil git:(master) ./build
drupal-7.22 downloaded.                                                                                                      [ok]
pov cloned from git@github.com:lslinnet/green-devil.git.                                                                     [ok]
Checked out branch profile.                                                                                                  [ok]
➜  green-devil git:(master) cd profile
➜  profile git:(master) ls -l
total 40
-rwxr-xr-x  1 nobody  nogroup   486 May 28 22:39 build
-rw-r--r--  1 nobody  nogroup   363 May 28 22:39 platform.make
-rw-r--r--  1 nobody  nogroup  3654 May 28 22:39 pov.vhost
lrwxr-xr-x  1 nobody  nogroup    16 May 28 22:39 profile -> web/profiles/pov
-rw-r--r--  1 nobody  nogroup   191 May 28 22:39 readme.md
➜  profile git:(master) git branch -a
* master
  remotes/origin/HEAD -> origin/master
  remotes/origin/master
  remotes/origin/profile

build in the above code basically executes

drush make --working-copy platform.make web --no-gitinfofile

but maintains settings files.

jhedstrom’s picture

Status: Active » Fixed

Thanks! Committed #1 to both 5.x and 6.x.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.