Skip to content
This repository has been archived by the owner on Feb 1, 2021. It is now read-only.

Fix git checkout bug :: git checkout returns STDERR instead of STDOUT #72

Merged
merged 1 commit into from Aug 10, 2012

Conversation

jrschumacher
Copy link
Contributor

When building a project stderr is returned by git when it intends stdout. Following command prints to stderr and causes error

$ git checkout 'origin/master'
    HEAD is now at 43329a9... update MongoRecord

Dumping $process

// Builder.php::execute() | var_dump($process);
object(Symfony\Component\Process\Process)#159 (16) {
  ["commandline":"Symfony\Component\Process\Process":private]=>
  string(28) "git checkout 'origin/master'"
  ["cwd":"Symfony\Component\Process\Process":private]=>
  string(36) "/Users/Ryan/.sismo/data/build/ac1276"
  ["env":"Symfony\Component\Process\Process":private]=>
  NULL
  ["stdin":"Symfony\Component\Process\Process":private]=>
  NULL
  ["timeout":"Symfony\Component\Process\Process":private]=>
  int(3600)
  ["options":"Symfony\Component\Process\Process":private]=>
  array(2) {
    ["suppress_errors"]=>
    bool(true)
    ["binary_pipes"]=>
    bool(true)
  }
  ["exitcode":"Symfony\Component\Process\Process":private]=>
  int(0)
  ["processInformation":"Symfony\Component\Process\Process":private]=>
  array(8) {
    ["command"]=>
    string(28) "git checkout 'origin/master'"
    ["pid"]=>
    int(61774)
    ["running"]=>
    bool(false)
    ["signaled"]=>
    bool(false)
    ["stopped"]=>
    bool(false)
    ["exitcode"]=>
    int(0)
    ["termsig"]=>
    int(0)
    ["stopsig"]=>
    int(0)
  }
  ["stdout":"Symfony\Component\Process\Process":private]=>
  string(0) ""
  ["stderr":"Symfony\Component\Process\Process":private]=>
  string(45) "HEAD is now at 43329a9... update MongoRecord
"
  ["enhanceWindowsCompatibility":"Symfony\Component\Process\Process":private]=>
  bool(true)
  ["pipes":"Symfony\Component\Process\Process":private]=>
  array(0) {
  }
  ["process":"Symfony\Component\Process\Process":private]=>
  resource(23) of type (Unknown)
  ["status":"Symfony\Component\Process\Process":private]=>
  string(10) "terminated"
  ["fileHandles":"Symfony\Component\Process\Process":private]=>
  NULL
  ["readBytes":"Symfony\Component\Process\Process":private]=>
  NULL
}

Surprisingly adding git checkout -q 'origin/master' will suppress that error yet still return stderr. After browsing the net there are a number of issues where git uses stderr instead of stdout.

@jrschumacher
Copy link
Contributor Author

This will need others to test and look into to determine if it has to do with my version of git.

@fabpot
Copy link
Member

fabpot commented Aug 7, 2012

-g is not a valid switch for checkout (at least, not for me: git version 1.7.11.3).

@jrschumacher
Copy link
Contributor Author

Sorry that was a typo meant git checkout -q

fabpot added a commit that referenced this pull request Aug 10, 2012
Commits
-------

fcce354 fix git checkout bug through suppression

Discussion
----------

Fix git checkout bug :: git checkout returns STDERR instead of STDOUT

When building a project stderr is returned by git when it intends stdout. Following command prints to stderr and causes error
```
$ git checkout 'origin/master'
    HEAD is now at 43329a9... update MongoRecord
```

Dumping $process
```` php
// Builder.php::execute() | var_dump($process);
object(Symfony\Component\Process\Process)#159 (16) {
  ["commandline":"Symfony\Component\Process\Process":private]=>
  string(28) "git checkout 'origin/master'"
  ["cwd":"Symfony\Component\Process\Process":private]=>
  string(36) "/Users/Ryan/.sismo/data/build/ac1276"
  ["env":"Symfony\Component\Process\Process":private]=>
  NULL
  ["stdin":"Symfony\Component\Process\Process":private]=>
  NULL
  ["timeout":"Symfony\Component\Process\Process":private]=>
  int(3600)
  ["options":"Symfony\Component\Process\Process":private]=>
  array(2) {
    ["suppress_errors"]=>
    bool(true)
    ["binary_pipes"]=>
    bool(true)
  }
  ["exitcode":"Symfony\Component\Process\Process":private]=>
  int(0)
  ["processInformation":"Symfony\Component\Process\Process":private]=>
  array(8) {
    ["command"]=>
    string(28) "git checkout 'origin/master'"
    ["pid"]=>
    int(61774)
    ["running"]=>
    bool(false)
    ["signaled"]=>
    bool(false)
    ["stopped"]=>
    bool(false)
    ["exitcode"]=>
    int(0)
    ["termsig"]=>
    int(0)
    ["stopsig"]=>
    int(0)
  }
  ["stdout":"Symfony\Component\Process\Process":private]=>
  string(0) ""
  ["stderr":"Symfony\Component\Process\Process":private]=>
  string(45) "HEAD is now at 43329a9... update MongoRecord
"
  ["enhanceWindowsCompatibility":"Symfony\Component\Process\Process":private]=>
  bool(true)
  ["pipes":"Symfony\Component\Process\Process":private]=>
  array(0) {
  }
  ["process":"Symfony\Component\Process\Process":private]=>
  resource(23) of type (Unknown)
  ["status":"Symfony\Component\Process\Process":private]=>
  string(10) "terminated"
  ["fileHandles":"Symfony\Component\Process\Process":private]=>
  NULL
  ["readBytes":"Symfony\Component\Process\Process":private]=>
  NULL
}
````

Surprisingly adding `git checkout -q 'origin/master'` will suppress that error yet still return stderr. After browsing the net there are a number of issues where git uses stderr instead of stdout.

---------------------------------------------------------------------------

by jrschumacher at 2012-08-06T20:59:14Z

This will need others to test and look into to determine if it has to do with my version of git.

---------------------------------------------------------------------------

by fabpot at 2012-08-07T05:59:17Z

`-g` is not a valid switch for `checkout` (at least, not for me: git version 1.7.11.3).

---------------------------------------------------------------------------

by jrschumacher at 2012-08-08T18:53:28Z

Sorry that was a typo meant `git checkout -q`
@fabpot fabpot merged commit fcce354 into FriendsOfPHP:master Aug 10, 2012
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
2 participants