#8181 Non-bare git repos cause "Broken pipe" error

unreleased
open
nobody
None
General
nobody
2018-01-30
2018-01-30
No

If a git repo directory is not a "bare" repo, the webpages error with this:

File '/var/local/allura/ForgeGit/forgegit/model/git_repo.py', line 594 in head
  if head.is_valid():
File '/var/local/env-allura/lib/python2.7/site-packages/GitPython-0.3.2rc1.post20140304-py2.7.egg/git/refs/symbolic.py', line 323 in is_valid
  self.object
File '/var/local/env-allura/lib/python2.7/site-packages/GitPython-0.3.2rc1.post20140304-py2.7.egg/git/refs/symbolic.py', line 161 in _get_object
  return Object.new_from_sha(self.repo, hex_to_bin(self.dereference_recursive(self.repo, self.path)))
File '/var/local/env-allura/lib/python2.7/site-packages/GitPython-0.3.2rc1.post20140304-py2.7.egg/git/objects/base.py', line 64 in new_from_sha
  oinfo = repo.odb.info(sha1)
File '/var/local/env-allura/lib/python2.7/site-packages/GitPython-0.3.2rc1.post20140304-py2.7.egg/git/db.py', line 37 in info
  hexsha, typename, size = self._git.get_object_header(bin_to_hex(sha))
File '/var/local/env-allura/lib/python2.7/site-packages/GitPython-0.3.2rc1.post20140304-py2.7.egg/git/cmd.py', line 514 in get_object_header
  return self.__get_object_header(cmd, ref)
File '/var/local/env-allura/lib/python2.7/site-packages/GitPython-0.3.2rc1.post20140304-py2.7.egg/git/cmd.py', line 501 in __get_object_header
  cmd.stdin.write(self.__prepare_ref(ref))
IOError: [Errno 32] File '/var/local/allura/ForgeGit/forgegit/model/git_repo.py', line 594 in head
  if head.is_valid():
File '/var/local/env-allura/lib/python2.7/site-packages/GitPython-0.3.2rc1.post20140304-py2.7.egg/git/refs/symbolic.py', line 323 in is_valid
  self.object
File '/var/local/env-allura/lib/python2.7/site-packages/GitPython-0.3.2rc1.post20140304-py2.7.egg/git/refs/symbolic.py', line 161 in _get_object
  return Object.new_from_sha(self.repo, hex_to_bin(self.dereference_recursive(self.repo, self.path)))
File '/var/local/env-allura/lib/python2.7/site-packages/GitPython-0.3.2rc1.post20140304-py2.7.egg/git/objects/base.py', line 64 in new_from_sha
  oinfo = repo.odb.info(sha1)
File '/var/local/env-allura/lib/python2.7/site-packages/GitPython-0.3.2rc1.post20140304-py2.7.egg/git/db.py', line 37 in info
  hexsha, typename, size = self._git.get_object_header(bin_to_hex(sha))
File '/var/local/env-allura/lib/python2.7/site-packages/GitPython-0.3.2rc1.post20140304-py2.7.egg/git/cmd.py', line 514 in get_object_header
  return self.__get_object_header(cmd, ref)
File '/var/local/env-allura/lib/python2.7/site-packages/GitPython-0.3.2rc1.post20140304-py2.7.egg/git/cmd.py', line 501 in __get_object_header
  cmd.stdin.write(self.__prepare_ref(ref))
IOError: [Errno 32] Broken pipe

The underlying error is as follows. (And I believe is executed in the parent dir instead of in the .git dir)

fatal: Not a git repository (or any parent up to mount point /gitrepo)
Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).

Omitting odbt=git.GitCmdObjectDB from the git.Repo constructor seems to avoid the issue a little bit, but a repo refresh is needed and that still errors. Anyways, changing odbt could have other unwanted affects.

I think the best workaround is to change the repo to a bare repo. E.g. fork to a new location, remove original, fork back. Or do a local check out, remove repo, create new one, push all branches back.

Discussion


Log in to post a comment.