Skip to content

Commit

Permalink
Rename gitbin* to git-location
Browse files Browse the repository at this point in the history
  • Loading branch information
kit-ty-kate committed Jan 10, 2024
1 parent a86e13f commit 64c4d6c
Show file tree
Hide file tree
Showing 13 changed files with 57 additions and 57 deletions.
8 changes: 4 additions & 4 deletions src/client/opamAction.ml
Original file line number Diff line number Diff line change
Expand Up @@ -534,12 +534,12 @@ let compilation_env t opam =
let cygbin = OpamFilename.Dir.to_string cygbin in
[ OpamTypesBase.env_update_resolved "PATH" EqPlus cygbin
~comment:"Cygwin path"
] @ (match OpamCoreConfig.(!r.gitbinpath) with
] @ (match OpamCoreConfig.(!r.git_location) with
| None -> []
| Some gitbinpath ->
if String.equal cygbin gitbinpath then [] else
| Some git_location ->
if String.equal cygbin git_location then [] else
[ OpamTypesBase.env_update_resolved "PATH" PlusEq
gitbinpath ~comment:"Git binary path"])
git_location ~comment:"Git binary path"])
| None -> []
in
let shell_sanitization = "shell env sanitization" in
Expand Down
6 changes: 3 additions & 3 deletions src/client/opamArg.ml
Original file line number Diff line number Diff line change
Expand Up @@ -597,9 +597,9 @@ let apply_global_options cli o =
{ pelem = String cygcheck; _}::_ ->
let cygbin = Filename.dirname cygcheck in
OpamCoreConfig.update ~cygbin ()
| Some { pelem = String "gitbinfield"; _},
{ pelem = String gitbinpath; _}::_ ->
OpamCoreConfig.update ~gitbinpath ()
| Some { pelem = String "git-location"; _},
{ pelem = String git_location; _}::_ ->
OpamCoreConfig.update ~git_location ()
| _, element::elements -> aux (Some element) elements
in
aux None elements
Expand Down
12 changes: 6 additions & 6 deletions src/client/opamClient.ml
Original file line number Diff line number Diff line change
Expand Up @@ -656,7 +656,7 @@ let git_for_windows_check =
match gitbin with
| Some _ -> gitbin
| None ->
OpamConsole.read "Please enter the path containing git.exe (e.g. C:\Program Files\Git\cmd):"
OpamConsole.read "Please enter the path containing git.exe (e.g. C:\\Program Files\\Git\\cmd):"
in
match bin with
| None -> None
Expand Down Expand Up @@ -726,7 +726,7 @@ let git_for_windows_check =
OpamStd.Option.iter (fun _ ->
OpamConsole.msg
"You can change that later with \
'opam option \"gitbinfield=C:\\A\\Path\\bin\"'")
'opam option \"git-location=C:\\A\\Path\\bin\"'")
gitbin;
gitbin

Expand All @@ -737,12 +737,12 @@ let windows_checks ?cygwin_setup ?gitbin config =
|> OpamVariable.Map.of_list
in
(* Git handling *)
let gitbinpath : string option = git_for_windows_check ?gitbin () in
OpamCoreConfig.update ?gitbinpath ();
let git_location : string option = git_for_windows_check ?gitbin () in
OpamCoreConfig.update ?git_location ();
let config =
match gitbinpath with
match git_location with
| Some gitbin ->
OpamFile.Config.with_gitbinfield
OpamFile.Config.with_git_location
(OpamFilename.Dir.of_string gitbin) config
| None -> config
in
Expand Down
2 changes: 1 addition & 1 deletion src/client/opamClientConfig.mli
Original file line number Diff line number Diff line change
Expand Up @@ -165,5 +165,5 @@ val opam_init:
?merged_output:bool ->
?precise_tracking:bool ->
?cygbin:string ->
?gitbinpath:string ->
?git_location:string ->
unit -> unit
8 changes: 4 additions & 4 deletions src/client/opamConfigCommand.ml
Original file line number Diff line number Diff line change
Expand Up @@ -832,18 +832,18 @@ let global_allowed_fields, global_allowed_sections =
Config.with_sys_pkg_manager_cmd (Config.sys_pkg_manager_cmd Config.empty);
"swh-fallback", Atomic,
Config.with_swh_fallback (Config.swh_fallback Config.empty);
"gitbinfield", Atomic_pp
"git-location", Atomic_pp
(fun c ->
OpamStd.Option.iter (fun gitbin ->
if OpamSystem.bin_contains_bash
(OpamFilename.Dir.to_string gitbin) then
OpamConsole.error_and_exit `False
"Found a bash in given git bin directory,\
which is dangerous!")
(Config.gitbinfield c);
(Config.git_location c);
c),
Config.with_gitbinfield_opt
(InitConfig.gitbinfield in_config ++ Config.gitbinfield Config.empty);
Config.with_git_location_opt
(InitConfig.git_location in_config ++ Config.git_location Config.empty);
] @ List.map (fun f ->
f, Atomic, Config.with_criteria
(Config.criteria Config.empty))
Expand Down
12 changes: 6 additions & 6 deletions src/core/opamCoreConfig.ml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ type t = {
merged_output: bool;
precise_tracking: bool;
cygbin: string option;
gitbinpath: string option;
git_location: string option;
set: bool;
}

Expand All @@ -84,7 +84,7 @@ type 'a options_fun =
?merged_output:bool ->
?precise_tracking:bool ->
?cygbin:string ->
?gitbinpath:string ->
?git_location:string ->
'a

let default = {
Expand All @@ -106,7 +106,7 @@ let default = {
merged_output = true;
precise_tracking = false;
cygbin = None;
gitbinpath = None;
git_location = None;
set = false;
}

Expand All @@ -126,7 +126,7 @@ let setk k t
?merged_output
?precise_tracking
?cygbin
?gitbinpath
?git_location
=
let (+) x opt = match opt with Some x -> x | None -> x in
k {
Expand All @@ -148,7 +148,7 @@ let setk k t
merged_output = t.merged_output + merged_output;
precise_tracking = t.precise_tracking + precise_tracking;
cygbin = (match cygbin with Some _ -> cygbin | None -> t.cygbin);
gitbinpath = (match gitbinpath with Some _ -> gitbinpath | None -> t.gitbinpath);
git_location = (match git_location with Some _ -> git_location | None -> t.git_location);
set = true;
}

Expand Down Expand Up @@ -190,7 +190,7 @@ let initk k =
?merged_output:(E.mergeout ())
?precise_tracking:(E.precisetracking ())
?cygbin:None
?gitbinpath:None
?git_location:None

let init ?noop:_ = initk (fun () -> ())

Expand Down
4 changes: 2 additions & 2 deletions src/core/opamCoreConfig.mli
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ type t = private {
(** If set, will take full md5 of all files when checking diffs (to track
installations), rather than rely on just file size and mtime *)
cygbin: string option;
gitbinpath: string option;
git_location: string option;
set : bool;
(** Options have not yet been initialised (i.e. defaults are active) *)
}
Expand All @@ -93,7 +93,7 @@ type 'a options_fun =
?merged_output:bool ->
?precise_tracking:bool ->
?cygbin:string ->
?gitbinpath:string ->
?git_location:string ->
'a

val default : t
Expand Down
2 changes: 1 addition & 1 deletion src/core/opamProcess.ml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ let log ?level fmt =
let default_env =
let f () = lazy (
match OpamCoreConfig.(!r.cygbin) with
| Some cygbin -> OpamStd.Env.cyg_env cygbin OpamCoreConfig.(!r.gitbinpath)
| Some cygbin -> OpamStd.Env.cyg_env ~cygbin ~git_location:OpamCoreConfig.(!r.git_location)
| None -> OpamStd.Env.raw_env ()
) in
fun () -> Lazy.force (f ())
Expand Down
12 changes: 6 additions & 6 deletions src/core/opamStd.ml
Original file line number Diff line number Diff line change
Expand Up @@ -837,19 +837,19 @@ module Env = struct
let lazy_env = lazy (to_list (raw_env ())) in
fun () -> Lazy.force lazy_env

let cyg_env cygbin gitbinpath =
let cyg_env ~cygbin ~git_location =
let env = raw_env () in
let f v =
match OpamString.cut_at v '=' with
| Some (path, c) when Name.equal_string path "path" ->
(match gitbinpath with
(match git_location with
| None ->
Printf.sprintf "%s=%s;%s" path cygbin c
| Some gitbinpath ->
if String.equal gitbinpath cygbin then
| Some git_location ->
if String.equal git_location cygbin then
Printf.sprintf "%s=%s;%s" path cygbin c
else
Printf.sprintf "%s=%s;%s;%s" path gitbinpath cygbin c)
Printf.sprintf "%s=%s;%s;%s" path git_location cygbin c)
| _ -> v
in
Array.map f env
Expand Down Expand Up @@ -1209,7 +1209,7 @@ module OpamSys = struct
if Sys.win32 then
let results = Hashtbl.create 17 in
let requires_cygwin cygcheck name =
let env = Env.cyg_env (Filename.dirname cygcheck) None in
let env = Env.cyg_env ~cygbin:(Filename.dirname cygcheck) ~git_location:None in
let cmd = OpamCompat.Filename.quote_command cygcheck [name] in
let ((c, _, _) as process) = Unix.open_process_full cmd env in
let rec check_dll platform =
Expand Down
2 changes: 1 addition & 1 deletion src/core/opamStd.mli
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@ module Env : sig

val list: unit -> (Name.t * string) list
val raw_env: unit -> string Array.t
val cyg_env: string -> string option -> string Array.t
val cyg_env: cygbin:string -> git_location:string option -> string Array.t
end

(** {2 System query and exit handling} *)
Expand Down
30 changes: 15 additions & 15 deletions src/format/opamFile.ml
Original file line number Diff line number Diff line change
Expand Up @@ -865,7 +865,7 @@ module Syntax = struct
start =
start.Lexing.pos_lnum,
start.Lexing.pos_cnum - start.Lexing.pos_bol;
stop = (* XXX here we take current position, where error occurs as end position *)
stop = (* XXX here we take current position, where error occurs as end position *)
curr.Lexing.pos_lnum,
curr.Lexing.pos_cnum - curr.Lexing.pos_bol;
}
Expand Down Expand Up @@ -1407,7 +1407,7 @@ module ConfigSyntax = struct
depext_cannot_install : bool;
depext_bypass: OpamSysPkg.Set.t;
sys_pkg_manager_cmd: filename OpamStd.String.Map.t;
gitbinfield: dirname option;
git_location: dirname option;
swh_fallback: bool;
}

Expand Down Expand Up @@ -1452,7 +1452,7 @@ module ConfigSyntax = struct
let depext_bypass t = t.depext_bypass

let sys_pkg_manager_cmd t = t.sys_pkg_manager_cmd
let gitbinfield t = t.gitbinfield
let git_location t = t.git_location

let swh_fallback t = t.swh_fallback

Expand Down Expand Up @@ -1505,8 +1505,8 @@ module ConfigSyntax = struct
let with_sys_pkg_manager_cmd sys_pkg_manager_cmd t =
{ t with sys_pkg_manager_cmd }
let with_swh_fallback swh_fallback t = { t with swh_fallback }
let with_gitbinfield gitbinfield t = { t with gitbinfield = Some gitbinfield }
let with_gitbinfield_opt gitbinfield t = { t with gitbinfield }
let with_git_location git_location t = { t with git_location = Some git_location }
let with_git_location_opt git_location t = { t with git_location }

let empty = {
opam_version = file_format_version;
Expand All @@ -1532,7 +1532,7 @@ module ConfigSyntax = struct
depext_cannot_install = false;
depext_bypass = OpamSysPkg.Set.empty;
sys_pkg_manager_cmd = OpamStd.String.Map.empty;
gitbinfield = None;
git_location = None;
swh_fallback = true;
}

Expand Down Expand Up @@ -1637,8 +1637,8 @@ module ConfigSyntax = struct
Pp.V.string
(Pp.V.string -| Pp.of_module "filename" (module OpamFilename))))
-| Pp.of_pair "Distribution Map" OpamStd.String.Map.(of_list, bindings));
"gitbinfield", Pp.ppacc_opt
with_gitbinfield gitbinfield
"git-location", Pp.ppacc_opt
with_git_location git_location
(Pp.V.string -| Pp.of_module "dirname" (module OpamFilename.Dir));
"swh-fallback", Pp.ppacc
with_swh_fallback swh_fallback
Expand Down Expand Up @@ -1715,7 +1715,7 @@ module InitConfigSyntax = struct
recommended_tools : (string list * string option * filter option) list;
required_tools : (string list * string option * filter option) list;
init_scripts : ((string * string) * filter option) list;
gitbinfield: dirname option;
git_location: dirname option;
}

let opam_version t = t.opam_version
Expand All @@ -1736,7 +1736,7 @@ module InitConfigSyntax = struct
let init_scripts t = t.init_scripts
let criterion kind t =
OpamStd.(List.assoc_opt Compare.equal kind t.solver_criteria)
let gitbinfield t = t.gitbinfield
let git_location t = t.git_location

let with_opam_version opam_version t = {t with opam_version}
let with_repositories repositories t = {t with repositories}
Expand All @@ -1760,7 +1760,7 @@ module InitConfigSyntax = struct
kind t.solver_criteria)
in
{ t with solver_criteria }
let with_gitbinfield gitbinfield t = { t with gitbinfield = Some gitbinfield }
let with_git_location git_location t = { t with git_location = Some git_location }

let empty = {
opam_version = format_version;
Expand All @@ -1779,7 +1779,7 @@ module InitConfigSyntax = struct
recommended_tools = [];
required_tools = [];
init_scripts = [];
gitbinfield = None;
git_location = None;
}

let pp_repository_def =
Expand Down Expand Up @@ -1879,8 +1879,8 @@ module InitConfigSyntax = struct
(Pp.V.string)
(Pp.V.string_tr))
(Pp.opt Pp.V.filter)));
"gitbinfield", Pp.ppacc_opt
with_gitbinfield gitbinfield
"git-location", Pp.ppacc_opt
with_git_location git_location
(Pp.V.string -| Pp.of_module "dirname" (module OpamFilename.Dir));
] @
List.map
Expand Down Expand Up @@ -1927,7 +1927,7 @@ module InitConfigSyntax = struct
recommended_tools = list t2.recommended_tools t1.recommended_tools;
required_tools = list t2.required_tools t1.required_tools;
init_scripts = list t2.init_scripts t1.init_scripts;
gitbinfield = opt t2.gitbinfield t1.gitbinfield;
git_location = opt t2.git_location t1.git_location;
}

end
Expand Down
8 changes: 4 additions & 4 deletions src/format/opamFile.mli
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,8 @@ module Config: sig
val with_sys_pkg_manager_cmd: filename OpamStd.String.Map.t -> t -> t

val with_swh_fallback: bool -> t -> t
val with_gitbinfield: dirname -> t -> t
val with_gitbinfield_opt: dirname option -> t -> t
val with_git_location: dirname -> t -> t
val with_git_location_opt: dirname option -> t -> t

(** Return the opam version *)
val opam_version: t -> opam_version
Expand Down Expand Up @@ -235,7 +235,7 @@ module Config: sig
sources *)
val swh_fallback: t -> bool

val gitbinfield: t -> dirname option
val git_location: t -> dirname option

val fields: (string * (t, value) OpamPp.field_parser) list

Expand Down Expand Up @@ -269,7 +269,7 @@ module InitConfig: sig
val recommended_tools: t -> (string list * string option * filter option) list
val required_tools: t -> (string list * string option * filter option) list
val init_scripts: t -> ((string * string) * filter option) list
val gitbinfield: t -> dirname option
val git_location: t -> dirname option

val with_opam_version: opam_version -> t -> t
val with_repositories:
Expand Down
8 changes: 4 additions & 4 deletions tests/reftests/var-option.test
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ depext-cannot-install false
depext-run-installs true
download-command {}
download-jobs 3
gitbinfield {}
git-location {}
jobs {}
post-build-commands {}
post-install-commands {}
Expand Down Expand Up @@ -526,7 +526,7 @@ Removed variable dolore in global configuration
# Return code 2 #
### opam option bar=sit --global
[ERROR] There is no option named 'bar'. The allowed options are:
jobs download-command download-jobs archive-mirrors solver-criteria solver-upgrade-criteria solver-fixup-criteria best-effort-prefix-criteria solver global-variables eval-variables repository-validation-command depext depext-run-installs depext-cannot-install depext-bypass sys-pkg-manager-cmd gitbinfield swh-fallback pre-build-commands pre-install-commands pre-remove-commands pre-session-commands wrap-build-commands wrap-install-commands wrap-remove-commands post-build-commands post-install-commands post-remove-commands post-session-commands
jobs download-command download-jobs archive-mirrors solver-criteria solver-upgrade-criteria solver-fixup-criteria best-effort-prefix-criteria solver global-variables eval-variables repository-validation-command depext depext-run-installs depext-cannot-install depext-bypass sys-pkg-manager-cmd git-location swh-fallback pre-build-commands pre-install-commands pre-remove-commands pre-session-commands wrap-build-commands wrap-install-commands wrap-remove-commands post-build-commands post-install-commands post-remove-commands post-session-commands
# Return code 2 #
### opam option bar=sit --switch var-option
[ERROR] There is no option named 'bar'. The allowed options are:
Expand Down Expand Up @@ -612,7 +612,7 @@ depext-cannot-install false
depext-run-installs true
download-command {}
download-jobs 1
gitbinfield {}
git-location {}
jobs {}
post-build-commands {}
post-install-commands {}
Expand Down Expand Up @@ -644,7 +644,7 @@ depext-cannot-install false
depext-run-installs true
download-command {}
download-jobs 1
gitbinfield {}
git-location {}
jobs {}
post-build-commands {}
post-install-commands {}
Expand Down

0 comments on commit 64c4d6c

Please sign in to comment.