mirror of
https://github.com/klaussilveira/gitlist.git
synced 2026-07-12 19:01:52 +02:00
better Head detection if refs/heads is pointing to non-existing master
This commit is contained in:
@@ -422,14 +422,21 @@ class Repository
|
||||
else {
|
||||
return 'master';
|
||||
}
|
||||
// Find first existing branch
|
||||
foreach (explode("\n", $file) as $line) {
|
||||
$m = array();
|
||||
if (preg_match('#ref:\srefs/heads/(.+)#', $line, $m)) {
|
||||
return $m[1];
|
||||
if ($this->hasBranch($m[1])) {
|
||||
return $m[1];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Default to something sane if in a detached HEAD state.
|
||||
$branches = $this->getBranches();
|
||||
if (!empty($branches)) {
|
||||
return current($branches);
|
||||
}
|
||||
return 'master';
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user