File tree Expand file tree Collapse file tree 2 files changed +15
-3
lines changed
Expand file tree Collapse file tree 2 files changed +15
-3
lines changed Original file line number Diff line number Diff 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
Original file line number Diff line number Diff 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 ' );
You can’t perform that action at this time.
0 commit comments