-
-
Notifications
You must be signed in to change notification settings - Fork 918
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
Refreshing doesn't invalidate cached version_info #1829
Labels
Comments
Thanks for investigating! Indeed, since The reason this didn't come up earlier is probably that people rather restart the program than refreshing the Git version after changes. |
This was referenced Feb 20, 2024
EliahKagan
added a commit
to EliahKagan/GitPython
that referenced
this issue
Feb 22, 2024
Most of these don't pass yet, as such invalidation isn't implemented yet (gitpython-developers#1829).
EliahKagan
added a commit
to EliahKagan/GitPython
that referenced
this issue
Feb 22, 2024
EliahKagan
added a commit
to EliahKagan/GitPython
that referenced
this issue
Feb 22, 2024
EliahKagan
added a commit
to EliahKagan/GitPython
that referenced
this issue
Feb 22, 2024
Most of these don't pass yet, as such invalidation isn't implemented yet (gitpython-developers#1829).
EliahKagan
added a commit
to EliahKagan/GitPython
that referenced
this issue
Feb 22, 2024
EliahKagan
added a commit
to EliahKagan/GitPython
that referenced
this issue
Feb 26, 2024
This further improves the text previously introduced in gitpython-developers#1829 and improved in gitpython-developers#1844.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The
version_info
property ofGit
instances is cached per-instance, while thegit.refresh
function andGit.refresh
class method modify global state. Whenversion_info
has been read on aGit
instance, refreshing affects the behavior of that instance, but does not invalidate the cache, causing theversion_info
property and dynamicversion
method to give inconsistent results even when no changes to environment variables or the filesystem have occurred.Here's an example produced on a CentOS 7 system where I have both the system
git
and a newer upstreamgit
installed:Because I had accessed
g1.version_info
before refreshing, the stale version information is handed back even after the refresh.This is admittedly consistent with how
version_info
is documented:GitPython/git/cmd.py
Line 839 in afa5754
But it seems to me that the documentation, as currently written, does not prevent it from being surprising. I think that either this should be made clear in the
version_info
property docstring, or the behavior should be changed so that refreshing invalidates allGit
instances' cachedversion_info
properties. I am not sure which is better, because I don't know whyversion_info
is cached (and cached per instance).This issue can probably be considered minor. In particular, this does not prevent
FetchInfo.refresh
(whichgit.refresh
calls after callingGit.refresh
) from updatingFetchInfo._flag_map
correctly, becauseFetchInfo.refresh
accessesversion_info
on a newly createdGit
instance:GitPython/git/remote.py
Line 346 in afa5754
The text was updated successfully, but these errors were encountered: