You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Reading progress of Git operation using GitPython stuck (or not printing) #871
I'm trying to access the progress of time consuming Git operations using GitPython. I tried the sample solution taken from the official documentation, and also tried passing in a method following the exact signature of the update method below. Everytime I call fetch(), push(), pull()with the parameter progress=<anything>, the programm is stuck and the update method does not get called. If I call those operations without setting the progress parameter, it works flawlessly.
$ git --version is 2.21.0
Calling sys.stdout.flush() after print() does not help either
I use assert to assure my repo objects are available and in the expected state
ProgressPrinter() yields not None
I tried calling the functions from the main thread and multithreaded
I found out, that when I assign my ProgressPrinter instance and pass the assigned variable, the programm is not stuck anymore. Yet the update() method does not get called and no progress is printed:
# Not stuck anymore, yet no progresspp=ProgressPrinter()
fetch_info=origin.fetch(progress=pp)
Core of my implementation:
fromgitimportRemoteProgressclassProgressPrinter(RemoteProgress):
defupdate(self,
op_code,
cur_count,
max_count=None,
message=''):
print("Is this even called?")
Any recommendations on how to investigate this problem furthermore? I've been debugging this for several days now and feel like I am missing something.
Try an older version of git (v2.20.0) as in v2.21.0 of git they changed the output strings to allow for localization, and that's caused at least one bug, let's see if it caused others...
I switched to both the default macOS Git 2.14.ish as well as 2.20.1. Both versions are not getting stuck anymore. Yet there is still no progress being printed.
I'll create stripped down script to check if I can reproduce it reliably.
Since I switched to the older Git version and later on reinstalled Git 2.21.0, the very same code does not get stuck anymore. I don't know what caused this hickup. I will keep an eye on it and let you know if I can reproduce this behaviour in the upcoming weeks.
I solved the second problem of the progress not being logged though and have a proposal for an implementation-, or at least documentation-change:
If the git process finishes quickly, the update() method will never be called. I expected it to be called at least once. May I suggest implementing an additional method did_finish(exit_code, message) to the RemoteProgress class?
This way we do not break existing implementations and keep the progress handling in one place. Yes, I could check if my fetch() returned a string and know that way, the process is done, but it would be a lot nicer to implement, if the RemoteProgress subclass would be able to handle this as well.
Also a note within the documentation for update() would be awesome: Maybe with a hint for developers to grab a large repository, and prepare it for a longer process:
I proposed a pull request in which I adapt the behaviour in a way, that update() is called once, even when Git answers with = [up to date]. My project depending on GitPython has a deadline of ~6 weeks. Please let me know if this change will be implemented. So that I have time to adjust my planning. Thank you in advance!
Activity
jeking3 commentedon May 6, 2019
Try an older version of git (v2.20.0) as in v2.21.0 of git they changed the output strings to allow for localization, and that's caused at least one bug, let's see if it caused others...
t89 commentedon May 6, 2019
I switched to both the default macOS Git
2.14.ishas well as2.20.1. Both versions are not getting stuck anymore. Yet there is still no progress being printed.I'll create stripped down script to check if I can reproduce it reliably.
t89 commentedon May 6, 2019
Since I switched to the older Git version and later on reinstalled Git
2.21.0, the very same code does not get stuck anymore. I don't know what caused this hickup. I will keep an eye on it and let you know if I can reproduce this behaviour in the upcoming weeks.I solved the second problem of the progress not being logged though and have a proposal for an implementation-, or at least documentation-change:
If the git process finishes quickly, the
update()method will never be called. I expected it to be called at least once. May I suggest implementing an additional methoddid_finish(exit_code, message)to theRemoteProgressclass?This way we do not break existing implementations and keep the progress handling in one place. Yes, I could check if my
fetch()returned a string and know that way, the process is done, but it would be a lot nicer to implement, if theRemoteProgresssubclass would be able to handle this as well.Also a note within the documentation for
update()would be awesome: Maybe with a hint for developers to grab a large repository, and prepare it for a longer process:jeking3 commentedon May 6, 2019
Perhaps update() should always be called at least once?
Implement update call when the object is "up to date" gitpython-devel…
t89 commentedon May 7, 2019
I proposed a pull request in which I adapt the behaviour in a way, that
update()is called once, even when Git answers with= [up to date]. My project depending on GitPython has a deadline of ~6 weeks. Please let me know if this change will be implemented. So that I have time to adjust my planning. Thank you in advance!Revert "Implement update call when the object is "up to date" #871"
Revert "Revert "Implement update call when the object is "up to date" #…
Revert "Revert "Revert "Implement update call when the object is "up …
Dontoronto commentedon Nov 4, 2024
still an issue...
skarndev commentedon Feb 3, 2025
Still an issue. Not stuck, but not printing, git [INFO] git version -> 0; stdout: 'git version 2.39.5 (Apple Git-154)'
Implement update call when the object is "up to date" gitpython-devel…