Skip to content

Commit 7182295

Browse files
committed
Update to 1.4.4
1 parent 9f71d2e commit 7182295

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+471
-156
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
Details
44
-------
55

6-
Delphi / Free Pascal bindings for [libgit2](http://libgit2.github.com/) v1.3(.2).
6+
Delphi / Free Pascal bindings for [libgit2](http://libgit2.github.com/) v1.4(.4).
77

88
Since I could not find anything very up to date in the Delphi/Pascal world for recent libgit2 versions I decided to do something myself with assistance from [CHelper](https://wiki.freepascal.org/Chelper).
99

10-
No packages at this time, just add the LibGit2.pas file to a project and ensure that the git2/\*.inc files are available and Windows builds of the git2.dll is avaiable below (built with Visual Studio 2019).
10+
No packages at this time, just add the LibGit2.pas file to a project and ensure that the git2/\*.inc files are available and Windows builds of the git2.dll is avaiable below (built with Visual Studio 2022).
1111

1212
So far we are only using it on the Windows 32-bit platform so no idea how it will work on other platforms, but any fixes and/or improvements would be welcome.
1313

src/git2/apply.inc

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
*
1818
* @param delta The delta to be applied
1919
* @param payload User-specified payload
20+
* @return 0 if the delta is applied, < 0 if the apply process will be aborted
21+
* or > 0 if the delta will not be applied.
2022
*)
2123

2224
type
@@ -33,6 +35,8 @@ type
3335
*
3436
* @param hunk The hunk to be applied
3537
* @param payload User-specified payload
38+
* @return 0 if the hunk is applied, < 0 if the apply process will be aborted
39+
* or > 0 if the hunk will not be applied.
3640
*)
3741

3842
type
@@ -75,6 +79,17 @@ const
7579
GIT_APPLY_OPTIONS_VERSION = 1;
7680
//GIT_APPLY_OPTIONS_INIT = { GIT_APPLY_OPTIONS_VERSION };
7781

82+
(**
83+
* Initialize git_apply_options structure
84+
*
85+
* Initialize a `git_apply_options` with default values. Equivalent to creating
86+
* an instance with GIT_APPLY_OPTIONS_INIT.
87+
*
88+
* @param opts The `git_apply_options` struct to initialize.
89+
* @param version The struct version; pass `GIT_APPLY_OPTIONS_VERSION`
90+
* @return 0 on success or -1 on failure.
91+
*)
92+
7893
function git_apply_options_init(opts: Pgit_apply_options; version: Cardinal)
7994
: Integer; cdecl; external libgit2_dll;
8095

src/git2/attr.inc

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@ const
173173
* not have to exist, but if it does not, then it will be
174174
* treated as a plain file (not a directory).
175175
* @param name The name of the attribute to look up.
176+
* @return 0 or an error code.
176177
*)
177178

178179
function git_attr_get(value_out: PPAnsiChar; repo: Pgit_repository; flags: uint32_t; path,
@@ -192,6 +193,7 @@ function git_attr_get(value_out: PPAnsiChar; repo: Pgit_repository; flags: uint3
192193
* not have to exist, but if it does not, then it will be
193194
* treated as a plain file (not a directory).
194195
* @param name The name of the attribute to look up.
196+
* @return 0 or an error code.
195197
*)
196198

197199
function git_attr_get_ext(value_out: PPAnsiChar; repo: Pgit_repository; opts: Pgit_attr_options;
@@ -225,6 +227,7 @@ function git_attr_get_ext(value_out: PPAnsiChar; repo: Pgit_repository; opts: Pg
225227
* it will be treated as a plain file (i.e. not a directory).
226228
* @param num_attr The number of attributes being looked up
227229
* @param names An array of num_attr strings containing attribute names.
230+
* @return 0 or an error code.
228231
*)
229232

230233
function git_attr_get_many(values_out: PPAnsiChar; repo: Pgit_repository; flags: uint32_t; path: PAnsiChar;
@@ -245,6 +248,7 @@ function git_attr_get_many(values_out: PPAnsiChar; repo: Pgit_repository; flags:
245248
* it will be treated as a plain file (i.e. not a directory).
246249
* @param num_attr The number of attributes being looked up
247250
* @param names An array of num_attr strings containing attribute names.
251+
* @return 0 or an error code.
248252
*)
249253

250254
function git_attr_get_many_ext(values_out: PPAnsiChar; repo: Pgit_repository; opts: Pgit_attr_options; path: PAnsiChar; num_attr:
@@ -322,11 +326,16 @@ function git_attr_cache_flush(repo: Pgit_repository): Integer; cdecl; external l
322326
* Add a macro definition.
323327
*
324328
* Macros will automatically be loaded from the top level `.gitattributes`
325-
* file of the repository (plus the build-in "binary" macro). This
329+
* file of the repository (plus the built-in "binary" macro). This
326330
* function allows you to add others. For example, to add the default
327331
* macro, you would call:
328332
*
329333
* git_attr_add_macro(repo, "binary", "-diff -crlf");
334+
*
335+
* @param repo The repository to add the macro in.
336+
* @param name The name of the macro.
337+
* @param values The value for the macro.
338+
* @return 0 or an error code.
330339
*)
331340

332341
function git_attr_add_macro(repo: Pgit_repository; name_, values: PAnsiChar): Integer; cdecl; external libgit2_dll;

src/git2/blame.inc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,9 @@ type
175175

176176
(**
177177
* Gets the number of hunks that exist in the blame structure.
178+
*
179+
* @param blame The blame structure to query.
180+
* @return The number of hunks.
178181
*)
179182

180183
type

src/git2/blob.inc

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,12 +279,26 @@ function git_blob_create_from_buffer(id: Pgit_oid; repo: Pgit_repository; buffer
279279

280280
function git_blob_is_binary(blob: Pgit_blob): Integer; cdecl; external libgit2_dll;
281281

282+
(**
283+
* Determine if the given content is most certainly binary or not;
284+
* this is the same mechanism used by `git_blob_is_binary` but only
285+
* looking at raw data.
286+
*
287+
* @param data The blob data which content should be analyzed
288+
* @param len The length of the data
289+
* @return 1 if the content of the blob is detected
290+
* as binary; 0 otherwise.
291+
*)
292+
293+
function git_blob_data_is_binary(data: Pointer; len: size_t): Integer; cdecl; external libgit2_dll;
294+
282295
(**
283296
* Create an in-memory copy of a blob. The copy must be explicitly
284297
* free'd or it will leak.
285298
*
286299
* @param out Pointer to store the copy of the object
287300
* @param source Original object to copy
301+
* @return 0.
288302
*)
289303

290304
function git_blob_dup(out_: PPgit_blob; source: Pgit_blob): Integer; cdecl; external libgit2_dll;

src/git2/branch.inc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
*
2121
* @param out Pointer where to store the underlying reference.
2222
*
23+
* @param repo the repository to create the branch in.
24+
*
2325
* @param branch_name Name for the branch; this name is
2426
* validated for consistency. It should also not conflict with
2527
* an already existing branch name.

src/git2/buffer.inc

Lines changed: 18 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -3,116 +3,53 @@
33
*
44
* Sometimes libgit2 wants to return an allocated data buffer to the
55
* caller and have the caller take responsibility for freeing that memory.
6-
* This can be awkward if the caller does not have easy access to the same
7-
* allocation functions that libgit2 is using. In those cases, libgit2
8-
* will fill in a `git_buf` and the caller can use `git_buf_dispose()` to
9-
* release it when they are done.
6+
* To make ownership clear in these cases, libgit2 uses `git_buf` to
7+
* return this data. Callers should use `git_buf_dispose()` to release
8+
* the memory when they are done.
109
*
11-
* A `git_buf` may also be used for the caller to pass in a reference to
12-
* a block of memory they hold. In this case, libgit2 will not resize or
13-
* free the memory, but will read from it as needed.
14-
*
15-
* Some APIs may occasionally do something slightly unusual with a buffer,
16-
* such as setting `ptr` to a value that was passed in by the user. In
17-
* those cases, the behavior will be clearly documented by the API.
10+
* A `git_buf` contains a pointer to a NUL-terminated C string, and
11+
* the length of the string (not including the NUL terminator).
1812
*)
1913

2014
type
2115
git_buf = record
2216
(**
23-
* The buffer contents.
24-
*
25-
* `ptr` points to the start of the allocated memory. If it is NULL,
26-
* then the `git_buf` is considered empty and libgit2 will feel free
27-
* to overwrite it with new data.
17+
* The buffer contents. `ptr` points to the start of the buffer
18+
* being returned. The buffer's length (in bytes) is specified
19+
* by the `size` member of the structure, and contains a NUL
20+
* terminator at position `(size + 1)`.
2821
*)
2922
ptr: PAnsiChar;
3023
(**
31-
* `asize` holds the known total amount of allocated memory if the `ptr`
32-
* was allocated by libgit2. It may be larger than `size`. If `ptr`
33-
* was not allocated by libgit2 and should not be resized and/or freed,
34-
* then `asize` will be set to zero.
24+
* This field is reserved and unused.
3525
*)
36-
asize: size_t;
26+
reserved: size_t;
3727
(**
38-
* `size` holds the size (in bytes) of the data that is actually used.
28+
* The length (in bytes) of the buffer pointed to by `ptr`,
29+
* not including a NUL terminator.
3930
*)
4031
size: size_t;
4132
end;
4233

4334
(**
44-
* Static initializer for git_buf from static buffer
35+
* Use to initialize a `git_buf` before passing it to a function that
36+
* will populate it.
4537
*)
4638

47-
//#define GIT_BUF_INIT_CONST(STR,LEN) { (char *)(STR), 0, (size_t)(LEN) }
39+
//#define GIT_BUF_INIT { NULL, 0, 0 }
4840

4941
(**
5042
* Free the memory referred to by the git_buf.
5143
*
5244
* Note that this does not free the `git_buf` itself, just the memory
53-
* pointed to by `buffer->ptr`. This will not free the memory if it looks
54-
* like it was not allocated internally, but it will clear the buffer back
55-
* to the empty state.
45+
* pointed to by `buffer->ptr`.
5646
*
5747
* @param buffer The buffer to deallocate
5848
*)
5949

6050
type
6151
Pgit_buf = ^git_buf;
62-
procedure git_buf_dispose(buffer: Pgit_buf); cdecl; external libgit2_dll;
63-
64-
(**
65-
* Resize the buffer allocation to make more space.
66-
*
67-
* This will attempt to grow the buffer to accommodate the target size.
68-
*
69-
* If the buffer refers to memory that was not allocated by libgit2 (i.e.
70-
* the `asize` field is zero), then `ptr` will be replaced with a newly
71-
* allocated block of data. Be careful so that memory allocated by the
72-
* caller is not lost. As a special variant, if you pass `target_size` as
73-
* 0 and the memory is not allocated by libgit2, this will allocate a new
74-
* buffer of size `size` and copy the external data into it.
75-
*
76-
* Currently, this will never shrink a buffer, only expand it.
77-
*
78-
* If the allocation fails, this will return an error and the buffer will be
79-
* marked as invalid for future operations, invaliding the contents.
80-
*
81-
* @param buffer The buffer to be resized; may or may not be allocated yet
82-
* @param target_size The desired available size
83-
* @return 0 on success, -1 on allocation failure
84-
*)
85-
86-
function git_buf_grow(buffer: Pgit_buf; target_size: size_t): Integer; cdecl; external libgit2_dll;
87-
88-
(**
89-
* Set buffer to a copy of some raw data.
90-
*
91-
* @param buffer The buffer to set
92-
* @param data The data to copy into the buffer
93-
* @param datalen The length of the data to copy into the buffer
94-
* @return 0 on success, -1 on allocation failure
95-
*)
96-
97-
function git_buf_set(buffer: Pgit_buf; data: Pointer; datalen: size_t): Integer; cdecl; external libgit2_dll;
98-
99-
(**
100-
* Check quickly if buffer looks like it contains binary data
101-
*
102-
* @param buf Buffer to check
103-
* @return 1 if buffer looks like non-text data
104-
*)
105-
106-
function git_buf_is_binary(buf: Pgit_buf): Integer; cdecl; external libgit2_dll;
107-
108-
(**
109-
* Check quickly if buffer contains a NUL byte
110-
*
111-
* @param buf Buffer to check
112-
* @return 1 if buffer contains a NUL byte
113-
*)
114-
115-
function git_buf_contains_nul(buf: Pgit_buf): Integer; cdecl; external libgit2_dll;
11652

53+
procedure git_buf_dispose(buffer: Pgit_buf); cdecl; external libgit2_dll;
11754

11855

src/git2/checkout.inc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,14 @@ const
145145
GIT_CHECKOUT_DONT_REMOVE_EXISTING = (1 shl 22);
146146
(** Normally checkout writes the index upon completion; this prevents that. *)
147147
GIT_CHECKOUT_DONT_WRITE_INDEX = (1 shl 23);
148+
(**
149+
* Show what would be done by a checkout. Stop after sending
150+
* notifications; don't update the working directory or index.
151+
*)
152+
GIT_CHECKOUT_DRY_RUN = (1 shl 24);
153+
(** Include common ancestor data in zdiff3 format for conflicts *)
154+
GIT_CHECKOUT_CONFLICT_STYLE_ZDIFF3 = (1 shl 25);
155+
148156
(**
149157
* THE FOLLOWING OPTIONS ARE NOT YET IMPLEMENTED
150158
*)

src/git2/clone.inc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ type
5555
payload: Pointer): Integer; cdecl;
5656

5757
(**
58-
* The signature of a function matchin git_repository_init, with an
59-
* aditional void * as callback payload.
58+
* The signature of a function matching git_repository_init, with an
59+
* additional void * as callback payload.
6060
*
6161
* Callers of git_clone my provide a function matching this signature
6262
* to override the repository creation and customization process

src/git2/commit.inc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -457,6 +457,7 @@ function git_commit_create_buffer(out_: Pgit_buf; repo: Pgit_repository;
457457
* to the commit and write it into the given repository.
458458
*
459459
* @param out the resulting commit id
460+
* @param repo the repository to create the commit in.
460461
* @param commit_content the content of the unsigned commit object
461462
* @param signature the signature to add to the commit. Leave `NULL`
462463
* to create a commit without adding a signature field.
@@ -474,6 +475,7 @@ function git_commit_create_with_signature(out_: Pgit_oid; repo: Pgit_repository;
474475
*
475476
* @param out Pointer to store the copy of the commit
476477
* @param source Original commit to copy
478+
* @return 0
477479
*)
478480

479481
function git_commit_dup(out_: PPgit_commit; source: Pgit_commit): Integer; cdecl; external libgit2_dll;

0 commit comments

Comments
 (0)