summaryrefslogtreecommitdiff
path: root/git/repo/fun.py
diff options
context:
space:
mode:
authorSebastian Thiel <sebastian.thiel@icloud.com>2023-01-09 09:03:52 +0100
committerGitHub <noreply@github.com>2023-01-09 09:03:52 +0100
commit90c81a56dffe77fc08f863769d35762ca66240b0 (patch)
tree34be1eed222c85f5aa408a9a0f11415600869096 /git/repo/fun.py
parent27a283bbc26c7266c0bd8c63f4ac3072d4ffa9bc (diff)
parente50046688f734f65f452de9b8feb10189efd7c1b (diff)
downloadgitpython-90c81a56dffe77fc08f863769d35762ca66240b0.tar.gz
Merge pull request #1532 from marlamb/feature/reduce-resource-leaks
Fix some resource leaks by open file handles
Diffstat (limited to 'git/repo/fun.py')
-rw-r--r--git/repo/fun.py3
1 files changed, 2 insertions, 1 deletions
diff --git a/git/repo/fun.py b/git/repo/fun.py
index 2ca2e3d6..ae35aa81 100644
--- a/git/repo/fun.py
+++ b/git/repo/fun.py
@@ -2,6 +2,7 @@
from __future__ import annotations
import os
import stat
+from pathlib import Path
from string import digits
from git.exc import WorkTreeRepositoryUnsupported
@@ -83,7 +84,7 @@ def find_worktree_git_dir(dotgit: "PathLike") -> Optional[str]:
return None
try:
- lines = open(dotgit, "r").readlines()
+ lines = Path(dotgit).read_text().splitlines()
for key, value in [line.strip().split(": ") for line in lines]:
if key == "gitdir":
return value