threads / discuss / 31150

Return code in cmd (git describe)

Subject: Return code in cmd (git describe)

## tl;dr

3 messages between Jul 31, 2012 and Jul 31, 2012.

replies: 2people: 2as markdown or json

Manuela Hutter· Jul 31, 2012, 12:02 UTC · lore
Hi,

we have some python scripts that are run from Visual Studio, and one of them fails because of a wrong git return code when calling 'git describe --dirty'

Here's the issue:

============= import subprocess

GIT_EXE = "<path to git exe>" GIT_SRC = "<path to git repo>"

# call 'git describe --dirty':
run_git = subprocess.Popen([GIT_EXE, "describe", "--dirty"],
                            cwd=GIT_SRC,
                            stdout=subprocess.PIPE,
                            stderr=subprocess.PIPE)
(output, output_err) = run_git.communicate()
print "Returncode: %s" % run_git.returncode
print "Output:     %s" % output.strip()
=============

Run from wingw, the return code is 0. Run from cmd, the return code is 1.

Why?

Thanks, Manuela

Konstantin Khomoutov· Jul 31, 2012, 12:27 UTC · re: Manuela Hutter · lore

Re: Return code in cmd (git describe)

On Tue, 31 Jul 2012 14:02:50 +0200 "Manuela Hutter" <manuelah@opera.com> wrote:

> we have some python scripts that are run from Visual Studio, and one
> of them fails because of a wrong git return code when calling
> 'git describe --dirty'
[...]
> Run from wingw, the return code is 0.
> Run from cmd, the return code is 1.
> 
> Why?

Supposedly, when you run Git from cmd.exe, the git.cmd top-level script (which wraps the git.exe binary) gets executed, and it's currently affected by this bug [1] (fixed). When you run Git from Git bash, the git.exe binary runs directly and hence the bug is not exposed.

1. https://github.com/msysgit/msysgit/issues/43
Manuela Hutter· Jul 31, 2012, 12:54 UTC · re: Konstantin Khomoutov · lore

Re: Return code in cmd (git describe)

On Tue, 31 Jul 2012 14:27:15 +0200, Konstantin Khomoutov <flatworm@users.sourceforge.net> wrote:

Show 17 quoted lines
> On Tue, 31 Jul 2012 14:02:50 +0200
> "Manuela Hutter" <manuelah@opera.com> wrote:
>
>> we have some python scripts that are run from Visual Studio, and one
>> of them fails because of a wrong git return code when calling
>> 'git describe --dirty'
> [...]
>> Run from wingw, the return code is 0.
>> Run from cmd, the return code is 1.
>>
>> Why?
> Supposedly, when you run Git from cmd.exe, the git.cmd top-level script
> (which wraps the git.exe binary) gets executed, and it's currently
> affected by this bug [1] (fixed).  When you run Git from Git bash, the
> git.exe binary runs directly and hence the bug is not exposed.
>
> 1. https://github.com/msysgit/msysgit/issues/43

Great, thanks for the info! /Manuela

← back to recent threads