PHPGit icon indicating copy to clipboard operation
PHPGit copied to clipboard

Branch command doesn't fetch all branches

Open dnaber-de opened this issue 9 years ago • 1 comments

Here I have a strange situation where the branch command seems to stumble parsing all branches correctly.

Here's a plain git branch -a result:

$repo = '/path/to/repo';
var_dump( `cd $repo && git branch -a` );
/**
string(1268) "  1.5
  2.0
  2.1
  2.2
  2.3
  2.5
  2.6
  2.7
  2.8
  2.9
  3.0
  3.1
  3.2
  3.3
  3.4
  3.5
  3.6
  3.7
  3.8
  3.9
  4.0
  4.1
  4.2
  4.3
  4.4
  composer
* master
  remotes/mirror/1.5
  remotes/mirror/2.0
  remotes/mirror/2.1
  remotes/mirror/2.2
  remotes/mirror/2.3
  remotes/mirror/2.5
  remotes/mirror/2.6
  remotes/mirror/2.7
  remotes/mirror/2.8
  remotes/mirror/2.9
  remotes/mirror/3.0
  remotes/mirror/3.1
  remotes/mirror/3.2
  remotes/mirror/3.3
  remotes/mirror/3.4
  remotes/mirror/3.5
  remotes/mirror/3.6
  remotes/mirror/3.7
  remotes/mirror/3.8
  remotes/mirror/3.9
  remotes/mirror/4.0
  remotes/mirror/4.1
  remotes/mirror/4.2
  remotes/mirror/4.3
  remotes/mirror/4.4
  remotes/mirror/master
  remotes/origin/1.5
  remotes/origin/2.0
  remotes/origin/2.1
  remotes/origin/2.2
  remotes/origin/2.3
  remotes/origin/2.5
  remotes/origin/2.6
  remotes/origin/2.7
  remotes/origin/2.8
  remotes/origin/2.9
  remotes/origin/3.0
  remotes/origin/3.1
  remotes/origin/3.2
  remotes/origin/3.3
  remotes/origin/3.4
  remotes/origin/3.5
  remotes/origin/3.6
  remotes/origin/3.7
  remotes/origin/3.8
  remotes/origin/3.9
  remotes/origin/4.0
  remotes/origin/4.1
  remotes/origin/4.2
  remotes/origin/4.3
  remotes/origin/4.4
  remotes/origin/master
"
*/

Now this is what PHPGit returns:

$repo = '/path/to/repo';
$git->setRepository( $repo );
$branches = $git->branch( [ 'all' => TRUE ] );
var_dump( array_keys( $branches )  );
/**
array(78) {
  [0]=>
  string(3) "1.5"
  [1]=>
  string(3) "2.0"
  [2]=>
  string(3) "2.1"
  [3]=>
  string(3) "2.2"
  [4]=>
  string(3) "2.3"
  [5]=>
  string(3) "2.5"
  [6]=>
  string(3) "2.6"
  [7]=>
  string(3) "2.7"
  [8]=>
  string(3) "2.8"
  [9]=>
  string(3) "2.9"
  [10]=>
  string(3) "3.0"
  [11]=>
  string(3) "3.1"
  [12]=>
  string(3) "3.2"
  [13]=>
  string(3) "3.3"
  [14]=>
  string(3) "3.4"
  [15]=>
  string(3) "3.5"
  [16]=>
  string(3) "3.6"
  [17]=>
  string(3) "3.7"
  [18]=>
  string(3) "3.8"
  [19]=>
  string(3) "3.9"
  [20]=>
  string(3) "4.0"
  [21]=>
  string(3) "4.1"
  [22]=>
  string(3) "4.2"
  [23]=>
  string(3) "4.3"
  [24]=>
  string(3) "4.4"
  [25]=>
  string(8) "composer"
  [26]=>
  string(0) ""
  [27]=>
  string(18) "remotes/mirror/1.5"
  [28]=>
  string(18) "remotes/mirror/2.0"
  [29]=>
  string(18) "remotes/mirror/2.1"
  [30]=>
  string(18) "remotes/mirror/2.2"
  [31]=>
  string(18) "remotes/mirror/2.3"
  [32]=>
  string(18) "remotes/mirror/2.5"
  [33]=>
  string(18) "remotes/mirror/2.6"
  [34]=>
  string(18) "remotes/mirror/2.7"
  [35]=>
  string(18) "remotes/mirror/2.8"
  [36]=>
  string(18) "remotes/mirror/2.9"
  [37]=>
  string(18) "remotes/mirror/3.0"
  [38]=>
  string(18) "remotes/mirror/3.1"
  [39]=>
  string(18) "remotes/mirror/3.2"
  [40]=>
  string(18) "remotes/mirror/3.3"
  [41]=>
  string(18) "remotes/mirror/3.4"
  [42]=>
  string(18) "remotes/mirror/3.5"
  [43]=>
  string(18) "remotes/mirror/3.6"
  [44]=>
  string(18) "remotes/mirror/3.7"
  [45]=>
  string(18) "remotes/mirror/3.8"
  [46]=>
  string(18) "remotes/mirror/3.9"
  [47]=>
  string(18) "remotes/mirror/4.0"
  [48]=>
  string(18) "remotes/mirror/4.1"
  [49]=>
  string(18) "remotes/mirror/4.2"
  [50]=>
  string(18) "remotes/mirror/4.3"
  [51]=>
  string(18) "remotes/mirror/4.4"
  [52]=>
  string(18) "remotes/origin/1.5"
  [53]=>
  string(18) "remotes/origin/2.0"
  [54]=>
  string(18) "remotes/origin/2.1"
  [55]=>
  string(18) "remotes/origin/2.2"
  [56]=>
  string(18) "remotes/origin/2.3"
  [57]=>
  string(18) "remotes/origin/2.5"
  [58]=>
  string(18) "remotes/origin/2.6"
  [59]=>
  string(18) "remotes/origin/2.7"
  [60]=>
  string(18) "remotes/origin/2.8"
  [61]=>
  string(18) "remotes/origin/2.9"
  [62]=>
  string(18) "remotes/origin/3.0"
  [63]=>
  string(18) "remotes/origin/3.1"
  [64]=>
  string(18) "remotes/origin/3.2"
  [65]=>
  string(18) "remotes/origin/3.3"
  [66]=>
  string(18) "remotes/origin/3.4"
  [67]=>
  string(18) "remotes/origin/3.5"
  [68]=>
  string(18) "remotes/origin/3.6"
  [69]=>
  string(18) "remotes/origin/3.7"
  [70]=>
  string(18) "remotes/origin/3.8"
  [71]=>
  string(18) "remotes/origin/3.9"
  [72]=>
  string(18) "remotes/origin/4.0"
  [73]=>
  string(18) "remotes/origin/4.1"
  [74]=>
  string(18) "remotes/origin/4.2"
  [75]=>
  string(18) "remotes/origin/4.3"
  [76]=>
  string(18) "remotes/origin/4.4"
  [77]=>
  string(21) "remotes/origin/master"
}
*/

I used array_keys() to keep the output short. You can see, it seems to loose master and ignores completely remotes/mirror/master.

Any idea what could be the reason on this?

dnaber-de avatar Dec 19 '15 16:12 dnaber-de

It points out that the missing branch master has a hash that is 8 characters long. So this in in fact a symptom of #22.

dnaber-de avatar Dec 19 '15 16:12 dnaber-de