If I do this:
pip install -e git://github.com/nimbis/django.git#egg=Django-dev
Then pip will grab the default branch from that repository (1.4.1-patched) and install it, as you can see in the src directory where it’s installed:
cd ~/.virtualenvs/nimbis/src/django
[(1.4.1-patched) ~/.virtualenvs/nimbis/src/django]
$ git log | head -n4
commit a5d7c7b3a2d6a729bf5ede2254b5c75be9da94d7
Author: Lorin Hochstein <...>
Date: Mon Jul 30 21:44:20 2012 -0400
If I do it again, the HEAD becomes the same as the remote master branch, although it still uses 1.4.1-patched (default branch) as the branch name.
$ pip install -e git://github.com/nimbis/django.git#egg=Django-dev
[(1.4.1-patched) lorin@nibbler ~/.virtualenvs/nimbis/src/django]
$ git log | head -n4
commit e567f439bdfc60e16c465220fdaa8ea8a0fae936
Merge: c0748a6 226a3e7
Author: Alex Gaynor <...>
Date: Sun Jul 29 17:07:55 2012 -0700
I can resolve the problem by explicitly specifying the branch I want, but why does pip do this?
PIP VersionControl object (pip.vcs.VersionControl) checks in check_destination if the destination path already exists. If so, it calls update method instead of obtain. Update hard resets the branch per default.
You can see the exact behaviour in the VersionControl class referenced above and in pip.vcs.git.
EDIT: Misread the code a bit. Obtain is called every time, but if the repository already exists at the destination, update if called instead of clone. Since rev_options defaults to “origin/master”, update resets to this branch.
This very well may be a bug!