There are many ways to name commits in git. For example:
$ git show HEAD^ # the parent of the HEAD commit
This made me hope that there was an analog for finding an immediate child. I did not see any evidence of this in the docs. So I went on the git IRC room and engaged in a discussion.
I suggested using a syntax such as HEAD$ — inspired by regular expressions, which use ^ to match the beginning of a line and $ to match the end of a line. I got a lot of pushback along the lines of (1) “this can’t be sanely done” or (2) “I don’t see why this would be useful.”
1. “This can’t be sanely done”
I don’t believe it. I’m sure the git community has solved far harder problems already. Git stores a repository as a directed acyclic graph and it is easy to lookup a parent. Traversing to a child is more expensive (but probably not prohibitively expensive.) With some caching and incremental updating, looking up a child should not be very costly. This is an interesting discussion to have — and there are lots of salient details that we can talk about in the comments — but ultimately this is a matter of ‘how to do it’ not ‘if it can be done’.
2. “I don’t see why this would be useful”
I have mixed feelings about this statement. I understand that building software is about choices, and open source software is often about scratching your own itches. So I can understand why a person might say, “I wouldn’t use the child style syntax, so why should I care about it?” Indifference is one thing: it is perhaps natural. But sometimes people take indifference a step further and also say that the idea is not of value to the community — this is flawed. In any case, broad concepts of user interface symmetry and beauty have more gravitas than one-off individual preferences.
Design should drive implementation
Git is unnecessarily complicated to new users. Parts of the git community do not grok the importance of the user perspective. Symmetry and beauty are not just nice to have: they are essential drivers for API design. A good API design goes a long way in enhancing the user experience.
The intrinsic worth of symmetry
The discussion was interesting and civil but somewhat unsatisfying because there was an elephant in the room: the importance of symmetry as a fundamental concept. Sometimes I see things as symmetrical or beautiful and others just don’t. I will try to explain.
Symmetry in user interface design can be defended on psychological or linguistic grounds. Humans think in opposites. Hot and cold. Parent and child. Love and hate. Don’t let ‘opposite’ throw you — the ‘opposite’ relationship is a very strong cognitive link.
Once an API lets you find a parent, it won’t be long before a user asks for the ability to find the child. Big surprise! Opposites are just part of how humans think. My suggestion: when people ask for symmetry, give it to them whenever you can.
It is expensive to try to fight that expectation. So don’t. Build great software for people. Don’t propagate the status quo by holding onto your current view of the software as being ‘good enough.’
Instead, admit that your API has a little flaw (of asymmetry) and take an objective look at what can be done about it. Remember: API design is more important than implementation details; so change the implementation as needed.
Don’t try to convince users that their intuition is wrong; instead, build a better user experience so that their intuition is right. As the application designer, you have the ability to frame concepts as you see fit. Frame them so the opposites make sense and everyone will be better off.
Conclusion
Neither pushback #1 nor #2 convinced me. I suspect they are veneers; the real reason seems to be: (3) “we have more important things to work on”. There is nothing wrong with saying that, but I find it interesting when people do not admit it up front. It seems like a defense mechanism.