Skip to content

Commit

Permalink
Rename gitbin* to git-location for consistency and readability
Browse files Browse the repository at this point in the history
  • Loading branch information
kit-ty-kate committed Jan 11, 2024
1 parent ce6a775 commit 10fe1a4
Show file tree
Hide file tree
Showing 15 changed files with 97 additions and 97 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
68 changes: 34 additions & 34 deletions src/client/opamClient.ml
Original file line number Diff line number Diff line change
Expand Up @@ -636,8 +636,8 @@ let init_checks ?(hard_fail_exn=true) init_config =
else not (soft_fail || hard_fail)

let git_for_windows_check =
if not Sys.win32 && not Sys.cygwin then fun ?gitbin:_ () -> None else
fun ?gitbin () ->
if not Sys.win32 && not Sys.cygwin then fun ?git_location:_ () -> None else
fun ?git_location () ->
let header () = OpamConsole.header_msg "Git" in
let contains_git p =
OpamSystem.resolve_command ~env:[||] (Filename.concat p "git.exe")
Expand All @@ -651,33 +651,33 @@ let git_for_windows_check =
Some (git, OpamSystem.bin_contains_bash p)
| None -> None)
in
let get_gitbin ?gitbin () =
let get_git_location ?git_location () =
let bin =
match gitbin with
| Some _ -> gitbin
match git_location with
| Some _ -> git_location
| 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
| Some gitbin ->
match contains_git gitbin, OpamSystem.bin_contains_bash gitbin with
| Some git_location ->
match contains_git git_location, OpamSystem.bin_contains_bash git_location with
| Some _, false ->
OpamConsole.msg "Using Git from %s" gitbin;
Some gitbin
OpamConsole.msg "Using Git from %s" git_location;
Some git_location
| Some _, true ->
OpamConsole.error
"A bash executable was found in %s, which will override \
Cygwin's bash. Please check your binary path."
gitbin;
git_location;
None
| None, _ ->
OpamConsole.error "No Git executable found in %s." gitbin;
OpamConsole.error "No Git executable found in %s." git_location;
None
in
let rec loop ?gitbin () =
match get_gitbin ?gitbin () with
| Some _ as gitbin -> gitbin
let rec loop ?git_location () =
match get_git_location ?git_location () with
| Some _ as git_location -> git_location
| None -> menu ()
and menu () =
let prompt () =
Expand All @@ -699,17 +699,17 @@ let git_for_windows_check =
match prompt () with
| `Default -> None
| `Specify -> loop ()
| `Location gitbin -> loop ~gitbin ()
| `Location git_location -> loop ~git_location ()
| `Abort ->
OpamConsole.note "Once your choosen Git installed, open a new PowerShell or Command Prompt window, and relaunch opam init.";
OpamStd.Sys.exit_because `Aborted
in
let gitbin =
match gitbin with
let git_location =
match git_location with
| Some (Right ()) -> None
| Some (Left gitbin) ->
| Some (Left git_location) ->
header ();
get_gitbin ~gitbin:(OpamFilename.Dir.to_string gitbin) ()
get_git_location ~git_location:(OpamFilename.Dir.to_string git_location) ()
| None ->
if OpamStd.Sys.tty_out then
(header ();
Expand All @@ -726,24 +726,24 @@ let git_for_windows_check =
OpamStd.Option.iter (fun _ ->
OpamConsole.msg
"You can change that later with \
'opam option \"gitbinfield=C:\\A\\Path\\bin\"'")
gitbin;
gitbin
'opam option \"git-location=C:\\A\\Path\\bin\"'")
git_location;
git_location

let windows_checks ?cygwin_setup ?gitbin config =
let windows_checks ?cygwin_setup ?git_location config =
let vars = OpamFile.Config.global_variables config in
let env =
List.map (fun (v, c, s) -> v, (lazy (Some c), s)) vars
|> 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 ?git_location () in
OpamCoreConfig.update ?git_location ();
let config =
match gitbinpath with
| Some gitbin ->
OpamFile.Config.with_gitbinfield
(OpamFilename.Dir.of_string gitbin) config
match git_location with
| Some git_location ->
OpamFile.Config.with_git_location
(OpamFilename.Dir.of_string git_location) config
| None -> config
in
(* Cygwin handling *)
Expand Down Expand Up @@ -1011,11 +1011,11 @@ let update_with_init_config ?(overwrite=false) config init_config =
let reinit ?(init_config=OpamInitDefaults.init_config()) ~interactive
?dot_profile ?update_config ?env_hook ?completion ?inplace
?(check_sandbox=true) ?(bypass_checks=false)
?cygwin_setup ?gitbin
?cygwin_setup ?git_location
config shell =
let root = OpamStateConfig.(!r.root_dir) in
let config = update_with_init_config config init_config in
let config = windows_checks ?cygwin_setup ?gitbin config in
let config = windows_checks ?cygwin_setup ?git_location config in
let _all_ok =
if bypass_checks then false else
init_checks ~hard_fail_exn:false init_config
Expand Down Expand Up @@ -1056,7 +1056,7 @@ let init
?repo ?(bypass_checks=false)
?dot_profile ?update_config ?env_hook ?(completion=true)
?(check_sandbox=true)
?cygwin_setup ?gitbin
?cygwin_setup ?git_location
shell =
log "INIT %a"
(slog @@ OpamStd.Option.to_string OpamRepositoryBackend.to_string) repo;
Expand Down Expand Up @@ -1092,7 +1092,7 @@ let init
init_config |>
OpamFile.Config.with_repositories (List.map fst repos)
in
let config = windows_checks ?cygwin_setup ?gitbin config in
let config = windows_checks ?cygwin_setup ?git_location config in

let dontswitch =
if bypass_checks then false else
Expand Down
4 changes: 2 additions & 2 deletions src/client/opamClient.mli
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ val init:
?completion:bool ->
?check_sandbox:bool ->
?cygwin_setup: [ `internal | `default_location | `location of dirname | `no ] ->
?gitbin:(dirname, unit) either ->
?git_location:(dirname, unit) either ->
shell ->
rw global_state * unlocked repos_state * atom list

Expand All @@ -47,7 +47,7 @@ val reinit:
?update_config:bool -> ?env_hook:bool -> ?completion:bool -> ?inplace:bool ->
?check_sandbox:bool -> ?bypass_checks:bool ->
?cygwin_setup: [ `internal | `default_location | `location of dirname | `no ] ->
?gitbin:(dirname, unit) either ->
?git_location:(dirname, unit) either ->
OpamFile.Config.t -> shell -> unit

(** Install the given list of packages. [add_to_roots], if given, specifies that
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
16 changes: 8 additions & 8 deletions src/client/opamCommands.ml
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ let init cli =
else
Term.const None
in
let gitbin =
let git_location =
if Sys.win32 then
mk_opt ~cli (cli_from ~experimental:true cli2_2)
["git-location"] "DIR"
Expand All @@ -337,7 +337,7 @@ let init cli =
else
Term.const None
in
let nogitbin =
let no_git_location =
if Sys.win32 then
mk_flag ~cli (cli_from ~experimental:true cli2_2)
["no-git-location"]
Expand All @@ -351,7 +351,7 @@ let init cli =
interactive update_config completion env_hook no_sandboxing shell
dot_profile_o compiler no_compiler config_file no_config_file reinit
show_opamrc bypass_checks
cygwin_internal cygwin_location gitbin nogitbin
cygwin_internal cygwin_location git_location no_git_location
() =
apply_global_options cli global_options;
apply_build_options cli build_options;
Expand Down Expand Up @@ -420,8 +420,8 @@ let init cli =
| (`default_location | `none), Some dir -> Some (`location dir)
| (`internal | `default_location | `no) as setup, None -> Some setup
in
let gitbin =
match gitbin, nogitbin with
let git_location =
match git_location, no_git_location with
| Some _, true ->
OpamConsole.error_and_exit `Bad_arguments
"Options --no-git-location and --git-location are incompatible";
Expand All @@ -438,7 +438,7 @@ let init cli =
let reinit conf =
OpamClient.reinit ~init_config ~interactive ?dot_profile
?update_config ?env_hook ?completion ~inplace ~bypass_checks
~check_sandbox:(not no_sandboxing) ?cygwin_setup ?gitbin
~check_sandbox:(not no_sandboxing) ?cygwin_setup ?git_location
conf shell
in
let config =
Expand Down Expand Up @@ -478,7 +478,7 @@ let init cli =
?repo ~bypass_checks ?dot_profile
?update_config ?env_hook ?completion
~check_sandbox:(not no_sandboxing)
?cygwin_setup ?gitbin
?cygwin_setup ?git_location
shell
in
OpamStd.Exn.finally (fun () -> OpamRepositoryState.drop rt)
Expand Down Expand Up @@ -527,7 +527,7 @@ let init cli =
$setup_completion $env_hook $no_sandboxing $shell_opt cli
cli_original $dot_profile_flag cli cli_original $compiler
$no_compiler $config_file $no_config_file $reinit $show_default_opamrc
$bypass_checks $cygwin_internal $cygwin_location $gitbin $nogitbin)
$bypass_checks $cygwin_internal $cygwin_location $git_location $no_git_location)

(* LIST *)
let list_doc = "Display the list of available packages."
Expand Down
12 changes: 6 additions & 6 deletions src/client/opamConfigCommand.ml
Original file line number Diff line number Diff line change
Expand Up @@ -855,18 +855,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 ->
OpamStd.Option.iter (fun git_location ->
if OpamSystem.bin_contains_bash
(OpamFilename.Dir.to_string gitbin) then
(OpamFilename.Dir.to_string git_location) 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
Loading

0 comments on commit 10fe1a4

Please sign in to comment.