onlywei / explain-git-with-d3

Use D3 to visualize simple git branching operations.
MIT License
1.71k stars 390 forks source link

Support referencing a unique abbreviated commit hash, like “bb92” #35

Open roryokane opened 9 years ago

roryokane commented 9 years ago

In the git checkout example, I tried to type git checkout bb92 to check out the commit labeled “bb92e0e…” on the graph. I got the error “Cannot find commit: bb92”. I had to type the full 7-character name to perform the checkout command.

Abbreviated commits hashes should work, to save the user typing when exploring Git. The command line should only display an error if the hash is ambiguous, like “Ambiguous abbreviated ref: e”, or if no commit begins with that prefix, like “No such ref: 123”.

The code that identifies a ref given its name is getCommit in historyview.js.