Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jgit-dev] GarbageCollectCommand does not prune unreferenced commit

To be honest, I was also a little bit of surprised.

But when reading the javadoc it makes sense. The javadoc of says
"Parse a git revision string and return an object id". Nowhere it is
mentioned that this objectid does actually exist in the objectdatabase
of the repo (although you and me somehow expects this). So whenever
the method can compute an objectid for the input string it will return
that. If you call
repo.resolve("a73692b9992fc5d2476f08195a2c0511a1d96d1c") then it is no
doubt which objectid to return. No need to open pack files, search the
.git/objects/* file system hierarchy, etc. But If you call
repo.resolve("HEAD~9") then there is no other way then for the method
than to go the very expensive way and to resolve HEAD, read the commit
object HEAD points to, get the objectid of the the first parent, read
the commitobject this objectid points to, parse that commit, get the
objectid of the the first parent...... . Even if you say
repo.resolve("master") and there is a file called
.git/refs/heads/master containing the string
"a73692b9992fc5d2476f08195a2c0511a1d96d1c" then a
ObjectId.fromString("a73692b9992fc5d2476f08195a2c0511a1d96d1c") will
be returned. It is not checked whether such an object really exists in
the object database.


Back to the top