-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Fix "detached head" issue #8296
base: master
Are you sure you want to change the base?
Conversation
9212244
to
68b6f1b
Compare
As it's my first pull-request, I did all possible mistakes -- forgot updating tests in the beginning, then missing some, finally prepared local test environment (excellent, just a piece of marvel) Now all tests are working |
The problem with the current solution is that it does not check what branch the existing codebase is on. It just blindly does I think a better idea would be to keep |
@p12tic -- the problem with your proposal is that it will checkout the tip of the branch and not the wanted |
I don't think this is the case. The sequence of commands which I'm suggesting is this:
In step 3 we create branch at HEAD (which is the same as Here's a list of commands for reproduction:
|
@p12tic -- I agree your sequence result in the same state, so it's a matter of taste.
If you prefer your sequence, are you going to add it? (tons of matching fixes in the |
@p12tic -- btw, there's a small semantic difference between the two sequences in the case that, by mistake, the provided
|
Thanks, now I understand why we arrive to different conclusions.
The issue is that This is the reason why just |
In incremental mode the failure may not happen because the step reuses existing git repository, so the commit may exist even if the branch does not contain it. |
@p12tic -- so maybe we need |
Re-reading the code, I can see now this delicate dance at the end of the
This is really strange -- why do this at the end, after we already sit on the exact wanted |
I agree that this is more correct due to the reasons you've outlined. My concern is that if I think a better idea would be to have an explicit check if |
This leads to more file operations. Best to checkout to By the way, the fact that call to |
@p12tic -- but the About amount of file operations (assuming a big rewind is needed) -- let's assume we do this as you initially proposed:
I think that if the tip of |
Isn't |
Yes, but the
On clean clone both approaches are the same, I'm concerned with incremental checkouts. |
@p12tic -- for my use-case, any approach will work, so you can take your pick. |
I would say that The correct way would be to use |
@p12tic -- just tested and you are correct.
And what about the final |
I'm wondering if we are observing some kind of a bug, because |
Regarding |
OK, so the revised workflow would be:
And what about the |
I'm saying that |
@p12tic -- my problem is not with
|
The communication between us broke a bit :) Initially I suggested |
For my specific use-case, your solution would be equivalent -- so if you prefer it, go ahead. But generally, there are two points I want to raise:
As you said, some miscommunication -- if you intend to use |
Still some miscommunication :) What I'm saying is that the current code already has However, reality is different. This is why I'm saying you should debug your builds and figure out why you have |
Regarding doing This does not fully solve the issue. Why? Because in incremental |
Now we set the correct commit via
git reset --hard <rev>
:Unlike
checkout -f <rev>
that create "detached head"<rev>
isn't found on<branch>
it will fail loudlyThis is the correct behavior when contradicting parameters are provided
Fixes #8295