Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
867 changes: 586 additions & 281 deletions git/config.py

Large diffs are not rendered by default.

7 changes: 4 additions & 3 deletions git/objects/submodule/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
__all__ = ["Submodule", "UpdateProgress"]

import gc
from configparser import NoSectionError
from io import BytesIO
import logging
import os
Expand All @@ -16,7 +17,7 @@
import git
from git.cmd import Git
from git.compat import defenc
from git.config import GitConfigParser, SectionConstraint, cp
from git.config import GitConfigParser, SectionConstraint
from git.exc import (
BadName,
InvalidGitRepositoryError,
Expand Down Expand Up @@ -172,7 +173,7 @@ def _set_cache_(self, attr: str) -> None:
# Default submodule values.
try:
self.path = reader.get("path")
except cp.NoSectionError as e:
except NoSectionError as e:
if self.repo.working_tree_dir is not None:
raise ValueError(
"This submodule instance does not exist anymore in '%s' file"
Expand Down Expand Up @@ -1503,7 +1504,7 @@ def exists(self) -> bool:
if hasattr(self, attr):
loc[attr] = getattr(self, attr)
# END if we have the attribute cache
except (cp.NoSectionError, ValueError):
except (NoSectionError, ValueError):
# On PY3, this can happen apparently... don't know why this doesn't
# happen on PY2.
pass
Expand Down
2 changes: 1 addition & 1 deletion git/objects/submodule/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ def flush_to_index(self) -> None:
# } END interface

# { Overridden Methods
def write(self) -> None: # type: ignore[override]
def write(self) -> None:
rval: None = super().write()
self.flush_to_index()
return rval
Expand Down
9 changes: 5 additions & 4 deletions git/remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@
__all__ = ["RemoteProgress", "PushInfo", "FetchInfo", "Remote"]

import contextlib
from configparser import NoOptionError, NoSectionError
import logging
import re

from git.cmd import Git, handle_process_output
from git.compat import defenc, force_text
from git.config import GitConfigParser, SectionConstraint, cp
from git.config import GitConfigParser, SectionConstraint
from git.exc import GitCommandError
from git.refs import Head, Reference, RemoteReference, SymbolicReference, TagReference
from git.util import (
Expand Down Expand Up @@ -577,7 +578,7 @@ def __getattr__(self, attr: str) -> Any:
# though a slot of the same name exists.
try:
return self._config_reader.get(attr)
except cp.NoOptionError:
except NoOptionError:
return super().__getattr__(attr)
# END handle exception

Expand Down Expand Up @@ -619,10 +620,10 @@ def exists(self) -> bool:
try:
self.config_reader.get("url")
return True
except cp.NoOptionError:
except NoOptionError:
# We have the section at least...
return True
except cp.NoSectionError:
except NoSectionError:
return False

@classmethod
Expand Down
4 changes: 1 addition & 3 deletions test/fixtures/git_config
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@
url = git://gitorious.org/~martin.marcher/git-python/serverhorror.git
fetch = +refs/heads/*:refs/remotes/MartinMarcher/*
# can handle comments - the section name is supposed to be stripped
# causes stock git-config puke
[ gui ]
[gui]
geometry = 1316x820+219+243 207 192
[branch "mainline_performance"]
remote = mainline
Expand All @@ -43,4 +42,3 @@
# inclusions should be processed immediately
[sec]
var1 = value1_main

2 changes: 1 addition & 1 deletion test/fixtures/git_config_multiple
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
[section1]
option1 = value1a
option1 = value1b
other_option1 = other_value1
other-option1 = other_value1
2 changes: 0 additions & 2 deletions test/fixtures/git_config_with_quotes_escapes
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,5 @@
hasbackslash = "foo\\bar"
hasquote = "ab\"cd"
hastrailingbackslash = "word\\"
hasunrecognized = "p\qrs"
hasunescapedquotes = "ab"cd"e"
ordinary = "hello world"
unquoted = good evening
Loading
Loading