fix create tmp/ directory before opening a git store

ocaml-git's Store.v expects a tmp/ directory inside the git directory and returns an error when it cannot create one. Repositories set up by git-receive-pack do not include this directory, so opening them from a process without write access to the repository root fails with an internal server error. Pre-create the directory (ignoring permission errors) so that Store.v succeeds even when ogit runs as a read-only user.

Commit
7109266b482181ec31b15ca37393309fedc73912
Author
Marius Peter <dev@marius-peter.com>
Author date
Committer
Marius Peter <dev@marius-peter.com>
Committer date
lib/resolvers.ml
index c66bd020..530f588b 100644..100644
@@ -181,6 +181,12 @@
181 181 | Error error -> Lwt_result.fail error
182 182 | Ok None -> Lwt_result.fail (Not_found ("not a Git repository " ^ name))
183 183 | Ok (Some ({ worktree; git_dir } as layout)) ->
184 Added: (* ocaml-git's Store.v expects a tmp/ directory inside the git directory
185 Added: and fails if it cannot create one. Since ogit only reads repositories,
186 Added: we ensure the directory exists beforehand so that Store.v succeeds even
187 Added: when the process lacks write access to the repository root. *)
188 Added: (let tmp = Filename.concat git_dir "tmp" in
189 Added: try Unix.mkdir tmp 0o755 with Unix.Unix_error _ -> ());
184 190 let* store =
185 191 map_store (Store.v ~dotgit:(Fpath.v git_dir) (Fpath.v worktree))
186 192 in