reinject: Fix crash when reinjecting a file from outside the repository
authorJoey Hess <joeyh@joeyh.name>
Fri, 1 Oct 2021 18:04:18 +0000 (14:04 -0400)
committerJoey Hess <joeyh@joeyh.name>
Fri, 1 Oct 2021 18:06:34 +0000 (14:06 -0400)
commit9012fa01877a78542c64f104bd60a80825ce3c86
tree3c73cb808b43eb5c179cfac47a3f1b2c8a84de61
parentb2efbd1cd39e0476499fdf4aa34de049d72c2ea7
reinject: Fix crash when reinjecting a file from outside the repository

Commit 4bf7940d6b912fbf692b268f621ebd41ed871125 introduced this
problem, but was otherwise doing a good thing. Problem being
that fileRef "/foo" used to return ":./foo", which was actually wrong,
but as long as there was no foo in the local repository, catKey
could operate on it without crashing. After that fix though, fileRef
would return eg "../../foo", resulting in fileRef returning
":./../../foo", which will make git cat-file crash since that's
not a valid path in the repo.

Fix is simply to make fileRef detect paths outside the repo and return
Nothing. Then catKey can be skipped. This needed several bugfixes to
dirContains as well, in previous commits.

In Command.Smudge, this led to needing to check for Nothing. That case
should actually never happen, because the fileoutsiderepo check will
detect it earlier.

Sponsored-by: Brock Spratlen on Patreon
Annex/CatFile.hs
CHANGELOG
Command/Smudge.hs
Git.hs
Git/Ref.hs
doc/todo/recent_change_to_fileRef_breaks_reinject_--known.mdwn
doc/todo/recent_change_to_fileRef_breaks_reinject_--known/comment_1_5d3ade0367d3913bc115082ef2abd842._comment [new file with mode: 0644]