Skip to content

Question: How to just print stdout and stderr when executing commands #1239

@markusdd

Description

@markusdd

Hi,

I am using gitpython for a small helper tool to manage somewhat complicated submodule setups.

I want it to work alongside standard git, not agaionst or around it.

Hence I want users to see the output of the commands. as they know it from plain vanilla git

e.g. a "Everything up to date" after a push without changes.

From the docs I was not really able to figure out a consistent way to do it.

For commit, I was able to achieve it like this: print(toprepo.git.commit(a=pa.add, m=msg, with_stdout=True))

For push, the same does not work, because it ends up on stderr print(toprepo.git.push(pa.remote, with_stdout=True)):
Logger produces this:
INFO:git.cmd:git push origin -> 0; stdout: '<OUTPUT_STREAM>'; stderr: 'Everything up-to-date'

When using the built in remote.push() and remote.pull() methosds I cannot find a way to retrieve the output at all, as with_stdout=False is hardcoded without a way to override it via kwargs.

Can you give guidance on how to cover my use-case?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions