1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283(*
* Copyright (c) 2013-2017 Thomas Gazagnaire <thomas@gazagnaire.org>
* and Romain Calascibetta <romain.calascibetta@gmail.com>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*)letsrc=Logs.Src.create"git.blob"~doc:"logs git's blob event"moduleLog=(valLogs.src_logsrc:Logs.LOG)typet=Cstruct.texternalof_cstruct:Cstruct.t->t="%identity"externalto_cstruct:t->Cstruct.t="%identity"letof_stringx:t=Cstruct.of_stringxletto_string(x:t)=Cstruct.to_stringxletlength:t->int64=funt->Int64.of_int(Cstruct.lengtht)letppppfblob=Fmt.stringppf(Cstruct.to_stringblob)letequal=Cstruct.equalletcompare=Cstruct.comparelethash=Hashtbl.hashmoduletypeS=sigtypehashtypenonrect=tincludeS.DIGESTwithtypet:=tandtypehash:=hashincludeS.BASEwithtypet:=tvallength:t->int64valof_cstruct:Cstruct.t->tvalto_cstruct:t->Cstruct.tvalof_string:string->tvalto_string:t->stringendmoduleMake(Hash:S.HASH)=structtypehash=Hash.ttypenonrect=texternalof_cstruct:Cstruct.t->t="%identity"externalto_cstruct:t->Cstruct.t="%identity"letof_stringx:t=Cstruct.of_stringxletto_string(x:t)=Cstruct.to_stringxletlength:t->int64=funt->Int64.of_int(Cstruct.lengtht)letdigestcs=letctx=Hash.init()inlethdr=Fmt.str"blob %Ld\000"(lengthcs)inletctx=Hash.feed_stringctxhdrinletctx=Hash.feed_cstructctxcsinHash.getctxletppppfblob=Fmt.stringppf(Cstruct.to_stringblob)letequal=Cstruct.equalletcompare=Cstruct.comparelethash=Hashtbl.hashmoduleSet=Set.Make(structtypenonrect=tletcompare=compareend)moduleMap=Map.Make(structtypenonrect=tletcompare=compareend)end