-
-
Notifications
You must be signed in to change notification settings - Fork 933
Assertion on creating or adding files in bare repositories #59
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
Comments
Would you try the latest version please ? Its can be downloaded here: |
Still fails:
Also repo.iter_commits(...) similarly does not work on bare repositories:
AssertionError: Repository at '/home/allura/scm/git/p/jcltest/code.git' is bare and does not have a working tree directory Note: The "rev-list" sub-command in git does not care if it is run in a bare repository. |
Thanks for verifying this issue. For some reason I was pretty sure this actually worked, but maybe I always used non-bare repositories in the test-suite as well, which let this issue slip. |
Not to pressure, but any sense of an ETA? I'd be happy to help, and have time to do so, but would need likely an intro to the model/assumption in the current code. |
Currently, I have no ETAs for git-python, first I would have to free up some time by getting rid of other projects of mine, and I would say, I am working on that at least. The best introduction you could get is by strolling through the actual code and have a look at the accompanying unit-tests. Generally, every line of code must be run by a unit-test, and ideally it is approached from a few vectors as well. In this particular case, the cause of the issue is likely to be found in the Repo implementation, the respective test is in test_repo.py I assume. |
I would be interested in this too. |
On 28 Jun 2012, at 15:17, Danilo Bargen wrote:
FWLIW my company's priorities have changed (yay, startup!) and it is not likely I'll get back to this for a long while yet. -- JCL |
@clearclaw OK :) i currently don't have time to get started with GitPython code either, but i've played around with libgit2/pygit2 which is more focused on lowlevel and works with bare repositories too (but is poorly documented). |
The code of IndexFile.add() was altered to only require a working directory when it actually needs one. This should resolve this issue. |
Would be cool to have a convenience method for this, like: class Repo(...):
...
def add_blob(self, path: PathLike, data: bytes, mode: int = 0o100644):
istream = IStream('blob', len(data), io.BytesIO(data))
repo.odb.store(istream)
return git.Blob(repo, istream.binsha, mode, str(path)) Also: Is |
@flying-sheep I like the idea, but wonder if the suggested implementation would be what most people expect when adding something to the repository. After all, without updating the index it's not obviously there. |
Well, adding a |
I can create new files from in-memory bytestreams in non-bare
repositories easily enough:
However this fails with bare repositories with an assertion error
around repo.working_tree_dir.
/home/allura/scm/git/p/jcltest/code.git/ in ()
----> 1 repo.index.add ([git.IndexEntry.from_blob (blob),])
/home/allura/anvil/local/lib/python2.7/site-packages/GitPython-0.3.0_beta2-py2.7.egg/git/index/util.pyc in
set_git_working_dir(self, _args, *_kwargs)
73 def set_git_working_dir(self, _args, *_kwargs):
74 cur_wd = os.getcwd()
---> 75 os.chdir(self.repo.working_tree_dir)
76 try:
77 return func(self, _args, *_kwargs)
/home/allura/anvil/local/lib/python2.7/site-packages/GitPython-0.3.0_beta2-py2.7.egg/git/repo/base.pyc in working_tree_dir(self)
174 :raise AssertionError: If we are a bare repository"""
175 if self._working_tree_dir is None:
--> 176 raise AssertionError( "Repository at %r is bare and does not have a working tree directory" % self.git_dir )
177 return self._working_tree_dir/home/allura/scm/git/p/jcltest/code.git/ in ()
----> 1 repo.index.add ([git.IndexEntry.from_blob (blob),])
/home/allura/anvil/local/lib/python2.7/site-packages/GitPython-0.3.0_beta2-py2.7.egg/git/index/util.pyc in set_git_working_dir(self, _args, *_kwargs)
73 def set_git_working_dir(self, _args, *_kwargs):
74 cur_wd = os.getcwd()
---> 75 os.chdir(self.repo.working_tree_dir)
76 try:
77 return func(self, _args, *_kwargs)
/home/allura/anvil/local/lib/python2.7/site-packages/GitPython-0.3.0_beta2-py2.7.egg/git/repo/base.pyc in working_tree_dir(self)
174 :raise AssertionError: If we are a bare repository"""
175 if self._working_tree_dir is None:
--> 176 raise AssertionError( "Repository at %r is bare and does not have a working tree directory" % self.git_dir )
177 return self._working_tree_dir
The text was updated successfully, but these errors were encountered: