Skip to content

Commit

Permalink
Fix root path issue with Irmin-git, and remove allow_duplicate fo…
Browse files Browse the repository at this point in the history
…r root spec key
  • Loading branch information
zazedd committed Aug 29, 2024
1 parent 649657d commit b2ec310
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 14 deletions.
2 changes: 0 additions & 2 deletions src/irmin-cli/resolver.ml
Original file line number Diff line number Diff line change
Expand Up @@ -446,8 +446,6 @@ let rec json_of_yaml : Yaml.value -> Yojson.Basic.t = function

let parse_config ?root y spec =
let config = Conf.empty spec in
(* Initialise root for the examples in README to pass. *)
let config = Conf.add config (Conf.root spec) "." in
let config =
List.fold_left
(fun config k ->
Expand Down
7 changes: 3 additions & 4 deletions src/irmin-git/conf.ml
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,14 @@ module Key = struct
"dot-git"
Irmin.Type.(option string)
None

let root = root spec
end

let init ?head ?bare ?level ?dot_git ?buffers root =
let module C = Irmin.Backend.Conf in
let config = C.empty spec in
(* Initialise an fresh root_key, otherwise [C.add config root_key root] has no
effect on current config. *)
let root_key = C.root spec in
let config = C.add config root_key root in
let config = C.add config (Key.root) root in
let config =
match bare with
| None -> C.add config Key.bare (C.default Key.bare)
Expand Down
14 changes: 7 additions & 7 deletions src/irmin-test/common.ml
Original file line number Diff line number Diff line change
Expand Up @@ -220,13 +220,13 @@ module Make_helpers (S : Generic_key) = struct
let module Conf = Irmin.Backend.Conf in
let generate_random_root config =
let id = Random.int 100 |> string_of_int in
let root_value =
match Conf.find_root config with
| None -> "test_" ^ id
| Some v -> v ^ "_" ^ id
in
let root_key = Conf.(root (spec config)) in
Conf.add config root_key root_value
let root_value = "test_" ^ id in
let sp = Conf.spec config in
match Conf.Spec.find_key sp "root" with
| None -> config
| Some (K k) ->
let v = Irmin.Type.of_string (Conf.ty k) root_value |> Result.get_ok in
Conf.add config k v
in
let config = generate_random_root x.config in
config_ptr := Some config;
Expand Down
2 changes: 1 addition & 1 deletion src/irmin/conf.ml
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ let equal t1 t2 =

(* ~root *)
let root spec =
key ~allow_duplicate:true ~spec ~docv:"ROOT"
key ~spec ~docv:"ROOT"
~doc:"The location of the Irmin store on disk." ~docs:"COMMON OPTIONS"
"root"
Type.(string)
Expand Down

0 comments on commit b2ec310

Please sign in to comment.