Skip to content

Commit 8a84f69

Browse files
committed
GitRepository: checkout - removed '--end-of-options' (closes #77)
1 parent 807e59f commit 8a84f69

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

src/GitRepository.php

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,19 @@ public function getLocalBranches()
234234
*/
235235
public function checkout($name)
236236
{
237-
$this->run('checkout', '--end-of-options', $name);
237+
if (!is_string($name)) {
238+
throw new InvalidArgumentException('Branch name must be string.');
239+
}
240+
241+
if ($name === '') {
242+
throw new InvalidArgumentException('Branch name cannot be empty.');
243+
}
244+
245+
if ($name[0] === '-') {
246+
throw new InvalidArgumentException('Branch name cannot be option name.');
247+
}
248+
249+
$this->run('checkout', $name);
238250
return $this;
239251
}
240252

tests/GitPhp/GitRepository.branches.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ $git = new Git($runner);
1212

1313
$runner->assert(['branch', '--end-of-options', 'master']);
1414
$runner->assert(['branch', '--end-of-options', 'develop']);
15-
$runner->assert(['checkout', '--end-of-options', 'develop']);
15+
$runner->assert(['checkout', 'develop']);
1616
$runner->assert(['merge', '--end-of-options', 'feature-1']);
1717
$runner->assert(['branch', '-d', 'feature-1']);
18-
$runner->assert(['checkout', '--end-of-options', 'master']);
18+
$runner->assert(['checkout', 'master']);
1919

2020
$repo = $git->open(__DIR__);
2121
$repo->createBranch('master');

0 commit comments

Comments
 (0)