It looks like as of git version 2.39.5*, you can just do this:
git branch --show-current
Assuming someone has a relatively recent version of git, am I missing a reason not to just do that? It seems a lot simpler than some of the other answers, though I certainly appreciate the creativity that's gone into some of them.
*Probably some earlier versions as well. I've just been too lazy to check.