Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions fuzz/smart.ml
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,11 @@ let () =

Crowbar.add_test ~name:"pkt-line" Crowbar.[ packet >>= bytes_fixed; range 4 ]
@@ fun payload len ->
let str = Fmt.strf "%04x" (String.length payload + 4) ^ payload in
let str = Fmt.str "%04x" (String.length payload + 4) ^ payload in
let res = of_string str in
Crowbar.check_eq ~pp:(Fmt.fmt "%S") ~eq:String.equal ~cmp:String.compare res
payload;
let str = Fmt.strf "%04x" len in
let str = Fmt.str "%04x" len in
let res = of_string str in
Crowbar.check_eq ~pp:(Fmt.fmt "%S") ~eq:String.equal ~cmp:String.compare res
""
Expand Down
2 changes: 1 addition & 1 deletion src/carton-git/carton_git_unix.ml
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ struct
include Carton_git.Make (Carton_lwt.Scheduler) (Lwt) (Store) (Uid)

let idx_major_uid_of_uid root uid =
Fpath.(root / Fmt.strf "pack-%s.idx" (Uid.to_hex uid))
Fpath.(root / Fmt.str "pack-%s.idx" (Uid.to_hex uid))

let uid_of_major_uid path =
let str = Fpath.basename (Fpath.rem_ext path) in
Expand Down
6 changes: 3 additions & 3 deletions src/carton/dec.ml
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ module Fp (Uid : UID) = struct
let is_inflate = function Inflate _ -> true | _ -> false
let src_rem = i_rem
let eoi d = { d with i = Bigstringaf.empty; i_pos = 0; i_len = min_int }
let malformedf fmt = Fmt.kstrf (fun err -> `Malformed err) fmt
let malformedf fmt = Fmt.kstr (fun err -> `Malformed err) fmt

let src d s j l =
if j < 0 || l < 0 || j + l > Bigstringaf.length s then
Expand Down Expand Up @@ -413,7 +413,7 @@ module Fp (Uid : UID) = struct
ctx = Uid.feed d.ctx d.i ~off:d.i_pos ~len;
}
| `Flush z -> go (Zl.Inf.flush z)
| `Malformed err -> `Malformed (Fmt.strf "inflate: %s" err)
| `Malformed err -> `Malformed (Fmt.str "inflate: %s" err)
| `End z ->
let len = i_rem d - Zl.Inf.src_rem z in
let crc = Checkseum.Crc32.digest_bigstring d.i d.i_pos len crc in
Expand Down Expand Up @@ -470,7 +470,7 @@ module Fp (Uid : UID) = struct
first := false );

go (Zl.Inf.flush z)
| `Malformed err -> `Malformed (Fmt.strf "inflate: %s" err)
| `Malformed err -> `Malformed (Fmt.str "inflate: %s" err)
| `End z ->
if !first then (
let len = Bigstringaf.length d.o - Zl.Inf.dst_rem z in
Expand Down
2 changes: 1 addition & 1 deletion src/carton/dec.mli
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ val of_offset_with_path :
| `B -> "tree"
| `C -> "blob"
| `D -> "tag" in
let hdr = Fmt.strf "%s %d\000" kind (len v) int
let hdr = Fmt.str "%s %d\000" kind (len v) int
let ctx = Digest.empty in
feed_string ctx hdr ;
feed_bigstring ctx (Bigstringaf.sub (raw v) 0 (len v)) ;
Expand Down
2 changes: 1 addition & 1 deletion src/carton/h.ml
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ module M = struct
let dst_rem d = bigstring_length d.dst - d.o_pos
let src_len { src_len; _ } = src_len
let dst_len { dst_len; _ } = dst_len
let malformedf fmt = Fmt.kstrf (fun s -> Malformed s) fmt
let malformedf fmt = Fmt.kstr (fun s -> Malformed s) fmt

let t_need d n =
d.t_len <- 0;
Expand Down
4 changes: 2 additions & 2 deletions src/git-index/git_index.ml
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ module Entry = struct
go ctx
in
let len = in_channel_length ic in
let ctx = Hash.feed_string ctx (Fmt.strf "blob %d\000" len) in
let ctx = Hash.feed_string ctx (Fmt.str "blob %d\000" len) in
let hash = go ctx in
close_in ic;
Rresult.R.ok hash
Expand All @@ -168,7 +168,7 @@ module Entry = struct
let ctx = Hash.empty in
let ctx =
Hash.feed_string ctx
(Fmt.strf "blob %d\000%s" (String.length contents) contents)
(Fmt.str "blob %d\000%s" (String.length contents) contents)
in
Rresult.R.ok (Hash.get ctx)

Expand Down
12 changes: 6 additions & 6 deletions src/git-unix/git_unix.ml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ module Fold = struct
| Unix.Unix_error (Unix.EINTR, _, _) -> contents ~dotfiles ~rel dir
| Unix.Unix_error (err, _, _) ->
let err =
Fmt.strf "directory contents %a: %s" Fpath.pp dir
Fmt.str "directory contents %a: %s" Fpath.pp dir
(Unix.error_message err)
in
Log.err (fun m -> m "%s" err);
Expand Down Expand Up @@ -616,10 +616,10 @@ module Make (Digestif : Digestif.S) = struct
{
Git.Store.pck_major_uid_of_uid =
(fun root uid ->
Fpath.(root / Fmt.strf "pack-%s.pack" (Digestif.to_hex uid)));
Fpath.(root / Fmt.str "pack-%s.pack" (Digestif.to_hex uid)));
Git.Store.idx_major_uid_of_uid =
(fun root uid ->
Fpath.(root / Fmt.strf "pack-%s.idx" (Digestif.to_hex uid)));
Fpath.(root / Fmt.str "pack-%s.idx" (Digestif.to_hex uid)));
Git.Store.uid_of_major_uid =
(fun path ->
let str = Fpath.basename (Fpath.rem_ext path) in
Expand Down Expand Up @@ -663,15 +663,15 @@ module Sync (Git_store : Git.S) (HTTP : Smart_git.HTTP) = struct

let random_path pat =
let rand = Random.State.bits (Lazy.force random_gen) land 0xFFFFFF in
Fpath.v (Fmt.strf pat (Fmt.strf "%06x" rand))
Fpath.v (Fmt.str pat (Fmt.str "%06x" rand))

let failwithf fmt = Fmt.kstrf (fun err -> Lwt.fail (Failure err)) fmt
let failwithf fmt = Fmt.kstr (fun err -> Lwt.fail (Failure err)) fmt

let create_tmp_path mode dir pat =
let rec loop count =
if count < 0 then
failwithf "Create a temporary file %s in %a: too many failing attempts"
(Fmt.strf pat "XXXXXX") Fpath.pp dir
(Fmt.str pat "XXXXXX") Fpath.pp dir
else
let file = random_path pat in
let sfile = Fpath.to_string Fpath.(dir // file) in
Expand Down
8 changes: 4 additions & 4 deletions src/git-unix/ogit-fetch/main.ml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ let reporter ppf =
let dt = Mtime.Span.to_us (Mtime_clock.elapsed ()) in
Fmt.kpf k ppf
("%s %a %a: @[" ^^ fmt ^^ "@]@.")
(pad 10 (Fmt.strf "%+04.0fus" dt))
(pad 10 (Fmt.str "%+04.0fus" dt))
pp_header (level, h)
Fmt.(styled `Magenta string)
(pad 10 @@ Logs.Src.name src)
Expand Down Expand Up @@ -69,7 +69,7 @@ let ssh_cfg edn ssh_seed =
let key = Awa.Keys.of_seed ssh_seed in
match edn with
| { Smart_git.scheme = `SSH user; path; _ } ->
let req = Awa.Ssh.Exec (Fmt.strf "git-upload-pack '%s'" path) in
let req = Awa.Ssh.Exec (Fmt.str "git-upload-pack '%s'" path) in
Some { Awa_conduit.user; key; req; authenticator = None }
| _ -> None

Expand Down Expand Up @@ -116,7 +116,7 @@ module Flag = struct
match str with
| "stdout" -> Ok Fmt.stdout
| "stderr" -> Ok Fmt.stderr
| s -> Error (`Msg (Fmt.strf "%s is not an output." s))
| s -> Error (`Msg (Fmt.str "%s is not an output." s))
in
let print ppf v =
Fmt.pf ppf "%s" (if v == Fmt.stdout then "stdout" else "stderr")
Expand Down Expand Up @@ -182,7 +182,7 @@ let setup_log =
let main _ ssh_seed references directory repository _ =
match Lwt_main.run (main ssh_seed references directory repository) with
| Ok () -> `Ok ()
| Error (#error as err) -> `Error (false, Fmt.strf "%a" pp_error err)
| Error (#error as err) -> `Error (false, Fmt.str "%a" pp_error err)

let command =
let doc = "Fetch a Git repository by the HTTP protocol." in
Expand Down
2 changes: 1 addition & 1 deletion src/git/blob.ml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ module Make (Hash : S.HASH) = struct

let digest cs =
let ctx = Hash.init () in
let hdr = Fmt.strf "blob %Ld\000" (length cs) in
let hdr = Fmt.str "blob %Ld\000" (length cs) in
let ctx = Hash.feed_string ctx hdr in
let ctx = Hash.feed_cstruct ctx cs in
Hash.get ctx
Expand Down
8 changes: 4 additions & 4 deletions src/git/mem.ml
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ let batch_write :
in
iter index ~f

let failuref fmt = Fmt.kstrf (fun err -> Failure err) fmt
let failuref fmt = Fmt.kstr (fun err -> Failure err) fmt

(* XXX(dinosaure): a point about modules, functors and alias.
* The choice was made to _defunctorize_ any types to avoid to
Expand Down Expand Up @@ -185,7 +185,7 @@ module Make (Digestif : Digestif.S) = struct
let len = Cstruct.len raw in
let ctx = Hash.init () in
let hdr =
Fmt.strf "%s %d\000%!"
Fmt.str "%s %d\000%!"
( match kind with
| `Commit -> "commit"
| `Blob -> "blob"
Expand All @@ -206,7 +206,7 @@ module Make (Digestif : Digestif.S) = struct
lazy
( match Value.of_raw ~kind inflated with
| Error (`Msg err) ->
let str = Fmt.strf "Value.of_raw(%a): %s" Hash.pp hash err in
let str = Fmt.str "Value.of_raw(%a): %s" Hash.pp hash err in
raise (Failure str)
| Ok value -> value )
in
Expand Down Expand Up @@ -242,7 +242,7 @@ module Make (Digestif : Digestif.S) = struct
Hashtbl.add t.values h (lazy v);
Ok v
| Error (`Msg err) ->
let str = Fmt.strf "Value.of_raw(%a): %s" Hash.pp h err in
let str = Fmt.str "Value.of_raw(%a): %s" Hash.pp h err in
raise (Failure str)
with Not_found -> Error (`Not_found h) )

Expand Down
6 changes: 3 additions & 3 deletions src/git/reference.ml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ type t = string (* non empty *)

let dir_sep = "/"
let dir_sep_char = '/'
let error_msgf fmt = Fmt.kstrf (fun err -> Error (`Msg err)) fmt
let error_msgf fmt = Fmt.kstr (fun err -> Error (`Msg err)) fmt

let validate_and_collapse_seps p =
let max_idx = String.length p - 1 in
Expand Down Expand Up @@ -233,8 +233,8 @@ let write { Carton.bind; Carton.return } t store reference contents =

let str =
match contents with
| Uid uid -> Fmt.strf "%s\n" (store.uid_to_hex uid)
| Ref t -> Fmt.strf "ref: %s\n" t
| Uid uid -> Fmt.str "%s\n" (store.uid_to_hex uid)
| Ref t -> Fmt.str "ref: %s\n" t
in
store.atomic_wr t reference str >>| reword_error (fun err -> `Store err)

Expand Down
6 changes: 3 additions & 3 deletions src/git/store.ml
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ struct
read t hash >>= function
| Ok v -> Lwt.return v
| Error _ ->
let err = Fmt.strf "Git.Store.read_exn: %a not found" Hash.pp hash in
let err = Fmt.str "Git.Store.read_exn: %a not found" Hash.pp hash in
Lwt.fail_invalid_arg err

let stream_of_raw ?(chunk = De.io_buffer_size) raw =
Expand Down Expand Up @@ -308,7 +308,7 @@ struct
Loose.atomic_add t.minor buffers v >>= function
| Ok (hash, _) -> Lwt.return hash
| Error (`Store err) ->
Lwt.fail (Failure (Fmt.strf "%a" pp_error (`Minor err)))
Lwt.fail (Failure (Fmt.str "%a" pp_error (`Minor err)))
| Error `Non_atomic -> (
let consumed = Stdlib.ref false in
let stream () =
Expand All @@ -320,7 +320,7 @@ struct
Loose.add t.minor buffers (kind, Int64.of_int len) stream >>= function
| Ok (hash, _) -> Lwt.return hash
| Error (`Store err) ->
Lwt.fail (Failure (Fmt.strf "%a" pp_error (`Minor err))) )
Lwt.fail (Failure (Fmt.str "%a" pp_error (`Minor err))) )

let mem t hash =
if not (Pack.exists t.major t.packs hash) then Loose.exists t.minor hash
Expand Down
8 changes: 4 additions & 4 deletions src/git/stream.ml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ let src =
module Log = (val Logs.src_log src : Logs.LOG)

let hdr = function
| `Blob -> Fmt.strf "blob %Ld\000"
| `Tree -> Fmt.strf "tree %Ld\000"
| `Tag -> Fmt.strf "tag %Ld\000"
| `Commit -> Fmt.strf "commit %Ld\000"
| `Blob -> Fmt.str "blob %Ld\000"
| `Tree -> Fmt.str "tree %Ld\000"
| `Tag -> Fmt.str "tag %Ld\000"
| `Commit -> Fmt.str "commit %Ld\000"

type ('uid, 't) digest = {
empty : 't;
Expand Down
2 changes: 1 addition & 1 deletion src/loose/loose_git_unix.ml
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ module Make (Uid : UID) = struct
(* fold *)

let always x _ = x
let failwithf fmt = Fmt.kstrf Lwt.fail_with fmt
let failwithf fmt = Fmt.kstr Lwt.fail_with fmt

let contents ?(dotfiles = false) ?(rel = false) dir =
let rec readdir dh acc =
Expand Down
8 changes: 4 additions & 4 deletions src/not-so-smart/capability.ml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ let to_string = function
| `Side_band -> "side-band"
| `Side_band_64k -> "side-band-64k"
| `Ofs_delta -> "ofs-delta"
| `Agent agent -> Fmt.strf "agent=%s" agent
| `Agent agent -> Fmt.str "agent=%s" agent
| `Shallow -> "shallow"
| `Deepen_since -> "deepen-since"
| `Deepen_not -> "deepen-not"
Expand All @@ -47,10 +47,10 @@ let to_string = function
| `Push_options -> "push-options"
| `Allow_tip_sha1_in_want -> "allow-tip-sha1-in-want"
| `Allow_reachable_sha1_in_want -> "allow-reachable-sha1-in-want"
| `Push_cert cert -> Fmt.strf "push-cert=%s" cert
| `Symref (ref0, ref1) -> Fmt.strf "symref=%s:%s" ref0 ref1
| `Push_cert cert -> Fmt.str "push-cert=%s" cert
| `Symref (ref0, ref1) -> Fmt.str "symref=%s:%s" ref0 ref1
| `Other capability -> capability
| `Parameter (key, value) -> Fmt.strf "%s=%s" key value
| `Parameter (key, value) -> Fmt.str "%s=%s" key value

exception Capability_expect_value of string

Expand Down
2 changes: 1 addition & 1 deletion src/not-so-smart/decoder.ml
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ let error_end_of_input decoder () = fail decoder `End_of_input
let reliable_pkt k decoder () =
match get_pkt_len decoder with
| Some _len ->
let hdr = Fmt.strf "%04X" (decoder.max - decoder.pos) in
let hdr = Fmt.str "%04X" (decoder.max - decoder.pos) in
Bytes.blit_string hdr 0 decoder.buffer decoder.pos 4;
(* unsafe! *)
k decoder
Expand Down
2 changes: 1 addition & 1 deletion src/not-so-smart/find_common.ml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ let run :
translated as is [fetch-pack.c:find_common] in OCaml. *)

let unsafe_write_have ctx hex =
let packet = Fmt.strf "have %s\n" hex in
let packet = Fmt.str "have %s\n" hex in
Smart.Unsafe.write ctx packet

let next_flush stateless count =
Expand Down
10 changes: 5 additions & 5 deletions src/not-so-smart/protocol.ml
Original file line number Diff line number Diff line change
Expand Up @@ -722,7 +722,7 @@ module Encoder = struct
k0 encoder;
(* XXX(dinosaure): or [encoder.pos <- encoder.pos + 4]? *)
let len = encoder.pos - pos in
Bytes.blit_string (Fmt.strf "%04X" len) 0 encoder.payload pos 4;
Bytes.blit_string (Fmt.str "%04X" len) 0 encoder.payload pos 4;
flush k1 encoder

let kdone _encoder = Done
Expand All @@ -741,17 +741,17 @@ module Encoder = struct
| `Upload_archive -> write encoder "git-upload-archive"
in
let write_version encoder version =
let version = Fmt.strf "version=%d" version in
let version = Fmt.str "version=%d" version in
write encoder version
in
let write_host encoder = function
| host, Some port ->
let host =
Fmt.strf "host=%s:%d" (Conduit.Endpoint.to_string host) port
Fmt.str "host=%s:%d" (Conduit.Endpoint.to_string host) port
in
write encoder host
| host, None ->
let host = Fmt.strf "host=%s" (Conduit.Endpoint.to_string host) in
let host = Fmt.str "host=%s" (Conduit.Endpoint.to_string host) in
write encoder host
in
let k encoder =
Expand Down Expand Up @@ -860,7 +860,7 @@ module Encoder = struct
encoder.pos <- encoder.pos + 4;
Encoder.write encoder packet;
let len = encoder.pos - pos in
Bytes.blit_string (Fmt.strf "%04X" len) 0 encoder.payload pos 4
Bytes.blit_string (Fmt.str "%04X" len) 0 encoder.payload pos 4

let write_command encoder = function
| Commands.Create (uid, r) ->
Expand Down
Loading