Skip to content

Commit 223dbec

Browse files
committed
refactor(cmd.git): Improved handling of C
1 parent 5ac38b0 commit 223dbec

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

libvcs/cmd/git.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ def run(
4444
man_path: Optional[bool] = None,
4545
info_path: Optional[bool] = None,
4646
# Normal flags
47+
C: Optional[Union[StrOrBytesPath, list[StrOrBytesPath]]] = None,
4748
cwd: Optional[StrOrBytesPath] = None,
4849
git_dir: Optional[StrOrBytesPath] = None,
4950
work_tree: Optional[StrOrBytesPath] = None,
@@ -71,8 +72,10 @@ def run(
7172
7273
Parameters
7374
----------
74-
cwd : :attr:`libvcs.cmd.types.StrOrBytesPath`, optional
75-
``-C <path>``, Defaults to :attr:`~.cwd`
75+
cwd : :attr:`libvcs.cmd.types.StrOrBytesPath`, optional, passed to subprocess's
76+
``cwd`` the command runs from. Defaults to :attr:`~.cwd`.
77+
C : :attr:`libvcs.cmd.types.StrOrBytesPath`, optional
78+
``-C <path>``
7679
git_dir : :attr:`libvcs.cmd.types.StrOrBytesPath`, optional
7780
``--git-dir <path>``
7881
work_tree : :attr:`libvcs.cmd.types.StrOrBytesPath`, optional
@@ -148,8 +151,11 @@ def run(
148151
#
149152
# Flags
150153
#
151-
if cwd is not None:
152-
cli_args.append(f"-C {cwd}")
154+
if C is not None:
155+
if not isinstance(C, list):
156+
C = [C]
157+
C = [str(c) for c in C]
158+
cli_args.extend(["-C", C])
153159
if git_dir is not None:
154160
cli_args.append(f"--git-dir {git_dir}")
155161
if work_tree is not None:
@@ -1384,6 +1390,9 @@ def status(
13841390
13851391
>>> git.status(porcelain='2')
13861392
'? new_file.txt'
1393+
1394+
>>> git.status(C=git_local_clone.dir / '.git', porcelain='2')
1395+
'? new_file.txt'
13871396
"""
13881397
local_flags: list[str] = []
13891398

0 commit comments

Comments
 (0)