reinject: Fix crash when reinjecting a file from outside the repository
Commit 4bf7940d6b
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
This commit is contained in:
parent
b2efbd1cd3
commit
9012fa0187
7 changed files with 48 additions and 22 deletions
2
Git.hs
2
Git.hs
|
@ -71,7 +71,7 @@ repoLocation Repo { location = LocalUnknown dir } = fromRawFilePath dir
|
|||
repoLocation Repo { location = Unknown } = error "unknown repoLocation"
|
||||
|
||||
{- Path to a repository. For non-bare, this is the worktree, for bare,
|
||||
- it's the gitdit, and for URL repositories, is the path on the remote
|
||||
- it's the gitdir, and for URL repositories, is the path on the remote
|
||||
- host. -}
|
||||
repoPath :: Repo -> RawFilePath
|
||||
repoPath Repo { location = Url u } = toRawFilePath $ unEscapeString $ uriPath u
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue