Previously, errors would be 'unfolded' so there was no error chain,
but the lowest error would become the top-most one that way.
I thought this was accidental, but it turns out that it wasn't.
To fix this generally, make sure that we always use the message
of the lowest-possible error if no context is provided.
This also rewrites some other checks in preference of opening the git directory
in isolation. Doing so is very fast, and the only way to know for certain if a
repository is bare.
In future, once the repository is more separated from the worktree (in terms of mindset)
it should be possible to handle bare repos with worktrees as well.
The issue initially was that the wrapping of anyhow around a `thiserror`
type, which is when manually added context gets lost as there is no way
to downcast such an `anyhow` error back to a concrete type without
wanting to know it.
The solution was to remove the intermediate `thiserror` type which didn't
serve an actual purpose.
- assure that `repository` can't be misused in `hunks_by_filepath()`.
- Use more obvious enumeration to describe and match on lines
- make clear that diff_lines can be a hash
- avoid multiple hashmasps if one would do
- `Hunk::hash_diff` now uses lines with terminator to be close to being a true content hash. This was probably intended by the code originally.
The input is variable and maybe empty, maybe a diff header followed
by diff-lines, and it could be an SHA1 of a binary file, which now is
hashed like any other content.
Note that the comment above 'deltas' merely removed, as it wasn't actionable
without changing the frontend, which can probably already deal with
multiple of these.
Now that types are better understood though, it was straightforward to
change the type of `file_path` to not be a string, which now is even
clearer of a necessity thanks to the `tauri`-independent `watcher` crate.
Also, remove a comment related to the lack of worktree support.
It now fails gracefully, and that will come up again if support should be added.
If for whichever reason the parsing of parts of the vbranch.toml file
fails, this would be a permanent error until the file is fixed or removed.
Now it's also displayed along with the error to make clearing the file
more convenient.
Instead, fail gracefully by displaying fill-characters.
Ideally, we would be able to use the commit-encoding header field as well,
but one step at a time.
This will make the diffing engine more correct overall, as only for
display there will be a potentially lossy conversion.
This will also prevent it to be considered binary even though it is not.