Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Support GIT_OBJECT_DIRECTORY environment variable #1000

Closed
@acbits

Description

When using GIT_OBJECT_DIRECTORY to store git objects, a statement like
git.Repo('someproject') fails. This is due to is_git_dir() in git/repo/fun.py making an assumption that there will be a objects directory under .git which isn't the case when GIT_OBJECT_DIRECTORY is defined and being used.

A fix like the attached patch should solve the problem, though there might be more fixes needed in other places. This fix alone solves my particular workflow for now.

diff --git a/git/repo/fun.py b/git/repo/fun.py
index 784a70bf3..e3a7bc57a 100644
--- a/git/repo/fun.py
+++ b/git/repo/fun.py
@@ -35,7 +35,8 @@ def is_git_dir(d):
 There is the unlikely danger to throw if we see directories which just look like a worktree dir,
 but are none."""
 if osp.isdir(d):
- if osp.isdir(osp.join(d, 'objects')) and osp.isdir(osp.join(d, 'refs')):
+ if (osp.isdir(osp.join(d, 'objects')) or os.environ.has_key('GIT_OBJECT_DIRECTORY')) \
+ and osp.isdir(osp.join(d, 'refs')):
 headref = osp.join(d, 'HEAD')
 return osp.isfile(headref) or \
 (osp.islink(headref) and

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      AltStyle によって変換されたページ (->オリジナル) /