fix(fetch): use the correct FETCH_HEAD from within a worktree#1108
fix(fetch): use the correct FETCH_HEAD from within a worktree#1108Byron merged 1 commit intogitpython-developers:masterfrom muggenhor:fix/fetch-parse-fetch-head-from-worktree
Conversation
FETCH_HEAD is one of the symbolic references local to the current worktree and as such should _not_ be looked up in the 'common_dir'. But instead of just hard coding the "right thing" (git_dir) lets defer this to the SymbolicReference class which already contains this knowledge in its 'abspath' property.
|
Thanks a lot for the fix, the thorough PR description and for trying to even put this into a test. No matter what, this fix should definitely be merged as I have a feeling it did break a lot of things downstream and it's surprising there weren't any bug reports yet. |
I think I've got some idea why there weren't any yet. My team's been encountering this problem for at least as early as about June 2019 (unfortunately our CI logs don't go further than that). But it was very rare, and we couldn't consistently reproduce it. Then somewhere early in 2020 the frequency of this happening jumped up to close to 100% but our initial attempts to diagnose it where unsuccessful and we had a simple workaround (disabling the use of multiple nodes in our Jenkins setup to prevent the need to fetch into worktrees from one node to another). My colleague who did that investigation felt, at the time, uncomfortable filing a bug report without having a good reproduction scenario. I later discovered that the cause of this frequency jump was a commit to our meta-CI system tomtom-international/hopic@14a4338 (that change causes the introduction of a conditional, but almost always occurring, extra It's the combination of fetching first in the top-level and only then fetching in a worktree that may cause this bug to cause an exception to be raised. In plenty of other cases you may just silently get wrong results being returned from Then the error we got itself (and the above reproduction script will give with the old version) is also misleading: it's a I still believe there's at least one bug, maybe two, in the processing of I hope that bit of history helps to understand at least partially why this hasn't been reported before. The (feeling of) inability to describe what the problem is is a big obstacle there. Anyway, thanks for your quick response :-) |
|
Thanks so much for sharing, but… oh my…every paragraph I could feel the time spent and nerves lost and it hurt :/. Even though for GitPython I do believe the fight is lost, there is another endeavour which will definitely reach an entirely new level of quality. Maybe one day it will even arrive in Python. |
FETCH_HEADis one of the symbolic references local to the currentworktree and as such should not be looked up in the
common_dir. Butinstead of just hard coding the "right thing" (
git_dir) lets defer thisto the
SymbolicReferenceclass which already contains this knowledge inits
abspathproperty.This was introduced by #654. I suspect an overzealous search & replace of
git_dir->common_dirwas the cause here.FYI: this bug can be reproduced by this Python script. I've not been able to convert that into a test case though: