Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Branch command assumes all short hashes are 7 characters #22

Open
Pudge601 opened this issue Mar 13, 2015 · 0 comments
Open

Branch command assumes all short hashes are 7 characters #22

Pudge601 opened this issue Mar 13, 2015 · 0 comments

Comments

@Pudge601
Copy link

The regular expression for parsing lines of output from the git branch command assumes that all short hashes will be exactly 7 characters, but this is not always the case.

The specific line is at src/PHPGit/Command/BranchCommand.php:67:

preg_match('/(?<current>\*| ) (?<name>[^\s]+) +((?:->) (?<alias>[^\s]+)|(?<hash>[0-9a-z]{7}) (?<title>.*))/', $line, $matches);

Suggest changing the hash capturing group to (?<hash>[0-9a-z]{7,40}) to handle all possible cases.

Additionally, the result of preg_match should probably be checked to see if it succeeded, and either continue the loop or throw an exception?

dnaber-de added a commit to dnaber-de/PHPGit that referenced this issue Dec 19, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant