GitPython 3.1.49__py3-none-any.whl → 3.1.50__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- git/__init__.py +1 -1
- git/config.py +16 -1
- git/repo/base.py +22 -0
- {gitpython-3.1.49.dist-info → gitpython-3.1.50.dist-info}/METADATA +1 -1
- {gitpython-3.1.49.dist-info → gitpython-3.1.50.dist-info}/RECORD +9 -9
- {gitpython-3.1.49.dist-info → gitpython-3.1.50.dist-info}/WHEEL +0 -0
- {gitpython-3.1.49.dist-info → gitpython-3.1.50.dist-info}/licenses/AUTHORS +0 -0
- {gitpython-3.1.49.dist-info → gitpython-3.1.50.dist-info}/licenses/LICENSE +0 -0
- {gitpython-3.1.49.dist-info → gitpython-3.1.50.dist-info}/top_level.txt +0 -0
git/__init__.py
CHANGED
git/config.py
CHANGED
|
@@ -72,6 +72,9 @@ CONDITIONAL_INCLUDE_REGEXP = re.compile(r"(?<=includeIf )\"(gitdir|gitdir/i|onbr
|
|
|
72
72
|
See: https://git-scm.com/docs/git-config#_conditional_includes
|
|
73
73
|
"""
|
|
74
74
|
|
|
75
|
+
UNSAFE_CONFIG_CHARS_RE = re.compile(r"[\r\n\x00]")
|
|
76
|
+
"""Characters that cannot be safely written in config names or values."""
|
|
77
|
+
|
|
75
78
|
|
|
76
79
|
class MetaParserBuilder(abc.ABCMeta): # noqa: B024
|
|
77
80
|
"""Utility class wrapping base-class methods into decorators that assure read-only
|
|
@@ -778,6 +781,7 @@ class GitConfigParser(cp.RawConfigParser, metaclass=MetaParserBuilder):
|
|
|
778
781
|
|
|
779
782
|
def add_section(self, section: "cp._SectionName") -> None:
|
|
780
783
|
"""Assures added options will stay in order."""
|
|
784
|
+
self._assure_config_name_safe(section, "section")
|
|
781
785
|
return super().add_section(section)
|
|
782
786
|
|
|
783
787
|
@property
|
|
@@ -884,10 +888,14 @@ class GitConfigParser(cp.RawConfigParser, metaclass=MetaParserBuilder):
|
|
|
884
888
|
|
|
885
889
|
def _value_to_string_safe(self, value: Union[str, bytes, int, float, bool]) -> str:
|
|
886
890
|
value_str = self._value_to_string(value)
|
|
887
|
-
if
|
|
891
|
+
if UNSAFE_CONFIG_CHARS_RE.search(value_str):
|
|
888
892
|
raise ValueError("Git config values must not contain CR, LF, or NUL")
|
|
889
893
|
return value_str
|
|
890
894
|
|
|
895
|
+
def _assure_config_name_safe(self, name: "cp._SectionName", label: str) -> None:
|
|
896
|
+
if isinstance(name, str) and UNSAFE_CONFIG_CHARS_RE.search(name):
|
|
897
|
+
raise ValueError("Git config %s names must not contain CR, LF, or NUL" % label)
|
|
898
|
+
|
|
891
899
|
@needs_values
|
|
892
900
|
@set_dirty_and_flush_changes
|
|
893
901
|
def set(
|
|
@@ -896,6 +904,8 @@ class GitConfigParser(cp.RawConfigParser, metaclass=MetaParserBuilder):
|
|
|
896
904
|
option: str,
|
|
897
905
|
value: Union[str, bytes, int, float, bool, None] = None,
|
|
898
906
|
) -> None:
|
|
907
|
+
self._assure_config_name_safe(section, "section")
|
|
908
|
+
self._assure_config_name_safe(option, "option")
|
|
899
909
|
if value is not None:
|
|
900
910
|
value = self._value_to_string_safe(value)
|
|
901
911
|
return super().set(section, option, value)
|
|
@@ -920,6 +930,8 @@ class GitConfigParser(cp.RawConfigParser, metaclass=MetaParserBuilder):
|
|
|
920
930
|
:return:
|
|
921
931
|
This instance
|
|
922
932
|
"""
|
|
933
|
+
self._assure_config_name_safe(section, "section")
|
|
934
|
+
self._assure_config_name_safe(option, "option")
|
|
923
935
|
value_str = self._value_to_string_safe(value)
|
|
924
936
|
if not self.has_section(section):
|
|
925
937
|
self.add_section(section)
|
|
@@ -948,6 +960,8 @@ class GitConfigParser(cp.RawConfigParser, metaclass=MetaParserBuilder):
|
|
|
948
960
|
:return:
|
|
949
961
|
This instance
|
|
950
962
|
"""
|
|
963
|
+
self._assure_config_name_safe(section, "section")
|
|
964
|
+
self._assure_config_name_safe(option, "option")
|
|
951
965
|
value_str = self._value_to_string_safe(value)
|
|
952
966
|
if not self.has_section(section):
|
|
953
967
|
self.add_section(section)
|
|
@@ -968,6 +982,7 @@ class GitConfigParser(cp.RawConfigParser, metaclass=MetaParserBuilder):
|
|
|
968
982
|
"""
|
|
969
983
|
if not self.has_section(section):
|
|
970
984
|
raise ValueError("Source section '%s' doesn't exist" % section)
|
|
985
|
+
self._assure_config_name_safe(new_name, "section")
|
|
971
986
|
if self.has_section(new_name):
|
|
972
987
|
raise ValueError("Destination section '%s' already exists" % new_name)
|
|
973
988
|
|
git/repo/base.py
CHANGED
|
@@ -242,6 +242,28 @@ class Repo:
|
|
|
242
242
|
# It's important to normalize the paths, as submodules will otherwise
|
|
243
243
|
# initialize their repo instances with paths that depend on path-portions
|
|
244
244
|
# that will not exist after being removed. It's just cleaner.
|
|
245
|
+
if (
|
|
246
|
+
osp.isfile(osp.join(curpath, "gitdir"))
|
|
247
|
+
and osp.isfile(osp.join(curpath, "commondir"))
|
|
248
|
+
and osp.isfile(osp.join(curpath, "HEAD"))
|
|
249
|
+
):
|
|
250
|
+
git_dir = curpath
|
|
251
|
+
|
|
252
|
+
if "GIT_WORK_TREE" in os.environ:
|
|
253
|
+
self._working_tree_dir = os.getenv("GIT_WORK_TREE")
|
|
254
|
+
else:
|
|
255
|
+
# Linked worktree administrative directories store the path to the
|
|
256
|
+
# worktree's .git file in their gitdir file (without "gitdir: " prefix).
|
|
257
|
+
with open(osp.join(git_dir, "gitdir")) as fp:
|
|
258
|
+
worktree_gitfile = fp.read().strip()
|
|
259
|
+
|
|
260
|
+
if not osp.isabs(worktree_gitfile):
|
|
261
|
+
worktree_gitfile = osp.normpath(osp.join(git_dir, worktree_gitfile))
|
|
262
|
+
|
|
263
|
+
self._working_tree_dir = osp.dirname(worktree_gitfile)
|
|
264
|
+
|
|
265
|
+
break
|
|
266
|
+
|
|
245
267
|
if is_git_dir(curpath):
|
|
246
268
|
git_dir = curpath
|
|
247
269
|
# from man git-config : core.worktree
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
git/__init__.py,sha256
|
|
1
|
+
git/__init__.py,sha256=-XcbLWMd0hzWrSVPHoz9wDkN1bWkUznLYN6x5oCYGdQ,8899
|
|
2
2
|
git/cmd.py,sha256=4Ly0NF9kt1JarTD0zpPv7a0Al5I2PaohRMIG0UGKLCw,68559
|
|
3
3
|
git/compat.py,sha256=y1E6y6O2q5r8clSlr8ZNmuIWG9nmHuehQEsVsmBffs8,4526
|
|
4
|
-
git/config.py,sha256=
|
|
4
|
+
git/config.py,sha256=tPAXhoQozL0Mr7x4gtoUlFGUkkT8LtO3Ocqsqz-7ZrU,37412
|
|
5
5
|
git/db.py,sha256=vIW9uWSbqu99zbuU2ZDmOhVOv1UPTmxrnqiCtRHCfjE,2368
|
|
6
6
|
git/diff.py,sha256=xhOeMmFDmXOdpje2vA1mzJpmpBnyX-nrt-mp2RiVR1M,27172
|
|
7
7
|
git/exc.py,sha256=Gc7g1pHpn8OmTse30NHmJVsBJ2CYH8LxaR8y8UA3lIM,7119
|
|
@@ -34,11 +34,11 @@ git/refs/remote.py,sha256=WTlkJtpu895jJxbknDNOwL31tivQY_AHQrvroUoFBX4,2902
|
|
|
34
34
|
git/refs/symbolic.py,sha256=7ScmZHwlqPDKX9bxVC5queSZXUgqEY7_J_Si6gDBSLw,36139
|
|
35
35
|
git/refs/tag.py,sha256=AKrFrMhkNzX8e9x5WmDRtHovbN9zYQghuKoneVW-TJg,5002
|
|
36
36
|
git/repo/__init__.py,sha256=CILSVH36fX_WxVFSjD9o1WF5LgsNedPiJvSngKZqfVU,210
|
|
37
|
-
git/repo/base.py,sha256=
|
|
37
|
+
git/repo/base.py,sha256=EohoIREtbdpmUqVs7kfUgBIosEzZ29nMgiO9YMuAYDU,61165
|
|
38
38
|
git/repo/fun.py,sha256=PDFNkuTSGGoQc0EEEXjxHw2_KaKYvVjBZ9rrkwH5Q6Y,23462
|
|
39
|
-
gitpython-3.1.
|
|
40
|
-
gitpython-3.1.
|
|
41
|
-
gitpython-3.1.
|
|
42
|
-
gitpython-3.1.
|
|
43
|
-
gitpython-3.1.
|
|
44
|
-
gitpython-3.1.
|
|
39
|
+
gitpython-3.1.50.dist-info/licenses/AUTHORS,sha256=uyjC8YZ5vcAlx2nSJ44J8gE7wjA8nc69_zWYo_HKtVc,2360
|
|
40
|
+
gitpython-3.1.50.dist-info/licenses/LICENSE,sha256=hvyUwyGpr7wRUUcTURuv3tIl8lEA3MD3NQ6CvCMbi-s,1503
|
|
41
|
+
gitpython-3.1.50.dist-info/METADATA,sha256=3LhbhjxZJPBAeX0855vAyV3Eod7P7L0GlQB4qw6mNzY,14187
|
|
42
|
+
gitpython-3.1.50.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
|
|
43
|
+
gitpython-3.1.50.dist-info/top_level.txt,sha256=0hzDuIp8obv624V3GmbqsagBWkk8ohtGU-Bc1PmTT0o,4
|
|
44
|
+
gitpython-3.1.50.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|