-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
pip install -e resets to origin/master #647
Comments
which version of pip? |
pip 1.1 |
yes, I see exactly what you describe. sure looks like a bug. but know that you can use the '@' parameter to reliably get the |
Yeah, that's what I'm doing now. |
FWIW, I added a pdb.set_trace() to req.py update_editable() (line 380), and traced this down to the point where vcs/git.py(110)obtain() does |
Currently pip is inconsistent because it checks out the HEAD symbolic ref (aka the "default branch") when not instructed to do otherwise, but updates the master (not the default branch) when not instructed to do otherwise. Its checkout vs. update strategies are inconsistent. There are two competing actions that could be taken to make pip consistent here:
The former is harder than the latter. I don't know any way to get the HEAD symbolic ref from a remote repository without actually just re-checking-out the entire repository and seeing what its initial branch name is. The latter is easier, but it might be confusing for people that use gitflow or some other model where the default branch is not master. If there's a way to get the HEAD symbolic ref from a remote repo, we can easily issue a command to get it and use it. @lorin, do you know how to do that by any chance? If not, we'll likely either need to both check out and update master when otherwise unspecified, or close this as a wontfix. |
@mcdonc I think you can use "git remote show" to do this, and it will tell you what the remote head branch is: For example:
|
Seems, that this bug is still there. |
I mean, it is still resets to the given branch or revision even if there is uncommited changes. This is very bad behaviour — yesterday I lost few hours of work this way. |
I think we have this problem, too. The checkout of "pip install -e git+https:..." is broken. I looked at the source vcs/git.py, and I guess this comment says it all:
I don't know why pip does a lookup of GIT-HASH-ID --> REV if I do install a git branch. One GIT-HASH-ID can be referenced in several branches. If two branches refer to the same hash-id, the guess is a guess and not deterministic. What can I do to fix this? At the moment I don't get what pip does at all. |
To set up development environments, we use a pip requirements file with lines like:
There are a bunch of repositories that go into the environment. In development I'll use manual git commands to create branches in the particular repositories I'm working on. Every now and then, it's useful to re-run the pip install command that set up the dev environment (to pick up changes like new scripts installed to bin, deleted files, or new dependencies; things that aren't always automatically handled just by changing the files inside an editable-installed package). If I have any non-master branches still checked out, pip hard resets those to origin/master; this results in losing uncommitted edits as @svetlyak40wt noted, but also any committed changes on the branch that aren't included on another branch (as well clobbering the branch pointer itself). The way I would have expected pip to behave is one of these three:
|
The description on the pull request and the linked issue sound like the thing that was fixed is that pip would use origin/master when doing an editable install using an existing checkout, even though the default branch might not be origin/master. Is that all that's been fixed? For me, the most problematic part of this issue wasn't the potential mismatch of origin/master and origin/HEAD, but rather that it updates the existing checkout by blindly doing a hard reset. That's a problem because it doesn't check what the locally active branch is; if you're actually using the checkout to do work in (and if you're not, what's the point of an editable install?) then the branch active in the local checkout is quite likely to be a topic branch, or to be ahead of the default branch on the remote. In those cases the hard reset loses committed work (as well as any uncommitted changes, of course). Has this been addressed by the change that closed this issue? If not, should I report a new issue to get that looked at specifically, or should we reopen this one? |
Hi @cumber, I totally agree with you that a hard reset doesn't seem like the right approach for the reasons you mentioned. It seems a bit dangerous in fact because, like you said, you can even lose work. It's one of the things I noticed while preparing some of my refactoring PR's in this area of the code. It's also one of the things I was planning to address after some of my PR's are accepted, but so far it seems to be slow going for PR's to be merged. On the subject of the issue tracker, while there are a few related issues I've come across, I don't think it's been specifically reported yet. The closest one I think is issue #2037 (since it's mentioned as a side comment), but that's still different. I'd recommend creating a new issue for it. I wouldn't reopen this issue because this issue was solving a different problem. |
Thanks for clarifying, @cjerdonek. I had misinterpreted this issue as being about the hard reset. I'll raise a new issue then. |
If I do this:
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: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.
The text was updated successfully, but these errors were encountered: