Closed OEP closed 11 years ago
The only problem I've found is when GitRepo.log() is used on an empty repo. Everything else seems to behave normally. Have you found otherwise? If that's the only place where git differs, I think we should probably handle that case gracefully and return an empty list.
Defining a VCSRepo.empty() does seem like a good idea. I'll go ahead and add it.
"git rev-parse HEAD" seems to behave differently on bare and non-bare repos. On an empty bare repo it prints "HEAD" to stdout and exits 0. On an empty non-bare repo it does that then spews some stuff on stderr and exits 128. While the focus is on bare repos, I'd like to keep it working on non-bare repos if possible too.
Implemented in e3da32f49d61750cdbf41d47c3afee1b32e1045a
(leaving closed, just clarifying)
I had trouble remembering what I meant. I think what I meant is that it is impossible to use GitRepo.ls() on an empty repository because there is nothing you can use for the 'rev' argument, whereas you can use '0' for Hg and SVN. This makes sense by nature of how Git works, but it ends up being kind of confusing since you can get away with it on Hg and SVN. It seems like leaving that as undefined behavior and providing VCSRepo.empty() is a safe way to do things.
Different types of empty repositories seem to behave differently. The main offender is git, which throws CalledProcessErrors on a lot of its commands.
For SVN and Hg, there is a concept of a "0" revision which can safely be used as the rev argument. There's not an equivalent for git (well, that I know of). I can think of two things to work around this:
I like (1) since it seems easier and respects the different philosophies about zero-commits, plus (2) seems kind of fudgy and counter-intuitive.
Seems like we need a uniform way of checking of the repo has zero commits since git's log() command fails in zero commit case.
EDIT: I forgot to add some info about how to check for zero commits: