I am working on the difflint project and have an open issue where the program fails when the current state is that of an orphaned branch (which could happen in a few different ways -- the most common of which would be when you are creating a new repository via git init
.) It is failing because it is trying to use git stash
which doesn't work if there is no prior history.
I am looking for a way to programatically determine if the current branch has no history. One option would be to run git show-branch
and look for the string "No revs to be shown."
but that seems a bit hacky. I'm hoping for a solution that seems less brittle, such as something to determine the longest history path from a given state; I could simply check if it is 0. Are there any less brittle/hacky ways to detect if there is no previous history?
(Porcelain commands are acceptable, if necessary. The project already relies on them.)