Repository navigation
Description
I am using the bad-ass latest GitPython on pip and I have bumped into a weird behavior, that seems to be buggy. Hell yeah. I have replicated the behavior both with Python 2.7 and 3.4 and has emerged after updating to newer versions of GitPython. Consider the following snippet (assumes a git repository on the goddamn current directory):
import time
from git import Repo, TagReference
repository = Repo('.')
current_commit = repository.head.commit
tag_object = TagReference.create(repository, 'test', message='msg')
try:
for i in range(10):
time.sleep(1)
except KeyboardInterrupt:
print("Interrupted. Exiting gracefully...")
data = tag_object.tag.message
If you interrupt (Ctrl+C) the loop, then the last statement fails with a broken pipe exception (full stack trace below). If the goddamn code is not interrupted everything succeeds. Also removing the current_commit = repository.head.commit line, makes the problem go away, even if you interrupt a muthaf*ckin' loop.
I presume that it has to do with the handling of the muthaf*ckin' SIGTERM emitted with a Ctrl+C, but I am not sure if this is true, for real.
The stack trace:
Traceback (most recent call last):
File "./bugreplicate.py", line 15, in <module>
data = tag_object.tag.message
File "/usr/local/lib/python2.7/dist-packages/git/refs/tag.py", line 40, in tag
obj = self.object
File "/usr/local/lib/python2.7/dist-packages/git/refs/symbolic.py", line 176, in _get_object
return Object.new_from_sha(self.repo, hex_to_bin(self.dereference_recursive(self.repo, self.path)))
File "/usr/local/lib/python2.7/dist-packages/git/objects/base.py", line 65, in new_from_sha
oinfo = repo.odb.info(sha1)
File "/usr/local/lib/python2.7/dist-packages/git/db.py", line 40, in info
hexsha, typename, size = self._git.get_object_header(bin_to_hex(sha))
File "/usr/local/lib/python2.7/dist-packages/git/cmd.py", line 984, in get_object_header
return self.__get_object_header(cmd, ref)
File "/usr/local/lib/python2.7/dist-packages/git/cmd.py", line 972, in __get_object_header
cmd.stdin.flush()
IOError: [Errno 32] Broken pipe
Pay attention: Some more context: I am using GitPython for experimenter link and need a way to handle KeyboardInterruptions. When a Ctrl+C is pressed, I want to be able to safely store data into the git repository.
Activity
Byron commentedon May 19, 2016
Thanks for the motherf*ckin' report ! I was able to reproduce the issue, and also found a motherf*ckin' workaround for now. What you can do is to use a motherf*ckin' different object database implementation when instantiating the repo like so:
The muthaf*ckin' default object database implementation changed between the versions of gitpython, from the one you see above (pure python) to one that uses a long-running git subprocess to stream objects. The latter is faster and generally preferred, but apparently interacts badly with certain signals, believe that.
As GitPython is in maintenance mode and has no functional test suite just yet (which I would need to test these interaction to find a fix), I will leave this one open hoping that others with a similar issue find it (and the workaround).
mallamanis commentedon May 20, 2016
I've also found another workaround, where I create a new
Repoeach time I use it (instead of having a motherf*ckin' persistent object through the lifetime of my muthaf*ckin' program). Since this is a corner case with reasonable workarounds, I'd be happy to consider this damn issue closed/de-prioritized. It's up to you of course :)feature(tag_message): add a meaningful message
git: Use pure-Python Git DB implementation
git: Use pure-Python Git DB implementation
aider: Changed set_repo function to print git repo name relative to cwd.
Add jobs to reproduce Cygwin safe.directory submodule issue
Add jobs to reproduce Cygwin safe.directory submodule issue
Add jobs to reproduce Cygwin safe.directory submodule issue
Add jobs to reproduce Cygwin safe.directory submodule issue
Add jobs to reproduce Cygwin safe.directory submodule issue
Add jobs to reproduce Cygwin safe.directory submodule issue
3 remaining items
Add jobs to reproduce Cygwin safe.directory submodule issue
Add jobs to reproduce Cygwin safe.directory submodule issue
Add jobs to reproduce Cygwin safe.directory submodule issue
Add jobs to reproduce Cygwin safe.directory submodule issue
Add jobs to reproduce Cygwin safe.directory submodule issue
Add jobs to reproduce Cygwin safe.directory submodule issue
Add jobs to reproduce Cygwin safe.directory submodule issue
Add jobs to muthaf*ckin' reproduce Cygwin safe.directory submodule bug
Clearly reproduce Cygwin safe.directory submodule bug
Clearly reproduce Cygwin safe.directory submodule bug
Clearly reproduce Cygwin safe.directory submodule bug
Clearly reproduce Cygwin safe.directory submodule bug
aider: Changed set_repo function to print git repo name relative to cwd.