diff --git a/__tests__/git.spec.js b/__tests__/git.spec.js index 16ba09de..c5ea12ba 100644 --- a/__tests__/git.spec.js +++ b/__tests__/git.spec.js @@ -23,6 +23,13 @@ describe('Git', function() { ); }); + it('handles lower case branch options', function() { + expectTreeAsync( + 'git branch banana c0; git commit; git checkout -b side banana; git branch -d banana;git branch -f another c1; git commit', + '{"branches":{"master":{"target":"C2","id":"master"},"side":{"target":"C3","id":"side"},"another":{"target":"C1","id":"another"}},"commits":{"C0":{"parents":[],"id":"C0","rootCommit":true},"C1":{"parents":["C0"],"id":"C1"},"C2":{"parents":["C1"],"id":"C2"},"C3":{"parents":["C0"],"id":"C3"}},"HEAD":{"target":"side","id":"HEAD"}}' + ); + }); + it('handles branch options', function() { expectTreeAsync( 'git branch banana C0; git commit; git checkout -b side banana; git branch -d banana;git branch -f another C1; git commit', diff --git a/src/js/git/index.js b/src/js/git/index.js index 631b7166..eb3005de 100644 --- a/src/js/git/index.js +++ b/src/js/git/index.js @@ -1663,6 +1663,10 @@ GitEngine.prototype.resolveStringRef = function(ref) { if (this.refs[ref]) { return this.refs[ref]; } + // Commit hashes like C4 are case insensitive + if (ref.match(/^c\d+$/) && this.refs[ref.toUpperCase()]) { + return this.refs[ref.toUpperCase()]; + } // Attempt to split ref string into a reference and a string of ~ and ^ modifiers. var startRef = null;