GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — use git rev-parse to look for config file by bdauvergne · Pull Request #894 · gitpython-developers/GitPython

use git rev-parse to look for config file #894

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.

Sign up for GitHub

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

Merged
Byron merged 1 commit into gitpython-developers:master from bdauvergne:worktree-config-support
Aug 11, 2019

Uh oh!

There was an error while loading. Please reload this page.

Merged

use git rev-parse to look for config file #894

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
1 commit
Select commit
7f12bd4
use git rev-parse to look for config file
bdauvergne Jul 16, 2019
File filter
Filter by extension

Clear filters
Conversations
Failed to load comments.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Jump to
Jump to file
Failed to load files.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Diff view
Diff view

There are no files selected for viewing

56 changes: 40 additions & 16 deletions 56 git/repo/base.py
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class Repo(object):
'git_dir' is the .git repository directory, which is always set."""
DAEMON_EXPORT_FILE = 'git-daemon-export-ok'

git = None # Must exist, or __del__ will fail in case we raise on `__init__()`
_git = None # Must exist, or __del__ will fail in case we raise on `__init__()`
working_dir = None
_working_tree_dir = None
git_dir = None
Expand Down Expand Up @@ -202,14 +202,42 @@ def __init__(self, path=None, odbt=GitCmdObjectDB, search_parent_directories=Fal
# END working dir handling

self.working_dir = self._working_tree_dir or self.common_dir
self.git = self.GitCommandWrapperType(self.working_dir)

# special handling, in special times
args = [osp.join(self.common_dir, 'objects')]
if issubclass(odbt, GitCmdObjectDB):
args.append(self.git)
self.odb = odbt(*args)

def _get_git(self):
working_dir = self._working_tree_dir or self.common_dir
if self._git:
if self._git._working_dir != expand_path(working_dir):
self.close()
self._git = None

if not self._git:
self._git = self.GitCommandWrapperType(working_dir)
return self._git

def _del_git(self):
if self._git:
self._git.clear_cache()
self._git = None
# Tempfiles objects on Windows are holding references to
# open files until they are collected by the garbage
# collector, thus preventing deletion.
# TODO: Find these references and ensure they are closed
# and deleted synchronously rather than forcing a gc
# collection.
if is_win:
gc.collect()
gitdb.util.mman.collect()
if is_win:
gc.collect()

git = property(fget=_get_git, fdel=_del_git)

def __enter__(self):
return self

Expand All @@ -223,19 +251,7 @@ def __del__(self):
pass

def close(self):
if self.git:
self.git.clear_cache()
# Tempfiles objects on Windows are holding references to
# open files until they are collected by the garbage
# collector, thus preventing deletion.
# TODO: Find these references and ensure they are closed
# and deleted synchronously rather than forcing a gc
# collection.
if is_win:
gc.collect()
gitdb.util.mman.collect()
if is_win:
gc.collect()
del self.git

def __eq__(self, rhs):
if isinstance(rhs, Repo):
Expand Down Expand Up @@ -431,7 +447,15 @@ def _get_config_path(self, config_level):
elif config_level == "global":
return osp.normpath(osp.expanduser("~/.gitconfig"))
elif config_level == "repository":
return osp.normpath(osp.join(self._common_dir or self.git_dir, "config"))
try:
config_path = self.git.rev_parse("config", git_path=True)
except GitCommandError:
return osp.normpath(osp.join(self._common_dir or self.git_dir, "config"))
else:
if self.git._working_dir:
return osp.normpath(osp.join(self.git._working_dir, config_path))
else:
return config_path

raise ValueError("Invalid configuration level: %r" % config_level)

Expand Down
3 changes: 1 addition & 2 deletions 3 git/test/lib/helper.py
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -366,8 +366,7 @@ def setUpClass(cls):

@classmethod
def tearDownClass(cls):
cls.rorepo.git.clear_cache()
cls.rorepo.git = None
del cls.rorepo.git

def _make_file(self, rela_path, data, repo=None):
"""
Expand Down
Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.