Hacker News new | past | comments | ask | show | jobs | submit login

Previous/Next is a bit complicated if one of the key features of the versioning system you're using is that it's a graph.

Of course, that graph could easily be flattened (e.g. simply sort by date) but that'd cause you to jump all over the graph. It would make for a terrible and confusing user experience as the next commit is suddenly based on a state of the code you saw 20 steps ago.

As it would only work properly for projects with a completely linear history (which most projects don't have) I can understand Github not adding this feature. I'd say this is something a third party app using the Github API could do very well for projects specifically set up for learning through their history (like this one).




git is a digraph though, so it's not as complicated as an arbitrary graph. Every commit has a single parent, making a previous button trivial. The next commit is difficult, since that's where branching happens, but that's not so hard to represent: show all options and let the user continue along one path or another.

The implementation probably just involves walking backwards through history until you reach the initial commit, maintaining a bidirectional linked list as you go.

Github already allows users to walk forward and backward though history via the commits page[0]. It seems reasonable to provide the same "Newer", "Older" buttons when viewing an individual commit.

[0]: https://github.com/torvalds/linux/commits/master?page=1


> Every commit has a single parent, making a previous button trivial.

Until, of course, you hit a merge commit. Which most projects have a lot of regardless of whether that's a good thing. I suppose you could always pick the parent which is on the same branch, but still.




Consider applying for YC's W25 batch! Applications are open till Nov 12.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: