Add to git-annex unused a --history or similar switch, that makes it look at the full history of all specified refs, and only consider files unused if they never appeared in a git commit at all.
This would, like git gc
, find files that were added, but then
deleted/changed before being committed. Which git-annex unused already
does, but it also finds files in past versions. If the user wants to keep
past versions, but gc any dangling objects, this would be useful.
To traverse the whole history and get the list of changes, could use git
log --raw
. That is reasonably performant but then it needs to feed every
sha into cat-file to find the annex objects, which would probably take a
while. Alternatively perhaps git log --diff and parsing might be faster.
Alternate name,
git-annex gc
since this would be very analagous togit gc
.I wonder if someone might want to keep all versions of files from one branch, but only the current version of another branch? For such a person it would be better if the interface was all in
git-annex unused
as part of the--used-refspec
with a way to indicate if past versions of a ref should be examined.Another name for a
git-annex unused
switch could be--unreachable
. I supposegit-annex gc
would drop unreachable files without a separategit-annex dropunused
invocation? That would work for me as well.Personally I don't have the use case of
git-annex unused
only looking at the history of some refs and treating other refs normally.Since dropunused, --unused, etc refer to what git-annex unused finds, it probably makes sense to keep it in there.
git-annex unused --ever
is another name idea.