Good evening!
I am trying to set up a minimal working example for libgit2-delphi (GitHub - todaysoftware/libgit2-delphi: libgit2 bindings for Delphi/Free Pascal).
As I am relatively new to this aspect of Delphi (Pointers, cdecl; external etc.), I would appreciate some help - thank you!
With the compiled *.dll and source from the release I can call the functions, but I get an error when calling even basic functionality like git_repository_init(...).
I am sure there is something fundamental I am overlooking.
program GetItWorking;
{$APPTYPE CONSOLE}
{$R *.res}
uses
System.SysUtils,
libgit2 in 'libgit2-delphi-main\src\libgit2.pas';
var
statusRepository : integer;
repoPP : PPgit_repository;
gitError : Pgit_error;
const
repoPath : PAnsiChar = 'C:/TEMP/';
begin
try
InitLibgit2; //with this setup in "LibGit2.pas" you can only init a single repository at a time... (Singleton Pattern)
statusRepository := git_repository_init(repoPP, repoPath, 0); //function git_repository_init(out_: PPgit_repository; path: PAnsiChar; is_bare: Cardinal): Integer; cdecl; external libgit2_dll;
if statusRepository <> 0 then begin
gitError := git_error_last(); //message: invalid argument: "out"
end;
//How to look into the repo?
//ToDo
ShutdownLibgit2;
except
on E: Exception do
Writeln(E.ClassName, ': ', E.Message);
end;
//keep console open
readln;
end.
LibGit2_GetItWorking.zip