diff --git a/Makefile b/Makefile index e0ed2db..f34ee27 100644 --- a/Makefile +++ b/Makefile @@ -3,7 +3,7 @@ PACKAGES := ctypes.foreign,uri CCLIB := libgit2.0.22.0.dylib SRC := git.ml -.PHONY: clean +.PHONY: clean distclean uninstall all:install @@ -12,8 +12,10 @@ native:libgit set_meta -cclib `ocamlfind query ocaml-libgit2`/$(CCLIB) -linkpkg $(SRC) bytecode:libgit set_meta - ocamlfind ocamlc -package $(PACKAGES) \ - -cclib `ocamlfind query ocaml-libgit2`/$(CCLIB) -linkpkg $(SRC) + # ocamlfind ocamlc -package $(PACKAGES) \ + # -cclib `ocamlfind query ocaml-libgit2`/$(CCLIB) -linkpkg $(SRC) + ocamlfind ocamlc -custom -package ctypes.foreign,uri \ + -linkpkg -cclib -L$(shell ocamlfind query ocaml-libgit2) -cclib -lgit2 git.ml libgit: # Not sure why this doesn't work with opam yet. @@ -22,7 +24,7 @@ libgit: ocamlfind install ocaml-libgit2 META # The trick is the ; since cd is done in a separate shell cd `ocamlfind query ocaml-libgit2`; \ - cmake $(ROOT)/libgit2 -DBUILD_CLAR=OFF; \ + cmake $(ROOT)/libgit2 -DBUILD_CLAR=OFF -DCMAKE_MACOSX_RPATH=. ;\ cmake --build .; \ find . -not -name "*.dylib" -not -name "META" -delete @@ -33,6 +35,9 @@ set_meta: install:native bytecode ocamlfind install ocaml-libgit2 -add git.cmo git.cmi git.cmt git.o git.cmx + +distclean:clean uninstall + uninstall: ocamlfind remove ocaml-libgit2 clean: diff --git a/git.ml b/git.ml index 18bd702..f71617c 100644 --- a/git.ml +++ b/git.ml @@ -551,8 +551,8 @@ module Repository = struct let git_repository_open_ext = foreign "git_repository_open_ext" - ((ptr (ptr Types.git_repository)) @-> - string @-> int @-> string @-> returning int) + ((ptr_opt (ptr Types.git_repository)) @-> + string @-> int @-> string_opt @-> returning int) let git_repository_open_bare = foreign @@ -1086,3 +1086,11 @@ let find_repo ~path:p = let result = getf root Buffer.ptr_ in let length = getf root Buffer.size_ |> Unsigned.Size_t.to_int in string_from_ptr result length + +let is_a_repo ~path:p = + try + Repository.git_repository_open_ext None p 0 None |> git_cont; + true + with + Git_Errored _ -> false + diff --git a/libgit2 b/libgit2 index ff8d635..41a71c1 160000 --- a/libgit2 +++ b/libgit2 @@ -1 +1 @@ -Subproject commit ff8d635adbf1208927c7319178d29b0ed973a107 +Subproject commit 41a71c1a5eb891e7af1c7a3226c3c26e1a70b97c