Skip to content

Commit 7b83f7a

Browse files
authored
Merge pull request #2144 from mvanhorn/osc/2016-clarify-execute-string-arg
docs(cmd): clarify Git.execute() string vs list command argument
2 parents c7648c0 + d172e54 commit 7b83f7a

1 file changed

Lines changed: 10 additions & 3 deletions

File tree

git/cmd.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1131,9 +1131,16 @@ def execute(
11311131
information (stdout).
11321132
11331133
:param command:
1134-
The command argument list to execute.
1135-
It should be a sequence of program arguments, or a string. The
1136-
program to execute is the first item in the args sequence or string.
1134+
The command to execute. A sequence of program arguments is the
1135+
recommended form when `shell` is ``False`` (the default), e.g.
1136+
``["git", "log", "-n", "1"]``.
1137+
1138+
A string is accepted, but with `shell` set to ``False`` it is passed
1139+
as a single executable name to :class:`subprocess.Popen`. For example,
1140+
``"git log -n 1"`` looks for an executable literally named
1141+
``git log -n 1`` and will fail with :class:`GitCommandNotFound`. To
1142+
split a command string into argv tokens, pass ``shlex.split(...)`` as
1143+
a sequence or set `shell` to ``True`` (see the warning below).
11371144
11381145
:param istream:
11391146
Standard input filehandle passed to :class:`subprocess.Popen`.

0 commit comments

Comments
 (0)