├── .gitignore ├── LICENSE ├── README.md ├── lib └── README.md └── src ├── git2 ├── annotated_commit.inc ├── apply.inc ├── attr.inc ├── blame.inc ├── blob.inc ├── branch.inc ├── buffer.inc ├── cert.inc ├── checkout.inc ├── cherrypick.inc ├── clone.inc ├── commit.inc ├── common.inc ├── config.inc ├── credential.inc ├── credential_helpers.inc ├── describe.inc ├── diff.inc ├── email.inc ├── errors.inc ├── filter.inc ├── global.inc ├── graph.inc ├── ignore.inc ├── index.inc ├── indexer.inc ├── mailmap.inc ├── merge.inc ├── message.inc ├── net.inc ├── notes.inc ├── object.inc ├── odb.inc ├── odb_backend.inc ├── oid.inc ├── oidarray.inc ├── pack.inc ├── patch.inc ├── pathspec.inc ├── proxy.inc ├── rebase.inc ├── refdb.inc ├── reflog.inc ├── refs.inc ├── refspec.inc ├── remote.inc ├── repository.inc ├── reset.inc ├── revert.inc ├── revparse.inc ├── revwalk.inc ├── signature.inc ├── stash.inc ├── status.inc ├── stdint.inc ├── strarray.inc ├── submodule.inc ├── tag.inc ├── trace.inc ├── transaction.inc ├── transport.inc ├── tree.inc ├── types.inc ├── version.inc └── worktree.inc └── libgit2.pas /.gitignore: -------------------------------------------------------------------------------- 1 | # Uncomment these types if you want even more clean repository. But be careful. 2 | # It can make harm to an existing project source. Read explanations below. 3 | # 4 | # Resource files are binaries containing manifest, project icon and version info. 5 | # They can not be viewed as text or compared by diff-tools. Consider replacing them with .rc files. 6 | #*.res 7 | # 8 | # Type library file (binary). In old Delphi versions it should be stored. 9 | # Since Delphi 2009 it is produced from .ridl file and can safely be ignored. 10 | #*.tlb 11 | # 12 | # Diagram Portfolio file. Used by the diagram editor up to Delphi 7. 13 | # Uncomment this if you are not using diagrams or use newer Delphi version. 14 | #*.ddp 15 | # 16 | # Visual LiveBindings file. Added in Delphi XE2. 17 | # Uncomment this if you are not using LiveBindings Designer. 18 | #*.vlb 19 | # 20 | # Deployment Manager configuration file for your project. Added in Delphi XE2. 21 | # Uncomment this if it is not mobile development and you do not use remote debug feature. 22 | #*.deployproj 23 | # 24 | # C++ object files produced when C/C++ Output file generation is configured. 25 | # Uncomment this if you are not using external objects (zlib library for example). 26 | #*.obj 27 | # 28 | 29 | # Delphi compiler-generated binaries (safe to delete) 30 | *.exe 31 | *.dll 32 | *.bpl 33 | *.bpi 34 | *.dcp 35 | *.so 36 | *.apk 37 | *.drc 38 | *.map 39 | *.dres 40 | *.rsm 41 | *.tds 42 | *.dcu 43 | *.lib 44 | *.a 45 | *.o 46 | *.ocx 47 | 48 | # Delphi autogenerated files (duplicated info) 49 | *.cfg 50 | *.hpp 51 | *Resource.rc 52 | 53 | # Delphi local files (user-specific info) 54 | *.local 55 | *.identcache 56 | *.projdata 57 | *.tvsconfig 58 | *.dsk 59 | 60 | # Delphi history and backups 61 | __history/ 62 | __recovery/ 63 | *.~* 64 | 65 | # Castalia statistics file (since XE7 Castalia is distributed with Delphi) 66 | *.stat 67 | 68 | # Boss dependency manager vendor folder https://github.com/HashLoad/boss 69 | modules/ 70 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 todaysoftware 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # libgit2-delphi 2 | 3 | Details 4 | ------- 5 | 6 | Delphi / Free Pascal bindings for [libgit2](https://www.libgit2.org/) v1.9(.1). 7 | 8 | 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). 9 | 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 available below (built with Visual Studio 2022). 11 | 12 | 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. 13 | 14 | Windows Binaries 15 | ---------------- 16 | 17 | Now included as part of the releases. 18 | 19 | License 20 | ------- 21 | 22 | MIT, see the LICENSE file if you've never seen an MIT license before. 23 | 24 | Authors 25 | ------- 26 | 27 | - Mark Jones 28 | -------------------------------------------------------------------------------- /lib/README.md: -------------------------------------------------------------------------------- 1 | Windows Binaries 2 | ---------------- 3 | 4 | Now included as part of the releases 5 | 6 | 7 | The oldest V1.0.1 can be accessed from below: 8 | 9 | [win32](https://1drv.ms/u/s!Asf6C964OtqIgn8mF6vy72j2pEbM?e=gSRuk5) 10 | 11 | [win64](https://1drv.ms/u/s!Asf6C964OtqIgwANFBhPCidIgB1S?e=6bvtOo) 12 | -------------------------------------------------------------------------------- /src/git2/annotated_commit.inc: -------------------------------------------------------------------------------- 1 | (** 2 | * @file git2/annotated_commit.h 3 | * @brief A commit and information about how it was looked up by the user. 4 | * @defgroup git_annotated_commit Git annotated commit routines 5 | * @ingroup Git 6 | * 7 | * An "annotated commit" is a commit that contains information about 8 | * how the commit was resolved, which can be used for maintaining the 9 | * user's "intent" through commands like merge and rebase. For example, 10 | * if a user wants to "merge HEAD" then an annotated commit is used to 11 | * both contain the HEAD commit _and_ the fact that it was resolved as 12 | * the HEAD ref. 13 | * @{ 14 | *) 15 | 16 | (** 17 | * Creates a `git_annotated_commit` from the given reference. 18 | * The resulting git_annotated_commit must be freed with 19 | * `git_annotated_commit_free`. 20 | * 21 | * @param[out] out pointer to store the git_annotated_commit result in 22 | * @param repo repository that contains the given reference 23 | * @param ref reference to use to lookup the git_annotated_commit 24 | * @return 0 on success or error code 25 | *) 26 | 27 | function git_annotated_commit_from_ref(out_: PPgit_annotated_commit; repo: Pgit_repository; 28 | ref: Pgit_reference): Integer; cdecl; external libgit2_dll; 29 | 30 | (** 31 | * Creates a `git_annotated_commit` from the given fetch head data. 32 | * The resulting git_annotated_commit must be freed with 33 | * `git_annotated_commit_free`. 34 | * 35 | * @param[out] out pointer to store the git_annotated_commit result in 36 | * @param repo repository that contains the given commit 37 | * @param branch_name name of the (remote) branch 38 | * @param remote_url url of the remote 39 | * @param id the commit object id of the remote branch 40 | * @return 0 on success or error code 41 | *) 42 | 43 | function git_annotated_commit_from_fetchhead(out_: PPgit_annotated_commit; repo: Pgit_repository; branch_name, remote_url: 44 | PAnsiChar; id: Pgit_oid): Integer; cdecl; external libgit2_dll; 45 | 46 | (** 47 | * Creates a `git_annotated_commit` from the given commit id. 48 | * The resulting git_annotated_commit must be freed with 49 | * `git_annotated_commit_free`. 50 | * 51 | * An annotated commit contains information about how it was 52 | * looked up, which may be useful for functions like merge or 53 | * rebase to provide context to the operation. For example, 54 | * conflict files will include the name of the source or target 55 | * branches being merged. It is therefore preferable to use the 56 | * most specific function (eg `git_annotated_commit_from_ref`) 57 | * instead of this one when that data is known. 58 | * 59 | * @param[out] out pointer to store the git_annotated_commit result in 60 | * @param repo repository that contains the given commit 61 | * @param id the commit object id to lookup 62 | * @return 0 on success or error code 63 | *) 64 | 65 | function git_annotated_commit_lookup(out_: PPgit_annotated_commit; repo: Pgit_repository; 66 | id: Pgit_oid): Integer; cdecl; external libgit2_dll; 67 | 68 | (** 69 | * Creates a `git_annotated_commit` from a revision string. 70 | * 71 | * See `man gitrevisions`, or 72 | * http://git-scm.com/docs/git-rev-parse.html#_specifying_revisions for 73 | * information on the syntax accepted. 74 | * 75 | * @param[out] out pointer to store the git_annotated_commit result in 76 | * @param repo repository that contains the given commit 77 | * @param revspec the extended sha syntax string to use to lookup the commit 78 | * @return 0 on success or error code 79 | *) 80 | 81 | function git_annotated_commit_from_revspec(out_: PPgit_annotated_commit; repo: Pgit_repository; 82 | revspec: PAnsiChar): Integer; cdecl; external libgit2_dll; 83 | 84 | (** 85 | * Gets the commit ID that the given `git_annotated_commit` refers to. 86 | * 87 | * @param commit the given annotated commit 88 | * @return commit id 89 | *) 90 | 91 | function git_annotated_commit_id(commit: Pgit_annotated_commit): Pgit_oid; cdecl; external libgit2_dll; 92 | 93 | (** 94 | * Get the refname that the given `git_annotated_commit` refers to. 95 | * 96 | * @param commit the given annotated commit 97 | * @return ref name. 98 | *) 99 | 100 | function git_annotated_commit_ref(commit: Pgit_annotated_commit): PAnsiChar; cdecl; external libgit2_dll; 101 | 102 | (** 103 | * Frees a `git_annotated_commit`. 104 | * 105 | * @param commit annotated commit to free 106 | *) 107 | 108 | procedure git_annotated_commit_free(commit: Pgit_annotated_commit); cdecl; external libgit2_dll; 109 | 110 | (** @} *) 111 | 112 | 113 | 114 | -------------------------------------------------------------------------------- /src/git2/apply.inc: -------------------------------------------------------------------------------- 1 | (** 2 | * @file git2/apply.h 3 | * @brief Apply patches to the working directory or index 4 | * @defgroup git_apply Git patch application routines 5 | * @ingroup Git 6 | * 7 | * Mechanisms to apply a patch to the index, the working directory, 8 | * or both. 9 | * @{ 10 | *) 11 | 12 | (** 13 | * When applying a patch, callback that will be made per delta (file). 14 | * 15 | * When the callback: 16 | * - returns < 0, the apply process will be aborted. 17 | * - returns > 0, the delta will not be applied, but the apply process 18 | * continues 19 | * - returns 0, the delta is applied, and the apply process continues. 20 | * 21 | * @param delta The delta to be applied 22 | * @param payload User-specified payload 23 | * @return 0 if the delta is applied, < 0 if the apply process will be aborted 24 | * or > 0 if the delta will not be applied. 25 | *) 26 | 27 | type 28 | git_apply_delta_cb = function(delta: Pgit_diff_delta; payload: Pointer): Integer; cdecl; 29 | 30 | (** 31 | * When applying a patch, callback that will be made per hunk. 32 | * 33 | * When the callback: 34 | * - returns < 0, the apply process will be aborted. 35 | * - returns > 0, the hunk will not be applied, but the apply process 36 | * continues 37 | * - returns 0, the hunk is applied, and the apply process continues. 38 | * 39 | * @param hunk The hunk to be applied 40 | * @param payload User-specified payload 41 | * @return 0 if the hunk is applied, < 0 if the apply process will be aborted 42 | * or > 0 if the hunk will not be applied. 43 | *) 44 | 45 | type 46 | git_apply_hunk_cb = function(hunk: Pgit_diff_hunk; payload: Pointer): Integer; cdecl; 47 | 48 | (** 49 | * Flags controlling the behavior of `git_apply`. 50 | * 51 | * When the callback: 52 | * - returns < 0, the apply process will be aborted. 53 | * - returns > 0, the hunk will not be applied, but the apply process 54 | * continues 55 | * - returns 0, the hunk is applied, and the apply process continues. 56 | *) 57 | 58 | const 59 | (** 60 | * Don't actually make changes, just test that the patch applies. 61 | * This is the equivalent of `git apply --check`. 62 | *) 63 | GIT_APPLY_CHECK = (1 shl 0); 64 | type 65 | git_apply_flags_t = Integer; 66 | 67 | (** 68 | * Apply options structure. 69 | * 70 | * When the callback: 71 | * - returns < 0, the apply process will be aborted. 72 | * - returns > 0, the hunk will not be applied, but the apply process 73 | * continues 74 | * - returns 0, the hunk is applied, and the apply process continues. 75 | * 76 | * Initialize with `GIT_APPLY_OPTIONS_INIT`. Alternatively, you can 77 | * use `git_apply_options_init`. 78 | * 79 | * @see git_apply_to_tree 80 | * @see git_apply 81 | *) 82 | 83 | git_apply_options = record 84 | version: Cardinal; (**< The version *) 85 | (** When applying a patch, callback that will be made per delta (file). *) 86 | delta_cb: git_apply_delta_cb; 87 | (** When applying a patch, callback that will be made per hunk. *) 88 | hunk_cb: git_apply_hunk_cb; 89 | (** Payload passed to both `delta_cb` & `hunk_cb`. *) 90 | payload: Pointer; 91 | (** Bitmask of `git_apply_flags_t` *) 92 | flags: Cardinal; 93 | end; 94 | Pgit_apply_options = ^git_apply_options; 95 | 96 | const 97 | (** Current version for the `git_apply_options` structure *) 98 | GIT_APPLY_OPTIONS_VERSION = 1; 99 | (** Static constructor for `git_apply_options` *) 100 | //GIT_APPLY_OPTIONS_INIT = { GIT_APPLY_OPTIONS_VERSION }; 101 | 102 | (** 103 | * Initialize git_apply_options structure 104 | * 105 | * Initialize a `git_apply_options` with default values. Equivalent to creating 106 | * an instance with GIT_APPLY_OPTIONS_INIT. 107 | * 108 | * @param opts The `git_apply_options` struct to initialize. 109 | * @param version The struct version; pass `GIT_APPLY_OPTIONS_VERSION` 110 | * @return 0 on success or -1 on failure. 111 | *) 112 | 113 | function git_apply_options_init(opts: Pgit_apply_options; version: Cardinal) 114 | : Integer; cdecl; external libgit2_dll; 115 | 116 | (** 117 | * Apply a `git_diff` to a `git_tree`, and return the resulting image 118 | * as an index. 119 | * 120 | * @param out the postimage of the application 121 | * @param repo the repository to apply 122 | * @param preimage the tree to apply the diff to 123 | * @param diff the diff to apply 124 | * @param options the options for the apply (or null for defaults) 125 | * @return 0 or an error code 126 | *) 127 | 128 | function git_apply_to_tree(out_: PPgit_index; repo: Pgit_repository; preimage: Pgit_tree; diff: Pgit_diff; options: 129 | Pgit_apply_options): Integer; cdecl; external libgit2_dll; 130 | 131 | (** Possible application locations for git_apply *) 132 | 133 | const 134 | (** 135 | * Apply the patch to the workdir, leaving the index untouched. 136 | * This is the equivalent of `git apply` with no location argument. 137 | *) 138 | GIT_APPLY_LOCATION_WORKDIR = 0; 139 | (** 140 | * Apply the patch to the index, leaving the working directory 141 | * untouched. This is the equivalent of `git apply --cached`. 142 | *) 143 | GIT_APPLY_LOCATION_INDEX = 1; 144 | (** 145 | * Apply the patch to both the working directory and the index. 146 | * This is the equivalent of `git apply --index`. 147 | *) 148 | GIT_APPLY_LOCATION_BOTH = 2; 149 | type 150 | git_apply_location_t = Integer; 151 | 152 | (** 153 | * Apply a `git_diff` to the given repository, making changes directly 154 | * in the working directory, the index, or both. 155 | * 156 | * @param repo the repository to apply to 157 | * @param diff the diff to apply 158 | * @param location the location to apply (workdir, index or both) 159 | * @param options the options for the apply (or null for defaults) 160 | * @return 0 or an error code 161 | *) 162 | 163 | function git_apply(repo: Pgit_repository; diff: Pgit_diff; location: git_apply_location_t; options: Pgit_apply_options): Integer; 164 | cdecl; external libgit2_dll; 165 | 166 | (** @} *) 167 | 168 | -------------------------------------------------------------------------------- /src/git2/buffer.inc: -------------------------------------------------------------------------------- 1 | (** 2 | * @file git2/buffer.h 3 | * @brief A data structure to return data to callers 4 | * @ingroup Git 5 | * 6 | * The `git_buf` buffer is used to return arbitrary data - typically 7 | * strings - to callers. Callers are responsible for freeing the memory 8 | * in a buffer with the `git_buf_dispose` function. 9 | *) 10 | 11 | type 12 | git_buf = record 13 | (** 14 | * The buffer contents. `ptr` points to the start of the buffer 15 | * being returned. The buffer's length (in bytes) is specified 16 | * by the `size` member of the structure, and contains a NUL 17 | * terminator at position `(size + 1)`. 18 | *) 19 | ptr: PAnsiChar; 20 | (** 21 | * This field is reserved and unused. 22 | *) 23 | reserved: size_t; 24 | (** 25 | * The length (in bytes) of the buffer pointed to by `ptr`, 26 | * not including a NUL terminator. 27 | *) 28 | size: size_t; 29 | end; 30 | Pgit_buf = ^git_buf; 31 | 32 | (** 33 | * Use to initialize a `git_buf` before passing it to a function that 34 | * will populate it. 35 | *) 36 | 37 | //#define GIT_BUF_INIT { NULL, 0, 0 } 38 | 39 | (** 40 | * Free the memory referred to by the git_buf. 41 | * 42 | * Note that this does not free the `git_buf` itself, just the memory 43 | * pointed to by `buffer->ptr`. 44 | * 45 | * @param buffer The buffer to deallocate 46 | *) 47 | 48 | procedure git_buf_dispose(buffer: Pgit_buf); cdecl; external libgit2_dll; 49 | 50 | 51 | -------------------------------------------------------------------------------- /src/git2/cert.inc: -------------------------------------------------------------------------------- 1 | (** 2 | * @file git2/cert.h 3 | * @brief TLS and SSH certificate handling 4 | * @defgroup git_cert Certificate objects 5 | * @ingroup Git 6 | * @{ 7 | *) 8 | 9 | (** 10 | * Type of host certificate structure that is passed to the check callback 11 | *) 12 | 13 | const 14 | (** 15 | * No information about the certificate is available. This may 16 | * happen when using curl. 17 | *) 18 | GIT_CERT_NONE = 0; 19 | (** 20 | * The `data` argument to the callback will be a pointer to 21 | * the DER-encoded data. 22 | *) 23 | GIT_CERT_X509_ = 1; 24 | (** 25 | * The `data` argument to the callback will be a pointer to a 26 | * `git_cert_hostkey` structure. 27 | *) 28 | GIT_CERT_HOSTKEY_LIBSSH2 = 2; 29 | (** 30 | * The `data` argument to the callback will be a pointer to a 31 | * `git_strarray` with `name:content` strings containing 32 | * information about the certificate. This is used when using 33 | * curl. 34 | *) 35 | GIT_CERT_STRARRAY = 3; 36 | type 37 | git_cert_t = Integer; 38 | 39 | (** 40 | * Parent type for `git_cert_hostkey` and `git_cert_x509`. 41 | *) 42 | 43 | git_cert = record 44 | (** 45 | * Type of certificate. A `GIT_CERT_` value. 46 | *) 47 | cert_type: git_cert_t; 48 | end; 49 | Pgit_cert = ^git_cert; 50 | 51 | (** 52 | * Callback for the user's custom certificate checks. 53 | * 54 | * @param cert The host certificate 55 | * @param valid Whether the libgit2 checks (OpenSSL or WinHTTP) think 56 | * this certificate is valid 57 | * @param host Hostname of the host libgit2 connected to 58 | * @param payload Payload provided by the caller 59 | * @return 0 to proceed with the connection, < 0 to fail the connection 60 | * or > 0 to indicate that the callback refused to act and that 61 | * the existing validity determination should be honored 62 | *) 63 | 64 | type 65 | git_transport_certificate_check_cb = function(cert: Pgit_cert; valid: Integer; host: PAnsiChar; 66 | payload: Pointer): Integer; cdecl; 67 | 68 | (** 69 | * Type of SSH host fingerprint 70 | *) 71 | 72 | const 73 | (** MD5 is available *) 74 | GIT_CERT_SSH_MD5 = (1 shl 0); 75 | (** SHA-1 is available *) 76 | GIT_CERT_SSH_SHA1 = (1 shl 1); 77 | (** SHA-256 is available *) 78 | GIT_CERT_SSH_SHA256 = (1 shl 2); 79 | (** Raw hostkey is available *) 80 | GIT_CERT_SSH_RAW = (1 shl 3); 81 | type 82 | git_cert_ssh_t = Integer; 83 | 84 | const 85 | (** The raw key is of an unknown type. *) 86 | GIT_CERT_SSH_RAW_TYPE_UNKNOWN = 0; 87 | (** The raw key is an RSA key. *) 88 | GIT_CERT_SSH_RAW_TYPE_RSA = 1; 89 | (** The raw key is a DSS key. *) 90 | GIT_CERT_SSH_RAW_TYPE_DSS = 2; 91 | (** The raw key is a ECDSA 256 key. *) 92 | GIT_CERT_SSH_RAW_TYPE_KEY_ECDSA_256 = 3; 93 | (** The raw key is a ECDSA 384 key. *) 94 | GIT_CERT_SSH_RAW_TYPE_KEY_ECDSA_384 = 4; 95 | (** The raw key is a ECDSA 521 key. *) 96 | GIT_CERT_SSH_RAW_TYPE_KEY_ECDSA_521 = 5; 97 | (** The raw key is a ED25519 key. *) 98 | GIT_CERT_SSH_RAW_TYPE_KEY_ED25519 = 6; 99 | type 100 | git_cert_ssh_raw_type_t = Integer; 101 | 102 | (** 103 | * Hostkey information taken from libssh2 104 | *) 105 | 106 | git_cert_hostkey = record 107 | parent: git_cert; (**< The parent cert *) 108 | (** 109 | * A bitmask containing the available fields. 110 | *) 111 | type_: git_cert_ssh_t; 112 | (** 113 | * Hostkey hash. If `type` has `GIT_CERT_SSH_MD5` set, this will 114 | * have the MD5 hash of the hostkey. 115 | *) 116 | hash_md5: array[0..15] of Byte; 117 | (** 118 | * Hostkey hash. If `type` has `GIT_CERT_SSH_SHA1` set, this will 119 | * have the SHA-1 hash of the hostkey. 120 | *) 121 | hash_sha1: array[0..19] of Byte; 122 | (** 123 | * Hostkey hash. If `type` has `GIT_CERT_SSH_SHA256` set, this will 124 | * have the SHA-256 hash of the hostkey. 125 | *) 126 | hash_sha256: array[0..31] of Byte; 127 | (** 128 | * Raw hostkey type. If `type` has `GIT_CERT_SSH_RAW` set, this will 129 | * have the type of the raw hostkey. 130 | *) 131 | raw_type: git_cert_ssh_raw_type_t; 132 | (** 133 | * Pointer to the raw hostkey. If `type` has `GIT_CERT_SSH_RAW` set, 134 | * this will have the raw contents of the hostkey. 135 | *) 136 | hostkey: PAnsiChar; 137 | (** 138 | * Raw hostkey length. If `type` has `GIT_CERT_SSH_RAW` set, this will 139 | * have the length of the raw contents of the hostkey. 140 | *) 141 | hostkey_len: size_t; 142 | end; 143 | Pgit_cert_hostkey = ^git_cert_hostkey; 144 | 145 | (** 146 | * X.509 certificate information 147 | *) 148 | 149 | git_cert_x509 = record 150 | parent: git_cert; (**< The parent cert *) 151 | (** 152 | * Pointer to the X.509 certificate data 153 | *) 154 | data: Pointer; 155 | (** 156 | * Length of the memory block pointed to by `data`. 157 | *) 158 | len: size_t; 159 | end; 160 | Pgit_cert_x509 = ^git_cert_x509; 161 | 162 | (** @} *) 163 | 164 | 165 | 166 | -------------------------------------------------------------------------------- /src/git2/cherrypick.inc: -------------------------------------------------------------------------------- 1 | (** 2 | * @file git2/cherrypick.h 3 | * @brief Cherry-pick the contents of an individual commit 4 | * @defgroup git_cherrypick Git cherry-pick routines 5 | * @ingroup Git 6 | * 7 | * "Cherry-pick" will attempts to re-apply the changes in an 8 | * individual commit to the current index and working directory. 9 | * @{ 10 | *) 11 | 12 | (** 13 | * Cherry-pick options 14 | *) 15 | 16 | type 17 | git_cherrypick_options = record 18 | version: Cardinal; 19 | (** For merge commits, the "mainline" is treated as the parent. *) 20 | mainline: Cardinal; 21 | merge_opts: git_merge_options; (**< Options for the merging *) 22 | checkout_opts: git_checkout_options; (**< Options for the checkout *) 23 | end; 24 | Pgit_cherrypick_options = ^git_cherrypick_options; 25 | 26 | const 27 | (** Current version for the `git_cherrypick_options` structure *) 28 | GIT_CHERRYPICK_OPTIONS_VERSION = 1; 29 | (** Static constructor for `git_cherrypick_options` *) 30 | //GIT_CHERRYPICK_OPTIONS_INIT = { GIT_CHERRYPICK_OPTIONS_VERSION , 0 , GIT_MERGE_OPTIONS_INIT , GIT_CHECKOUT_OPTIONS_INIT }; 31 | (** 32 | * Initialize git_cherrypick_options structure 33 | * 34 | * Initializes a `git_cherrypick_options` with default values. Equivalent to creating 35 | * an instance with GIT_CHERRYPICK_OPTIONS_INIT. 36 | * 37 | * @param opts The `git_cherrypick_options` struct to initialize. 38 | * @param version The struct version; pass `GIT_CHERRYPICK_OPTIONS_VERSION`. 39 | * @return Zero on success; -1 on failure. 40 | *) 41 | 42 | function git_cherrypick_options_init(opts: Pgit_cherrypick_options; 43 | version: Cardinal): Integer; cdecl; external libgit2_dll; 44 | 45 | (** 46 | * Cherry-picks the given commit against the given "our" commit, producing an 47 | * index that reflects the result of the cherry-pick. 48 | * 49 | * The returned index must be freed explicitly with `git_index_free`. 50 | * 51 | * @param out pointer to store the index result in 52 | * @param repo the repository that contains the given commits 53 | * @param cherrypick_commit the commit to cherry-pick 54 | * @param our_commit the commit to cherry-pick against (eg, HEAD) 55 | * @param mainline the parent of the `cherrypick_commit`, if it is a merge 56 | * @param merge_options the merge options (or null for defaults) 57 | * @return zero on success, -1 on failure. 58 | *) 59 | 60 | function git_cherrypick_commit(out_: PPgit_index; repo: Pgit_repository; cherrypick_commit, our_commit: Pgit_commit; 61 | mainline: Cardinal; merge_options: Pgit_merge_options): Integer; cdecl; external libgit2_dll; 62 | 63 | (** 64 | * Cherry-pick the given commit, producing changes in the index and working directory. 65 | * 66 | * @param repo the repository to cherry-pick 67 | * @param commit the commit to cherry-pick 68 | * @param cherrypick_options the cherry-pick options (or null for defaults) 69 | * @return zero on success, -1 on failure. 70 | *) 71 | 72 | function git_cherrypick(repo: Pgit_repository; commit: Pgit_commit; 73 | cherrypick_options: Pgit_cherrypick_options): Integer; cdecl; external libgit2_dll; 74 | 75 | (** @} *) 76 | 77 | 78 | 79 | -------------------------------------------------------------------------------- /src/git2/clone.inc: -------------------------------------------------------------------------------- 1 | (** 2 | * @file git2/clone.h 3 | * @brief Clone a remote repository to the local disk 4 | * @defgroup git_clone Git cloning routines 5 | * @ingroup Git 6 | * 7 | * Clone will take a remote repository - located on a remote server 8 | * accessible by HTTPS or SSH, or a repository located elsewhere on 9 | * the local disk - and place a copy in the given local path. 10 | * @{ 11 | *) 12 | 13 | (** 14 | * Options for bypassing the git-aware transport on clone. Bypassing 15 | * it means that instead of a fetch, libgit2 will copy the object 16 | * database directory instead of figuring out what it needs, which is 17 | * faster. If possible, it will hardlink the files to save space. 18 | *) 19 | 20 | const 21 | (** 22 | * Auto-detect (default), libgit2 will bypass the git-aware 23 | * transport for local paths, but use a normal fetch for 24 | * `file://` urls. 25 | *) 26 | GIT_CLONE_LOCAL_AUTO = 0; 27 | (** 28 | * Bypass the git-aware transport even for a `file://` url. 29 | *) 30 | GIT_CLONE_LOCAL = 1; 31 | (** 32 | * Do no bypass the git-aware transport 33 | *) 34 | GIT_CLONE_NO_LOCAL = 2; 35 | (** 36 | * Bypass the git-aware transport, but do not try to use 37 | * hardlinks. 38 | *) 39 | GIT_CLONE_LOCAL_NO_LINKS = 3; 40 | type 41 | git_clone_local_t = Integer; 42 | 43 | (** 44 | * The signature of a function matching git_remote_create, with an additional 45 | * void* as a callback payload. 46 | * 47 | * Callers of git_clone may provide a function matching this signature to override 48 | * the remote creation and customization process during a clone operation. 49 | * 50 | * @param[out] out the resulting remote 51 | * @param repo the repository in which to create the remote 52 | * @param name the remote's name 53 | * @param url the remote's url 54 | * @param payload an opaque payload 55 | * @return 0, GIT_EINVALIDSPEC, GIT_EEXISTS or an error code 56 | *) 57 | 58 | git_remote_create_cb = function(out_: PPgit_remote; repo: Pgit_repository; name_, url: PAnsiChar; 59 | payload: Pointer): Integer; cdecl; 60 | 61 | (** 62 | * The signature of a function matching git_repository_init, with an 63 | * additional void * as callback payload. 64 | * 65 | * Callers of git_clone my provide a function matching this signature 66 | * to override the repository creation and customization process 67 | * during a clone operation. 68 | * 69 | * @param[out] out the resulting repository 70 | * @param path path in which to create the repository 71 | * @param bare whether the repository is bare. This is the value from the clone options 72 | * @param payload payload specified by the options 73 | * @return 0, or a negative value to indicate error 74 | *) 75 | 76 | git_repository_create_cb = function(out_: PPgit_repository; path: PAnsiChar; bare: Integer; 77 | payload: Pointer): Integer; cdecl; 78 | 79 | (** 80 | * Clone options structure 81 | * 82 | * Initialize with `GIT_CLONE_OPTIONS_INIT`. Alternatively, you can 83 | * use `git_clone_options_init`. 84 | * 85 | * @options[version] GIT_CLONE_OPTIONS_VERSION 86 | * @options[init_macro] GIT_CLONE_OPTIONS_INIT 87 | * @options[init_function] git_clone_options_init 88 | *) 89 | 90 | git_clone_options = record 91 | version: Cardinal; 92 | (** 93 | * These options are passed to the checkout step. To disable 94 | * checkout, set the `checkout_strategy` to `GIT_CHECKOUT_NONE` 95 | * or `GIT_CHECKOUT_DRY_RUN`. 96 | *) 97 | checkout_opts: git_checkout_options; 98 | (** 99 | * Options which control the fetch, including callbacks. 100 | * 101 | * The callbacks are used for reporting fetch progress, and for acquiring 102 | * credentials in the event they are needed. 103 | *) 104 | fetch_opts: git_fetch_options; 105 | (** 106 | * Set to zero (false) to create a standard repo, or non-zero 107 | * for a bare repo 108 | *) 109 | bare: Integer; 110 | (** 111 | * Whether to use a fetch or copy the object database. 112 | *) 113 | local_: git_clone_local_t; 114 | (** 115 | * The name of the branch to checkout. NULL means use the 116 | * remote's default branch. 117 | *) 118 | checkout_branch: PAnsiChar; 119 | (** 120 | * A callback used to create the new repository into which to 121 | * clone. If NULL, the 'bare' field will be used to determine 122 | * whether to create a bare repository. 123 | *) 124 | repository_cb: git_repository_create_cb; 125 | (** 126 | * An opaque payload to pass to the git_repository creation callback. 127 | * This parameter is ignored unless repository_cb is non-NULL. 128 | *) 129 | repository_cb_payload: Pointer; 130 | (** 131 | * A callback used to create the git_remote, prior to its being 132 | * used to perform the clone operation. See the documentation for 133 | * git_remote_create_cb for details. This parameter may be NULL, 134 | * indicating that git_clone should provide default behavior. 135 | *) 136 | remote_cb: git_remote_create_cb; 137 | (** 138 | * An opaque payload to pass to the git_remote creation callback. 139 | * This parameter is ignored unless remote_cb is non-NULL. 140 | *) 141 | remote_cb_payload: Pointer; 142 | end; 143 | Pgit_clone_options = ^git_clone_options; 144 | 145 | const 146 | (** Current version for the `git_clone_options` structure *) 147 | GIT_CLONE_OPTIONS_VERSION = 1; 148 | (** Static constructor for `git_clone_options` *) 149 | //GIT_CLONE_OPTIONS_INIT = { GIT_CLONE_OPTIONS_VERSION , { GIT_CHECKOUT_OPTIONS_VERSION , GIT_CHECKOUT_SAFE } , GIT_FETCH_OPTIONS_INIT }; 150 | (** 151 | * Initialize git_clone_options structure 152 | * 153 | * Initializes a `git_clone_options` with default values. Equivalent to creating 154 | * an instance with GIT_CLONE_OPTIONS_INIT. 155 | * 156 | * @param opts The `git_clone_options` struct to initialize. 157 | * @param version The struct version; pass `GIT_CLONE_OPTIONS_VERSION`. 158 | * @return Zero on success; -1 on failure. 159 | *) 160 | 161 | function git_clone_options_init(opts: Pgit_clone_options; version: Cardinal): Integer; cdecl; external libgit2_dll; 162 | 163 | (** 164 | * Clone a remote repository. 165 | * 166 | * By default this creates its repository and initial remote to match 167 | * git's defaults. You can use the options in the callback to 168 | * customize how these are created. 169 | * 170 | * Note that the libgit2 library _must_ be initialized using 171 | * `git_libgit2_init` before any APIs can be called, including 172 | * this one. 173 | * 174 | * @param[out] out pointer that will receive the resulting repository object 175 | * @param url the remote repository to clone 176 | * @param local_path local directory to clone to 177 | * @param options configuration options for the clone. If NULL, the 178 | * function works as though GIT_OPTIONS_INIT were passed. 179 | * @return 0 on success, any non-zero return value from a callback 180 | * function, or a negative value to indicate an error (use 181 | * `git_error_last` for a detailed error message) 182 | *) 183 | 184 | function git_clone(out_: PPgit_repository; url, local_path: PAnsiChar; 185 | options: Pgit_clone_options): Integer; cdecl; external libgit2_dll; 186 | 187 | (** @} *) 188 | 189 | 190 | 191 | -------------------------------------------------------------------------------- /src/git2/credential_helpers.inc: -------------------------------------------------------------------------------- 1 | (** 2 | * @file git2/credential_helpers.h 3 | * @brief Utility functions for credential management 4 | * @defgroup git_credential_helpers credential management helpers 5 | * @ingroup Git 6 | * @{ 7 | *) 8 | 9 | (** 10 | * Payload for git_credential_userpass_plaintext. 11 | *) 12 | 13 | type 14 | git_credential_userpass_payload = record 15 | username: PAnsiChar; 16 | password: PAnsiChar; 17 | end; 18 | 19 | (** 20 | * Stock callback usable as a git_credential_acquire_cb. This calls 21 | * git_cred_userpass_plaintext_new unless the protocol has not specified 22 | * `GIT_CREDENTIAL_USERPASS_PLAINTEXT` as an allowed type. 23 | * 24 | * @param out The newly created credential object. 25 | * @param url The resource for which we are demanding a credential. 26 | * @param user_from_url The username that was embedded in a "user\@host" 27 | * remote url, or NULL if not included. 28 | * @param allowed_types A bitmask stating which credential types are OK to return. 29 | * @param payload The payload provided when specifying this callback. (This is 30 | * interpreted as a `git_credential_userpass_payload*`.) 31 | * @return 0 or an error code. 32 | *) 33 | 34 | function git_credential_userpass(out_: PPgit_credential; url, user_from_url: PAnsiChar; 35 | allowed_types: Cardinal; payload: Pointer): Integer; cdecl; external libgit2_dll; 36 | 37 | (** @} *) 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /src/git2/describe.inc: -------------------------------------------------------------------------------- 1 | (** 2 | * @file git2/describe.h 3 | * @brief Describe a commit in reference to tags 4 | * @defgroup git_describe Git describing routines 5 | * @ingroup Git 6 | * @{ 7 | * 8 | * Describe a commit, showing information about how the current commit 9 | * relates to the tags. This can be useful for showing how the current 10 | * commit has changed from a particular tagged version of the repository. 11 | * @{ 12 | *) 13 | 14 | (** 15 | * Reference lookup strategy 16 | * 17 | * These behave like the --tags and --all options to git-describe, 18 | * namely they say to look for any reference in either refs/tags/ or 19 | * refs/ respectively. 20 | *) 21 | 22 | const 23 | GIT_DESCRIBE_DEFAULT = 0; 24 | GIT_DESCRIBE_TAGS = 1; 25 | GIT_DESCRIBE_ALL = 2; 26 | type 27 | git_describe_strategy_t = Integer; 28 | 29 | (** 30 | * Describe options structure 31 | * 32 | * Initialize with `GIT_DESCRIBE_OPTIONS_INIT`. Alternatively, you can 33 | * use `git_describe_options_init`. 34 | * 35 | *) 36 | 37 | git_describe_options = record 38 | version: Cardinal; 39 | max_candidates_tags: Cardinal; (**< default: 10 *) 40 | describe_strategy: Cardinal; (**< default: GIT_DESCRIBE_DEFAULT *) 41 | pattern: PAnsiChar; 42 | (** 43 | * When calculating the distance from the matching tag or 44 | * reference, only walk down the first-parent ancestry. 45 | *) 46 | only_follow_first_parent: Integer; 47 | (** 48 | * If no matching tag or reference is found, the describe 49 | * operation would normally fail. If this option is set, it 50 | * will instead fall back to showing the full id of the 51 | * commit. 52 | *) 53 | show_commit_oid_as_fallback: Integer; 54 | end; 55 | Pgit_describe_options = ^git_describe_options; 56 | 57 | const 58 | (** Default maximum candidate tags *) 59 | GIT_DESCRIBE_DEFAULT_MAX_CANDIDATES_TAGS = 10; 60 | (** Default abbreviated size *) 61 | GIT_DESCRIBE_DEFAULT_ABBREVIATED_SIZE = 7; 62 | 63 | (** Current version for the `git_describe_options` structure *) 64 | GIT_DESCRIBE_OPTIONS_VERSION = 1; 65 | (** Static constructor for `git_describe_options` *) 66 | //GIT_DESCRIBE_OPTIONS_INIT = { GIT_DESCRIBE_OPTIONS_VERSION , GIT_DESCRIBE_DEFAULT_MAX_CANDIDATES_TAGS , }; 67 | (** 68 | * Initialize git_describe_options structure 69 | * 70 | * Initializes a `git_describe_options` with default values. Equivalent to creating 71 | * an instance with GIT_DESCRIBE_OPTIONS_INIT. 72 | * 73 | * @param opts The `git_describe_options` struct to initialize. 74 | * @param version The struct version; pass `GIT_DESCRIBE_OPTIONS_VERSION`. 75 | * @return Zero on success; -1 on failure. 76 | *) 77 | 78 | function git_describe_options_init(opts: Pgit_describe_options; version: Cardinal): Integer; cdecl; external libgit2_dll; 79 | 80 | (** 81 | * Describe format options structure 82 | * 83 | * Initialize with `GIT_DESCRIBE_FORMAT_OPTIONS_INIT`. Alternatively, you can 84 | * use `git_describe_format_options_init`. 85 | * 86 | *) 87 | 88 | type 89 | git_describe_format_options = record 90 | version: Cardinal; 91 | (** 92 | * Size of the abbreviated commit id to use. This value is the 93 | * lower bound for the length of the abbreviated string. The 94 | * default is 7. 95 | *) 96 | abbreviated_size: Cardinal; 97 | (** 98 | * Set to use the long format even when a shorter name could be used. 99 | *) 100 | always_use_long_format: Integer; 101 | (** 102 | * If the workdir is dirty and this is set, this string will 103 | * be appended to the description string. 104 | *) 105 | dirty_suffix: PAnsiChar; 106 | end; 107 | Pgit_describe_format_options = ^git_describe_format_options; 108 | 109 | const 110 | (** Current version for the `git_describe_format_options` structure *) 111 | GIT_DESCRIBE_FORMAT_OPTIONS_VERSION = 1; 112 | (** Static constructor for `git_describe_format_options` *) 113 | //GIT_DESCRIBE_FORMAT_OPTIONS_INIT = { GIT_DESCRIBE_FORMAT_OPTIONS_VERSION , GIT_DESCRIBE_DEFAULT_ABBREVIATED_SIZE , }; 114 | (** 115 | * Initialize git_describe_format_options structure 116 | * 117 | * Initializes a `git_describe_format_options` with default values. Equivalent to creating 118 | * an instance with GIT_DESCRIBE_FORMAT_OPTIONS_INIT. 119 | * 120 | * @param opts The `git_describe_format_options` struct to initialize. 121 | * @param version The struct version; pass `GIT_DESCRIBE_FORMAT_OPTIONS_VERSION`. 122 | * @return Zero on success; -1 on failure. 123 | *) 124 | 125 | function git_describe_format_options_init(opts: Pgit_describe_format_options; 126 | version: Cardinal): Integer; cdecl; external libgit2_dll; 127 | 128 | (** 129 | * A struct that stores the result of a describe operation. 130 | *) 131 | 132 | type 133 | git_describe_result = record 134 | end; 135 | Pgit_describe_result = ^git_describe_result; 136 | PPgit_describe_result = ^Pgit_describe_result; 137 | 138 | (** 139 | * Describe a commit 140 | * 141 | * Perform the describe operation on the given committish object. 142 | * 143 | * @param result pointer to store the result. You must free this once 144 | * you're done with it. 145 | * @param committish a committish to describe 146 | * @param opts the lookup options (or NULL for defaults) 147 | * @return 0 or an error code. 148 | *) 149 | 150 | function git_describe_commit(Result: PPgit_describe_result; committish: Pgit_object; 151 | opts: Pgit_describe_options): Integer; cdecl; external libgit2_dll; 152 | 153 | (** 154 | * Describe a commit 155 | * 156 | * Perform the describe operation on the current commit and the 157 | * worktree. After performing describe on HEAD, a status is run and the 158 | * description is considered to be dirty if there are. 159 | * 160 | * @param out pointer to store the result. You must free this once 161 | * you're done with it. 162 | * @param repo the repository in which to perform the describe 163 | * @param opts the lookup options (or NULL for defaults) 164 | * @return 0 or an error code. 165 | *) 166 | 167 | function git_describe_workdir(out_: PPgit_describe_result; repo: Pgit_repository; 168 | opts: Pgit_describe_options): Integer; cdecl; external libgit2_dll; 169 | 170 | (** 171 | * Print the describe result to a buffer 172 | * 173 | * @param out The buffer to store the result 174 | * @param result the result from `git_describe_commit()` or 175 | * `git_describe_workdir()`. 176 | * @param opts the formatting options (or NULL for defaults) 177 | * @return 0 or an error code. 178 | *) 179 | 180 | function git_describe_format(out_: Pgit_buf; Result: Pgit_describe_result; 181 | opts: Pgit_describe_format_options): Integer; cdecl; external libgit2_dll; 182 | 183 | (** 184 | * Free the describe result. 185 | * 186 | * @param result The result to free. 187 | *) 188 | 189 | procedure git_describe_result_free(Result: Pgit_describe_result); cdecl; external libgit2_dll; 190 | 191 | (** @} *) 192 | 193 | 194 | 195 | -------------------------------------------------------------------------------- /src/git2/email.inc: -------------------------------------------------------------------------------- 1 | (** 2 | * @file git2/email.h 3 | * @brief Produce email-ready patches 4 | * @ingroup Git 5 | * @{ 6 | *) 7 | 8 | (** 9 | * Formatting options for diff e-mail generation 10 | *) 11 | 12 | const 13 | (** Normal patch, the default *) 14 | GIT_EMAIL_CREATE_DEFAULT = 0; 15 | (** do not include patch numbers in the subject prefix. *) 16 | GIT_EMAIL_CREATE_OMIT_NUMBERS = 1 shl 0; 17 | 18 | (** 19 | * Include numbers in the subject prefix even when the 20 | * patch is for a single commit (1/1). 21 | *) 22 | GIT_EMAIL_CREATE_ALWAYS_NUMBER = 1 shl 1; 23 | 24 | (** Do not perform rename or similarity detection. *) 25 | GIT_EMAIL_CREATE_NO_RENAMES = 1 shl 2; 26 | type 27 | git_email_create_flags_t = Integer; 28 | 29 | (** 30 | * Options for controlling the formatting of the generated e-mail. 31 | *) 32 | 33 | type 34 | git_email_create_options = record 35 | version: Cardinal; 36 | (** see `git_email_create_flags_t` above *) 37 | flags: uint32_t; 38 | (** Options to use when creating diffs *) 39 | diff_opts: git_diff_options; 40 | 41 | (** Options for finding similarities within diffs *) 42 | diff_find_opts: git_diff_find_options; 43 | 44 | (** 45 | * The subject prefix, by default "PATCH". If set to an empty 46 | * string ("") then only the patch numbers will be shown in the 47 | * prefix. If the subject_prefix is empty and patch numbers 48 | * are not being shown, the prefix will be omitted entirely. 49 | *) 50 | subject_prefix: PAnsiChar; 51 | 52 | (** 53 | * The starting patch number; this cannot be 0. By default, 54 | * this is 1. 55 | *) 56 | start_number: size_t; 57 | 58 | (** The "re-roll" number. By default, there is no re-roll. *) 59 | reroll_number: size_t; 60 | 61 | (** This patch number *) 62 | patch_no: size_t; 63 | (** Total number of patches in this series *) 64 | total_patches: size_t; 65 | (** id to use for the commit *) 66 | id: Pgit_oid; 67 | (** Summary of the change *) 68 | summary: PAnsiChar; 69 | (** Commit message's body *) 70 | body: PAnsiChar; 71 | (** Author of the change *) 72 | author: Pgit_signature; 73 | end; 74 | Pgit_email_create_options = ^git_email_create_options; 75 | 76 | const 77 | (** Current version for the `git_email_create_options` structure *) 78 | GIT_EMAIL_CREATE_OPTIONS_VERSION = 1; 79 | (** Static constructor for `git_email_create_options` 80 | * 81 | * By default, our options include rename detection and binary 82 | * diffs to match `git format-patch`. 83 | *) 84 | (*GIT_EMAIL_CREATE_OPTIONS_INIT = 85 | { \ 86 | GIT_EMAIL_CREATE_OPTIONS_VERSION, \ 87 | GIT_EMAIL_CREATE_DEFAULT, \ 88 | { GIT_DIFF_OPTIONS_VERSION, GIT_DIFF_SHOW_BINARY, GIT_SUBMODULE_IGNORE_UNSPECIFIED, {NULL,0}, NULL, NULL, NULL, 3 }, \ 89 | GIT_DIFF_FIND_OPTIONS_INIT \ 90 | } 91 | *) 92 | 93 | (** 94 | * Create a diff for a commit in mbox format for sending via email. 95 | * The commit must not be a merge commit. 96 | * 97 | * @param out buffer to store the e-mail patch in 98 | * @param commit commit to create a patch for 99 | * @param opts email creation options 100 | * @return 0 or an error code 101 | *) 102 | 103 | function git_email_create_from_commit(_out: Pgit_buf; commit: Pgit_commit; 104 | opts: Pgit_email_create_options): Integer; cdecl; external libgit2_dll; 105 | 106 | (** @} *) 107 | 108 | 109 | 110 | -------------------------------------------------------------------------------- /src/git2/errors.inc: -------------------------------------------------------------------------------- 1 | (** 2 | * @file git2/errors.h 3 | * @brief Error handling routines and variables 4 | * @ingroup Git 5 | * @{ 6 | *) 7 | 8 | (** Generic return codes *) 9 | 10 | const 11 | (** 12 | * No error occurred; the call was successful. 13 | *) 14 | GIT_OK = 0; 15 | (** 16 | * An error occurred; call `git_error_last` for more information. 17 | *) 18 | GIT_ERROR = -1; 19 | GIT_ENOTFOUND = -3; (**< Requested object could not be found. *) 20 | GIT_EEXISTS = -4; (**< Object exists preventing operation. *) 21 | GIT_EAMBIGUOUS = -5; (**< More than one object matches. *) 22 | GIT_EBUFS = -6; (**< Output buffer too short to hold data. *) 23 | (** 24 | * GIT_EUSER is a special error that is never generated by libgit2 25 | * code. You can return it from a callback (e.g to stop an iteration) 26 | * to know that it was generated by the callback and not by libgit2. 27 | *) 28 | GIT_EUSER = -7; 29 | GIT_EBAREREPO = -8; (**< Operation not allowed on bare repository. *) 30 | GIT_EUNBORNBRANCH = -9; (**< HEAD refers to branch with no commits. *) 31 | GIT_EUNMERGED = -10; (**< Merge in progress prevented operation *) 32 | GIT_ENONFASTFORWARD = -11; (**< Reference was not fast-forwardable *) 33 | GIT_EINVALIDSPEC = -12; (**< Name/ref spec was not in a valid format *) 34 | GIT_ECONFLICT = -13; (**< Checkout conflicts prevented operation *) 35 | GIT_ELOCKED = -14; (**< Lock file prevented operation *) 36 | GIT_EMODIFIED = -15; (**< Reference value does not match expected *) 37 | GIT_EAUTH = -16; (**< Authentication error *) 38 | GIT_ECERTIFICATE = -17; (**< Server certificate is invalid *) 39 | GIT_EAPPLIED = -18; (**< Patch/merge has already been applied *) 40 | GIT_EPEEL = -19; (**< The requested peel operation is not possible *) 41 | GIT_EEOF = -20; (**< Unexpected EOF *) 42 | GIT_EINVALID = -21; (**< Invalid operation or input *) 43 | GIT_EUNCOMMITTED = -22; (**< Uncommitted changes in index prevented operation *) 44 | GIT_EDIRECTORY = -23; (**< The operation is not valid for a directory *) 45 | GIT_EMERGECONFLICT = -24; (**< A merge conflict exists and cannot continue *) 46 | GIT_PASSTHROUGH = -30; (**< A user-configured callback refused to act *) 47 | GIT_ITEROVER = -31; (**< Signals end of iteration with iterator *) 48 | GIT_RETRY = -32; (**< Internal only *) 49 | GIT_EMISMATCH = -33; (**< Hashsum mismatch in object *) 50 | GIT_EINDEXDIRTY = -34; (**< Unsaved changes in the index would be overwritten *) 51 | GIT_EAPPLYFAIL = -35; (**< Patch application failed *) 52 | GIT_EOWNER = -36; (**< The object is not owned by the current user *) 53 | GIT_TIMEOUT = -37; (**< The operation timed out *) 54 | GIT_EUNCHANGED = -38; (**< There were no changes *) 55 | GIT_ENOTSUPPORTED = -39; (**< An option is not supported *) 56 | GIT_EREADONLY = -40; (**< The subject is read-only *) 57 | type 58 | git_error_code = Integer; 59 | 60 | (** 61 | * Error classes are the category of error. They reflect the area of the 62 | * code where an error occurred. 63 | *) 64 | 65 | const 66 | GIT_ERROR_NONE = 0; 67 | GIT_ERROR_NOMEMORY = 1; 68 | GIT_ERROR_OS = 2; 69 | GIT_ERROR_INVALID = 3; 70 | GIT_ERROR_REFERENCE = 4; 71 | GIT_ERROR_ZLIB = 5; 72 | GIT_ERROR_REPOSITORY = 6; 73 | GIT_ERROR_CONFIG = 7; 74 | GIT_ERROR_REGEX = 8; 75 | GIT_ERROR_ODB = 9; 76 | GIT_ERROR_INDEX = 10; 77 | GIT_ERROR_OBJECT = 11; 78 | GIT_ERROR_NET = 12; 79 | GIT_ERROR_TAG = 13; 80 | GIT_ERROR_TREE = 14; 81 | GIT_ERROR_INDEXER = 15; 82 | GIT_ERROR_SSL = 16; 83 | GIT_ERROR_SUBMODULE = 17; 84 | GIT_ERROR_THREAD = 18; 85 | GIT_ERROR_STASH = 19; 86 | GIT_ERROR_CHECKOUT = 20; 87 | GIT_ERROR_FETCHHEAD = 21; 88 | GIT_ERROR_MERGE = 22; 89 | GIT_ERROR_SSH = 23; 90 | GIT_ERROR_FILTER = 24; 91 | GIT_ERROR_REVERT = 25; 92 | GIT_ERROR_CALLBACK = 26; 93 | GIT_ERROR_CHERRYPICK = 27; 94 | GIT_ERROR_DESCRIBE = 28; 95 | GIT_ERROR_REBASE = 29; 96 | GIT_ERROR_FILESYSTEM = 30; 97 | GIT_ERROR_PATCH = 31; 98 | GIT_ERROR_WORKTREE = 32; 99 | GIT_ERROR_SHA = 33; 100 | GIT_ERROR_HTTP = 34; 101 | GIT_ERROR_INTERNAL = 35; 102 | GIT_ERROR_GRAFTS = 36; 103 | type 104 | git_error_t = Integer; 105 | 106 | (** 107 | * Structure to store extra details of the last error that occurred. 108 | * 109 | * This is kept on a per-thread basis if GIT_THREADS was defined when the 110 | * library was build, otherwise one is kept globally for the library 111 | *) 112 | git_error_ = record 113 | message: PAnsiChar; (**< The error message for the last error. *) 114 | klass: Integer; (**< The category of the last error. @type git_error_t *) 115 | end; 116 | Pgit_error = ^git_error_; 117 | 118 | (** 119 | * Return the last `git_error` object that was generated for the 120 | * current thread. 121 | * 122 | * This function will never return NULL. 123 | * 124 | * Callers should not rely on this to determine whether an error has 125 | * occurred. For error checking, callers should examine the return 126 | * codes of libgit2 functions. 127 | * 128 | * This call can only reliably report error messages when an error 129 | * has occurred. (It may contain stale information if it is called 130 | * after a different function that succeeds.) 131 | * 132 | * The memory for this object is managed by libgit2. It should not 133 | * be freed. 134 | * 135 | * @return A pointer to a `git_error` object that describes the error. 136 | *) 137 | 138 | function git_error_last: Pgit_error; cdecl; external libgit2_dll; 139 | 140 | (** @} *) 141 | 142 | -------------------------------------------------------------------------------- /src/git2/filter.inc: -------------------------------------------------------------------------------- 1 | (** 2 | * @file git2/filter.h 3 | * @brief Filters modify files during checkout or commit 4 | * @ingroup Git 5 | * 6 | * During checkout, filters update a file from a "canonical" state to 7 | * a format appropriate for the local filesystem; during commit, filters 8 | * produce the canonical state. For example, on Windows, the line ending 9 | * filters _may_ take a canonical state (with Unix-style newlines) in 10 | * the repository, and place the contents on-disk with Windows-style 11 | * `\r\n` line endings. 12 | * @{ 13 | *) 14 | 15 | (** 16 | * Filters are applied in one of two directions: smudging - which is 17 | * exporting a file from the Git object database to the working directory, 18 | * and cleaning - which is importing a file from the working directory to 19 | * the Git object database. These values control which direction of 20 | * change is being applied. 21 | *) 22 | 23 | const 24 | GIT_FILTER_TO_WORKTREE = 0; 25 | GIT_FILTER_SMUDGE = GIT_FILTER_TO_WORKTREE; 26 | GIT_FILTER_TO_ODB = 1; 27 | GIT_FILTER_CLEAN = GIT_FILTER_TO_ODB; 28 | type 29 | git_filter_mode_t = Integer; 30 | 31 | (** 32 | * Filter option flags. 33 | *) 34 | 35 | const 36 | GIT_FILTER_DEFAULT = 0; 37 | (** Don't error for `safecrlf` violations, allow them to continue. *) 38 | GIT_FILTER_ALLOW_UNSAFE = (1 shl 0); 39 | (** Don't load `/etc/gitattributes` (or the system equivalent) *) 40 | GIT_FILTER_NO_SYSTEM_ATTRIBUTES = (1 shl 1); 41 | (** Load attributes from `.gitattributes` in the root of HEAD *) 42 | GIT_FILTER_ATTRIBUTES_FROM_HEAD = (1 shl 2); 43 | (** 44 | * Load attributes from `.gitattributes` in a given commit. 45 | * This can only be specified in a `git_filter_options`. 46 | *) 47 | GIT_FILTER_ATTRIBUTES_FROM_COMMIT = (1 shl 3); 48 | type 49 | git_filter_flag_t = Integer; 50 | 51 | (** 52 | * Filtering options 53 | *) 54 | git_filter_options = record 55 | version: Cardinal; 56 | 57 | (** See `git_filter_flag_t` above *) 58 | flags: Cardinal; 59 | 60 | {$IFDEF GIT_DEPRECATE_HARD} 61 | reserved: Pointer; 62 | {$ELSE} 63 | commit_id: Pgit_oid; 64 | {$ENDIF} 65 | (** 66 | * The commit to load attributes from, when 67 | * `GIT_FILTER_ATTRIBUTES_FROM_COMMIT` is specified. 68 | *) 69 | attr_commit_id: git_oid; 70 | end; 71 | Pgit_filter_options = ^git_filter_options; 72 | 73 | const 74 | (** Current version for the `git_filter_options` structure *) 75 | GIT_FILTER_OPTIONS_VERSION = 1; 76 | (** Static constructor for `git_filter_options` *) 77 | //GIT_FILTER_OPTIONS_INIT {GIT_FILTER_OPTIONS_VERSION} 78 | 79 | (** 80 | * A filter that can transform file data 81 | * 82 | * This represents a filter that can be used to transform or even replace 83 | * file data. Libgit2 includes one built in filter and it is possible to 84 | * write your own (see git2/sys/filter.h for information on that). 85 | * 86 | * The two builtin filters are: 87 | * 88 | * * "crlf" which uses the complex rules with the "text", "eol", and 89 | * "crlf" file attributes to decide how to convert between LF and CRLF 90 | * line endings 91 | * * "ident" which replaces "$Id$" in a blob with "$Id: $" upon 92 | * checkout and replaced "$Id: $" with "$Id$" on checkin. 93 | *) 94 | 95 | type 96 | git_filter = record 97 | end; 98 | 99 | (** 100 | * List of filters to be applied 101 | * 102 | * This represents a list of filters to be applied to a file / blob. You 103 | * can build the list with one call, apply it with another, and dispose it 104 | * with a third. In typical usage, there are not many occasions where a 105 | * git_filter_list is needed directly since the library will generally 106 | * handle conversions for you, but it can be convenient to be able to 107 | * build and apply the list sometimes. 108 | *) 109 | 110 | git_filter_list = record 111 | end; 112 | Pgit_filter_list = ^git_filter_list; 113 | PPgit_filter_list = ^Pgit_filter_list; 114 | 115 | (** 116 | * Load the filter list for a given path. 117 | * 118 | * This will return 0 (success) but set the output git_filter_list to NULL 119 | * if no filters are requested for the given file. 120 | * 121 | * @param filters Output newly created git_filter_list (or NULL) 122 | * @param repo Repository object that contains `path` 123 | * @param blob The blob to which the filter will be applied (if known) 124 | * @param path Relative path of the file to be filtered 125 | * @param mode Filtering direction (WT->ODB or ODB->WT) 126 | * @param flags Combination of `git_filter_flag_t` flags 127 | * @return 0 on success (which could still return NULL if no filters are 128 | * needed for the requested file), <0 on error 129 | *) 130 | 131 | function git_filter_list_load(filters: PPgit_filter_list; repo: Pgit_repository; blob: Pgit_blob; 132 | path: PAnsiChar; mode: git_filter_mode_t; flags: uint32_t): Integer; cdecl; external libgit2_dll; 133 | 134 | (** 135 | * Load the filter list for a given path. 136 | * 137 | * This will return 0 (success) but set the output git_filter_list to NULL 138 | * if no filters are requested for the given file. 139 | * 140 | * @param filters Output newly created git_filter_list (or NULL) 141 | * @param repo Repository object that contains `path` 142 | * @param blob The blob to which the filter will be applied (if known) 143 | * @param path Relative path of the file to be filtered 144 | * @param mode Filtering direction (WT->ODB or ODB->WT) 145 | * @param opts The `git_filter_options` to use when loading filters 146 | * @return 0 on success (which could still return NULL if no filters are 147 | * needed for the requested file), <0 on error 148 | *) 149 | 150 | function git_filter_list_load_ext(filters: PPgit_filter_list; repo: Pgit_repository; blob: Pgit_blob; 151 | path: PAnsiChar; mode: git_filter_mode_t; opts: Pgit_filter_options): Integer; cdecl; external libgit2_dll; 152 | 153 | (** 154 | * Query the filter list to see if a given filter (by name) will run. 155 | * The built-in filters "crlf" and "ident" can be queried, otherwise this 156 | * is the name of the filter specified by the filter attribute. 157 | * 158 | * This will return 0 if the given filter is not in the list, or 1 if 159 | * the filter will be applied. 160 | * 161 | * @param filters A loaded git_filter_list (or NULL) 162 | * @param name The name of the filter to query 163 | * @return 1 if the filter is in the list, 0 otherwise 164 | *) 165 | 166 | function git_filter_list_contains(filters: Pgit_filter_list; name_: PAnsiChar): Integer; cdecl; external libgit2_dll; 167 | 168 | (** 169 | * Apply filter list to a data buffer. 170 | * 171 | * @param out Buffer to store the result of the filtering 172 | * @param filters A loaded git_filter_list (or NULL) 173 | * @param in Buffer containing the data to filter 174 | * @param in_len The length of the input buffer 175 | * @return 0 on success, an error code otherwise 176 | *) 177 | 178 | function git_filter_list_apply_to_buffer(out_: Pgit_buf; filters: Pgit_filter_list; const in_: PAnsiChar; 179 | in_len: size_t): Integer; cdecl; external libgit2_dll; 180 | 181 | (** 182 | * Apply a filter list to the contents of a file on disk 183 | * 184 | * @param out buffer into which to store the filtered file 185 | * @param filters the list of filters to apply 186 | * @param repo the repository in which to perform the filtering 187 | * @param path the path of the file to filter, a relative path will be 188 | * taken as relative to the workdir 189 | * @return 0 or an error code. 190 | *) 191 | 192 | function git_filter_list_apply_to_file(out_: Pgit_buf; filters: Pgit_filter_list; repo: Pgit_repository; 193 | path: PAnsiChar): Integer; cdecl; external libgit2_dll; 194 | 195 | (** 196 | * Apply a filter list to the contents of a blob 197 | * 198 | * @param out buffer into which to store the filtered file 199 | * @param filters the list of filters to apply 200 | * @param blob the blob to filter 201 | * @return 0 or an error code. 202 | *) 203 | 204 | function git_filter_list_apply_to_blob(out_: Pgit_buf; filters: Pgit_filter_list; 205 | blob: Pgit_blob): Integer; cdecl; external libgit2_dll; 206 | 207 | (** 208 | * Apply a filter list to an arbitrary buffer as a stream 209 | * 210 | * @param filters the list of filters to apply 211 | * @param buffer the buffer to filter 212 | * @param len the size of the buffer 213 | * @param target the stream into which the data will be written 214 | * @return 0 or an error code. 215 | *) 216 | 217 | function git_filter_list_stream_buffer(filters: Pgit_filter_list; const buffer: PAnsiChar; len: size_t; 218 | target: Pgit_writestream): Integer; cdecl; external libgit2_dll; 219 | 220 | (** 221 | * Apply a filter list to a file as a stream 222 | * 223 | * @param filters the list of filters to apply 224 | * @param repo the repository in which to perform the filtering 225 | * @param path the path of the file to filter, a relative path will be 226 | * taken as relative to the workdir 227 | * @param target the stream into which the data will be written 228 | * @return 0 or an error code. 229 | *) 230 | 231 | function git_filter_list_stream_file(filters: Pgit_filter_list; repo: Pgit_repository; path: PAnsiChar; 232 | target: Pgit_writestream): Integer; cdecl; external libgit2_dll; 233 | 234 | (** 235 | * Apply a filter list to a blob as a stream 236 | * 237 | * @param filters the list of filters to apply 238 | * @param blob the blob to filter 239 | * @param target the stream into which the data will be written 240 | * @return 0 or an error code. 241 | *) 242 | 243 | function git_filter_list_stream_blob(filters: Pgit_filter_list; blob: Pgit_blob; 244 | target: Pgit_writestream): Integer; cdecl; external libgit2_dll; 245 | 246 | (** 247 | * Free a git_filter_list 248 | * 249 | * @param filters A git_filter_list created by `git_filter_list_load` 250 | *) 251 | 252 | procedure git_filter_list_free(filters: Pgit_filter_list); cdecl; external libgit2_dll; 253 | 254 | (** @} *) 255 | 256 | 257 | 258 | -------------------------------------------------------------------------------- /src/git2/global.inc: -------------------------------------------------------------------------------- 1 | (** 2 | * @file git2/global.h 3 | * @brief libgit2 library initializer and shutdown functionality 4 | * @ingroup Git 5 | * @{ 6 | *) 7 | 8 | (** 9 | * Init the global state 10 | * 11 | * This function must be called before any other libgit2 function in 12 | * order to set up global state and threading. 13 | * 14 | * This function may be called multiple times - it will return the number 15 | * of times the initialization has been called (including this one) that have 16 | * not subsequently been shutdown. 17 | * 18 | * @return the number of initializations of the library, or an error code. 19 | *) 20 | 21 | function git_libgit2_init: Integer; cdecl; external libgit2_dll; 22 | 23 | (** 24 | * Shutdown the global state 25 | * 26 | * Clean up the global state and threading context after calling it as 27 | * many times as `git_libgit2_init()` was called - it will return the 28 | * number of remainining initializations that have not been shutdown 29 | * (after this one). 30 | * 31 | * @return the number of remaining initializations of the library, or an 32 | * error code. 33 | *) 34 | 35 | function git_libgit2_shutdown: Integer; cdecl; external libgit2_dll; 36 | 37 | (** @} *) 38 | 39 | -------------------------------------------------------------------------------- /src/git2/graph.inc: -------------------------------------------------------------------------------- 1 | (** 2 | * @file git2/graph.h 3 | * @brief Graph traversal routines 4 | * @defgroup git_revwalk Git graph traversal routines 5 | * @ingroup Git 6 | * @{ 7 | *) 8 | 9 | (** 10 | * Count the number of unique commits between two commit objects 11 | * 12 | * There is no need for branches containing the commits to have any 13 | * upstream relationship, but it helps to think of one as a branch and 14 | * the other as its upstream, the `ahead` and `behind` values will be 15 | * what git would report for the branches. 16 | * 17 | * @param ahead number of unique from commits in `upstream` 18 | * @param behind number of unique from commits in `local` 19 | * @param repo the repository where the commits exist 20 | * @param local the commit for local 21 | * @param upstream the commit for upstream 22 | * @return 0 or an error code. 23 | *) 24 | 25 | function git_graph_ahead_behind(ahead, behind: Psize_t; repo: Pgit_repository; 26 | local_, upstream: Pgit_oid): Integer; cdecl; external libgit2_dll; 27 | 28 | (** 29 | * Determine if a commit is the descendant of another commit. 30 | * 31 | * Note that a commit is not considered a descendant of itself, in contrast 32 | * to `git merge-base --is-ancestor`. 33 | * 34 | * @param repo the repository where the commits exist 35 | * @param commit a previously loaded commit 36 | * @param ancestor a potential ancestor commit 37 | * @return 1 if the given commit is a descendant of the potential ancestor, 38 | * 0 if not, error code otherwise. 39 | *) 40 | 41 | function git_graph_descendant_of(repo: Pgit_repository; commit, ancestor: Pgit_oid): Integer; cdecl; external libgit2_dll; 42 | 43 | (** 44 | * Determine if a commit is reachable from any of a list of commits by 45 | * following parent edges. 46 | * 47 | * @param repo the repository where the commits exist 48 | * @param commit a previously loaded commit 49 | * @param descendant_array oids of the commits 50 | * @param length the number of commits in the provided `descendant_array` 51 | * @return 1 if the given commit is an ancestor of any of the given potential 52 | * descendants, 0 if not, error code otherwise. 53 | *) 54 | 55 | function git_graph_reachable_from_any(repo: Pgit_repository; commit: Pgit_oid; 56 | descendant_array: Pgit_oid; Length: size_t): Integer; cdecl; external libgit2_dll; 57 | 58 | (** @} *) 59 | 60 | 61 | 62 | -------------------------------------------------------------------------------- /src/git2/ignore.inc: -------------------------------------------------------------------------------- 1 | (** 2 | * @file git2/ignore.h 3 | * @brief Ignore particular untracked files 4 | * @ingroup Git 5 | * @{ 6 | * 7 | * When examining the repository status, git can optionally ignore 8 | * specified untracked files. 9 | *) 10 | 11 | (** 12 | * Add ignore rules for a repository. 13 | * 14 | * Excludesfile rules (i.e. .gitignore rules) are generally read from 15 | * .gitignore files in the repository tree or from a shared system file 16 | * only if a "core.excludesfile" config value is set. The library also 17 | * keeps a set of per-repository internal ignores that can be configured 18 | * in-memory and will not persist. This function allows you to add to 19 | * that internal rules list. 20 | * 21 | * Example usage: 22 | * 23 | * error = git_ignore_add_rule(myrepo, "*.c\ndir/\nFile with space\n"); 24 | * 25 | * This would add three rules to the ignores. 26 | * 27 | * @param repo The repository to add ignore rules to. 28 | * @param rules Text of rules, the contents to add on a .gitignore file. 29 | * It is okay to have multiple rules in the text; if so, 30 | * each rule should be terminated with a newline. 31 | * @return 0 on success 32 | *) 33 | 34 | function git_ignore_add_rule(repo: Pgit_repository; rules: PAnsiChar): Integer; cdecl; external libgit2_dll; 35 | 36 | (** 37 | * Clear ignore rules that were explicitly added. 38 | * 39 | * Resets to the default internal ignore rules. This will not turn off 40 | * rules in .gitignore files that actually exist in the filesystem. 41 | * 42 | * The default internal ignores ignore ".", ".." and ".git" entries. 43 | * 44 | * @param repo The repository to remove ignore rules from. 45 | * @return 0 on success 46 | *) 47 | 48 | function git_ignore_clear_internal_rules(repo: Pgit_repository): Integer; cdecl; external libgit2_dll; 49 | 50 | (** 51 | * Test if the ignore rules apply to a given path. 52 | * 53 | * This function checks the ignore rules to see if they would apply to the 54 | * given file. This indicates if the file would be ignored regardless of 55 | * whether the file is already in the index or committed to the repository. 56 | * 57 | * One way to think of this is if you were to do "git check-ignore --no-index" 58 | * on the given file, would it be shown or not? 59 | * 60 | * @param ignored boolean returning 0 if the file is not ignored, 1 if it is 61 | * @param repo a repository object 62 | * @param path the file to check ignores for, relative to the repo's workdir. 63 | * @return 0 if ignore rules could be processed for the file (regardless 64 | * of whether it exists or not), or an error < 0 if they could not. 65 | *) 66 | 67 | function git_ignore_path_is_ignored(ignored: PInteger; repo: Pgit_repository; 68 | path: PAnsiChar): Integer; cdecl; external libgit2_dll; 69 | 70 | -------------------------------------------------------------------------------- /src/git2/indexer.inc: -------------------------------------------------------------------------------- 1 | (** 2 | * @file git2/indexer.h 3 | * @brief Packfile indexing 4 | * @ingroup Git 5 | * @{ 6 | * 7 | * Indexing is the operation of taking a packfile - which is simply a 8 | * collection of unordered commits - and producing an "index" so that 9 | * one can lookup a commit in the packfile by object ID. 10 | *) 11 | 12 | (** A git indexer object *) 13 | 14 | type 15 | git_indexer = record 16 | end; 17 | PPgit_indexer = ^Pgit_indexer; 18 | Pgit_indexer = ^git_indexer; 19 | 20 | (** 21 | * This structure is used to provide callers information about the 22 | * progress of indexing a packfile, either directly or part of a 23 | * fetch or clone that downloads a packfile. 24 | *) 25 | 26 | git_indexer_progress = record 27 | (** number of objects in the packfile being indexed *) 28 | total_objects: Cardinal; 29 | (** received objects that have been hashed *) 30 | indexed_objects: Cardinal; 31 | (** received_objects: objects which have been downloaded *) 32 | received_objects: Cardinal; 33 | (** 34 | * locally-available objects that have been injected in order 35 | * to fix a thin pack 36 | *) 37 | local_objects: Cardinal; 38 | (** number of deltas in the packfile being indexed *) 39 | total_deltas: Cardinal; 40 | (** received deltas that have been indexed *) 41 | indexed_deltas: Cardinal; 42 | (** size of the packfile received up to now *) 43 | received_bytes: size_t; 44 | end; 45 | Pgit_indexer_progress = ^git_indexer_progress; 46 | 47 | (** 48 | * Type for progress callbacks during indexing. Return a value less 49 | * than zero to cancel the indexing or download. 50 | * 51 | * @param stats Structure containing information about the state of the tran sfer 52 | * @param payload Payload provided by caller 53 | *) 54 | 55 | type 56 | git_indexer_progress_cb = function(stats: Pgit_indexer_progress; payload: Pointer): Integer; cdecl; 57 | 58 | (** 59 | * Options for indexer configuration 60 | *) 61 | 62 | type 63 | git_indexer_options = record 64 | version: Cardinal; 65 | {$IFDEF GIT_EXPERIMENTAL_SHA256} 66 | (** permissions to use creating packfile or 0 for defaults *) 67 | mode: Cardinal; 68 | (** the type of object ids in the packfile or 0 for SHA1 *) 69 | oid_type: git_oid_t; 70 | (** 71 | * object database from which to read base objects when 72 | * fixing thin packs. This can be NULL if there are no thin 73 | * packs; if a thin pack is encountered, an error will be 74 | * returned if there are bases missing. 75 | *) 76 | odb: Pgit_odb; 77 | {$ENDIF} 78 | (** progress_cb function to call with progress information *) 79 | progress_cb: git_indexer_progress_cb; 80 | (** progress_cb_payload payload for the progress callback *) 81 | progress_cb_payload: Pointer; 82 | (** Do connectivity checks for the received pack *) 83 | verify: Byte; 84 | end; 85 | Pgit_indexer_options = ^git_indexer_options; 86 | 87 | const 88 | (** Current version for the `git_indexer_options` structure *) 89 | GIT_INDEXER_OPTIONS_VERSION = 1; 90 | (** Static constructor for `git_indexer_options` *) 91 | //GIT_INDEXER_OPTIONS_INIT = { GIT_INDEXER_OPTIONS_VERSION }; 92 | (** 93 | * Initializes a `git_indexer_options` with default values. Equivalent to 94 | * creating an instance with GIT_INDEXER_OPTIONS_INIT. 95 | * 96 | * @param opts the `git_indexer_options` struct to initialize. 97 | * @param version Version of struct; pass `GIT_INDEXER_OPTIONS_VERSION` 98 | * @return Zero on success; -1 on failure. 99 | *) 100 | 101 | function git_indexer_options_init(opts: Pgit_indexer_options; version: Cardinal): Integer; cdecl; external libgit2_dll; 102 | 103 | {$IFDEF GIT_EXPERIMENTAL_SHA256} 104 | (** 105 | * Create a new indexer instance 106 | * 107 | * @param out where to store the indexer instance 108 | * @param path to the directory where the packfile should be stored 109 | * @param opts the options to create the indexer with 110 | * @return 0 or an error code. 111 | *) 112 | function git_indexer_new(out_: PPgit_indexer; path: PAnsiChar; 113 | opts: Pgit_indexer_options): Integer; cdecl; external libgit2_dll; 114 | {$ELSE} 115 | (** 116 | * Create a new indexer instance 117 | * 118 | * @param out where to store the indexer instance 119 | * @param path to the directory where the packfile should be stored 120 | * @param mode permissions to use creating packfile or 0 for defaults 121 | * @param odb object database from which to read base objects when 122 | * fixing thin packs. Pass NULL if no thin pack is expected (an error 123 | * will be returned if there are bases missing) 124 | * @param opts Optional structure containing additional options. See 125 | * `git_indexer_options` above. 126 | * @return 0 or an error code. 127 | *) 128 | 129 | function git_indexer_new(out_: PPgit_indexer; path: PAnsiChar; mode: Cardinal; odb: Pgit_odb; 130 | opts: Pgit_indexer_options): Integer; cdecl; external libgit2_dll; 131 | {$ENDIF} 132 | 133 | (** 134 | * Add data to the indexer 135 | * 136 | * @param idx the indexer 137 | * @param data the data to add 138 | * @param size the size of the data in bytes 139 | * @param stats stat storage 140 | * @return 0 or an error code. 141 | *) 142 | function git_indexer_append(idx: Pgit_indexer; data: Pointer; size: size_t; 143 | stats: Pgit_indexer_progress): Integer; cdecl; external libgit2_dll; 144 | 145 | (** 146 | * Finalize the pack and index 147 | * 148 | * Resolve any pending deltas and write out the index file 149 | * 150 | * @param idx the indexer 151 | * @param stats Stat storage. 152 | * @return 0 or an error code. 153 | *) 154 | 155 | function git_indexer_commit(idx: Pgit_indexer; stats: Pgit_indexer_progress): Integer; cdecl; external libgit2_dll; 156 | 157 | {$IFNDEF GIT_DEPRECATE_HARD} 158 | (** 159 | * Get the packfile's hash 160 | * 161 | * A packfile's name is derived from the sorted hashing of all object 162 | * names. This is only correct after the index has been finalized. 163 | * 164 | * @deprecated use git_indexer_name 165 | * @param idx the indexer instance 166 | * @return the packfile's hash 167 | *) 168 | 169 | function git_indexer_hash(idx: Pgit_indexer): Pgit_oid; cdecl; external libgit2_dll; 170 | {$ENDIF} 171 | 172 | (** 173 | * Get the unique name for the resulting packfile. 174 | * 175 | * The packfile's name is derived from the packfile's content. 176 | * This is only correct after the index has been finalized. 177 | * 178 | * @param idx the indexer instance 179 | * @return a NUL terminated string for the packfile name 180 | *) 181 | function git_indexer_name(idx: Pgit_indexer): PAnsiChar; cdecl; external libgit2_dll; 182 | 183 | (** 184 | * Free the indexer and its resources 185 | * 186 | * @param idx the indexer to free 187 | *) 188 | 189 | procedure git_indexer_free(idx: Pgit_indexer); cdecl; external libgit2_dll; 190 | 191 | 192 | 193 | -------------------------------------------------------------------------------- /src/git2/mailmap.inc: -------------------------------------------------------------------------------- 1 | (** 2 | * @file git2/mailmap.h 3 | * @brief Mailmaps provide alternate email addresses for users 4 | * @defgroup git_mailmap Git mailmap routines 5 | * @ingroup Git 6 | * @{ 7 | * 8 | * A mailmap can be used to specify alternate email addresses for 9 | * repository committers or authors. This allows systems to map 10 | * commits made using different email addresses to the same logical 11 | * person. 12 | *) 13 | 14 | (** 15 | * Allocate a new mailmap object. 16 | * 17 | * This object is empty, so you'll have to add a mailmap file before you can do 18 | * anything with it. The mailmap must be freed with 'git_mailmap_free'. 19 | * 20 | * @param out pointer to store the new mailmap 21 | * @return 0 on success, or an error code 22 | *) 23 | 24 | function git_mailmap_new(out_: PPgit_mailmap): Integer; cdecl; external libgit2_dll; 25 | 26 | (** 27 | * Free the mailmap and its associated memory. 28 | * 29 | * @param mm the mailmap to free 30 | *) 31 | 32 | procedure git_mailmap_free(mm: Pgit_mailmap); cdecl; external libgit2_dll; 33 | 34 | (** 35 | * Add a single entry to the given mailmap object. If the entry already exists, 36 | * it will be replaced with the new entry. 37 | * 38 | * @param mm mailmap to add the entry to 39 | * @param real_name the real name to use, or NULL 40 | * @param real_email the real email to use, or NULL 41 | * @param replace_name the name to replace, or NULL 42 | * @param replace_email the email to replace 43 | * @return 0 on success, or an error code 44 | *) 45 | 46 | function git_mailmap_add_entry(mm: Pgit_mailmap; 47 | real_name, real_email, replace_name, replace_email: PAnsiChar): Integer; cdecl; external libgit2_dll; 48 | 49 | (** 50 | * Create a new mailmap instance containing a single mailmap file 51 | * 52 | * @param out pointer to store the new mailmap 53 | * @param buf buffer to parse the mailmap from 54 | * @param len the length of the input buffer 55 | * @return 0 on success, or an error code 56 | *) 57 | 58 | function git_mailmap_from_buffer(out_: PPgit_mailmap; buf: PAnsiChar; len: size_t): Integer; cdecl; external libgit2_dll; 59 | 60 | (** 61 | * Create a new mailmap instance from a repository, loading mailmap files based 62 | * on the repository's configuration. 63 | * 64 | * Mailmaps are loaded in the following order: 65 | * 1. '.mailmap' in the root of the repository's working directory, if present. 66 | * 2. The blob object identified by the 'mailmap.blob' config entry, if set. 67 | * [NOTE: 'mailmap.blob' defaults to 'HEAD:.mailmap' in bare repositories] 68 | * 3. The path in the 'mailmap.file' config entry, if set. 69 | * 70 | * @param out pointer to store the new mailmap 71 | * @param repo repository to load mailmap information from 72 | * @return 0 on success, or an error code 73 | *) 74 | 75 | function git_mailmap_from_repository(out_: PPgit_mailmap; repo: Pgit_repository): Integer; cdecl; external libgit2_dll; 76 | 77 | (** 78 | * Resolve a name and email to the corresponding real name and email. 79 | * 80 | * The lifetime of the strings are tied to `mm`, `name`, and `email` parameters. 81 | * 82 | * @param real_name pointer to store the real name 83 | * @param real_email pointer to store the real email 84 | * @param mm the mailmap to perform a lookup with (may be NULL) 85 | * @param name the name to look up 86 | * @param email the email to look up 87 | * @return 0 on success, or an error code 88 | *) 89 | 90 | function git_mailmap_resolve(real_name, real_email: PPAnsiChar; mm: Pgit_mailmap; 91 | name_, email: PAnsiChar): Integer; cdecl; external libgit2_dll; 92 | 93 | (** 94 | * Resolve a signature to use real names and emails with a mailmap. 95 | * 96 | * Call `git_signature_free()` to free the data. 97 | * 98 | * @param out new signature 99 | * @param mm mailmap to resolve with 100 | * @param sig signature to resolve 101 | * @return 0 or an error code 102 | *) 103 | 104 | function git_mailmap_resolve_signature(out_: PPgit_signature; mm: Pgit_mailmap; 105 | sig: Pgit_signature): Integer; cdecl; external libgit2_dll; 106 | 107 | (** @} *) 108 | 109 | 110 | -------------------------------------------------------------------------------- /src/git2/message.inc: -------------------------------------------------------------------------------- 1 | (** 2 | * @file git2/message.h 3 | * @brief Commit messages 4 | * @ingroup Git 5 | * @{ 6 | *) 7 | 8 | (** 9 | * Clean up excess whitespace and make sure there is a trailing newline in the message. 10 | * 11 | * Optionally, it can remove lines which start with the comment character. 12 | * 13 | * @param out The user-allocated git_buf which will be filled with the 14 | * cleaned up message. 15 | * 16 | * @param message The message to be prettified. 17 | * 18 | * @param strip_comments Non-zero to remove comment lines, 0 to leave them in. 19 | * 20 | * @param comment_char Comment character. Lines starting with this character 21 | * are considered to be comments and removed if `strip_comments` is non-zero. 22 | * 23 | * @return 0 or an error code. 24 | *) 25 | 26 | function git_message_prettify(out_: Pgit_buf; message: PAnsiChar; strip_comments: Integer; 27 | comment_char: AnsiChar): Integer; cdecl; external libgit2_dll; 28 | 29 | (** 30 | * Represents a single git message trailer. 31 | *) 32 | 33 | type 34 | git_message_trailer = record 35 | key: PAnsiChar; 36 | Value: PAnsiChar; 37 | end; 38 | Pgit_message_trailer = ^git_message_trailer; 39 | 40 | (** 41 | * Represents an array of git message trailers. 42 | * 43 | * Struct members under the private comment are private, subject to change 44 | * and should not be used by callers. 45 | *) 46 | 47 | type 48 | git_message_trailer_array = record 49 | trailers: Pgit_message_trailer; 50 | Count: size_t; 51 | (* private *) 52 | _trailer_block: PAnsiChar; 53 | end; 54 | Pgit_message_trailer_array = ^git_message_trailer_array; 55 | 56 | (** 57 | * Parse trailers out of a message, filling the array pointed to by +arr+. 58 | * 59 | * Trailers are key/value pairs in the last paragraph of a message, not 60 | * including any patches or conflicts that may be present. 61 | * 62 | * @param arr A pre-allocated git_message_trailer_array struct to be filled in 63 | * with any trailers found during parsing. 64 | * @param message The message to be parsed 65 | * @return 0 on success, or non-zero on error. 66 | *) 67 | 68 | function git_message_trailers(arr: Pgit_message_trailer_array; message: PAnsiChar): Integer; cdecl; external libgit2_dll; 69 | 70 | (** 71 | * Clean's up any allocated memory in the git_message_trailer_array filled by 72 | * a call to git_message_trailers. 73 | * 74 | * @param arr The trailer to free. 75 | *) 76 | 77 | procedure git_message_trailer_array_free(arr: Pgit_message_trailer_array); cdecl; external libgit2_dll; 78 | 79 | (** @} *) 80 | 81 | 82 | 83 | -------------------------------------------------------------------------------- /src/git2/net.inc: -------------------------------------------------------------------------------- 1 | (** 2 | * @file git2/net.h 3 | * @brief Low-level networking functionality 4 | * @ingroup Git 5 | * @{ 6 | *) 7 | 8 | const 9 | (** Default git protocol port number *) 10 | GIT_DEFAULT_PORT = '9418'; 11 | (** 12 | * Direction of the connection. 13 | * 14 | * We need this because we need to know whether we should call 15 | * git-upload-pack or git-receive-pack on the remote end when get_refs 16 | * gets called. 17 | *) 18 | 19 | const 20 | GIT_DIRECTION_FETCH = 0; 21 | GIT_DIRECTION_PUSH = 1; 22 | type 23 | git_direction = Integer; 24 | 25 | (** 26 | * Description of a reference advertised by a remote server, given out 27 | * on `ls` calls. 28 | *) 29 | 30 | git_remote_head = record 31 | local_: Integer; (* available locally *) 32 | oid: git_oid; 33 | loid: git_oid; 34 | name_: PAnsiChar; 35 | (** 36 | * If the server send a symref mapping for this ref, this will 37 | * point to the target. 38 | *) 39 | symref_target: PAnsiChar; 40 | end; 41 | Pgit_remote_head = ^git_remote_head; 42 | PPgit_remote_head = ^Pgit_remote_head; 43 | PPPgit_remote_head = ^PPgit_remote_head; 44 | 45 | (** @} *) 46 | 47 | 48 | -------------------------------------------------------------------------------- /src/git2/notes.inc: -------------------------------------------------------------------------------- 1 | (** 2 | * @file git2/notes.h 3 | * @brief Notes are metadata attached to an object 4 | * @defgroup git_note Git notes management routines 5 | * @ingroup Git 6 | * @{ 7 | *) 8 | 9 | (** 10 | * Callback for git_note_foreach. 11 | * 12 | * @param blob_id object id of the blob containing the message 13 | * @param annotated_object_id the id of the object being annotated 14 | * @param payload user-specified data to the foreach function 15 | * @return 0 on success, or a negative number on failure 16 | *) 17 | 18 | type 19 | git_note_foreach_cb = function(blob_id, annotated_object_id: Pgit_oid; payload: Pointer): Integer; cdecl; 20 | 21 | (** 22 | * note iterator 23 | *) 24 | 25 | git_iterator = record 26 | end; 27 | git_note_iterator = git_iterator; 28 | PPgit_note_iterator = ^Pgit_note_iterator; 29 | Pgit_note_iterator = ^git_note_iterator; 30 | 31 | (** 32 | * Creates a new iterator for notes 33 | * 34 | * The iterator must be freed manually by the user. 35 | * 36 | * @param out pointer to the iterator 37 | * @param repo repository where to look up the note 38 | * @param notes_ref canonical name of the reference to use (optional); defaults to 39 | * "refs/notes/commits" 40 | * 41 | * @return 0 or an error code 42 | *) 43 | 44 | function git_note_iterator_new(out_: PPgit_note_iterator; repo: Pgit_repository; 45 | notes_ref: PAnsiChar): Integer; cdecl; external libgit2_dll; 46 | 47 | (** 48 | * Creates a new iterator for notes from a commit 49 | * 50 | * The iterator must be freed manually by the user. 51 | * 52 | * @param out pointer to the iterator 53 | * @param notes_commit a pointer to the notes commit object 54 | * 55 | * @return 0 or an error code 56 | *) 57 | 58 | function git_note_commit_iterator_new(out_: PPgit_note_iterator; notes_commit: Pgit_commit): Integer; cdecl; external libgit2_dll; 59 | 60 | (** 61 | * Frees an git_note_iterator 62 | * 63 | * @param it pointer to the iterator 64 | *) 65 | 66 | procedure git_note_iterator_free(it: Pgit_note_iterator); cdecl; external libgit2_dll; 67 | 68 | (** 69 | * Return the current item (note_id and annotated_id) and advance the iterator 70 | * internally to the next value 71 | * 72 | * @param note_id id of blob containing the message 73 | * @param annotated_id id of the git object being annotated 74 | * @param it pointer to the iterator 75 | * 76 | * @return 0 (no error), GIT_ITEROVER (iteration is done) or an error code 77 | * (negative value) 78 | *) 79 | 80 | function git_note_next(note_id, annotated_id: Pgit_oid; it: Pgit_note_iterator): Integer; cdecl; external libgit2_dll; 81 | 82 | (** 83 | * Read the note for an object 84 | * 85 | * The note must be freed manually by the user. 86 | * 87 | * @param out pointer to the read note; NULL in case of error 88 | * @param repo repository where to look up the note 89 | * @param notes_ref canonical name of the reference to use (optional); defaults to 90 | * "refs/notes/commits" 91 | * @param oid OID of the git object to read the note from 92 | * 93 | * @return 0 or an error code 94 | *) 95 | 96 | function git_note_read(out_: PPgit_note; repo: Pgit_repository; notes_ref: PAnsiChar; 97 | oid: Pgit_oid): Integer; cdecl; external libgit2_dll; 98 | 99 | (** 100 | * Read the note for an object from a note commit 101 | * 102 | * The note must be freed manually by the user. 103 | * 104 | * @param out pointer to the read note; NULL in case of error 105 | * @param repo repository where to look up the note 106 | * @param notes_commit a pointer to the notes commit object 107 | * @param oid OID of the git object to read the note from 108 | * 109 | * @return 0 or an error code 110 | *) 111 | 112 | function git_note_commit_read(out_: PPgit_note; repo: Pgit_repository; notes_commit: Pgit_commit; 113 | oid: Pgit_oid): Integer; cdecl; external libgit2_dll; 114 | 115 | (** 116 | * Get the note author 117 | * 118 | * @param note the note 119 | * @return the author 120 | *) 121 | 122 | function git_note_author(note: Pgit_note): Pgit_signature; cdecl; external libgit2_dll; 123 | 124 | (** 125 | * Get the note committer 126 | * 127 | * @param note the note 128 | * @return the committer 129 | *) 130 | 131 | function git_note_committer(note: Pgit_note): Pgit_signature; cdecl; external libgit2_dll; 132 | 133 | (** 134 | * Get the note message 135 | * 136 | * @param note the note 137 | * @return the note message 138 | *) 139 | 140 | function git_note_message(note: Pgit_note): PAnsiChar; cdecl; external libgit2_dll; 141 | 142 | (** 143 | * Get the note object's id 144 | * 145 | * @param note the note 146 | * @return the note object's id 147 | *) 148 | 149 | function git_note_id(note: Pgit_note): Pgit_oid; cdecl; external libgit2_dll; 150 | 151 | (** 152 | * Add a note for an object 153 | * 154 | * @param out pointer to store the OID (optional); NULL in case of error 155 | * @param repo repository where to store the note 156 | * @param notes_ref canonical name of the reference to use (optional); 157 | * defaults to "refs/notes/commits" 158 | * @param author signature of the notes commit author 159 | * @param committer signature of the notes commit committer 160 | * @param oid OID of the git object to decorate 161 | * @param note Content of the note to add for object oid 162 | * @param force Overwrite existing note 163 | * 164 | * @return 0 or an error code 165 | *) 166 | 167 | function git_note_create(out_: Pgit_oid; repo: Pgit_repository; notes_ref: PAnsiChar; 168 | author, committer: Pgit_signature; oid: Pgit_oid; note: PAnsiChar; force: Integer): Integer; cdecl; external libgit2_dll; 169 | 170 | (** 171 | * Add a note for an object from a commit 172 | * 173 | * This function will create a notes commit for a given object, 174 | * the commit is a dangling commit, no reference is created. 175 | * 176 | * @param notes_commit_out pointer to store the commit (optional); 177 | * NULL in case of error 178 | * @param notes_blob_out a point to the id of a note blob (optional) 179 | * @param repo repository where the note will live 180 | * @param parent Pointer to parent note 181 | * or NULL if this shall start a new notes tree 182 | * @param author signature of the notes commit author 183 | * @param committer signature of the notes commit committer 184 | * @param oid OID of the git object to decorate 185 | * @param note Content of the note to add for object oid 186 | * @param allow_note_overwrite Overwrite existing note 187 | * 188 | * @return 0 or an error code 189 | *) 190 | 191 | function git_note_commit_create(notes_commit_out, notes_blob_out: Pgit_oid; repo: Pgit_repository; 192 | parent: Pgit_commit; author, committer: Pgit_signature; oid: Pgit_oid; note: PAnsiChar; 193 | allow_note_overwrite: Integer): Integer; cdecl; external libgit2_dll; 194 | 195 | (** 196 | * Remove the note for an object 197 | * 198 | * @param repo repository where the note lives 199 | * @param notes_ref canonical name of the reference to use (optional); 200 | * defaults to "refs/notes/commits" 201 | * @param author signature of the notes commit author 202 | * @param committer signature of the notes commit committer 203 | * @param oid OID of the git object to remove the note from 204 | * 205 | * @return 0 or an error code 206 | *) 207 | 208 | function git_note_remove(repo: Pgit_repository; notes_ref: PAnsiChar; 209 | author, committer: Pgit_signature; oid: Pgit_oid): Integer; cdecl; external libgit2_dll; 210 | 211 | (** 212 | * Remove the note for an object 213 | * 214 | * @param notes_commit_out pointer to store the new notes commit (optional); 215 | * NULL in case of error. 216 | * When removing a note a new tree containing all notes 217 | * sans the note to be removed is created and a new commit 218 | * pointing to that tree is also created. 219 | * In the case where the resulting tree is an empty tree 220 | * a new commit pointing to this empty tree will be returned. 221 | * @param repo repository where the note lives 222 | * @param notes_commit a pointer to the notes commit object 223 | * @param author signature of the notes commit author 224 | * @param committer signature of the notes commit committer 225 | * @param oid OID of the git object to remove the note from 226 | * 227 | * @return 0 or an error code 228 | *) 229 | 230 | function git_note_commit_remove(notes_commit_out: Pgit_oid; repo: Pgit_repository; notes_commit: Pgit_commit; 231 | author, committer: Pgit_signature; oid: Pgit_oid): Integer; cdecl; external libgit2_dll; 232 | 233 | (** 234 | * Free a git_note object 235 | * 236 | * @param note git_note object 237 | *) 238 | 239 | procedure git_note_free(note: Pgit_note); cdecl; external libgit2_dll; 240 | 241 | (** 242 | * Get the default notes reference for a repository 243 | * 244 | * @param out buffer in which to store the name of the default notes reference 245 | * @param repo The Git repository 246 | * 247 | * @return 0 or an error code 248 | *) 249 | 250 | function git_note_default_ref(out_: Pgit_buf; repo: Pgit_repository): Integer; cdecl; external libgit2_dll; 251 | 252 | (** 253 | * Loop over all the notes within a specified namespace 254 | * and issue a callback for each one. 255 | * 256 | * @param repo Repository where to find the notes. 257 | * 258 | * @param notes_ref Reference to read from (optional); defaults to 259 | * "refs/notes/commits". 260 | * 261 | * @param note_cb Callback to invoke per found annotation. Return non-zero 262 | * to stop looping. 263 | * 264 | * @param payload Extra parameter to callback function. 265 | * 266 | * @return 0 on success, non-zero callback return value, or error code 267 | *) 268 | 269 | function git_note_foreach(repo: Pgit_repository; notes_ref: PAnsiChar; note_cb: git_note_foreach_cb; 270 | payload: Pointer): Integer; cdecl; external libgit2_dll; 271 | 272 | (** @} *) 273 | 274 | 275 | 276 | -------------------------------------------------------------------------------- /src/git2/object.inc: -------------------------------------------------------------------------------- 1 | (** 2 | * @file git2/object.h 3 | * @brief Objects are blobs (files), trees (directories), commits, and annotated tags 4 | * @defgroup git_object Git revision object management routines 5 | * @ingroup Git 6 | * @{ 7 | *) 8 | 9 | const 10 | (** Maximum size of a git object *) 11 | GIT_OBJECT_SIZE_MAX = UINT64_MAX; 12 | (** 13 | * Lookup a reference to one of the objects in a repository. 14 | * 15 | * The generated reference is owned by the repository and 16 | * should be closed with the `git_object_free` method 17 | * instead of free'd manually. 18 | * 19 | * The 'type' parameter must match the type of the object 20 | * in the odb; the method will fail otherwise. 21 | * The special value 'GIT_OBJECT_ANY' may be passed to let 22 | * the method guess the object's type. 23 | * 24 | * @param object pointer to the looked-up object 25 | * @param repo the repository to look up the object 26 | * @param id the unique identifier for the object 27 | * @param type the type of the object 28 | * @return 0 or an error code 29 | *) 30 | 31 | function git_object_lookup(object_: PPgit_object; repo: Pgit_repository; id: Pgit_oid; 32 | type_: git_object_t): Integer; cdecl; external libgit2_dll; 33 | 34 | (** 35 | * Lookup a reference to one of the objects in a repository, 36 | * given a prefix of its identifier (short id). 37 | * 38 | * The object obtained will be so that its identifier 39 | * matches the first 'len' hexadecimal characters 40 | * (packets of 4 bits) of the given `id`. `len` must be 41 | * at least `GIT_OID_MINPREFIXLEN`, and long enough to 42 | * identify a unique object matching the prefix; otherwise 43 | * the method will fail. 44 | * 45 | * The generated reference is owned by the repository and 46 | * should be closed with the `git_object_free` method 47 | * instead of free'd manually. 48 | * 49 | * The `type` parameter must match the type of the object 50 | * in the odb; the method will fail otherwise. 51 | * The special value `GIT_OBJECT_ANY` may be passed to let 52 | * the method guess the object's type. 53 | * 54 | * @param object_out pointer where to store the looked-up object 55 | * @param repo the repository to look up the object 56 | * @param id a short identifier for the object 57 | * @param len the length of the short identifier 58 | * @param type the type of the object 59 | * @return 0 or an error code 60 | *) 61 | 62 | function git_object_lookup_prefix(object_out: PPgit_object; repo: Pgit_repository; id: Pgit_oid; 63 | len: size_t; type_: git_object_t): Integer; cdecl; external libgit2_dll; 64 | 65 | (** 66 | * Lookup an object that represents a tree entry. 67 | * 68 | * @param out buffer that receives a pointer to the object (which must be freed 69 | * by the caller) 70 | * @param treeish root object that can be peeled to a tree 71 | * @param path relative path from the root object to the desired object 72 | * @param type type of object desired 73 | * @return 0 on success, or an error code 74 | *) 75 | 76 | function git_object_lookup_bypath(out_: PPgit_object; treeish: Pgit_object; path: PAnsiChar; 77 | type_: git_object_t): Integer; cdecl; external libgit2_dll; 78 | 79 | (** 80 | * Get the id (SHA1) of a repository object 81 | * 82 | * @param obj the repository object 83 | * @return the SHA1 id 84 | *) 85 | 86 | function git_object_id(obj: Pgit_object): Pgit_oid; cdecl; external libgit2_dll; 87 | 88 | (** 89 | * Get a short abbreviated OID string for the object 90 | * 91 | * This starts at the "core.abbrev" length (default 7 characters) and 92 | * iteratively extends to a longer string if that length is ambiguous. 93 | * The result will be unambiguous (at least until new objects are added to 94 | * the repository). 95 | * 96 | * @param out Buffer to write string into 97 | * @param obj The object to get an ID for 98 | * @return 0 on success, <0 for error 99 | *) 100 | 101 | function git_object_short_id(out_: Pgit_buf; obj: Pgit_object): Integer; cdecl; external libgit2_dll; 102 | 103 | (** 104 | * Get the object type of an object 105 | * 106 | * @param obj the repository object 107 | * @return the object's type 108 | *) 109 | 110 | function git_object_type(obj: Pgit_object): git_object_t; cdecl; external libgit2_dll; 111 | 112 | (** 113 | * Get the repository that owns this object 114 | * 115 | * Freeing or calling `git_repository_close` on the 116 | * returned pointer will invalidate the actual object. 117 | * 118 | * Any other operation may be run on the repository without 119 | * affecting the object. 120 | * 121 | * @param obj the object 122 | * @return the repository who owns this object 123 | *) 124 | 125 | function git_object_owner(obj: Pgit_object): Pgit_repository; cdecl; external libgit2_dll; 126 | 127 | (** 128 | * Close an open object 129 | * 130 | * This method instructs the library to close an existing 131 | * object; note that git_objects are owned and cached by the repository 132 | * so the object may or may not be freed after this library call, 133 | * depending on how aggressive is the caching mechanism used 134 | * by the repository. 135 | * 136 | * IMPORTANT: 137 | * It *is* necessary to call this method when you stop using 138 | * an object. Failure to do so will cause a memory leak. 139 | * 140 | * @param object the object to close 141 | *) 142 | 143 | procedure git_object_free(object_: Pgit_object); cdecl; external libgit2_dll; 144 | 145 | (** 146 | * Convert an object type to its string representation. 147 | * 148 | * The result is a pointer to a string in static memory and 149 | * should not be free()'ed. 150 | * 151 | * @param type object type to convert. 152 | * @return the corresponding string representation. 153 | *) 154 | 155 | function git_object_type2string(type_: git_object_t): PAnsiChar; cdecl; external libgit2_dll; 156 | 157 | (** 158 | * Convert a string object type representation to it's git_object_t. 159 | * 160 | * @param str the string to convert. 161 | * @return the corresponding git_object_t. 162 | *) 163 | 164 | function git_object_string2type(str: PAnsiChar): git_object_t; cdecl; external libgit2_dll; 165 | 166 | (** 167 | * Determine if the given git_object_t is a valid loose object type. 168 | * 169 | * @param type object type to test. 170 | * @return true if the type represents a valid loose object type, 171 | * false otherwise. 172 | *) 173 | 174 | function git_object_typeisloose(type_: git_object_t): Integer; cdecl; external libgit2_dll; 175 | 176 | (** 177 | * Recursively peel an object until an object of the specified type is met. 178 | * 179 | * If the query cannot be satisfied due to the object model, 180 | * GIT_EINVALIDSPEC will be returned (e.g. trying to peel a blob to a 181 | * tree). 182 | * 183 | * If you pass `GIT_OBJECT_ANY` as the target type, then the object will 184 | * be peeled until the type changes. A tag will be peeled until the 185 | * referenced object is no longer a tag, and a commit will be peeled 186 | * to a tree. Any other object type will return GIT_EINVALIDSPEC. 187 | * 188 | * If peeling a tag we discover an object which cannot be peeled to 189 | * the target type due to the object model, GIT_EPEEL will be 190 | * returned. 191 | * 192 | * You must free the returned object. 193 | * 194 | * @param peeled Pointer to the peeled git_object 195 | * @param object The object to be processed 196 | * @param target_type The type of the requested object (a GIT_OBJECT_ value) 197 | * @return 0 on success, GIT_EINVALIDSPEC, GIT_EPEEL, or an error code 198 | *) 199 | 200 | function git_object_peel(peeled: PPgit_object; object_: Pgit_object; 201 | target_type: git_object_t): Integer; cdecl; external libgit2_dll; 202 | 203 | (** 204 | * Create an in-memory copy of a Git object. The copy must be 205 | * explicitly free'd or it will leak. 206 | * 207 | * @param dest Pointer to store the copy of the object 208 | * @param source Original object to copy 209 | * @return 0 or an error code 210 | *) 211 | 212 | function git_object_dup(dest: PPgit_object; source: Pgit_object): Integer; cdecl; external libgit2_dll; 213 | 214 | {$IFDEF GIT_EXPERIMENTAL_SHA256} 215 | (** 216 | * Analyzes a buffer of raw object content and determines its validity. 217 | * Tree, commit, and tag objects will be parsed and ensured that they 218 | * are valid, parseable content. (Blobs are always valid by definition.) 219 | * An error message will be set with an informative message if the object 220 | * is not valid. 221 | * 222 | * @warning This function is experimental and its signature may change in 223 | * the future. 224 | * 225 | * @param valid Output pointer to set with validity of the object content 226 | * @param buf The contents to validate 227 | * @param len The length of the buffer 228 | * @param object_type The type of the object in the buffer 229 | * @param oid_type The object ID type for the OIDs in the given buffer 230 | * @return 0 on success or an error code 231 | *) 232 | 233 | function git_object_rawcontent_is_valid(valid: PInteger; buf: PAnsiChar; len: size_t; 234 | type_: git_object_t; oid_type: git_oid_t): Integer; cdecl; external libgit2_dll; 235 | 236 | {$ELSE} 237 | (** 238 | * Analyzes a buffer of raw object content and determines its validity. 239 | * Tree, commit, and tag objects will be parsed and ensured that they 240 | * are valid, parseable content. (Blobs are always valid by definition.) 241 | * An error message will be set with an informative message if the object 242 | * is not valid. 243 | * 244 | * @warning This function is experimental and its signature may change in 245 | * the future. 246 | * 247 | * @param[out] valid Output pointer to set with validity of the object content 248 | * @param buf The contents to validate 249 | * @param len The length of the buffer 250 | * @param object_type The type of the object in the buffer 251 | * @return 0 on success or an error code 252 | *) 253 | function git_object_rawcontent_is_valid(valid: PInteger; buf: PAnsiChar; len: size_t; 254 | type_: git_object_t): Integer; cdecl; external libgit2_dll; 255 | {$ENDIF} 256 | 257 | (** @} *) 258 | 259 | -------------------------------------------------------------------------------- /src/git2/odb_backend.inc: -------------------------------------------------------------------------------- 1 | (** 2 | * @file git2/backend.h 3 | * @brief Object database backends manage the storage of git objects 4 | * @defgroup git_odb Git object database routines 5 | * @ingroup Git 6 | * @{ 7 | *) 8 | 9 | (** Options for configuring a packfile object backend. *) 10 | type 11 | git_odb_backend_pack_options = record 12 | version: Cardinal; (**< version for the struct *) 13 | 14 | (** 15 | * Type of object IDs to use for this object database, or 16 | * 0 for default (currently SHA1). 17 | *) 18 | oid_type: git_oid_t; 19 | end; 20 | Pgit_odb_backend_pack_options = ^git_odb_backend_pack_options; 21 | 22 | const 23 | (** The current version of the diff options structure *) 24 | GIT_ODB_BACKEND_PACK_OPTIONS_VERSION = 1; 25 | 26 | (** 27 | * Stack initializer for odb pack backend options. Alternatively use 28 | * `git_odb_backend_pack_options_init` programmatic initialization. 29 | *) 30 | //#DEFINE GIT_ODB_BACKEND_PACK_OPTIONS_INIT { GIT_ODB_BACKEND_PACK_OPTIONS_VERSION } 31 | 32 | const 33 | GIT_ODB_BACKEND_LOOSE_FSYNC = (1 shl 0); 34 | type 35 | git_odb_backend_loose_flag_t = Integer; 36 | 37 | (** Options for configuring a loose object backend. *) 38 | type 39 | git_odb_backend_loose_options = record 40 | version: Cardinal; (**< version for the struct *) 41 | 42 | (** A combination of the `git_odb_backend_loose_flag_t` types. *) 43 | flags: uint32_t; 44 | 45 | (** 46 | * zlib compression level to use (0-9), where 1 is the fastest 47 | * at the expense of larger files, and 9 produces the best 48 | * compression at the expense of speed. 0 indicates that no 49 | * compression should be performed. -1 is the default (currently 50 | * optimizing for speed). 51 | *) 52 | compression_level: Integer; 53 | 54 | (** Permissions to use creating a directory or 0 for defaults *) 55 | dir_mode: Cardinal; 56 | 57 | (** Permissions to use creating a file or 0 for defaults *) 58 | file_mode: Cardinal; 59 | 60 | (** 61 | * Type of object IDs to use for this object database, or 62 | * 0 for default (currently SHA1). 63 | *) 64 | oid_type: git_oid_t; 65 | end; 66 | Pgit_odb_backend_loose_options = ^git_odb_backend_loose_options; 67 | 68 | const 69 | (** The current version of the diff options structure *) 70 | GIT_ODB_BACKEND_LOOSE_OPTIONS_VERSION = 1; 71 | 72 | (** 73 | * Stack initializer for odb loose backend options. Alternatively use 74 | * `git_odb_backend_loose_options_init` programmatic initialization. 75 | *) 76 | //#define GIT_ODB_BACKEND_LOOSE_OPTIONS_INIT { GIT_ODB_BACKEND_LOOSE_OPTIONS_VERSION, 0, -1 } 77 | 78 | (* 79 | * Constructors for in-box ODB backends. 80 | *) 81 | 82 | {$IFDEF GIT_EXPERIMENTAL_SHA256} 83 | 84 | (** 85 | * Create a backend for a directory containing packfiles. 86 | * 87 | * @param[out] out location to store the odb backend pointer 88 | * @param objects_dir the Git repository's objects directory 89 | * @param opts the options to use when creating the pack backend 90 | * @return 0 or an error code 91 | *) 92 | function git_odb_backend_pack(out_: PPgit_odb_backend; objects_dir: PAnsiChar; 93 | opts: Pgit_odb_backend_pack_options): Integer; cdecl; external libgit2_dll; 94 | 95 | (** 96 | * Create a backend for a single packfile. 97 | * 98 | * @param[out] out location to store the odb backend pointer 99 | * @param index_file path to the packfile's .idx file 100 | * @param opts the options to use when creating the pack backend 101 | * @return 0 or an error code 102 | *) 103 | function git_odb_backend_one_pack(out_: PPgit_odb_backend; index_file: PAnsiChar; 104 | opts: Pgit_odb_backend_pack_options): Integer; cdecl; external libgit2_dll; 105 | 106 | (** 107 | * Create a backend for loose objects 108 | * 109 | * @param[out] out location to store the odb backend pointer 110 | * @param objects_dir the Git repository's objects directory 111 | * @param opts options for the loose object backend or NULL 112 | * 113 | * @return 0 or an error code 114 | *) 115 | function git_odb_backend_loose(out_: PPgit_odb_backend; objects_dir: PAnsiChar; 116 | opts: Pgit_odb_backend_loose_options): Integer; cdecl; external libgit2_dll; 117 | 118 | {$ELSE} 119 | 120 | (** 121 | * Create a backend for a directory containing packfiles. 122 | * 123 | * @param[out] out location to store the odb backend pointer 124 | * @param objects_dir the Git repository's objects directory 125 | * @return 0 or an error code 126 | *) 127 | function git_odb_backend_pack(out_: PPgit_odb_backend; objects_dir: PAnsiChar): Integer; cdecl; external libgit2_dll; 128 | 129 | (** 130 | * Create a backend out of a single packfile 131 | * 132 | * This can be useful for inspecting the contents of a single 133 | * packfile. 134 | * 135 | * @param[out] out location to store the odb backend pointer 136 | * @param index_file path to the packfile's .idx file 137 | * @return 0 or an error code 138 | *) 139 | function git_odb_backend_one_pack(out_: PPgit_odb_backend; index_file: PAnsiChar): Integer; cdecl; external libgit2_dll; 140 | 141 | (** 142 | * Create a backend for loose objects 143 | * 144 | * @param[out] out location to store the odb backend pointer 145 | * @param objects_dir the Git repository's objects directory 146 | * @param compression_level zlib compression level (0-9), or -1 for the default 147 | * @param do_fsync if non-zero, perform an fsync on write 148 | * @param dir_mode permission to use when creating directories, or 0 for default 149 | * @param file_mode permission to use when creating directories, or 0 for default 150 | * @return 0 or an error code 151 | *) 152 | function git_odb_backend_loose(out_: PPgit_odb_backend; objects_dir: PAnsiChar; compression_level, do_fsync: Integer; 153 | dir_mode, file_mode: Cardinal): Integer; cdecl; external libgit2_dll; 154 | 155 | {$ENDIF} 156 | 157 | (** Streaming mode *) 158 | 159 | const 160 | GIT_STREAM_RDONLY = (1 shl 1); 161 | GIT_STREAM_WRONLY = (1 shl 2); 162 | GIT_STREAM_RW = (GIT_STREAM_RDONLY or GIT_STREAM_WRONLY); 163 | type 164 | git_odb_stream_t = Integer; 165 | 166 | (** 167 | * A stream to read/write from a backend. 168 | * 169 | * This represents a stream of data being written to or read from a 170 | * backend. When writing, the frontend functions take care of 171 | * calculating the object's id and all `finalize_write` needs to do is 172 | * store the object with the id it is passed. 173 | *) 174 | 175 | Pgit_odb_stream = ^git_odb_stream; 176 | PPgit_odb_stream = ^Pgit_odb_stream; 177 | git_odb_stream = record 178 | backend: Pgit_odb_backend; 179 | mode: Cardinal; 180 | hash_ctx: Pointer; 181 | declared_size: git_object_size_t; 182 | received_bytes: git_object_size_t; 183 | (** 184 | * Write at most `len` bytes into `buffer` and advance the stream. 185 | *) 186 | read_: function(stream: Pgit_odb_stream; buffer: PAnsiChar; len: size_t): Integer; cdecl; 187 | (** 188 | * Write `len` bytes from `buffer` into the stream. 189 | *) 190 | write_: function(stream: Pgit_odb_stream; buffer: PAnsiChar; len: size_t): Integer; cdecl; 191 | (** 192 | * Store the contents of the stream as an object with the id 193 | * specified in `oid`. 194 | * 195 | * This method might not be invoked if: 196 | * - an error occurs earlier with the `write` callback, 197 | * - the object referred to by `oid` already exists in any backend, or 198 | * - the final number of received bytes differs from the size declared 199 | * with `git_odb_open_wstream()` 200 | *) 201 | finalize_write: function(stream: Pgit_odb_stream; oid: Pgit_oid): Integer; cdecl; 202 | (** 203 | * Free the stream's memory. 204 | * 205 | * This method might be called without a call to `finalize_write` if 206 | * an error occurs or if the object is already present in the ODB. 207 | *) 208 | Free: procedure(stream: Pgit_odb_stream); cdecl; 209 | end; 210 | 211 | (** A stream to write a pack file to the ODB *) 212 | 213 | type 214 | Pgit_odb_writepack = ^git_odb_writepack; 215 | PPgit_odb_writepack = ^Pgit_odb_writepack; 216 | git_odb_writepack = record 217 | backend: Pgit_odb_backend; 218 | append: function(writepack: Pgit_odb_writepack; data: Pointer; size: size_t; 219 | stats: Pgit_indexer_progress): Integer; cdecl; 220 | commit: function(writepack: Pgit_odb_writepack; 221 | stats: Pgit_indexer_progress) : Integer; cdecl; 222 | Free: procedure(writepack: Pgit_odb_writepack); cdecl; 223 | end; 224 | 225 | 226 | 227 | -------------------------------------------------------------------------------- /src/git2/oidarray.inc: -------------------------------------------------------------------------------- 1 | (** 2 | * @file git2/oidarray.h 3 | * @brief An array of object IDs 4 | * @defgroup git_oidarray Arrays of object IDs 5 | * @ingroup Git 6 | * @{ 7 | *) 8 | 9 | (** Array of object ids *) 10 | 11 | type 12 | git_oidarray = record 13 | ids: Pgit_oid; 14 | Count: size_t; 15 | end; 16 | 17 | (** 18 | * Free the object IDs contained in an oid_array. This method should 19 | * be called on `git_oidarray` objects that were provided by the 20 | * library. Not doing so will result in a memory leak. 21 | * 22 | * This does not free the `git_oidarray` itself, since the library will 23 | * never allocate that object directly itself. 24 | * 25 | * @param array git_oidarray from which to free oid data 26 | *) 27 | 28 | type 29 | Pgit_oidarray = ^git_oidarray; 30 | 31 | procedure git_oidarray_dispose(array_: Pgit_oidarray); cdecl; external libgit2_dll; 32 | 33 | (** @} *) 34 | 35 | 36 | -------------------------------------------------------------------------------- /src/git2/pack.inc: -------------------------------------------------------------------------------- 1 | (** 2 | * @file git2/pack.h 3 | * @brief Git pack management routines 4 | * 5 | * Packing objects 6 | * --------------- 7 | * 8 | * Creation of packfiles requires two steps: 9 | * 10 | * - First, insert all the objects you want to put into the packfile 11 | * using `git_packbuilder_insert` and `git_packbuilder_insert_tree`. 12 | * It's important to add the objects in recency order ("in the order 13 | * that they are 'reachable' from head"). 14 | * 15 | * "ANY order will give you a working pack, ... [but it is] the thing 16 | * that gives packs good locality. It keeps the objects close to the 17 | * head (whether they are old or new, but they are _reachable_ from the 18 | * head) at the head of the pack. So packs actually have absolutely 19 | * _wonderful_ IO patterns." - Linus Torvalds 20 | * git.git/Documentation/technical/pack-heuristics.txt 21 | * 22 | * - Second, use `git_packbuilder_write` or `git_packbuilder_foreach` to 23 | * write the resulting packfile. 24 | * 25 | * libgit2 will take care of the delta ordering and generation. 26 | * `git_packbuilder_set_threads` can be used to adjust the number of 27 | * threads used for the process. 28 | * 29 | * See tests/pack/packbuilder.c for an example. 30 | * 31 | * @ingroup Git 32 | * @{ 33 | *) 34 | 35 | (** 36 | * Stages that are reported by the packbuilder progress callback. 37 | *) 38 | 39 | const 40 | GIT_PACKBUILDER_ADDING_OBJECTS = 0; 41 | GIT_PACKBUILDER_DELTAFICATION = 1; 42 | type 43 | git_packbuilder_stage_t = Integer; 44 | 45 | (** 46 | * Initialize a new packbuilder 47 | * 48 | * @param out The new packbuilder object 49 | * @param repo The repository 50 | * 51 | * @return 0 or an error code 52 | *) 53 | 54 | function git_packbuilder_new(out_: PPgit_packbuilder; repo: Pgit_repository): Integer; cdecl; external libgit2_dll; 55 | 56 | (** 57 | * Set number of threads to spawn 58 | * 59 | * By default, libgit2 won't spawn any threads at all; 60 | * when set to 0, libgit2 will autodetect the number of 61 | * CPUs. 62 | * 63 | * @param pb The packbuilder 64 | * @param n Number of threads to spawn 65 | * @return number of actual threads to be used 66 | *) 67 | 68 | function git_packbuilder_set_threads(pb: Pgit_packbuilder; n: Cardinal): Cardinal; cdecl; external libgit2_dll; 69 | 70 | (** 71 | * Insert a single object 72 | * 73 | * For an optimal pack it's mandatory to insert objects in recency order, 74 | * commits followed by trees and blobs. 75 | * 76 | * @param pb The packbuilder 77 | * @param id The oid of the commit 78 | * @param name The name; might be NULL 79 | * 80 | * @return 0 or an error code 81 | *) 82 | 83 | function git_packbuilder_insert(pb: Pgit_packbuilder; id: Pgit_oid; name_: PAnsiChar): Integer; cdecl; external libgit2_dll; 84 | 85 | (** 86 | * Insert a root tree object 87 | * 88 | * This will add the tree as well as all referenced trees and blobs. 89 | * 90 | * @param pb The packbuilder 91 | * @param id The oid of the root tree 92 | * 93 | * @return 0 or an error code 94 | *) 95 | 96 | function git_packbuilder_insert_tree(pb: Pgit_packbuilder; id: Pgit_oid): Integer; cdecl; external libgit2_dll; 97 | 98 | (** 99 | * Insert a commit object 100 | * 101 | * This will add a commit as well as the completed referenced tree. 102 | * 103 | * @param pb The packbuilder 104 | * @param id The oid of the commit 105 | * 106 | * @return 0 or an error code 107 | *) 108 | 109 | function git_packbuilder_insert_commit(pb: Pgit_packbuilder; id: Pgit_oid): Integer; cdecl; external libgit2_dll; 110 | 111 | (** 112 | * Insert objects as given by the walk 113 | * 114 | * Those commits and all objects they reference will be inserted into 115 | * the packbuilder. 116 | * 117 | * @param pb the packbuilder 118 | * @param walk the revwalk to use to fill the packbuilder 119 | * 120 | * @return 0 or an error code 121 | *) 122 | 123 | function git_packbuilder_insert_walk(pb: Pgit_packbuilder; walk: Pgit_revwalk): Integer; cdecl; external libgit2_dll; 124 | 125 | (** 126 | * Recursively insert an object and its referenced objects 127 | * 128 | * Insert the object as well as any object it references. 129 | * 130 | * @param pb the packbuilder 131 | * @param id the id of the root object to insert 132 | * @param name optional name for the object 133 | * @return 0 or an error code 134 | *) 135 | 136 | function git_packbuilder_insert_recur(pb: Pgit_packbuilder; id: Pgit_oid; name_: PAnsiChar): Integer; cdecl; external libgit2_dll; 137 | 138 | (** 139 | * Write the contents of the packfile to an in-memory buffer 140 | * 141 | * The contents of the buffer will become a valid packfile, even though there 142 | * will be no attached index 143 | * 144 | * @param buf Buffer where to write the packfile 145 | * @param pb The packbuilder 146 | * @return 0 or an error code 147 | *) 148 | 149 | function git_packbuilder_write_buf(buf: Pgit_buf; pb: Pgit_packbuilder): Integer; cdecl; external libgit2_dll; 150 | 151 | (** 152 | * Write the new pack and corresponding index file to path. 153 | * 154 | * @param pb The packbuilder 155 | * @param path Path to the directory where the packfile and index should be stored, or NULL for default location 156 | * @param mode permissions to use creating a packfile or 0 for defaults 157 | * @param progress_cb function to call with progress information from the indexer (optional) 158 | * @param progress_cb_payload payload for the progress callback (optional) 159 | * 160 | * @return 0 or an error code 161 | *) 162 | 163 | function git_packbuilder_write(pb: Pgit_packbuilder; path: PAnsiChar; mode: Cardinal; 164 | progress_cb: git_indexer_progress_cb; progress_cb_payload: Pointer): Integer; cdecl; external libgit2_dll; 165 | 166 | {$IFNDEF GIT_DEPRECATE_HARD} 167 | (** 168 | * Get the packfile's hash 169 | * 170 | * A packfile's name is derived from the sorted hashing of all object 171 | * names. This is only correct after the packfile has been written. 172 | * 173 | * @deprecated use git_packbuilder_name 174 | * @param pb The packbuilder object 175 | * @return 0 or an error code 176 | *) 177 | 178 | function git_packbuilder_hash(pb: Pgit_packbuilder): Pgit_oid; cdecl; external libgit2_dll; 179 | {$ENDIF} 180 | 181 | (** 182 | * Get the unique name for the resulting packfile. 183 | * 184 | * The packfile's name is derived from the packfile's content. 185 | * This is only correct after the packfile has been written. 186 | * 187 | * @param pb the packbuilder instance 188 | * @return a NUL terminated string for the packfile name 189 | *) 190 | function git_packbuilder_name(pb: Pgit_packbuilder): PAnsiChar; cdecl; external libgit2_dll; 191 | 192 | (** 193 | * Callback used to iterate over packed objects 194 | * 195 | * @see git_packbuilder_foreach 196 | * 197 | * @param buf A pointer to the object's data 198 | * @param size The size of the underlying object 199 | * @param payload Payload passed to git_packbuilder_foreach 200 | * @return non-zero to terminate the iteration 201 | *) 202 | 203 | type 204 | git_packbuilder_foreach_cb = function(buf: Pointer; size: size_t; 205 | payload: Pointer): Integer; cdecl; 206 | 207 | (** 208 | * Create the new pack and pass each object to the callback 209 | * 210 | * @param pb the packbuilder 211 | * @param cb the callback to call with each packed object's buffer 212 | * @param payload the callback's data 213 | * @return 0 or an error code 214 | *) 215 | 216 | function git_packbuilder_foreach(pb: Pgit_packbuilder; cb: git_packbuilder_foreach_cb; 217 | payload: Pointer): Integer; cdecl; external libgit2_dll; 218 | 219 | (** 220 | * Get the total number of objects the packbuilder will write out 221 | * 222 | * @param pb the packbuilder 223 | * @return the number of objects in the packfile 224 | *) 225 | 226 | function git_packbuilder_object_count(pb: Pgit_packbuilder): size_t; cdecl; external libgit2_dll; 227 | 228 | (** 229 | * Get the number of objects the packbuilder has already written out 230 | * 231 | * @param pb the packbuilder 232 | * @return the number of objects which have already been written 233 | *) 234 | 235 | function git_packbuilder_written(pb: Pgit_packbuilder): size_t; cdecl; external libgit2_dll; 236 | 237 | (** 238 | * Packbuilder progress notification function. 239 | * 240 | * @param stage the stage of the packbuilder 241 | * @param current the current object 242 | * @param total the total number of objects 243 | * @param payload the callback payload 244 | * @return 0 on success or an error code 245 | *) 246 | 247 | type 248 | git_packbuilder_progress = function(stage: Integer; current, total: uint32_t; payload: Pointer): Integer; cdecl; 249 | 250 | (** 251 | * Set the callbacks for a packbuilder 252 | * 253 | * @param pb The packbuilder object 254 | * @param progress_cb Function to call with progress information during 255 | * pack building. Be aware that this is called inline with pack building 256 | * operations, so performance may be affected. 257 | * When progress_cb returns an error, the pack building process will be 258 | * aborted and the error will be returned from the invoked function. 259 | * `pb` must then be freed. 260 | * @param progress_cb_payload Payload for progress callback. 261 | * @return 0 or an error code 262 | *) 263 | 264 | function git_packbuilder_set_callbacks(pb: Pgit_packbuilder; progress_cb: git_packbuilder_progress; 265 | progress_cb_payload: Pointer): Integer; cdecl; external libgit2_dll; 266 | 267 | (** 268 | * Free the packbuilder and all associated data 269 | * 270 | * @param pb The packbuilder 271 | *) 272 | 273 | procedure git_packbuilder_free(pb: Pgit_packbuilder); cdecl; external libgit2_dll; 274 | 275 | (** @} *) 276 | 277 | 278 | 279 | -------------------------------------------------------------------------------- /src/git2/patch.inc: -------------------------------------------------------------------------------- 1 | (** 2 | * @file git2/patch.h 3 | * @brief Patches store the textual diffs in a delta 4 | * @ingroup Git 5 | * @{ 6 | *) 7 | 8 | (** 9 | * The diff patch is used to store all the text diffs for a delta. 10 | * 11 | * You can easily loop over the content of patches and get information about 12 | * them. 13 | *) 14 | 15 | type 16 | git_patch = record 17 | end; 18 | 19 | (** 20 | * Get the repository associated with this patch. May be NULL. 21 | * 22 | * @param patch the patch 23 | * @return a pointer to the repository 24 | *) 25 | 26 | type 27 | PPgit_patch = ^Pgit_patch; 28 | Pgit_patch = ^git_patch; 29 | 30 | (** 31 | * Get the repository associated with this patch. May be NULL. 32 | * 33 | * @param patch the patch 34 | * @return a pointer to the repository 35 | *) 36 | 37 | function git_patch_owner(patch: Pgit_patch): Pgit_repository; cdecl; external libgit2_dll; 38 | 39 | (** 40 | * Return a patch for an entry in the diff list. 41 | * 42 | * The `git_patch` is a newly created object contains the text diffs 43 | * for the delta. You have to call `git_patch_free()` when you are 44 | * done with it. You can use the patch object to loop over all the hunks 45 | * and lines in the diff of the one delta. 46 | * 47 | * For an unchanged file or a binary file, no `git_patch` will be 48 | * created, the output will be set to NULL, and the `binary` flag will be 49 | * set true in the `git_diff_delta` structure. 50 | * 51 | * It is okay to pass NULL for either of the output parameters; if you pass 52 | * NULL for the `git_patch`, then the text diff will not be calculated. 53 | * 54 | * @param out Output parameter for the delta patch object 55 | * @param diff Diff list object 56 | * @param idx Index into diff list 57 | * @return 0 on success, other value < 0 on error 58 | *) 59 | 60 | function git_patch_from_diff(out_: PPgit_patch; diff: Pgit_diff; idx: size_t): Integer; cdecl; external libgit2_dll; 61 | 62 | (** 63 | * Directly generate a patch from the difference between two blobs. 64 | * 65 | * This is just like `git_diff_blobs()` except it generates a patch object 66 | * for the difference instead of directly making callbacks. You can use the 67 | * standard `git_patch` accessor functions to read the patch data, and 68 | * you must call `git_patch_free()` on the patch when done. 69 | * 70 | * @param out The generated patch; NULL on error 71 | * @param old_blob Blob for old side of diff, or NULL for empty blob 72 | * @param old_as_path Treat old blob as if it had this filename; can be NULL 73 | * @param new_blob Blob for new side of diff, or NULL for empty blob 74 | * @param new_as_path Treat new blob as if it had this filename; can be NULL 75 | * @param opts Options for diff, or NULL for default options 76 | * @return 0 on success or error code < 0 77 | *) 78 | 79 | function git_patch_from_blobs(out_: PPgit_patch; old_blob: Pgit_blob; old_as_path: PAnsiChar; 80 | new_blob: Pgit_blob; new_as_path: PAnsiChar; opts: Pgit_diff_options): Integer; cdecl; external libgit2_dll; 81 | 82 | (** 83 | * Directly generate a patch from the difference between a blob and a buffer. 84 | * 85 | * This is just like `git_diff_blob_to_buffer()` except it generates a patch 86 | * object for the difference instead of directly making callbacks. You can 87 | * use the standard `git_patch` accessor functions to read the patch 88 | * data, and you must call `git_patch_free()` on the patch when done. 89 | * 90 | * @param out The generated patch; NULL on error 91 | * @param old_blob Blob for old side of diff, or NULL for empty blob 92 | * @param old_as_path Treat old blob as if it had this filename; can be NULL 93 | * @param buffer Raw data for new side of diff, or NULL for empty 94 | * @param buffer_len Length of raw data for new side of diff 95 | * @param buffer_as_path Treat buffer as if it had this filename; can be NULL 96 | * @param opts Options for diff, or NULL for default options 97 | * @return 0 on success or error code < 0 98 | *) 99 | 100 | function git_patch_from_blob_and_buffer(out_: PPgit_patch; old_blob: Pgit_blob; old_as_path: PAnsiChar; 101 | buffer: Pointer; buffer_len: size_t; buffer_as_path: PAnsiChar; opts: Pgit_diff_options): Integer; cdecl; external libgit2_dll; 102 | 103 | (** 104 | * Directly generate a patch from the difference between two buffers. 105 | * 106 | * This is just like `git_diff_buffers()` except it generates a patch 107 | * object for the difference instead of directly making callbacks. You can 108 | * use the standard `git_patch` accessor functions to read the patch 109 | * data, and you must call `git_patch_free()` on the patch when done. 110 | * 111 | * @param out The generated patch; NULL on error 112 | * @param old_buffer Raw data for old side of diff, or NULL for empty 113 | * @param old_len Length of the raw data for old side of the diff 114 | * @param old_as_path Treat old buffer as if it had this filename; can be NULL 115 | * @param new_buffer Raw data for new side of diff, or NULL for empty 116 | * @param new_len Length of raw data for new side of diff 117 | * @param new_as_path Treat buffer as if it had this filename; can be NULL 118 | * @param opts Options for diff, or NULL for default options 119 | * @return 0 on success or error code < 0 120 | *) 121 | 122 | function git_patch_from_buffers(out_: PPgit_patch; old_buffer: Pointer; old_len: size_t; 123 | old_as_path: PAnsiChar; new_buffer: Pointer; new_len: size_t; new_as_path: PAnsiChar; 124 | opts: Pgit_diff_options): Integer; cdecl; external libgit2_dll; 125 | 126 | (** 127 | * Free a git_patch object. 128 | * 129 | * @param patch The patch to free. 130 | *) 131 | 132 | procedure git_patch_free(patch: Pgit_patch); cdecl; external libgit2_dll; 133 | 134 | (** 135 | * Get the delta associated with a patch. This delta points to internal 136 | * data and you do not have to release it when you are done with it. 137 | * 138 | * @param patch The patch in which to get the delta. 139 | * @return The delta associated with the patch. 140 | *) 141 | 142 | function git_patch_get_delta(patch: Pgit_patch): Pgit_diff_delta; cdecl; external libgit2_dll; 143 | 144 | (** 145 | * Get the number of hunks in a patch 146 | * 147 | * @param patch The patch in which to get the number of hunks. 148 | * @return The number of hunks of the patch. 149 | *) 150 | 151 | function git_patch_num_hunks(patch: Pgit_patch): size_t; cdecl; external libgit2_dll; 152 | 153 | (** 154 | * Get line counts of each type in a patch. 155 | * 156 | * This helps imitate a diff --numstat type of output. For that purpose, 157 | * you only need the `total_additions` and `total_deletions` values, but we 158 | * include the `total_context` line count in case you want the total number 159 | * of lines of diff output that will be generated. 160 | * 161 | * All outputs are optional. Pass NULL if you don't need a particular count. 162 | * 163 | * @param total_context Count of context lines in output, can be NULL. 164 | * @param total_additions Count of addition lines in output, can be NULL. 165 | * @param total_deletions Count of deletion lines in output, can be NULL. 166 | * @param patch The git_patch object 167 | * @return 0 on success, <0 on error 168 | *) 169 | 170 | function git_patch_line_stats(total_context, total_additions, total_deletions: Psize_t; 171 | patch: Pgit_patch): Integer; cdecl; external libgit2_dll; 172 | 173 | (** 174 | * Get the information about a hunk in a patch 175 | * 176 | * Given a patch and a hunk index into the patch, this returns detailed 177 | * information about that hunk. Any of the output pointers can be passed 178 | * as NULL if you don't care about that particular piece of information. 179 | * 180 | * @param out Output pointer to git_diff_hunk of hunk 181 | * @param lines_in_hunk Output count of total lines in this hunk 182 | * @param patch Input pointer to patch object 183 | * @param hunk_idx Input index of hunk to get information about 184 | * @return 0 on success, GIT_ENOTFOUND if hunk_idx out of range, <0 on error 185 | *) 186 | 187 | type 188 | PPgit_diff_hunk = ^Pgit_diff_hunk; 189 | function git_patch_get_hunk(out_: PPgit_diff_hunk; lines_in_hunk: Psize_t; patch: Pgit_patch; 190 | hunk_idx: size_t): Integer; cdecl; external libgit2_dll; 191 | 192 | (** 193 | * Get the number of lines in a hunk. 194 | * 195 | * @param patch The git_patch object 196 | * @param hunk_idx Index of the hunk 197 | * @return Number of lines in hunk or GIT_ENOTFOUND if invalid hunk index 198 | *) 199 | 200 | function git_patch_num_lines_in_hunk(patch: Pgit_patch; hunk_idx: size_t): Integer; cdecl; external libgit2_dll; 201 | 202 | (** 203 | * Get data about a line in a hunk of a patch. 204 | * 205 | * Given a patch, a hunk index, and a line index in the hunk, this 206 | * will return a lot of details about that line. If you pass a hunk 207 | * index larger than the number of hunks or a line index larger than 208 | * the number of lines in the hunk, this will return -1. 209 | * 210 | * @param out The git_diff_line data for this line 211 | * @param patch The patch to look in 212 | * @param hunk_idx The index of the hunk 213 | * @param line_of_hunk The index of the line in the hunk 214 | * @return 0 on success, <0 on failure 215 | *) 216 | 217 | type 218 | PPgit_diff_line = ^Pgit_diff_line; 219 | function git_patch_get_line_in_hunk(out_: PPgit_diff_line; patch: Pgit_patch; 220 | hunk_idx, line_of_hunk: size_t): Integer; cdecl; external libgit2_dll; 221 | 222 | (** 223 | * Look up size of patch diff data in bytes 224 | * 225 | * This returns the raw size of the patch data. This only includes the 226 | * actual data from the lines of the diff, not the file or hunk headers. 227 | * 228 | * If you pass `include_context` as true (non-zero), this will be the size 229 | * of all of the diff output; if you pass it as false (zero), this will 230 | * only include the actual changed lines (as if `context_lines` was 0). 231 | * 232 | * @param patch A git_patch representing changes to one file 233 | * @param include_context Include context lines in size if non-zero 234 | * @param include_hunk_headers Include hunk header lines if non-zero 235 | * @param include_file_headers Include file header lines if non-zero 236 | * @return The number of bytes of data 237 | *) 238 | 239 | function git_patch_size(patch: Pgit_patch; 240 | include_context, include_hunk_headers, include_file_headers: Integer): size_t; cdecl; external libgit2_dll; 241 | 242 | (** 243 | * Serialize the patch to text via callback. 244 | * 245 | * Returning a non-zero value from the callback will terminate the iteration 246 | * and return that value to the caller. 247 | * 248 | * @param patch A git_patch representing changes to one file 249 | * @param print_cb Callback function to output lines of the patch. Will be 250 | * called for file headers, hunk headers, and diff lines. 251 | * @param payload Reference pointer that will be passed to your callbacks. 252 | * @return 0 on success, non-zero callback return value, or error code 253 | *) 254 | 255 | function git_patch_print(patch: Pgit_patch; print_cb: git_diff_line_cb; 256 | payload: Pointer): Integer; cdecl; external libgit2_dll; 257 | 258 | (** 259 | * Get the content of a patch as a single diff text. 260 | * 261 | * @param out The git_buf to be filled in 262 | * @param patch A git_patch representing changes to one file 263 | * @return 0 on success, <0 on failure. 264 | *) 265 | 266 | function git_patch_to_buf(out_: Pgit_buf; patch: Pgit_patch): Integer; cdecl; external libgit2_dll; 267 | 268 | (**@} *) 269 | 270 | 271 | 272 | -------------------------------------------------------------------------------- /src/git2/pathspec.inc: -------------------------------------------------------------------------------- 1 | (** 2 | * @file git2/pathspec.h 3 | * @brief Specifiers for path matching 4 | * @defgroup git_pathspec Specifiers for path matching 5 | * @ingroup Git 6 | * @{ 7 | *) 8 | 9 | (** 10 | * Compiled pathspec 11 | *) 12 | 13 | type 14 | git_pathspec = record 15 | end; 16 | 17 | (** 18 | * List of filenames matching a pathspec 19 | *) 20 | 21 | git_pathspec_match_list = record 22 | end; 23 | 24 | (** 25 | * Options controlling how pathspec match should be executed 26 | *) 27 | 28 | const 29 | GIT_PATHSPEC_DEFAULT = 0; 30 | (** 31 | * GIT_PATHSPEC_IGNORE_CASE forces match to ignore case; otherwise 32 | * match will use native case sensitivity of platform filesystem 33 | *) 34 | GIT_PATHSPEC_IGNORE_CASE = (1 shl 0); 35 | (** 36 | * GIT_PATHSPEC_USE_CASE forces case sensitive match; otherwise 37 | * match will use native case sensitivity of platform filesystem 38 | *) 39 | GIT_PATHSPEC_USE_CASE = (1 shl 1); 40 | (** 41 | * GIT_PATHSPEC_NO_GLOB disables glob patterns and just uses simple 42 | * string comparison for matching 43 | *) 44 | GIT_PATHSPEC_NO_GLOB = (1 shl 2); 45 | (** 46 | * GIT_PATHSPEC_NO_MATCH_ERROR means the match functions return error 47 | * code GIT_ENOTFOUND if no matches are found; otherwise no matches is 48 | * still success (return 0) but `git_pathspec_match_list_entrycount` 49 | * will indicate 0 matches. 50 | *) 51 | GIT_PATHSPEC_NO_MATCH_ERROR = (1 shl 3); 52 | (** 53 | * GIT_PATHSPEC_FIND_FAILURES means that the `git_pathspec_match_list` 54 | * should track which patterns matched which files so that at the end of 55 | * the match we can identify patterns that did not match any files. 56 | *) 57 | GIT_PATHSPEC_FIND_FAILURES = (1 shl 4); 58 | (** 59 | * GIT_PATHSPEC_FAILURES_ONLY means that the `git_pathspec_match_list` 60 | * does not need to keep the actual matching filenames. Use this to 61 | * just test if there were any matches at all or in combination with 62 | * GIT_PATHSPEC_FIND_FAILURES to validate a pathspec. 63 | *) 64 | GIT_PATHSPEC_FAILURES_ONLY = (1 shl 5); 65 | type 66 | git_pathspec_flag_t = Integer; 67 | 68 | (** 69 | * Compile a pathspec 70 | * 71 | * @param out Output of the compiled pathspec 72 | * @param pathspec A git_strarray of the paths to match 73 | * @return 0 on success, <0 on failure 74 | *) 75 | 76 | type 77 | PPgit_pathspec = ^Pgit_pathspec; 78 | Pgit_pathspec = ^git_pathspec; 79 | function git_pathspec_new(out_: PPgit_pathspec; pathspec: Pgit_strarray): Integer; cdecl; external libgit2_dll; 80 | 81 | (** 82 | * Free a pathspec 83 | * 84 | * @param ps The compiled pathspec 85 | *) 86 | 87 | procedure git_pathspec_free(ps: Pgit_pathspec); cdecl; external libgit2_dll; 88 | 89 | (** 90 | * Try to match a path against a pathspec 91 | * 92 | * Unlike most of the other pathspec matching functions, this will not 93 | * fall back on the native case-sensitivity for your platform. You must 94 | * explicitly pass flags to control case sensitivity or else this will 95 | * fall back on being case sensitive. 96 | * 97 | * @param ps The compiled pathspec 98 | * @param flags Combination of git_pathspec_flag_t options to control match 99 | * @param path The pathname to attempt to match 100 | * @return 1 is path matches spec, 0 if it does not 101 | *) 102 | 103 | function git_pathspec_matches_path(ps: Pgit_pathspec; flags: uint32_t; 104 | path: PAnsiChar): Integer; cdecl; external libgit2_dll; 105 | 106 | (** 107 | * Match a pathspec against the working directory of a repository. 108 | * 109 | * This matches the pathspec against the current files in the working 110 | * directory of the repository. It is an error to invoke this on a bare 111 | * repo. This handles git ignores (i.e. ignored files will not be 112 | * considered to match the `pathspec` unless the file is tracked in the 113 | * index). 114 | * 115 | * If `out` is not NULL, this returns a `git_patchspec_match_list`. That 116 | * contains the list of all matched filenames (unless you pass the 117 | * `GIT_PATHSPEC_FAILURES_ONLY` flag) and may also contain the list of 118 | * pathspecs with no match (if you used the `GIT_PATHSPEC_FIND_FAILURES` 119 | * flag). You must call `git_pathspec_match_list_free()` on this object. 120 | * 121 | * @param out Output list of matches; pass NULL to just get return value 122 | * @param repo The repository in which to match; bare repo is an error 123 | * @param flags Combination of git_pathspec_flag_t options to control match 124 | * @param ps Pathspec to be matched 125 | * @return 0 on success, -1 on error, GIT_ENOTFOUND if no matches and 126 | * the GIT_PATHSPEC_NO_MATCH_ERROR flag was given 127 | *) 128 | 129 | type 130 | PPgit_pathspec_match_list = ^Pgit_pathspec_match_list; 131 | Pgit_pathspec_match_list = ^git_pathspec_match_list; 132 | function git_pathspec_match_workdir(out_: PPgit_pathspec_match_list; repo: Pgit_repository; 133 | flags: uint32_t; ps: Pgit_pathspec): Integer; cdecl; external libgit2_dll; 134 | 135 | (** 136 | * Match a pathspec against entries in an index. 137 | * 138 | * This matches the pathspec against the files in the repository index. 139 | * 140 | * NOTE: At the moment, the case sensitivity of this match is controlled 141 | * by the current case-sensitivity of the index object itself and the 142 | * USE_CASE and IGNORE_CASE flags will have no effect. This behavior will 143 | * be corrected in a future release. 144 | * 145 | * If `out` is not NULL, this returns a `git_patchspec_match_list`. That 146 | * contains the list of all matched filenames (unless you pass the 147 | * `GIT_PATHSPEC_FAILURES_ONLY` flag) and may also contain the list of 148 | * pathspecs with no match (if you used the `GIT_PATHSPEC_FIND_FAILURES` 149 | * flag). You must call `git_pathspec_match_list_free()` on this object. 150 | * 151 | * @param out Output list of matches; pass NULL to just get return value 152 | * @param index The index to match against 153 | * @param flags Combination of git_pathspec_flag_t options to control match 154 | * @param ps Pathspec to be matched 155 | * @return 0 on success, -1 on error, GIT_ENOTFOUND if no matches and 156 | * the GIT_PATHSPEC_NO_MATCH_ERROR flag is used 157 | *) 158 | 159 | function git_pathspec_match_index(out_: PPgit_pathspec_match_list; index_: Pgit_index; flags: uint32_t; 160 | ps: Pgit_pathspec): Integer; cdecl; external libgit2_dll; 161 | 162 | (** 163 | * Match a pathspec against files in a tree. 164 | * 165 | * This matches the pathspec against the files in the given tree. 166 | * 167 | * If `out` is not NULL, this returns a `git_patchspec_match_list`. That 168 | * contains the list of all matched filenames (unless you pass the 169 | * `GIT_PATHSPEC_FAILURES_ONLY` flag) and may also contain the list of 170 | * pathspecs with no match (if you used the `GIT_PATHSPEC_FIND_FAILURES` 171 | * flag). You must call `git_pathspec_match_list_free()` on this object. 172 | * 173 | * @param out Output list of matches; pass NULL to just get return value 174 | * @param tree The root-level tree to match against 175 | * @param flags Combination of git_pathspec_flag_t options to control match 176 | * @param ps Pathspec to be matched 177 | * @return 0 on success, -1 on error, GIT_ENOTFOUND if no matches and 178 | * the GIT_PATHSPEC_NO_MATCH_ERROR flag is used 179 | *) 180 | 181 | function git_pathspec_match_tree(out_: PPgit_pathspec_match_list; tree: Pgit_tree; flags: uint32_t; 182 | ps: Pgit_pathspec): Integer; cdecl; external libgit2_dll; 183 | 184 | (** 185 | * Match a pathspec against files in a diff list. 186 | * 187 | * This matches the pathspec against the files in the given diff list. 188 | * 189 | * If `out` is not NULL, this returns a `git_patchspec_match_list`. That 190 | * contains the list of all matched filenames (unless you pass the 191 | * `GIT_PATHSPEC_FAILURES_ONLY` flag) and may also contain the list of 192 | * pathspecs with no match (if you used the `GIT_PATHSPEC_FIND_FAILURES` 193 | * flag). You must call `git_pathspec_match_list_free()` on this object. 194 | * 195 | * @param out Output list of matches; pass NULL to just get return value 196 | * @param diff A generated diff list 197 | * @param flags Combination of git_pathspec_flag_t options to control match 198 | * @param ps Pathspec to be matched 199 | * @return 0 on success, -1 on error, GIT_ENOTFOUND if no matches and 200 | * the GIT_PATHSPEC_NO_MATCH_ERROR flag is used 201 | *) 202 | 203 | function git_pathspec_match_diff(out_: PPgit_pathspec_match_list; diff: Pgit_diff; flags: uint32_t; 204 | ps: Pgit_pathspec): Integer; cdecl; external libgit2_dll; 205 | 206 | (** 207 | * Free memory associates with a git_pathspec_match_list 208 | * 209 | * @param m The git_pathspec_match_list to be freed 210 | *) 211 | 212 | procedure git_pathspec_match_list_free(m: Pgit_pathspec_match_list); cdecl; external libgit2_dll; 213 | 214 | (** 215 | * Get the number of items in a match list. 216 | * 217 | * @param m The git_pathspec_match_list object 218 | * @return Number of items in match list 219 | *) 220 | 221 | function git_pathspec_match_list_entrycount(m: Pgit_pathspec_match_list): size_t; cdecl; external libgit2_dll; 222 | 223 | (** 224 | * Get a matching filename by position. 225 | * 226 | * This routine cannot be used if the match list was generated by 227 | * `git_pathspec_match_diff`. If so, it will always return NULL. 228 | * 229 | * @param m The git_pathspec_match_list object 230 | * @param pos The index into the list 231 | * @return The filename of the match 232 | *) 233 | 234 | function git_pathspec_match_list_entry(m: Pgit_pathspec_match_list; pos: size_t): PAnsiChar; cdecl; external libgit2_dll; 235 | 236 | (** 237 | * Get a matching diff delta by position. 238 | * 239 | * This routine can only be used if the match list was generated by 240 | * `git_pathspec_match_diff`. Otherwise it will always return NULL. 241 | * 242 | * @param m The git_pathspec_match_list object 243 | * @param pos The index into the list 244 | * @return The filename of the match 245 | *) 246 | 247 | function git_pathspec_match_list_diff_entry(m: Pgit_pathspec_match_list; pos: size_t): Pgit_diff_delta; cdecl; external libgit2_dll; 248 | 249 | (** 250 | * Get the number of pathspec items that did not match. 251 | * 252 | * This will be zero unless you passed GIT_PATHSPEC_FIND_FAILURES when 253 | * generating the git_pathspec_match_list. 254 | * 255 | * @param m The git_pathspec_match_list object 256 | * @return Number of items in original pathspec that had no matches 257 | *) 258 | 259 | function git_pathspec_match_list_failed_entrycount(m: Pgit_pathspec_match_list): size_t; cdecl; external libgit2_dll; 260 | 261 | (** 262 | * Get an original pathspec string that had no matches. 263 | * 264 | * This will be return NULL for positions out of range. 265 | * 266 | * @param m The git_pathspec_match_list object 267 | * @param pos The index into the failed items 268 | * @return The pathspec pattern that didn't match anything 269 | *) 270 | 271 | function git_pathspec_match_list_failed_entry(m: Pgit_pathspec_match_list; pos: size_t): PAnsiChar; cdecl; external libgit2_dll; 272 | 273 | 274 | 275 | -------------------------------------------------------------------------------- /src/git2/proxy.inc: -------------------------------------------------------------------------------- 1 | (** 2 | * @file git2/proxy.h 3 | * @brief TLS proxies 4 | * @ingroup Git 5 | * @{ 6 | *) 7 | 8 | (** 9 | * The type of proxy to use. 10 | *) 11 | 12 | const 13 | (** 14 | * Do not attempt to connect through a proxy 15 | * 16 | * If built against libcurl, it itself may attempt to connect 17 | * to a proxy if the environment variables specify it. 18 | *) 19 | GIT_PROXY_NONE = 0; 20 | (** 21 | * Try to auto-detect the proxy from the git configuration. 22 | *) 23 | GIT_PROXY_AUTO = 1; 24 | (** 25 | * Connect via the URL given in the options 26 | *) 27 | GIT_PROXY_SPECIFIED = 2; 28 | type 29 | git_proxy_t = Integer; 30 | 31 | (** 32 | * Options for connecting through a proxy 33 | * 34 | * Note that not all types may be supported, depending on the platform 35 | * and compilation options. 36 | *) 37 | 38 | git_proxy_options = record 39 | version: Cardinal; 40 | (** 41 | * The type of proxy to use, by URL, auto-detect. 42 | *) 43 | type_: git_proxy_t; 44 | (** 45 | * The URL of the proxy. 46 | *) 47 | url: PAnsiChar; 48 | (** 49 | * This will be called if the remote host requires 50 | * authentication in order to connect to it. 51 | * 52 | * Returning GIT_PASSTHROUGH will make libgit2 behave as 53 | * though this field isn't set. 54 | *) 55 | credentials: git_credential_acquire_cb; 56 | (** 57 | * If cert verification fails, this will be called to let the 58 | * user make the final decision of whether to allow the 59 | * connection to proceed. Returns 0 to allow the connection 60 | * or a negative value to indicate an error. 61 | *) 62 | certificate_check: git_transport_certificate_check_cb; 63 | (** 64 | * Payload to be provided to the credentials and certificate 65 | * check callbacks. 66 | *) 67 | payload: Pointer; 68 | end; 69 | Pgit_proxy_options = ^git_proxy_options; 70 | 71 | const 72 | (** Current version for the `git_proxy_options` structure *) 73 | GIT_PROXY_OPTIONS_VERSION = 1; 74 | (** Static constructor for `git_proxy_options` *) 75 | //GIT_PROXY_OPTIONS_INIT = { GIT_PROXY_OPTIONS_VERSION }; 76 | 77 | (** 78 | * Initialize git_proxy_options structure 79 | * 80 | * Initializes a `git_proxy_options` with default values. Equivalent to 81 | * creating an instance with `GIT_PROXY_OPTIONS_INIT`. 82 | * 83 | * @param opts The `git_proxy_options` struct to initialize. 84 | * @param version The struct version; pass `GIT_PROXY_OPTIONS_VERSION`. 85 | * @return Zero on success; -1 on failure. 86 | *) 87 | 88 | function git_proxy_options_init(opts: Pgit_proxy_options; version: Cardinal): Integer; cdecl; external libgit2_dll; 89 | 90 | 91 | 92 | -------------------------------------------------------------------------------- /src/git2/refdb.inc: -------------------------------------------------------------------------------- 1 | (** 2 | * @file git2/refdb.h 3 | * @brief A database for references (branches and tags) 4 | * @defgroup git_refdb A database for references (branches and tags) 5 | * @ingroup Git 6 | * @{ 7 | *) 8 | 9 | (** 10 | * Create a new reference database with no backends. 11 | * 12 | * Before the Ref DB can be used for read/writing, a custom database 13 | * backend must be manually set using `git_refdb_set_backend()` 14 | * 15 | * @param out location to store the database pointer, if opened. 16 | * Set to NULL if the open failed. 17 | * @param repo the repository 18 | * @return 0 or an error code 19 | *) 20 | 21 | function git_refdb_new(out_: PPgit_refdb; repo: Pgit_repository): Integer; cdecl; external libgit2_dll; 22 | 23 | (** 24 | * Create a new reference database and automatically add 25 | * the default backends: 26 | * 27 | * - git_refdb_dir: read and write loose and packed refs 28 | * from disk, assuming the repository dir as the folder 29 | * 30 | * @param out location to store the database pointer, if opened. 31 | * Set to NULL if the open failed. 32 | * @param repo the repository 33 | * @return 0 or an error code 34 | *) 35 | 36 | function git_refdb_open(out_: PPgit_refdb; repo: Pgit_repository): Integer; cdecl; external libgit2_dll; 37 | 38 | (** 39 | * Suggests that the given refdb compress or optimize its references. 40 | * This mechanism is implementation specific. For on-disk reference 41 | * databases, for example, this may pack all loose references. 42 | * 43 | * @param refdb The reference database to optimize. 44 | * @return 0 or an error code. 45 | *) 46 | 47 | function git_refdb_compress(refdb: Pgit_refdb): Integer; cdecl; external libgit2_dll; 48 | 49 | (** 50 | * Close an open reference database. 51 | * 52 | * @param refdb reference database pointer or NULL 53 | *) 54 | 55 | procedure git_refdb_free(refdb: Pgit_refdb); cdecl; external libgit2_dll; 56 | 57 | (** @} *) 58 | 59 | -------------------------------------------------------------------------------- /src/git2/reflog.inc: -------------------------------------------------------------------------------- 1 | (** 2 | * @file git2/reflog.h 3 | * @brief Reference logs store how references change 4 | * @defgroup git_reflog Reference logs store how references change 5 | * @ingroup Git 6 | * @{ 7 | *) 8 | 9 | (** 10 | * Read the reflog for the given reference 11 | * 12 | * If there is no reflog file for the given 13 | * reference yet, an empty reflog object will 14 | * be returned. 15 | * 16 | * The reflog must be freed manually by using 17 | * git_reflog_free(). 18 | * 19 | * @param out pointer to reflog 20 | * @param repo the repository 21 | * @param name reference to look up 22 | * @return 0 or an error code 23 | *) 24 | 25 | function git_reflog_read(out_: PPgit_reflog; repo: Pgit_repository; name_: PAnsiChar): Integer; cdecl; external libgit2_dll; 26 | 27 | (** 28 | * Write an existing in-memory reflog object back to disk 29 | * using an atomic file lock. 30 | * 31 | * @param reflog an existing reflog object 32 | * @return 0 or an error code 33 | *) 34 | 35 | function git_reflog_write(reflog: Pgit_reflog): Integer; cdecl; external libgit2_dll; 36 | 37 | (** 38 | * Add a new entry to the in-memory reflog. 39 | * 40 | * `msg` is optional and can be NULL. 41 | * 42 | * @param reflog an existing reflog object 43 | * @param id the OID the reference is now pointing to 44 | * @param committer the signature of the committer 45 | * @param msg the reflog message 46 | * @return 0 or an error code 47 | *) 48 | 49 | function git_reflog_append(reflog: Pgit_reflog; id: Pgit_oid; committer: Pgit_signature; 50 | msg: PAnsiChar): Integer; cdecl; external libgit2_dll; 51 | 52 | (** 53 | * Rename a reflog 54 | * 55 | * The reflog to be renamed is expected to already exist 56 | * 57 | * The new name will be checked for validity. 58 | * See `git_reference_create_symbolic()` for rules about valid names. 59 | * 60 | * @param repo the repository 61 | * @param old_name the old name of the reference 62 | * @param name the new name of the reference 63 | * @return 0 on success, GIT_EINVALIDSPEC or an error code 64 | *) 65 | 66 | function git_reflog_rename(repo: Pgit_repository; old_name, name_: PAnsiChar): Integer; cdecl; external libgit2_dll; 67 | 68 | (** 69 | * Delete the reflog for the given reference 70 | * 71 | * @param repo the repository 72 | * @param name the reflog to delete 73 | * @return 0 or an error code 74 | *) 75 | 76 | function git_reflog_delete(repo: Pgit_repository; name_: PAnsiChar): Integer; cdecl; external libgit2_dll; 77 | 78 | (** 79 | * Get the number of log entries in a reflog 80 | * 81 | * @param reflog the previously loaded reflog 82 | * @return the number of log entries 83 | *) 84 | 85 | function git_reflog_entrycount(reflog: Pgit_reflog): size_t; cdecl; external libgit2_dll; 86 | 87 | (** 88 | * Lookup an entry by its index 89 | * 90 | * Requesting the reflog entry with an index of 0 (zero) will 91 | * return the most recently created entry. 92 | * 93 | * @param reflog a previously loaded reflog 94 | * @param idx the position of the entry to lookup. Should be greater than or 95 | * equal to 0 (zero) and less than `git_reflog_entrycount()`. 96 | * @return the entry; NULL if not found 97 | *) 98 | 99 | function git_reflog_entry_byindex(reflog: Pgit_reflog; idx: size_t): Pgit_reflog_entry; cdecl; external libgit2_dll; 100 | 101 | (** 102 | * Remove an entry from the reflog by its index 103 | * 104 | * To ensure there's no gap in the log history, set `rewrite_previous_entry` 105 | * param value to 1. When deleting entry `n`, member old_oid of entry `n-1` 106 | * (if any) will be updated with the value of member new_oid of entry `n+1`. 107 | * 108 | * @param reflog a previously loaded reflog. 109 | * 110 | * @param idx the position of the entry to remove. Should be greater than or 111 | * equal to 0 (zero) and less than `git_reflog_entrycount()`. 112 | * 113 | * @param rewrite_previous_entry 1 to rewrite the history; 0 otherwise. 114 | * 115 | * @return 0 on success, GIT_ENOTFOUND if the entry doesn't exist 116 | * or an error code. 117 | *) 118 | 119 | function git_reflog_drop(reflog: Pgit_reflog; idx: size_t; rewrite_previous_entry: Integer): Integer; cdecl; external libgit2_dll; 120 | 121 | (** 122 | * Get the old oid 123 | * 124 | * @param entry a reflog entry 125 | * @return the old oid 126 | *) 127 | 128 | function git_reflog_entry_id_old(entry: Pgit_reflog_entry): Pgit_oid; cdecl; external libgit2_dll; 129 | 130 | (** 131 | * Get the new oid 132 | * 133 | * @param entry a reflog entry 134 | * @return the new oid at this time 135 | *) 136 | 137 | function git_reflog_entry_id_new(entry: Pgit_reflog_entry): Pgit_oid; cdecl; external libgit2_dll; 138 | 139 | (** 140 | * Get the committer of this entry 141 | * 142 | * @param entry a reflog entry 143 | * @return the committer 144 | *) 145 | 146 | function git_reflog_entry_committer(entry: Pgit_reflog_entry): Pgit_signature; cdecl; external libgit2_dll; 147 | 148 | (** 149 | * Get the log message 150 | * 151 | * @param entry a reflog entry 152 | * @return the log msg 153 | *) 154 | 155 | function git_reflog_entry_message(entry: Pgit_reflog_entry): PAnsiChar; cdecl; external libgit2_dll; 156 | 157 | (** 158 | * Free the reflog 159 | * 160 | * @param reflog reflog to free 161 | *) 162 | 163 | procedure git_reflog_free(reflog: Pgit_reflog); cdecl; external libgit2_dll; 164 | 165 | (** @} *) 166 | 167 | 168 | -------------------------------------------------------------------------------- /src/git2/refspec.inc: -------------------------------------------------------------------------------- 1 | (** 2 | * @file git2/refspec.h 3 | * @brief Refspecs map local references to remote references 4 | * @defgroup git_refspec Refspecs map local references to remote references 5 | * @ingroup Git 6 | * @{ 7 | *) 8 | 9 | (** 10 | * Parse a given refspec string 11 | * 12 | * @param refspec a pointer to hold the refspec handle 13 | * @param input the refspec string 14 | * @param is_fetch is this a refspec for a fetch 15 | * @return 0 if the refspec string could be parsed, -1 otherwise 16 | *) 17 | 18 | function git_refspec_parse(refspec: PPgit_refspec; input: PAnsiChar; is_fetch: Integer): Integer; cdecl; external libgit2_dll; 19 | 20 | (** 21 | * Free a refspec object which has been created by git_refspec_parse 22 | * 23 | * @param refspec the refspec object 24 | *) 25 | 26 | procedure git_refspec_free(refspec: Pgit_refspec); cdecl; external libgit2_dll; 27 | 28 | (** 29 | * Get the source specifier 30 | * 31 | * @param refspec the refspec 32 | * @return the refspec's source specifier 33 | *) 34 | 35 | function git_refspec_src(refspec: Pgit_refspec): PAnsiChar; cdecl; external libgit2_dll; 36 | 37 | (** 38 | * Get the destination specifier 39 | * 40 | * @param refspec the refspec 41 | * @return the refspec's destination specifier 42 | *) 43 | 44 | function git_refspec_dst(refspec: Pgit_refspec): PAnsiChar; cdecl; external libgit2_dll; 45 | 46 | (** 47 | * Get the refspec's string 48 | * 49 | * @param refspec the refspec 50 | * @return the refspec's original string 51 | *) 52 | 53 | function git_refspec_string(refspec: Pgit_refspec): PAnsiChar; cdecl; external libgit2_dll; 54 | 55 | (** 56 | * Get the force update setting 57 | * 58 | * @param refspec the refspec 59 | * @return 1 if force update has been set, 0 otherwise 60 | *) 61 | 62 | function git_refspec_force(refspec: Pgit_refspec): Integer; cdecl; external libgit2_dll; 63 | 64 | (** 65 | * Get the refspec's direction. 66 | * 67 | * @param spec refspec 68 | * @return GIT_DIRECTION_FETCH or GIT_DIRECTION_PUSH 69 | *) 70 | 71 | function git_refspec_direction(spec: Pgit_refspec): git_direction; cdecl; external libgit2_dll; 72 | 73 | (** 74 | * Check if a refspec's source descriptor matches a negative reference 75 | * 76 | * @param refspec the refspec 77 | * @param refname the name of the reference to check 78 | * @return 1 if the refspec matches, 0 otherwise 79 | *) 80 | function git_refspec_src_matches_negative(refspec: Pgit_refspec; refname: PAnsiChar): Integer; cdecl; external libgit2_dll; 81 | 82 | (** 83 | * Check if a refspec's source descriptor matches a reference 84 | * 85 | * @param refspec the refspec 86 | * @param refname the name of the reference to check 87 | * @return 1 if the refspec matches, 0 otherwise 88 | *) 89 | 90 | function git_refspec_src_matches(refspec: Pgit_refspec; refname: PAnsiChar): Integer; cdecl; external libgit2_dll; 91 | 92 | (** 93 | * Check if a refspec's destination descriptor matches a reference 94 | * 95 | * @param refspec the refspec 96 | * @param refname the name of the reference to check 97 | * @return 1 if the refspec matches, 0 otherwise 98 | *) 99 | 100 | function git_refspec_dst_matches(refspec: Pgit_refspec; refname: PAnsiChar): Integer; cdecl; external libgit2_dll; 101 | 102 | (** 103 | * Transform a reference to its target following the refspec's rules 104 | * 105 | * @param out where to store the target name 106 | * @param spec the refspec 107 | * @param name the name of the reference to transform 108 | * @return 0, GIT_EBUFS or another error 109 | *) 110 | 111 | function git_refspec_transform(out_: Pgit_buf; spec: Pgit_refspec; name_: PAnsiChar): Integer; cdecl; external libgit2_dll; 112 | 113 | (** 114 | * Transform a target reference to its source reference following the refspec's rules 115 | * 116 | * @param out where to store the source reference name 117 | * @param spec the refspec 118 | * @param name the name of the reference to transform 119 | * @return 0, GIT_EBUFS or another error 120 | *) 121 | 122 | function git_refspec_rtransform(out_: Pgit_buf; spec: Pgit_refspec; name_: PAnsiChar): Integer; cdecl; external libgit2_dll; 123 | 124 | 125 | -------------------------------------------------------------------------------- /src/git2/reset.inc: -------------------------------------------------------------------------------- 1 | (** 2 | * @file git2/reset.h 3 | * @brief Reset will update the local repository to a prior state 4 | * @ingroup Git 5 | * @{ 6 | *) 7 | 8 | (** 9 | * Kinds of reset operation 10 | *) 11 | 12 | const 13 | GIT_RESET_SOFT = 1; (**< Move the head to the given commit *) 14 | GIT_RESET_MIXED = 2; (**< SOFT plus reset index to the commit *) 15 | GIT_RESET_HARD = 3; (**< MIXED plus changes in working tree discarded *) 16 | type 17 | git_reset_t = Integer; 18 | 19 | (** 20 | * Sets the current head to the specified commit oid and optionally 21 | * resets the index and working tree to match. 22 | * 23 | * SOFT reset means the Head will be moved to the commit. 24 | * 25 | * MIXED reset will trigger a SOFT reset, plus the index will be replaced 26 | * with the content of the commit tree. 27 | * 28 | * HARD reset will trigger a MIXED reset and the working directory will be 29 | * replaced with the content of the index. (Untracked and ignored files 30 | * will be left alone, however.) 31 | * 32 | * TODO: Implement remaining kinds of resets. 33 | * 34 | * @param repo Repository where to perform the reset operation. 35 | * 36 | * @param target Committish to which the Head should be moved to. This object 37 | * must belong to the given `repo` and can either be a git_commit or a 38 | * git_tag. When a git_tag is being passed, it should be dereferenceable 39 | * to a git_commit which oid will be used as the target of the branch. 40 | * 41 | * @param reset_type Kind of reset operation to perform. 42 | * 43 | * @param checkout_opts Optional checkout options to be used for a HARD reset. 44 | * The checkout_strategy field will be overridden (based on reset_type). 45 | * This parameter can be used to propagate notify and progress callbacks. 46 | * 47 | * @return 0 on success or an error code 48 | *) 49 | 50 | function git_reset(repo: Pgit_repository; target: Pgit_object; reset_type: git_reset_t; 51 | checkout_opts: Pgit_checkout_options): Integer; cdecl; external libgit2_dll; 52 | 53 | (** 54 | * Sets the current head to the specified commit oid and optionally 55 | * resets the index and working tree to match. 56 | * 57 | * This behaves like `git_reset()` but takes an annotated commit, 58 | * which lets you specify which extended sha syntax string was 59 | * specified by a user, allowing for more exact reflog messages. 60 | * 61 | * See the documentation for `git_reset()`. 62 | * 63 | * @param repo Repository where to perform the reset operation. 64 | * 65 | * @param target Annotated commit to which the Head should be moved to. 66 | * This object must belong to the given `repo`, it will be dereferenced 67 | * to a git_commit which oid will be used as the target of the branch. 68 | * 69 | * @param reset_type Kind of reset operation to perform. 70 | * 71 | * @param checkout_opts Optional checkout options to be used for a HARD reset. 72 | * The checkout_strategy field will be overridden (based on reset_type). 73 | * This parameter can be used to propagate notify and progress callbacks. 74 | * 75 | * @return 0 on success or an error code 76 | *) 77 | 78 | function git_reset_from_annotated(repo: Pgit_repository; target: Pgit_annotated_commit; 79 | reset_type: git_reset_t; checkout_opts: Pgit_checkout_options): Integer; cdecl; external libgit2_dll; 80 | 81 | (** 82 | * Updates some entries in the index from the target commit tree. 83 | * 84 | * The scope of the updated entries is determined by the paths 85 | * being passed in the `pathspec` parameters. 86 | * 87 | * Passing a NULL `target` will result in removing 88 | * entries in the index matching the provided pathspecs. 89 | * 90 | * @param repo Repository where to perform the reset operation. 91 | * 92 | * @param target The committish which content will be used to reset the content 93 | * of the index. 94 | * 95 | * @param pathspecs List of pathspecs to operate on. 96 | * 97 | * @return 0 on success or an error code < 0 98 | *) 99 | 100 | function git_reset_default(repo: Pgit_repository; target: Pgit_object; pathspecs: Pgit_strarray): Integer; cdecl; external libgit2_dll; 101 | 102 | (** @} *) 103 | 104 | 105 | 106 | -------------------------------------------------------------------------------- /src/git2/revert.inc: -------------------------------------------------------------------------------- 1 | (** 2 | * @file git2/revert.h 3 | * @brief Cherry-pick the inverse of a change to "undo" its effects 4 | * @defgroup git_revert Cherry-pick the inverse of a change to "undo" its effects 5 | * @ingroup Git 6 | * @{ 7 | *) 8 | 9 | (** 10 | * Options for revert 11 | *) 12 | 13 | type 14 | git_revert_options = record 15 | version: Cardinal; 16 | (** For merge commits, the "mainline" is treated as the parent. *) 17 | mainline: Cardinal; 18 | merge_opts: git_merge_options; (**< Options for the merging *) 19 | checkout_opts: git_checkout_options; (**< Options for the checkout *) 20 | end; 21 | Pgit_revert_options = ^git_revert_options; 22 | 23 | const 24 | (** Current version for the `git_revert_options` structure *) 25 | GIT_REVERT_OPTIONS_VERSION = 1; 26 | (** Static constructor for `git_revert_options` *) 27 | //GIT_REVERT_OPTIONS_INIT = { GIT_REVERT_OPTIONS_VERSION , 0 , GIT_MERGE_OPTIONS_INIT , GIT_CHECKOUT_OPTIONS_INIT }; 28 | (** 29 | * Initialize git_revert_options structure 30 | * 31 | * Initializes a `git_revert_options` with default values. Equivalent to 32 | * creating an instance with `GIT_REVERT_OPTIONS_INIT`. 33 | * 34 | * @param opts The `git_revert_options` struct to initialize. 35 | * @param version The struct version; pass `GIT_REVERT_OPTIONS_VERSION`. 36 | * @return Zero on success; -1 on failure. 37 | *) 38 | 39 | function git_revert_options_init(opts: Pgit_revert_options; version: Cardinal): Integer; cdecl; external libgit2_dll; 40 | 41 | (** 42 | * Reverts the given commit against the given "our" commit, producing an 43 | * index that reflects the result of the revert. 44 | * 45 | * The returned index must be freed explicitly with `git_index_free`. 46 | * 47 | * @param out pointer to store the index result in 48 | * @param repo the repository that contains the given commits 49 | * @param revert_commit the commit to revert 50 | * @param our_commit the commit to revert against (eg, HEAD) 51 | * @param mainline the parent of the revert commit, if it is a merge 52 | * @param merge_options the merge options (or null for defaults) 53 | * @return zero on success, -1 on failure. 54 | *) 55 | 56 | function git_revert_commit(out_: PPgit_index; repo: Pgit_repository; revert_commit, our_commit: Pgit_commit; 57 | mainline: Cardinal; merge_options: Pgit_merge_options): Integer; cdecl; external libgit2_dll; 58 | 59 | (** 60 | * Reverts the given commit, producing changes in the index and working directory. 61 | * 62 | * @param repo the repository to revert 63 | * @param commit the commit to revert 64 | * @param given_opts the revert options (or null for defaults) 65 | * @return zero on success, -1 on failure. 66 | *) 67 | 68 | function git_revert(repo: Pgit_repository; commit: Pgit_commit; 69 | given_opts: Pgit_revert_options): Integer; cdecl; external libgit2_dll; 70 | 71 | (** @} *) 72 | 73 | 74 | 75 | -------------------------------------------------------------------------------- /src/git2/revparse.inc: -------------------------------------------------------------------------------- 1 | (** 2 | * @file git2/revparse.h 3 | * @brief Parse the textual revision information 4 | * @defgroup git_revparse Parse the textual revision information 5 | * @ingroup Git 6 | * @{ 7 | *) 8 | 9 | (** 10 | * Find a single object, as specified by a revision string. 11 | * 12 | * See `man gitrevisions`, or 13 | * http://git-scm.com/docs/git-rev-parse.html#_specifying_revisions for 14 | * information on the syntax accepted. 15 | * 16 | * The returned object should be released with `git_object_free` when no 17 | * longer needed. 18 | * 19 | * @param out pointer to output object 20 | * @param repo the repository to search in 21 | * @param spec the textual specification for an object 22 | * @return 0 on success, GIT_ENOTFOUND, GIT_EAMBIGUOUS, GIT_EINVALIDSPEC or an error code 23 | *) 24 | 25 | function git_revparse_single(out_: PPgit_object; repo: Pgit_repository; spec: PAnsiChar): Integer; cdecl; external libgit2_dll; 26 | 27 | (** 28 | * Find a single object and intermediate reference by a revision string. 29 | * 30 | * See `man gitrevisions`, or 31 | * http://git-scm.com/docs/git-rev-parse.html#_specifying_revisions for 32 | * information on the syntax accepted. 33 | * 34 | * In some cases (`@{<-n>}` or `@{upstream}`), the expression may 35 | * point to an intermediate reference. When such expressions are being passed 36 | * in, `reference_out` will be valued as well. 37 | * 38 | * The returned object should be released with `git_object_free` and the 39 | * returned reference with `git_reference_free` when no longer needed. 40 | * 41 | * @param object_out pointer to output object 42 | * @param reference_out pointer to output reference or NULL 43 | * @param repo the repository to search in 44 | * @param spec the textual specification for an object 45 | * @return 0 on success, GIT_ENOTFOUND, GIT_EAMBIGUOUS, GIT_EINVALIDSPEC 46 | * or an error code 47 | *) 48 | 49 | function git_revparse_ext(object_out: PPgit_object; reference_out: PPgit_reference; repo: Pgit_repository; 50 | spec: PAnsiChar): Integer; cdecl; external libgit2_dll; 51 | 52 | (** 53 | * Revparse flags. These indicate the intended behavior of the spec passed to 54 | * git_revparse. 55 | *) 56 | 57 | const 58 | (** The spec targeted a single object. *) 59 | GIT_REVSPEC_SINGLE_ = 1 shl 0; 60 | (** The spec targeted a range of commits. *) 61 | GIT_REVSPEC_RANGE = 1 shl 1; 62 | (** The spec used the '...' operator, which invokes special semantics. *) 63 | GIT_REVSPEC_MERGE_BASE = 1 shl 2; 64 | type 65 | git_revspec_mode_t = Integer; 66 | 67 | (** 68 | * Git Revision Spec: output of a `git_revspec` operation 69 | *) 70 | 71 | git_revspec = record 72 | (** The left element of the revspec; must be freed by the user *) 73 | from: Pgit_object; 74 | (** The right element of the revspec; must be freed by the user *) 75 | to_: Pgit_object; 76 | (** The intent of the revspec (i.e. `git_revparse_mode_t` flags) *) 77 | flags: Cardinal; 78 | end; 79 | Pgit_revspec = ^git_revspec; 80 | 81 | (** 82 | * Parse a revision string for `from`, `to`, and intent. 83 | * 84 | * See `man gitrevisions` or 85 | * http://git-scm.com/docs/git-rev-parse.html#_specifying_revisions for 86 | * information on the syntax accepted. 87 | * 88 | * @param revspec Pointer to an user-allocated git_revspec struct where 89 | * the result of the rev-parse will be stored 90 | * @param repo the repository to search in 91 | * @param spec the rev-parse spec to parse 92 | * @return 0 on success, GIT_INVALIDSPEC, GIT_ENOTFOUND, GIT_EAMBIGUOUS or an error code 93 | *) 94 | 95 | function git_revparse(revspec: Pgit_revspec; repo: Pgit_repository; spec: PAnsiChar): Integer; cdecl; external libgit2_dll; 96 | 97 | (** @} *) 98 | 99 | 100 | 101 | -------------------------------------------------------------------------------- /src/git2/revwalk.inc: -------------------------------------------------------------------------------- 1 | (** 2 | * @file git2/revwalk.h 3 | * @brief Traverse (walk) the commit graph (revision history) 4 | * @defgroup git_revwalk Traverse (walk) the commit graph (revision history) 5 | * @ingroup Git 6 | * @{ 7 | *) 8 | 9 | (** 10 | * Flags to specify the sorting which a revwalk should perform. 11 | *) 12 | 13 | const 14 | (** 15 | * Sort the output with the same default method from `git`: reverse 16 | * chronological order. This is the default sorting for new walkers. 17 | *) 18 | GIT_SORT_NONE = 0; 19 | (** 20 | * Sort the repository contents in topological order (no parents before 21 | * all of its children are shown); this sorting mode can be combined 22 | * with time sorting to produce `git`'s `--date-order``. 23 | *) 24 | GIT_SORT_TOPOLOGICAL = 1 shl 0; 25 | (** 26 | * Sort the repository contents by commit time; 27 | * this sorting mode can be combined with 28 | * topological sorting. 29 | *) 30 | GIT_SORT_TIME = 1 shl 1; 31 | (** 32 | * Iterate through the repository contents in reverse 33 | * order; this sorting mode can be combined with 34 | * any of the above. 35 | *) 36 | GIT_SORT_REVERSE = 1 shl 2; 37 | type 38 | git_sort_t = Integer; 39 | 40 | (** 41 | * Allocate a new revision walker to iterate through a repo. 42 | * 43 | * This revision walker uses a custom memory pool and an internal 44 | * commit cache, so it is relatively expensive to allocate. 45 | * 46 | * For maximum performance, this revision walker should be 47 | * reused for different walks. 48 | * 49 | * This revision walker is *not* thread safe: it may only be 50 | * used to walk a repository on a single thread; however, 51 | * it is possible to have several revision walkers in 52 | * several different threads walking the same repository. 53 | * 54 | * @param out pointer to the new revision walker 55 | * @param repo the repo to walk through 56 | * @return 0 or an error code 57 | *) 58 | 59 | function git_revwalk_new(out_: PPgit_revwalk; repo: Pgit_repository): Integer; cdecl; external libgit2_dll; 60 | 61 | (** 62 | * Reset the revision walker for reuse. 63 | * 64 | * This will clear all the pushed and hidden commits, and 65 | * leave the walker in a blank state (just like at 66 | * creation) ready to receive new commit pushes and 67 | * start a new walk. 68 | * 69 | * The revision walk is automatically reset when a walk 70 | * is over. 71 | * 72 | * @param walker handle to reset. 73 | * @return 0 or an error code 74 | *) 75 | 76 | function git_revwalk_reset(walker: Pgit_revwalk): Integer; cdecl; external libgit2_dll; 77 | 78 | (** 79 | * Add a new root for the traversal 80 | * 81 | * The pushed commit will be marked as one of the roots from which to 82 | * start the walk. This commit may not be walked if it or a child is 83 | * hidden. 84 | * 85 | * At least one commit must be pushed onto the walker before a walk 86 | * can be started. 87 | * 88 | * The given id must belong to a committish on the walked 89 | * repository. 90 | * 91 | * @param walk the walker being used for the traversal. 92 | * @param id the oid of the commit to start from. 93 | * @return 0 or an error code 94 | *) 95 | 96 | function git_revwalk_push(walk: Pgit_revwalk; id: Pgit_oid): Integer; cdecl; external libgit2_dll; 97 | 98 | (** 99 | * Push matching references 100 | * 101 | * The OIDs pointed to by the references that match the given glob 102 | * pattern will be pushed to the revision walker. 103 | * 104 | * A leading 'refs/' is implied if not present as well as a trailing 105 | * '/\*' if the glob lacks '?', '\*' or '['. 106 | * 107 | * Any references matching this glob which do not point to a 108 | * committish will be ignored. 109 | * 110 | * @param walk the walker being used for the traversal 111 | * @param glob the glob pattern references should match 112 | * @return 0 or an error code 113 | *) 114 | 115 | function git_revwalk_push_glob(walk: Pgit_revwalk; glob: PAnsiChar): Integer; cdecl; external libgit2_dll; 116 | 117 | (** 118 | * Push the repository's HEAD 119 | * 120 | * @param walk the walker being used for the traversal 121 | * @return 0 or an error code 122 | *) 123 | 124 | function git_revwalk_push_head(walk: Pgit_revwalk): Integer; cdecl; external libgit2_dll; 125 | 126 | (** 127 | * Mark a commit (and its ancestors) uninteresting for the output. 128 | * 129 | * The given id must belong to a committish on the walked 130 | * repository. 131 | * 132 | * The resolved commit and all its parents will be hidden from the 133 | * output on the revision walk. 134 | * 135 | * @param walk the walker being used for the traversal. 136 | * @param commit_id the oid of commit that will be ignored during the traversal 137 | * @return 0 or an error code 138 | *) 139 | 140 | function git_revwalk_hide(walk: Pgit_revwalk; commit_id: Pgit_oid): Integer; cdecl; external libgit2_dll; 141 | 142 | (** 143 | * Hide matching references. 144 | * 145 | * The OIDs pointed to by the references that match the given glob 146 | * pattern and their ancestors will be hidden from the output on the 147 | * revision walk. 148 | * 149 | * A leading 'refs/' is implied if not present as well as a trailing 150 | * '/\*' if the glob lacks '?', '\*' or '['. 151 | * 152 | * Any references matching this glob which do not point to a 153 | * committish will be ignored. 154 | * 155 | * @param walk the walker being used for the traversal 156 | * @param glob the glob pattern references should match 157 | * @return 0 or an error code 158 | *) 159 | 160 | function git_revwalk_hide_glob(walk: Pgit_revwalk; glob: PAnsiChar): Integer; cdecl; external libgit2_dll; 161 | 162 | (** 163 | * Hide the repository's HEAD 164 | * 165 | * @param walk the walker being used for the traversal 166 | * @return 0 or an error code 167 | *) 168 | 169 | function git_revwalk_hide_head(walk: Pgit_revwalk): Integer; cdecl; external libgit2_dll; 170 | 171 | (** 172 | * Push the OID pointed to by a reference 173 | * 174 | * The reference must point to a committish. 175 | * 176 | * @param walk the walker being used for the traversal 177 | * @param refname the reference to push 178 | * @return 0 or an error code 179 | *) 180 | 181 | function git_revwalk_push_ref(walk: Pgit_revwalk; refname: PAnsiChar): Integer; cdecl; external libgit2_dll; 182 | 183 | (** 184 | * Hide the OID pointed to by a reference 185 | * 186 | * The reference must point to a committish. 187 | * 188 | * @param walk the walker being used for the traversal 189 | * @param refname the reference to hide 190 | * @return 0 or an error code 191 | *) 192 | 193 | function git_revwalk_hide_ref(walk: Pgit_revwalk; refname: PAnsiChar): Integer; cdecl; external libgit2_dll; 194 | 195 | (** 196 | * Get the next commit from the revision walk. 197 | * 198 | * The initial call to this method is *not* blocking when 199 | * iterating through a repo with a time-sorting mode. 200 | * 201 | * Iterating with Topological or inverted modes makes the initial 202 | * call blocking to preprocess the commit list, but this block should be 203 | * mostly unnoticeable on most repositories (topological preprocessing 204 | * times at 0.3s on the git.git repo). 205 | * 206 | * The revision walker is reset when the walk is over. 207 | * 208 | * @param out Pointer where to store the oid of the next commit 209 | * @param walk the walker to pop the commit from. 210 | * @return 0 if the next commit was found; 211 | * GIT_ITEROVER if there are no commits left to iterate 212 | *) 213 | 214 | function git_revwalk_next(out_: Pgit_oid; walk: Pgit_revwalk): Integer; cdecl; external libgit2_dll; 215 | 216 | (** 217 | * Change the sorting mode when iterating through the 218 | * repository's contents. 219 | * 220 | * Changing the sorting mode resets the walker. 221 | * 222 | * @param walk the walker being used for the traversal. 223 | * @param sort_mode combination of GIT_SORT_XXX flags 224 | * @return 0 or an error code 225 | *) 226 | 227 | function git_revwalk_sorting(walk: Pgit_revwalk; sort_mode: Cardinal): Integer; cdecl; external libgit2_dll; 228 | 229 | (** 230 | * Push and hide the respective endpoints of the given range. 231 | * 232 | * The range should be of the form 233 | * .. 234 | * where each is in the form accepted by 'git_revparse_single'. 235 | * The left-hand commit will be hidden and the right-hand commit pushed. 236 | * 237 | * @param walk the walker being used for the traversal 238 | * @param range the range 239 | * @return 0 or an error code 240 | * 241 | *) 242 | 243 | function git_revwalk_push_range(walk: Pgit_revwalk; range: PAnsiChar): Integer; cdecl; external libgit2_dll; 244 | 245 | (** 246 | * Simplify the history by first-parent 247 | * 248 | * No parents other than the first for each commit will be enqueued. 249 | * 250 | * @param walk The revision walker. 251 | * @return 0 or an error code 252 | *) 253 | 254 | function git_revwalk_simplify_first_parent(walk: Pgit_revwalk): Integer; cdecl; external libgit2_dll; 255 | 256 | (** 257 | * Free a revision walker previously allocated. 258 | * 259 | * @param walk traversal handle to close. If NULL nothing occurs. 260 | *) 261 | 262 | procedure git_revwalk_free(walk: Pgit_revwalk); cdecl; external libgit2_dll; 263 | 264 | (** 265 | * Return the repository on which this walker 266 | * is operating. 267 | * 268 | * @param walk the revision walker 269 | * @return the repository being walked 270 | *) 271 | 272 | function git_revwalk_repository(walk: Pgit_revwalk): Pgit_repository; cdecl; external libgit2_dll; 273 | 274 | (** 275 | * This is a callback function that user can provide to hide a 276 | * commit and its parents. If the callback function returns non-zero value, 277 | * then this commit and its parents will be hidden. 278 | * 279 | * @param commit_id oid of Commit 280 | * @param payload User-specified pointer to data to be passed as data payload 281 | * @return non-zero to hide the commmit and it parent. 282 | *) 283 | 284 | type 285 | git_revwalk_hide_cb = function(commit_id: Pgit_oid; payload: Pointer): Integer; cdecl; 286 | 287 | (** 288 | * Adds, changes or removes a callback function to hide a commit and its parents 289 | * 290 | * @param walk the revision walker 291 | * @param hide_cb callback function to hide a commit and its parents 292 | * @param payload data payload to be passed to callback function 293 | * @return 0 or an error code. 294 | *) 295 | 296 | function git_revwalk_add_hide_cb(walk: Pgit_revwalk; hide_cb: git_revwalk_hide_cb; 297 | payload: Pointer): Integer; cdecl; external libgit2_dll; 298 | 299 | (** @} *) 300 | 301 | 302 | 303 | -------------------------------------------------------------------------------- /src/git2/signature.inc: -------------------------------------------------------------------------------- 1 | (** 2 | * @file git2/signature.h 3 | * @brief Signatures are the actor in a repository and when they acted 4 | * @defgroup git_signature Git signature creation 5 | * @ingroup Git 6 | * 7 | * Signatures contain the information about the actor (committer or 8 | * author) in a repository, and the time that they performed the 9 | * commit, or authoring. 10 | * @{ 11 | *) 12 | 13 | (** 14 | * Create a new action signature. 15 | * 16 | * Call `git_signature_free()` to free the data. 17 | * 18 | * Note: angle brackets ('<' and '>') characters are not allowed 19 | * to be used in either the `name` or the `email` parameter. 20 | * 21 | * @param out new signature, in case of error NULL 22 | * @param name name of the person 23 | * @param email email of the person 24 | * @param time time (in seconds from epoch) when the action happened 25 | * @param offset timezone offset (in minutes) for the time 26 | * @return 0 or an error code 27 | *) 28 | 29 | function git_signature_new(out_: PPgit_signature; name_, email: PAnsiChar; time: git_time_t; 30 | offset: Integer): Integer; cdecl; external libgit2_dll; 31 | 32 | (** 33 | * Create a new action signature with a timestamp of 'now'. 34 | * 35 | * Call `git_signature_free()` to free the data. 36 | * 37 | * @param out new signature, in case of error NULL 38 | * @param name name of the person 39 | * @param email email of the person 40 | * @return 0 or an error code 41 | *) 42 | 43 | function git_signature_now(out_: PPgit_signature; name_, email: PAnsiChar): Integer; cdecl; external libgit2_dll; 44 | 45 | (** 46 | * Create a new author and/or committer signatures with default 47 | * information based on the configuration and environment variables. 48 | * 49 | * If `author_out` is set, it will be populated with the author 50 | * information. The `GIT_AUTHOR_NAME` and `GIT_AUTHOR_EMAIL` 51 | * environment variables will be honored, and `user.name` and 52 | * `user.email` configuration options will be honored if the 53 | * environment variables are unset. For timestamps, `GIT_AUTHOR_DATE` 54 | * will be used, otherwise the current time will be used. 55 | * 56 | * If `committer_out` is set, it will be populated with the 57 | * committer information. The `GIT_COMMITTER_NAME` and 58 | * `GIT_COMMITTER_EMAIL` environment variables will be honored, 59 | * and `user.name` and `user.email` configuration options will 60 | * be honored if the environment variables are unset. For timestamps, 61 | * `GIT_COMMITTER_DATE` will be used, otherwise the current time will 62 | * be used. 63 | * 64 | * If neither `GIT_AUTHOR_DATE` nor `GIT_COMMITTER_DATE` are set, 65 | * both timestamps will be set to the same time. 66 | * 67 | * It will return `GIT_ENOTFOUND` if either the `user.name` or 68 | * `user.email` are not set and there is no fallback from an environment 69 | * variable. One of `author_out` or `committer_out` must be set. 70 | * 71 | * @param author_out pointer to set the author signature, or NULL 72 | * @param committer_out pointer to set the committer signature, or NULL 73 | * @param repo repository pointer 74 | * @return 0 on success, GIT_ENOTFOUND if config is missing, or error code 75 | *) 76 | function git_signature_default_from_env(author_out, committer_out: PPgit_signature; 77 | repo: Pgit_repository): Integer; cdecl; external libgit2_dll; 78 | 79 | (** 80 | * Create a new action signature with default user and now timestamp. 81 | * 82 | * This looks up the user.name and user.email from the configuration and 83 | * uses the current time as the timestamp, and creates a new signature 84 | * based on that information. It will return GIT_ENOTFOUND if either the 85 | * user.name or user.email are not set. 86 | * 87 | * Note that these do not examine environment variables, only the 88 | * configuration files. Use `git_signature_default_from_env` to 89 | * consider the environment variables. 90 | * 91 | * @param out new signature 92 | * @param repo repository pointer 93 | * @return 0 on success, GIT_ENOTFOUND if config is missing, or error code 94 | *) 95 | 96 | function git_signature_default(out_: PPgit_signature; repo: Pgit_repository): Integer; cdecl; external libgit2_dll; 97 | 98 | (** 99 | * Create a new signature by parsing the given buffer, which is 100 | * expected to be in the format "Real Name timestamp tzoffset", 101 | * where `timestamp` is the number of seconds since the Unix epoch and 102 | * `tzoffset` is the timezone offset in `hhmm` format (note the lack 103 | * of a colon separator). 104 | * 105 | * @param out new signature 106 | * @param buf signature string 107 | * @return 0 on success, GIT_EINVALID if the signature is not parseable, or an error code 108 | *) 109 | 110 | function git_signature_from_buffer(out_: PPgit_signature; buf: PAnsiChar): Integer; cdecl; external libgit2_dll; 111 | 112 | (** 113 | * Create a copy of an existing signature. All internal strings are also 114 | * duplicated. 115 | * 116 | * Call `git_signature_free()` to free the data. 117 | * 118 | * @param dest pointer where to store the copy 119 | * @param sig signature to duplicate 120 | * @return 0 or an error code 121 | *) 122 | 123 | function git_signature_dup(dest: PPgit_signature; sig: Pgit_signature): Integer; cdecl; external libgit2_dll; 124 | 125 | (** 126 | * Free an existing signature. 127 | * 128 | * Because the signature is not an opaque structure, it is legal to free it 129 | * manually, but be sure to free the "name" and "email" strings in addition 130 | * to the structure itself. 131 | * 132 | * @param sig signature to free 133 | *) 134 | 135 | procedure git_signature_free(sig: Pgit_signature); cdecl; external libgit2_dll; 136 | 137 | (** @} *) 138 | 139 | 140 | -------------------------------------------------------------------------------- /src/git2/stash.inc: -------------------------------------------------------------------------------- 1 | (** 2 | * @file git2/stash.h 3 | * @brief Stashes stores some uncommitted state in the repository 4 | * @ingroup Git 5 | * 6 | * Stashes stores some uncommitted state in the repository; generally 7 | * this allows a user to stash some changes so that they can restore 8 | * the working directory to an unmodified state. This can allow a 9 | * developer to work on two different changes in parallel. 10 | * @{ 11 | *) 12 | 13 | (** 14 | * Stash flags 15 | *) 16 | 17 | const 18 | (** 19 | * No option, default 20 | *) 21 | GIT_STASH_DEFAULT = 0; 22 | (** 23 | * All changes already added to the index are left intact in 24 | * the working directory 25 | *) 26 | GIT_STASH_KEEP_INDEX = (1 shl 0); 27 | (** 28 | * All untracked files are also stashed and then cleaned up 29 | * from the working directory 30 | *) 31 | GIT_STASH_INCLUDE_UNTRACKED = (1 shl 1); 32 | (** 33 | * All ignored files are also stashed and then cleaned up from 34 | * the working directory 35 | *) 36 | GIT_STASH_INCLUDE_IGNORED = (1 shl 2); 37 | (** 38 | * All changes in the index and working directory are left intact 39 | *) 40 | GIT_STASH_KEEP_ALL = (1 shl 3); 41 | 42 | type 43 | git_stash_flags = Integer; 44 | 45 | (** 46 | * Save the local modifications to a new stash. 47 | * 48 | * @param out Object id of the commit containing the stashed state. 49 | * This commit is also the target of the direct reference refs/stash. 50 | * @param repo The owning repository. 51 | * @param stasher The identity of the person performing the stashing. 52 | * @param message Optional description along with the stashed state. 53 | * @param flags Flags to control the stashing process. (see GIT_STASH_* above) 54 | * @return 0 on success, GIT_ENOTFOUND where there's nothing to stash, 55 | * or error code. 56 | *) 57 | 58 | function git_stash_save(out_: Pgit_oid; repo: Pgit_repository; stasher: Pgit_signature; 59 | message: PAnsiChar; flags: uint32_t): Integer; cdecl; external libgit2_dll; 60 | 61 | (** 62 | * Stash save options structure 63 | * 64 | * Initialize with `GIT_STASH_SAVE_OPTIONS_INIT`. Alternatively, you can 65 | * use `git_stash_save_options_init`. 66 | * 67 | *) 68 | type 69 | git_stash_save_options = record 70 | version: Cardinal; 71 | 72 | (** Flags to control the stashing process. (see GIT_STASH_* above) *) 73 | flags: uint32_t; 74 | 75 | (** The identity of the person performing the stashing. *) 76 | stasher: Pgit_signature; 77 | 78 | (** Optional description along with the stashed state. *) 79 | message: PAnsiChar; 80 | 81 | (** Optional paths that control which files are stashed. *) 82 | paths: git_strarray; 83 | end; 84 | Pgit_stash_save_options = ^git_stash_save_options; 85 | 86 | const 87 | (** Current version for the `git_stash_save_options` structure *) 88 | GIT_STASH_SAVE_OPTIONS_VERSION = 1; 89 | (** Static constructor for `git_stash_save_options` *) 90 | //#define GIT_STASH_SAVE_OPTIONS_INIT { GIT_STASH_SAVE_OPTIONS_VERSION } 91 | 92 | (** 93 | * Initialize git_stash_save_options structure 94 | * 95 | * Initializes a `git_stash_save_options` with default values. Equivalent to 96 | * creating an instance with `GIT_STASH_SAVE_OPTIONS_INIT`. 97 | * 98 | * @param opts The `git_stash_save_options` struct to initialize. 99 | * @param version The struct version; pass `GIT_STASH_SAVE_OPTIONS_VERSION`. 100 | * @return Zero on success; -1 on failure. 101 | *) 102 | function git_stash_save_options_init(opts: Pgit_stash_save_options; 103 | version: Cardinal): Integer; cdecl; external libgit2_dll; 104 | 105 | (** 106 | * Save the local modifications to a new stash, with options. 107 | * 108 | * @param out Object id of the commit containing the stashed state. 109 | * This commit is also the target of the direct reference refs/stash. 110 | * @param repo The owning repository. 111 | * @param opts The stash options. 112 | * @return 0 on success, GIT_ENOTFOUND where there's nothing to stash, 113 | * or error code. 114 | *) 115 | function git_stash_save_with_opts(out_: Pgit_oid; repo: Pgit_repository; 116 | opts: Pgit_stash_save_options): Integer; cdecl; external libgit2_dll; 117 | 118 | (** Stash application flags. *) 119 | 120 | const 121 | GIT_STASH_APPLY_DEFAULT = 0; 122 | (* Try to reinstate not only the working tree's changes, 123 | * but also the index's changes. 124 | *) 125 | GIT_STASH_APPLY_REINSTATE_INDEX = (1 shl 0); 126 | type 127 | git_stash_apply_flags = Integer; 128 | 129 | (** Stash apply progression states *) 130 | 131 | const 132 | GIT_STASH_APPLY_PROGRESS_NONE = 0; 133 | (** Loading the stashed data from the object database. *) 134 | GIT_STASH_APPLY_PROGRESS_LOADING_STASH = 1; 135 | (** The stored index is being analyzed. *) 136 | GIT_STASH_APPLY_PROGRESS_ANALYZE_INDEX = 2; 137 | (** The modified files are being analyzed. *) 138 | GIT_STASH_APPLY_PROGRESS_ANALYZE_MODIFIED = 3; 139 | (** The untracked and ignored files are being analyzed. *) 140 | GIT_STASH_APPLY_PROGRESS_ANALYZE_UNTRACKED = 4; 141 | (** The untracked files are being written to disk. *) 142 | GIT_STASH_APPLY_PROGRESS_CHECKOUT_UNTRACKED = 5; 143 | (** The modified files are being written to disk. *) 144 | GIT_STASH_APPLY_PROGRESS_CHECKOUT_MODIFIED = 6; 145 | (** The stash was applied successfully. *) 146 | GIT_STASH_APPLY_PROGRESS_DONE = 7; 147 | type 148 | git_stash_apply_progress_t = Integer; 149 | 150 | (** 151 | * Stash application progress notification function. 152 | * Return 0 to continue processing, or a negative value to 153 | * abort the stash application. 154 | * 155 | * @param progress the progress information 156 | * @param payload the user-specified payload to the apply function 157 | * @return 0 on success, -1 on error 158 | *) 159 | 160 | git_stash_apply_progress_cb = function(progress: git_stash_apply_progress_t; payload: Pointer): Integer; cdecl; 161 | 162 | (** 163 | * Stash application options structure 164 | * 165 | * Initialize with `GIT_STASH_APPLY_OPTIONS_INIT`. Alternatively, you can 166 | * use `git_stash_apply_options_init`. 167 | * 168 | *) 169 | 170 | git_stash_apply_options = record 171 | version: Cardinal; 172 | (** See `git_stash_apply_flags`, above. *) 173 | flags: uint32_t; 174 | (** Options to use when writing files to the working directory. *) 175 | checkout_options: git_checkout_options; 176 | (** Optional callback to notify the consumer of application progress. *) 177 | progress_cb: git_stash_apply_progress_cb; 178 | progress_payload: Pointer; 179 | end; 180 | Pgit_stash_apply_options = ^git_stash_apply_options; 181 | 182 | const 183 | (** Current version for the `git_stash_apply_options` structure *) 184 | GIT_STASH_APPLY_OPTIONS_VERSION = 1; 185 | (** Static constructor for `git_stash_apply_options` *) 186 | //GIT_STASH_APPLY_OPTIONS_INIT = { GIT_STASH_APPLY_OPTIONS_VERSION , GIT_STASH_APPLY_DEFAULT , GIT_CHECKOUT_OPTIONS_INIT }; 187 | (** 188 | * Initialize git_stash_apply_options structure 189 | * 190 | * Initializes a `git_stash_apply_options` with default values. Equivalent to 191 | * creating an instance with `GIT_STASH_APPLY_OPTIONS_INIT`. 192 | * 193 | * @param opts The `git_stash_apply_options` struct to initialize. 194 | * @param version The struct version; pass `GIT_STASH_APPLY_OPTIONS_VERSION`. 195 | * @return Zero on success; -1 on failure. 196 | *) 197 | 198 | function git_stash_apply_options_init(opts: Pgit_stash_apply_options; version: Cardinal): Integer; cdecl; external libgit2_dll; 199 | 200 | (** 201 | * Apply a single stashed state from the stash list. 202 | * 203 | * If local changes in the working directory conflict with changes in the 204 | * stash then GIT_EMERGECONFLICT will be returned. In this case, the index 205 | * will always remain unmodified and all files in the working directory will 206 | * remain unmodified. However, if you are restoring untracked files or 207 | * ignored files and there is a conflict when applying the modified files, 208 | * then those files will remain in the working directory. 209 | * 210 | * If passing the GIT_STASH_APPLY_REINSTATE_INDEX flag and there would be 211 | * conflicts when reinstating the index, the function will return 212 | * GIT_EMERGECONFLICT and both the working directory and index will be left 213 | * unmodified. 214 | * 215 | * @param repo The owning repository. 216 | * @param index The position within the stash list. 0 points to the 217 | * most recent stashed state. 218 | * @param options Optional options to control how stashes are applied. 219 | * 220 | * @return 0 on success, GIT_ENOTFOUND if there's no stashed state for the 221 | * given index, GIT_EMERGECONFLICT if changes exist in the working 222 | * directory, or an error code 223 | *) 224 | 225 | function git_stash_apply(repo: Pgit_repository; index_: size_t; 226 | options: Pgit_stash_apply_options): Integer; cdecl; external libgit2_dll; 227 | 228 | (** 229 | * This is a callback function you can provide to iterate over all the 230 | * stashed states that will be invoked per entry. 231 | * 232 | * @param index The position within the stash list. 0 points to the 233 | * most recent stashed state. 234 | * @param message The stash message. 235 | * @param stash_id The commit oid of the stashed state. 236 | * @param payload Extra parameter to callback function. 237 | * @return 0 to continue iterating or non-zero to stop. 238 | *) 239 | 240 | type 241 | git_stash_cb = function(index_: size_t; message: PAnsiChar; stash_id: Pgit_oid; payload: Pointer): Integer; cdecl; 242 | 243 | (** 244 | * Loop over all the stashed states and issue a callback for each one. 245 | * 246 | * If the callback returns a non-zero value, this will stop looping. 247 | * 248 | * @param repo Repository where to find the stash. 249 | * 250 | * @param callback Callback to invoke per found stashed state. The most 251 | * recent stash state will be enumerated first. 252 | * 253 | * @param payload Extra parameter to callback function. 254 | * 255 | * @return 0 on success, non-zero callback return value, or error code. 256 | *) 257 | 258 | function git_stash_foreach(repo: Pgit_repository; callback: git_stash_cb; 259 | payload: Pointer): Integer; cdecl; external libgit2_dll; 260 | 261 | (** 262 | * Remove a single stashed state from the stash list. 263 | * 264 | * @param repo The owning repository. 265 | * 266 | * @param index The position within the stash list. 0 points to the 267 | * most recent stashed state. 268 | * 269 | * @return 0 on success, GIT_ENOTFOUND if there's no stashed state for the given 270 | * index, or error code. 271 | *) 272 | 273 | function git_stash_drop(repo: Pgit_repository; index_: size_t): Integer; cdecl; external libgit2_dll; 274 | 275 | (** 276 | * Apply a single stashed state from the stash list and remove it from the list 277 | * if successful. 278 | * 279 | * @param repo The owning repository. 280 | * @param index The position within the stash list. 0 points to the 281 | * most recent stashed state. 282 | * @param options Optional options to control how stashes are applied. 283 | * 284 | * @return 0 on success, GIT_ENOTFOUND if there's no stashed state for the given 285 | * index, or error code. (see git_stash_apply() above for details) 286 | *) 287 | 288 | function git_stash_pop(repo: Pgit_repository; index_: size_t; 289 | options: Pgit_stash_apply_options): Integer; cdecl; external libgit2_dll; 290 | 291 | (** @} *) 292 | 293 | -------------------------------------------------------------------------------- /src/git2/stdint.inc: -------------------------------------------------------------------------------- 1 | // ISO C9x compliant stdint.h for Microsoft Visual Studio 2 | // Based on ISO/IEC 9899:TC2 Committee draft (May 6, 2005) WG14/N1124 3 | // 4 | // Copyright (c) 2006-2008 Alexander Chemeris 5 | // 6 | // Redistribution and use in source and binary forms, with or without 7 | // modification, are permitted provided that the following conditions are met: 8 | // 9 | // 1. Redistributions of source code must retain the above copyright notice, 10 | // this list of conditions and the following disclaimer. 11 | // 12 | // 2. Redistributions in binary form must reproduce the above copyright 13 | // notice, this list of conditions and the following disclaimer in the 14 | // documentation and/or other materials provided with the distribution. 15 | // 16 | // 3. The name of the author may be used to endorse or promote products 17 | // derived from this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 20 | // WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 21 | // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 22 | // EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 24 | // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 25 | // OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 26 | // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 27 | // OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 28 | // ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | /////////////////////////////////////////////////////////////////////////////// 31 | 32 | (* 33 | // Define _W64 macros to mark types changing their size, like intptr_t. 34 | #ifndef _W64 35 | # if !defined(__midl) && (defined(_X86_) || defined(_M_IX86)) && _MSC_VER >= 1300 36 | # define _W64 __w64 37 | # else 38 | # define _W64 39 | # endif 40 | #endif 41 | *) 42 | // 7.18.1 Integer types 43 | 44 | // 7.18.1.1 Exact-width integer types 45 | 46 | type 47 | int8_t = Shortint; 48 | int16_t = Smallint; 49 | int32_t = Integer; 50 | uint8_t = Byte; 51 | uint16_t = Word; 52 | uint32_t = Cardinal; 53 | int64_t = Int64; 54 | uint64_t = UInt64; 55 | 56 | 57 | // 7.18.1.2 Minimum-width integer types 58 | type 59 | int_least8_t = int8_t; 60 | int_least16_t = int16_t; 61 | int_least32_t = int32_t; 62 | int_least64_t = int64_t; 63 | uint_least8_t = uint8_t; 64 | uint_least16_t = uint16_t; 65 | uint_least32_t = uint32_t; 66 | uint_least64_t = uint64_t; 67 | 68 | // 7.18.1.3 Fastest minimum-width integer types 69 | int_fast8_t = int8_t; 70 | int_fast16_t = int16_t; 71 | int_fast32_t = int32_t; 72 | int_fast64_t = int64_t; 73 | uint_fast8_t = uint8_t; 74 | uint_fast16_t = uint16_t; 75 | uint_fast32_t = uint32_t; 76 | uint_fast64_t = uint64_t; 77 | 78 | // 7.18.1.4 Integer types capable of holding object pointers 79 | 80 | {$IFDEF CPU64} 81 | intptr_t = Int64; 82 | uintptr_t = UInt64; 83 | {$ELSE} 84 | intptr_t = Integer; 85 | uintptr_t = Cardinal; 86 | {$ENDIF} 87 | 88 | // 7.18.1.5 Greatest-width integer types 89 | 90 | intmax_t = int64_t; 91 | uintmax_t = uint64_t; 92 | 93 | 94 | // 7.18.2 Limits of specified-width integer types 95 | 96 | // 7.18.2.1 Limits of exact-width integer types 97 | const 98 | INT8_MIN = int8_t(Low(int8_t)); 99 | INT8_MAX = int8_t(High(int8_t)); 100 | INT16_MIN = int16_t(Low(int16_t)); 101 | INT16_MAX = int16_t(High(int16_t)); 102 | INT32_MIN = int32_t(Low(int32_t)); 103 | INT32_MAX = int32_t(High(int32_t)); 104 | INT64_MIN = int64_t(Low(int64_t)); 105 | INT64_MAX = int64_t(High(int64_t)); 106 | UINT8_MAX = uint8_t(High(uint8_t)); 107 | UINT16_MAX = uint16_t(High(uint16_t)); 108 | UINT32_MAX = uint32_t(High(uint32_t)); 109 | UINT64_MAX = uint64_t(High(uint64_t)); 110 | // 7.18.2.2 Limits of minimum-width integer types 111 | INT_LEAST8_MIN = INT8_MIN; 112 | INT_LEAST8_MAX = INT8_MAX; 113 | INT_LEAST16_MIN = INT16_MIN; 114 | INT_LEAST16_MAX = INT16_MAX; 115 | INT_LEAST32_MIN = INT32_MIN; 116 | INT_LEAST32_MAX = INT32_MAX; 117 | INT_LEAST64_MIN = INT64_MIN; 118 | INT_LEAST64_MAX = INT64_MAX; 119 | UINT_LEAST8_MAX = UINT8_MAX; 120 | UINT_LEAST16_MAX = UINT16_MAX; 121 | UINT_LEAST32_MAX = UINT32_MAX; 122 | UINT_LEAST64_MAX = UINT64_MAX; 123 | // 7.18.2.3 Limits of fastest minimum-width integer types 124 | INT_FAST8_MIN = INT8_MIN; 125 | INT_FAST8_MAX = INT8_MAX; 126 | INT_FAST16_MIN = INT16_MIN; 127 | INT_FAST16_MAX = INT16_MAX; 128 | INT_FAST32_MIN = INT32_MIN; 129 | INT_FAST32_MAX = INT32_MAX; 130 | INT_FAST64_MIN = INT64_MIN; 131 | INT_FAST64_MAX = INT64_MAX; 132 | UINT_FAST8_MAX = UINT8_MAX; 133 | UINT_FAST16_MAX = UINT16_MAX; 134 | UINT_FAST32_MAX = UINT32_MAX; 135 | UINT_FAST64_MAX = UINT64_MAX; 136 | // 7.18.2.4 Limits of integer types capable of holding object pointers 137 | {$IFDEF CPU64} 138 | INTPTR_MIN = INT64_MIN; 139 | INTPTR_MAX = INT64_MAX; 140 | UINTPTR_MAX = UINT64_MAX; 141 | {$ELSE} 142 | INTPTR_MIN = INT32_MIN; 143 | INTPTR_MAX = INT32_MAX; 144 | UINTPTR_MAX = UINT32_MAX; 145 | {$ENDIF} 146 | // 7.18.2.5 Limits of greatest-width integer types 147 | INTMAX_MIN = INT64_MIN; 148 | INTMAX_MAX = INT64_MAX; 149 | UINTMAX_MAX = UINT64_MAX; 150 | // 7.18.3 Limits of other integer types 151 | 152 | 153 | {$IFDEF CPU64} 154 | PTRDIFF_MIN = INT64_MIN; 155 | PTRDIFF_MAX = INT64_MAX; 156 | {$ELSE} 157 | PTRDIFF_MIN = INT32_MIN; 158 | PTRDIFF_MAX = INT32_MAX; 159 | {$ENDIF} 160 | {$IFDEF CPU64} 161 | SIG_ATOMIC_MIN = INT64_MIN; 162 | SIG_ATOMIC_MAX = INT64_MAX; 163 | {$ELSE} 164 | SIG_ATOMIC_MIN = INT32_MIN; 165 | SIG_ATOMIC_MAX = INT32_MAX; 166 | {$ENDIF} 167 | {$IFDEF CPU64} 168 | SIZE_MAX = UINT64_MAX; 169 | {$ELSE} 170 | SIZE_MAX = UINT32_MAX; 171 | {$ENDIF} 172 | 173 | // WCHAR_MIN and WCHAR_MAX are also defined in 174 | const 175 | WCHAR_MIN = 0; 176 | WCHAR_MAX = UINT16_MAX; 177 | WINT_MIN = 0; 178 | WINT_MAX = UINT16_MAX; 179 | 180 | 181 | // 7.18.4 Limits of other integer types 182 | 183 | // 7.18.4.1 Macros for minimum-width integer constants 184 | (* 185 | #define INT8_C(val) val##i8 186 | #define INT16_C(val) val##i16 187 | #define INT32_C(val) val##i32 188 | #define INT64_C(val) val##i64 189 | 190 | #define UINT8_C(val) val##ui8 191 | #define UINT16_C(val) val##ui16 192 | #define UINT32_C(val) val##ui32 193 | #define UINT64_C(val) val##ui64 194 | 195 | // 7.18.4.2 Macros for greatest-width integer constants 196 | const 197 | INTMAX_C = INT64_C; 198 | UINTMAX_C = UINT64_C; 199 | *) 200 | 201 | -------------------------------------------------------------------------------- /src/git2/strarray.inc: -------------------------------------------------------------------------------- 1 | (** 2 | * @file git2/strarray.h 3 | * @brief An array of strings for the user to free 4 | * @defgroup git_strarray An array of strings for the user to free 5 | * @ingroup Git 6 | * @{ 7 | *) 8 | 9 | (** Array of strings *) 10 | 11 | type 12 | git_strarray = record 13 | strings: PPAnsiChar; 14 | Count: size_t; 15 | end; 16 | Pgit_strarray = ^git_strarray; 17 | 18 | (** 19 | * Free the strings contained in a string array. This method should 20 | * be called on `git_strarray` objects that were provided by the 21 | * library. Not doing so, will result in a memory leak. 22 | * 23 | * This does not free the `git_strarray` itself, since the library will 24 | * never allocate that object directly itself. 25 | * 26 | * @param array The git_strarray that contains strings to free 27 | *) 28 | 29 | procedure git_strarray_dispose(array_: Pgit_strarray); cdecl; external libgit2_dll; 30 | 31 | (** @} *) 32 | 33 | -------------------------------------------------------------------------------- /src/git2/trace.inc: -------------------------------------------------------------------------------- 1 | (** 2 | * @file git2/trace.h 3 | * @brief Tracing functionality to introspect libgit2 in your application 4 | * @defgroup git_trace Tracing functionality to introspect libgit2 in your application 5 | * @ingroup Git 6 | * @{ 7 | *) 8 | 9 | (** 10 | * Available tracing levels. When tracing is set to a particular level, 11 | * callers will be provided tracing at the given level and all lower levels. 12 | *) 13 | 14 | const 15 | (** No tracing will be performed. *) 16 | GIT_TRACE_NONE = 0; 17 | (** Severe errors that may impact the program's execution *) 18 | GIT_TRACE_FATAL = 1; 19 | (** Errors that do not impact the program's execution *) 20 | GIT_TRACE_ERROR = 2; 21 | (** Warnings that suggest abnormal data *) 22 | GIT_TRACE_WARN = 3; 23 | (** Informational messages about program execution *) 24 | GIT_TRACE_INFO = 4; 25 | (** Detailed data that allows for debugging *) 26 | GIT_TRACE_DEBUG = 5; 27 | (** Exceptionally detailed debugging data *) 28 | GIT_TRACE_TRACE = 6; 29 | type 30 | git_trace_level_t = Integer; 31 | 32 | (** 33 | * An instance for a tracing function 34 | * 35 | * @param level the trace level 36 | * @param msg the trace message 37 | *) 38 | 39 | git_trace_cb = procedure(level: git_trace_level_t; msg: PAnsiChar); cdecl; 40 | 41 | (** 42 | * Sets the system tracing configuration to the specified level with the 43 | * specified callback. When system events occur at a level equal to, or 44 | * lower than, the given level they will be reported to the given callback. 45 | * 46 | * @param level Level to set tracing to 47 | * @param cb Function to call with trace data 48 | * @return 0 or an error code 49 | *) 50 | 51 | function git_trace_set(level: git_trace_level_t; cb: git_trace_cb): Integer; cdecl; external libgit2_dll; 52 | 53 | (** @} *) 54 | 55 | 56 | -------------------------------------------------------------------------------- /src/git2/transaction.inc: -------------------------------------------------------------------------------- 1 | (** 2 | * @file git2/transaction.h 3 | * @brief Transactional reference handling 4 | * @defgroup git_transaction Transactional reference handling 5 | * @ingroup Git 6 | * @{ 7 | *) 8 | 9 | (** 10 | * Create a new transaction object 11 | * 12 | * This does not lock anything, but sets up the transaction object to 13 | * know from which repository to lock. 14 | * 15 | * @param out the resulting transaction 16 | * @param repo the repository in which to lock 17 | * @return 0 or an error code 18 | *) 19 | 20 | function git_transaction_new(out_: PPgit_transaction; repo: Pgit_repository): Integer; cdecl; external libgit2_dll; 21 | 22 | (** 23 | * Lock a reference 24 | * 25 | * Lock the specified reference. This is the first step to updating a 26 | * reference. 27 | * 28 | * @param tx the transaction 29 | * @param refname the reference to lock 30 | * @return 0 or an error message 31 | *) 32 | 33 | function git_transaction_lock_ref(tx: Pgit_transaction; refname: PAnsiChar): Integer; cdecl; external libgit2_dll; 34 | 35 | (** 36 | * Set the target of a reference 37 | * 38 | * Set the target of the specified reference. This reference must be 39 | * locked. 40 | * 41 | * @param tx the transaction 42 | * @param refname reference to update 43 | * @param target target to set the reference to 44 | * @param sig signature to use in the reflog; pass NULL to read the identity from the config 45 | * @param msg message to use in the reflog 46 | * @return 0, GIT_ENOTFOUND if the reference is not among the locked ones, or an error code 47 | *) 48 | 49 | function git_transaction_set_target(tx: Pgit_transaction; refname: PAnsiChar; target: Pgit_oid; 50 | sig: Pgit_signature; msg: PAnsiChar): Integer; cdecl; external libgit2_dll; 51 | 52 | (** 53 | * Set the target of a reference 54 | * 55 | * Set the target of the specified reference. This reference must be 56 | * locked. 57 | * 58 | * @param tx the transaction 59 | * @param refname reference to update 60 | * @param target target to set the reference to 61 | * @param sig signature to use in the reflog; pass NULL to read the identity from the config 62 | * @param msg message to use in the reflog 63 | * @return 0, GIT_ENOTFOUND if the reference is not among the locked ones, or an error code 64 | *) 65 | 66 | function git_transaction_set_symbolic_target(tx: Pgit_transaction; refname, target: PAnsiChar; 67 | sig: Pgit_signature; msg: PAnsiChar): Integer; cdecl; external libgit2_dll; 68 | 69 | (** 70 | * Set the reflog of a reference 71 | * 72 | * Set the specified reference's reflog. If this is combined with 73 | * setting the target, that update won't be written to the reflog. 74 | * 75 | * @param tx the transaction 76 | * @param refname the reference whose reflog to set 77 | * @param reflog the reflog as it should be written out 78 | * @return 0, GIT_ENOTFOUND if the reference is not among the locked ones, or an error code 79 | *) 80 | 81 | function git_transaction_set_reflog(tx: Pgit_transaction; refname: PAnsiChar; 82 | reflog: Pgit_reflog): Integer; cdecl; external libgit2_dll; 83 | 84 | (** 85 | * Remove a reference 86 | * 87 | * @param tx the transaction 88 | * @param refname the reference to remove 89 | * @return 0, GIT_ENOTFOUND if the reference is not among the locked ones, or an error code 90 | *) 91 | 92 | function git_transaction_remove(tx: Pgit_transaction; refname: PAnsiChar): Integer; cdecl; external libgit2_dll; 93 | 94 | (** 95 | * Commit the changes from the transaction 96 | * 97 | * Perform the changes that have been queued. The updates will be made 98 | * one by one, and the first failure will stop the processing. 99 | * 100 | * @param tx the transaction 101 | * @return 0 or an error code 102 | *) 103 | 104 | function git_transaction_commit(tx: Pgit_transaction): Integer; cdecl; external libgit2_dll; 105 | 106 | (** 107 | * Free the resources allocated by this transaction 108 | * 109 | * If any references remain locked, they will be unlocked without any 110 | * changes made to them. 111 | * 112 | * @param tx the transaction 113 | *) 114 | 115 | procedure git_transaction_free(tx: Pgit_transaction); cdecl; external libgit2_dll; 116 | 117 | (** @} *) 118 | 119 | 120 | -------------------------------------------------------------------------------- /src/git2/transport.inc: -------------------------------------------------------------------------------- 1 | (** 2 | * @file git2/transport.h 3 | * @brief Transports are the low-level mechanism to connect to a remote server 4 | * @defgroup git_transport Transports are the low-level mechanism to connect to a remote server 5 | * @ingroup Git 6 | * @{ 7 | *) 8 | 9 | (** 10 | * Callback for messages received by the transport. 11 | * 12 | * Return a negative value to cancel the network operation. 13 | * 14 | * @param str The message from the transport 15 | * @param len The length of the message 16 | * @param payload Payload provided by the caller 17 | * @return 0 on success or an error code 18 | *) 19 | 20 | type 21 | git_transport_message_cb = function(str: PAnsiChar; len: Integer; payload: Pointer): Integer; cdecl; 22 | 23 | (** Signature of a function which creates a transport *) 24 | 25 | type 26 | (** 27 | * Signature of a function which creates a transport. 28 | * 29 | * @param out the transport generate 30 | * @param owner the owner for the transport 31 | * @param param the param to the transport creation 32 | * @return 0 on success or an error code 33 | *) 34 | git_transport_cb = function(out_: PPgit_transport; owner: Pgit_remote; param: Pointer): Integer; cdecl; 35 | 36 | (** @} *) 37 | 38 | 39 | -------------------------------------------------------------------------------- /src/git2/version.inc: -------------------------------------------------------------------------------- 1 | (** 2 | * @file git2/version.h 3 | * @brief The version of libgit2 4 | * @ingroup Git 5 | * @{ 6 | *) 7 | 8 | const 9 | (** 10 | * The version string for libgit2. This string follows semantic 11 | * versioning (v2) guidelines. 12 | *) 13 | LIBGIT2_VERSION = '1.9.1'; 14 | 15 | (** The major version number for this version of libgit2. *) 16 | LIBGIT2_VERSION_MAJOR = 1; 17 | 18 | (** The minor version number for this version of libgit2. *) 19 | LIBGIT2_VERSION_MINOR = 9; 20 | 21 | (** The revision ("teeny") version number for this version of libgit2. *) 22 | LIBGIT2_VERSION_REVISION = 1; 23 | 24 | (** The Windows DLL patch number for this version of libgit2. *) 25 | LIBGIT2_VERSION_PATCH = 0; 26 | 27 | (** 28 | * The prerelease string for this version of libgit2. For development 29 | * (nightly) builds, this will be "alpha". For prereleases, this will be 30 | * a prerelease name like "beta" or "rc1". For final releases, this will 31 | * be `NULL`. 32 | *) 33 | LIBGIT2_VERSION_PRERELEASE : PAnsiChar = nil; 34 | 35 | (** 36 | * The library ABI soversion for this version of libgit2. This should 37 | * only be changed when the library has a breaking ABI change, and so 38 | * may not reflect the library's API version number. 39 | *) 40 | LIBGIT2_SOVERSION = '1.9'; 41 | 42 | (** 43 | * An integer value representing the libgit2 version number. For example, 44 | * libgit2 1.6.3 is 1060300. 45 | *) 46 | LIBGIT2_VERSION_NUMBER = 47 | (LIBGIT2_VERSION_MAJOR * 1000000) + 48 | (LIBGIT2_VERSION_MINOR * 10000) + 49 | (LIBGIT2_VERSION_REVISION * 100); 50 | 51 | (** 52 | * Compare the libgit2 version against a given version. Evaluates to true 53 | * if the given major, minor, and revision values are greater than or equal 54 | * to the currently running libgit2 version. For example: 55 | * 56 | * #if LIBGIT2_VERSION_CHECK(1, 6, 3) 57 | * # error libgit2 version is >= 1.6.3 58 | * #endif 59 | *) 60 | function LIBGIT2_VERSION_CHECK(major, minor, revision: Integer): Boolean; 61 | 62 | -------------------------------------------------------------------------------- /src/git2/worktree.inc: -------------------------------------------------------------------------------- 1 | (** 2 | * @file git2/worktree.h 3 | * @brief Additional working directories for a repository 4 | * @defgroup git_commit Additional working directories for a repository 5 | * @ingroup Git 6 | * @{ 7 | *) 8 | 9 | (** 10 | * List names of linked working trees 11 | * 12 | * The returned list should be released with `git_strarray_free` 13 | * when no longer needed. 14 | * 15 | * @param out pointer to the array of working tree names 16 | * @param repo the repo to use when listing working trees 17 | * @return 0 or an error code 18 | *) 19 | 20 | function git_worktree_list(out_: Pgit_strarray; repo: Pgit_repository): Integer; cdecl; external libgit2_dll; 21 | 22 | (** 23 | * Lookup a working tree by its name for a given repository 24 | * 25 | * @param out Output pointer to looked up worktree or `NULL` 26 | * @param repo The repository containing worktrees 27 | * @param name Name of the working tree to look up 28 | * @return 0 or an error code 29 | *) 30 | 31 | function git_worktree_lookup(out_: PPgit_worktree; repo: Pgit_repository; name_: PAnsiChar): Integer; cdecl; external libgit2_dll; 32 | 33 | (** 34 | * Open a worktree of a given repository 35 | * 36 | * If a repository is not the main tree but a worktree, this 37 | * function will look up the worktree inside the parent 38 | * repository and create a new `git_worktree` structure. 39 | * 40 | * @param out Out-pointer for the newly allocated worktree 41 | * @param repo Repository to look up worktree for 42 | * @return 0 or an error code 43 | *) 44 | 45 | function git_worktree_open_from_repository(out_: PPgit_worktree; 46 | repo: Pgit_repository): Integer; cdecl; external libgit2_dll; 47 | 48 | (** 49 | * Free a previously allocated worktree 50 | * 51 | * @param wt worktree handle to close. If NULL nothing occurs. 52 | *) 53 | 54 | procedure git_worktree_free(wt: Pgit_worktree); cdecl; external libgit2_dll; 55 | 56 | (** 57 | * Check if worktree is valid 58 | * 59 | * A valid worktree requires both the git data structures inside 60 | * the linked parent repository and the linked working copy to be 61 | * present. 62 | * 63 | * @param wt Worktree to check 64 | * @return 0 when worktree is valid, error-code otherwise 65 | *) 66 | 67 | function git_worktree_validate(wt: Pgit_worktree): Integer; cdecl; external libgit2_dll; 68 | 69 | (** 70 | * Worktree add options structure 71 | * 72 | * Initialize with `GIT_WORKTREE_ADD_OPTIONS_INIT`. Alternatively, you can 73 | * use `git_worktree_add_options_init`. 74 | * 75 | *) 76 | 77 | type 78 | git_worktree_add_options = record 79 | version: Cardinal; 80 | lock: Integer; (**< lock newly created worktree *) 81 | checkout_existing: Integer; (**< allow checkout of existing branch matching worktree name *) 82 | ref: Pgit_reference; (**< reference to use for the new worktree HEAD *) 83 | (** 84 | * Options for the checkout. 85 | *) 86 | checkout_options: git_checkout_options; 87 | end; 88 | Pgit_worktree_add_options = ^git_worktree_add_options; 89 | 90 | const 91 | (** Current version for the `git_worktree_add_options` structure *) 92 | GIT_WORKTREE_ADD_OPTIONS_VERSION = 1; 93 | (** Static constructor for `git_worktree_add_options` *) 94 | //GIT_WORKTREE_ADD_OPTIONS_INIT {GIT_WORKTREE_ADD_OPTIONS_VERSION,0,NULL,GIT_CHECKOUT_OPTIONS_INIT} 95 | (** 96 | * Initialize git_worktree_add_options structure 97 | * 98 | * Initializes a `git_worktree_add_options` with default values. Equivalent to 99 | * creating an instance with `GIT_WORKTREE_ADD_OPTIONS_INIT`. 100 | * 101 | * @param opts The `git_worktree_add_options` struct to initialize. 102 | * @param version The struct version; pass `GIT_WORKTREE_ADD_OPTIONS_VERSION`. 103 | * @return Zero on success; -1 on failure. 104 | *) 105 | 106 | function git_worktree_add_options_init(opts: Pgit_worktree_add_options; version: Cardinal): Integer; cdecl; external libgit2_dll; 107 | 108 | (** 109 | * Add a new working tree 110 | * 111 | * Add a new working tree for the repository, that is create the 112 | * required data structures inside the repository and check out 113 | * the current HEAD at `path` 114 | * 115 | * @param out Output pointer containing new working tree 116 | * @param repo Repository to create working tree for 117 | * @param name Name of the working tree 118 | * @param path Path to create working tree at 119 | * @param opts Options to modify default behavior. May be NULL 120 | * @return 0 or an error code 121 | *) 122 | 123 | function git_worktree_add(out_: PPgit_worktree; repo: Pgit_repository; name_, path: PAnsiChar; 124 | opts: Pgit_worktree_add_options): Integer; cdecl; external libgit2_dll; 125 | 126 | (** 127 | * Lock worktree if not already locked 128 | * 129 | * Lock a worktree, optionally specifying a reason why the linked 130 | * working tree is being locked. 131 | * 132 | * @param wt Worktree to lock 133 | * @param reason Reason why the working tree is being locked 134 | * @return 0 on success, non-zero otherwise 135 | *) 136 | 137 | function git_worktree_lock(wt: Pgit_worktree; reason: PAnsiChar): Integer; cdecl; external libgit2_dll; 138 | 139 | (** 140 | * Unlock a locked worktree 141 | * 142 | * @param wt Worktree to unlock 143 | * @return 0 on success, 1 if worktree was not locked, error-code 144 | * otherwise 145 | *) 146 | 147 | function git_worktree_unlock(wt: Pgit_worktree): Integer; cdecl; external libgit2_dll; 148 | 149 | (** 150 | * Check if worktree is locked 151 | * 152 | * A worktree may be locked if the linked working tree is stored 153 | * on a portable device which is not available. 154 | * 155 | * @param reason Buffer to store reason in. If NULL no reason is stored. 156 | * @param wt Worktree to check 157 | * @return 0 when the working tree not locked, a value greater 158 | * than zero if it is locked, less than zero if there was an 159 | * error 160 | *) 161 | 162 | function git_worktree_is_locked(reason: Pgit_buf; wt: Pgit_worktree): Integer; cdecl; external libgit2_dll; 163 | 164 | (** 165 | * Retrieve the name of the worktree 166 | * 167 | * @param wt Worktree to get the name for 168 | * @return The worktree's name. The pointer returned is valid for the 169 | * lifetime of the git_worktree 170 | *) 171 | 172 | function git_worktree_name(wt: Pgit_worktree): PAnsiChar; cdecl; external libgit2_dll; 173 | 174 | (** 175 | * Retrieve the filesystem path for the worktree 176 | * 177 | * @param wt Worktree to get the path for 178 | * @return The worktree's filesystem path. The pointer returned 179 | * is valid for the lifetime of the git_worktree. 180 | *) 181 | 182 | function git_worktree_path(wt: Pgit_worktree): PAnsiChar; cdecl; external libgit2_dll; 183 | 184 | (** 185 | * Flags which can be passed to git_worktree_prune to alter its 186 | * behavior. 187 | *) 188 | 189 | const 190 | (* Prune working tree even if working tree is valid *) 191 | GIT_WORKTREE_PRUNE_VALID = 1 shl 0; 192 | (* Prune working tree even if it is locked *) 193 | GIT_WORKTREE_PRUNE_LOCKED = 1 shl 1; 194 | (* Prune checked out working tree *) 195 | GIT_WORKTREE_PRUNE_WORKING_TREE = 1 shl 2; 196 | type 197 | git_worktree_prune_t = Integer; 198 | 199 | (** 200 | * Worktree prune options structure 201 | * 202 | * Initialize with `GIT_WORKTREE_PRUNE_OPTIONS_INIT`. Alternatively, you can 203 | * use `git_worktree_prune_options_init`. 204 | * 205 | *) 206 | 207 | git_worktree_prune_options = record 208 | version: Cardinal; 209 | (** A combination of `git_worktree_prune_t` *) 210 | flags: uint32_t; 211 | end; 212 | Pgit_worktree_prune_options = ^git_worktree_prune_options; 213 | 214 | const 215 | (** Current version for the `git_worktree_prune_options` structure *) 216 | GIT_WORKTREE_PRUNE_OPTIONS_VERSION = 1; 217 | (** Static constructor for `git_worktree_prune_options` *) 218 | //GIT_WORKTREE_PRUNE_OPTIONS_INIT = { GIT_WORKTREE_PRUNE_OPTIONS_VERSION , 0 }; 219 | (** 220 | * Initialize git_worktree_prune_options structure 221 | * 222 | * Initializes a `git_worktree_prune_options` with default values. Equivalent to 223 | * creating an instance with `GIT_WORKTREE_PRUNE_OPTIONS_INIT`. 224 | * 225 | * @param opts The `git_worktree_prune_options` struct to initialize. 226 | * @param version The struct version; pass `GIT_WORKTREE_PRUNE_OPTIONS_VERSION`. 227 | * @return Zero on success; -1 on failure. 228 | *) 229 | 230 | function git_worktree_prune_options_init(opts: Pgit_worktree_prune_options; version: Cardinal): Integer; cdecl; external libgit2_dll; 231 | 232 | (** 233 | * Is the worktree prunable with the given options? 234 | * 235 | * A worktree is not prunable in the following scenarios: 236 | * 237 | * - the worktree is linking to a valid on-disk worktree. The 238 | * `valid` member will cause this check to be ignored. 239 | * - the worktree is locked. The `locked` flag will cause this 240 | * check to be ignored. 241 | * 242 | * If the worktree is not valid and not locked or if the above 243 | * flags have been passed in, this function will return a 244 | * positive value. If the worktree is not prunable, an error 245 | * message will be set (visible in `giterr_last`) with details about 246 | * why. 247 | * 248 | * @param wt Worktree to check. 249 | * @param opts The prunable options. 250 | * @return 1 if the worktree is prunable, 0 otherwise, or an error code. 251 | *) 252 | function git_worktree_is_prunable(wt: Pgit_worktree; opts: Pgit_worktree_prune_options): Integer; cdecl; external libgit2_dll; 253 | 254 | (** 255 | * Prune working tree 256 | * 257 | * Prune the working tree, that is remove the git data 258 | * structures on disk. The repository will only be pruned of 259 | * `git_worktree_is_prunable` succeeds. 260 | * 261 | * @param wt Worktree to prune 262 | * @param opts Specifies which checks to override. See 263 | * `git_worktree_is_prunable`. May be NULL 264 | * @return 0 or an error code 265 | *) 266 | 267 | function git_worktree_prune(wt: Pgit_worktree; opts: Pgit_worktree_prune_options): Integer; cdecl; external libgit2_dll; 268 | 269 | (** @} *) 270 | -------------------------------------------------------------------------------- /src/libgit2.pas: -------------------------------------------------------------------------------- 1 | (* 2 | * Copyright (C) 2021-2025 Today Software 3 | * Distributed under the MIT licence see LICENCE file for more details 4 | * https://opensource.org/licenses/MIT 5 | *) 6 | unit LibGit2; 7 | 8 | {$IFDEF FPC} 9 | {$MODE objfpc}{$H+} 10 | {$ELSE} 11 | {$IF RTLVersion >= 23} 12 | {$DEFINE DOTTEDUNITS} 13 | {$IFEND} 14 | {$ENDIF} 15 | 16 | {$DEFINE GIT_DEPRECATE_HARD} 17 | {*$DEFINE GIT_EXPERIMENTAL_SHA256} 18 | 19 | interface 20 | 21 | uses 22 | {$IF DEFINED(DOTTEDUNITS) OR DEFINED(FPC_DOTTEDUNITS)} 23 | System.SysUtils; 24 | {$ELSE} 25 | SysUtils; 26 | {$IFEND} 27 | 28 | const 29 | {$IF DEFINED(MSWINDOWS)} 30 | libgit2_dll = 'git2.dll'; 31 | {$ELSEIF DEFINED(MACOS)} 32 | libgit2_dll = 'libgit2.dylib'; 33 | {$ELSE} 34 | libgit2_dll = 'libgit2.so'; 35 | {$ENDIF} 36 | 37 | type 38 | PPByte = ^PByte; 39 | 40 | {$I git2/stdint.inc} 41 | {$IF NOT DECLARED(size_t)} 42 | type 43 | size_t = uintptr_t; 44 | {$IFEND} 45 | 46 | procedure InitLibgit2; 47 | procedure ShutdownLibgit2; 48 | 49 | // Headers sourced and converted from https://github.com/libgit2/libgit2 and where all under the following licence 50 | (* 51 | * Copyright (C) the libgit2 contributors. All rights reserved. 52 | * 53 | * This file is part of libgit2, distributed under the GNU GPL v2 with 54 | * a Linking Exception. For full terms see the included COPYING file. 55 | * 56 | * https://github.com/libgit2/libgit2/blob/main/COPYING 57 | *) 58 | {$I git2/version.inc} 59 | {$I git2/common.inc} 60 | {$I git2/types.inc} 61 | {$I git2/buffer.inc} 62 | {$I git2/oid.inc} 63 | {$I git2/oidarray.inc} 64 | {$I git2/strarray.inc} 65 | {$I git2/commit.inc} 66 | {$I git2/repository.inc} 67 | {$I git2/diff.inc} 68 | {$I git2/object.inc} 69 | {$I git2/annotated_commit.inc} 70 | {$I git2/apply.inc} 71 | {$I git2/attr.inc} 72 | {$I git2/blame.inc} 73 | {$I git2/blob.inc} 74 | {$I git2/branch.inc} 75 | {$I git2/cert.inc} 76 | {$I git2/checkout.inc} 77 | {$I git2/email.inc} 78 | {$I git2/indexer.inc} 79 | {$I git2/index.inc} 80 | {$I git2/merge.inc} 81 | {$I git2/cherrypick.inc} 82 | {$I git2/pack.inc} 83 | {$I git2/credential.inc} 84 | {$I git2/credential_helpers.inc} 85 | {$I git2/proxy.inc} 86 | {$I git2/net.inc} 87 | {$I git2/refspec.inc} 88 | {$I git2/transport.inc} 89 | {$I git2/remote.inc} 90 | {$I git2/clone.inc} 91 | {$I git2/config.inc} 92 | {$I git2/describe.inc} 93 | {$I git2/errors.inc} 94 | {$I git2/filter.inc} 95 | {$I git2/global.inc} 96 | {$I git2/graph.inc} 97 | {$I git2/ignore.inc} 98 | {$I git2/mailmap.inc} 99 | {$I git2/message.inc} 100 | {$I git2/notes.inc} 101 | {$I git2/odb_backend.inc} 102 | {$I git2/odb.inc} 103 | {$I git2/patch.inc} 104 | {$I git2/pathspec.inc} 105 | {$I git2/rebase.inc} 106 | {$I git2/refdb.inc} 107 | {$I git2/reflog.inc} 108 | {$I git2/refs.inc} 109 | {$I git2/reset.inc} 110 | {$I git2/revert.inc} 111 | {$I git2/revparse.inc} 112 | {$I git2/revwalk.inc} 113 | {$I git2/signature.inc} 114 | {$I git2/stash.inc} 115 | {$I git2/status.inc} 116 | {$I git2/submodule.inc} 117 | {$I git2/tag.inc} 118 | {$I git2/trace.inc} 119 | {$I git2/transaction.inc} 120 | {$I git2/tree.inc} 121 | {$I git2/worktree.inc} 122 | 123 | implementation 124 | 125 | var 126 | Libgit2init: Boolean; 127 | 128 | procedure InitLibgit2; 129 | begin 130 | if not Libgit2init then 131 | begin 132 | Libgit2init := True; 133 | git_libgit2_init; 134 | end; 135 | end; 136 | 137 | procedure ShutdownLibgit2; 138 | begin 139 | if Libgit2init then 140 | begin 141 | Libgit2init := False; 142 | git_libgit2_shutdown; 143 | end; 144 | end; 145 | 146 | { attr } 147 | 148 | function GIT_ATTR_IS_TRUE(attr: PAnsiChar): Boolean; 149 | begin 150 | Result := git_attr_value(attr) = GIT_ATTR_VALUE_TRUE; 151 | end; 152 | 153 | function GIT_ATTR_IS_FALSE(attr: PAnsiChar): Boolean; 154 | begin 155 | Result := git_attr_value(attr) = GIT_ATTR_VALUE_FALSE; 156 | end; 157 | 158 | function GIT_ATTR_IS_UNSPECIFIED(attr: PAnsiChar): Boolean; 159 | begin 160 | Result := git_attr_value(attr) = GIT_ATTR_VALUE_UNSPECIFIED; 161 | end; 162 | 163 | function GIT_ATTR_HAS_VALUE(attr: PAnsiChar): Boolean; 164 | begin 165 | Result := git_attr_value(attr) = GIT_ATTR_VALUE_STRING; 166 | end; 167 | 168 | { index } 169 | 170 | function GIT_INDEX_ENTRY_STAGE_GET(var E: git_index_entry): uint16_t; 171 | begin 172 | Result := (E.flags and GIT_INDEX_ENTRY_STAGEMASK) shr GIT_INDEX_ENTRY_STAGESHIFT; 173 | end; 174 | 175 | procedure GIT_INDEX_ENTRY_STAGE_SET(var E: git_index_entry; S: uint16_t); 176 | begin 177 | E.flags := (E.flags and not GIT_INDEX_ENTRY_STAGEMASK) or ((S and 3) shl GIT_INDEX_ENTRY_STAGESHIFT); 178 | end; 179 | 180 | { submodule } 181 | 182 | function GIT_SUBMODULE_STATUS_IS_UNMODIFIED(S: Integer): Boolean; 183 | begin 184 | Result := (S and not GIT_SUBMODULE_STATUS__IN_FLAGS) = 0; 185 | end; 186 | 187 | function GIT_SUBMODULE_STATUS_IS_INDEX_UNMODIFIED(S: Integer): Boolean; 188 | begin 189 | Result := (S and GIT_SUBMODULE_STATUS__INDEX_FLAGS) = 0; 190 | end; 191 | 192 | function GIT_SUBMODULE_STATUS_IS_WD_UNMODIFIED(S: Integer): Boolean; 193 | begin 194 | Result := (S and GIT_SUBMODULE_STATUS__WD_FLAGS and not GIT_SUBMODULE_STATUS_WD_UNINITIALIZED) = 0; 195 | end; 196 | 197 | function GIT_SUBMODULE_STATUS_IS_WD_DIRTY(S: Integer): Boolean; 198 | begin 199 | Result := (S and (GIT_SUBMODULE_STATUS_WD_INDEX_MODIFIED or GIT_SUBMODULE_STATUS_WD_WD_MODIFIED or 200 | GIT_SUBMODULE_STATUS_WD_UNTRACKED)) = 0; 201 | end; 202 | 203 | { version } 204 | 205 | function LIBGIT2_VERSION_CHECK(major, minor, revision: Integer): Boolean; 206 | begin 207 | Result := LIBGIT2_VERSION_NUMBER >= ((major) * 1000000) + ((minor) * 10000) + ((revision) * 100); 208 | end; 209 | 210 | end. 211 | --------------------------------------------------------------------------------