diff --git a/lib/src/bindings/libgit2_bindings.dart b/lib/src/bindings/libgit2_bindings.dart index ea4497a..fc28542 100644 --- a/lib/src/bindings/libgit2_bindings.dart +++ b/lib/src/bindings/libgit2_bindings.dart @@ -2080,6 +2080,14 @@ class Libgit2 { /// > authentication, use expect/continue when POSTing data. /// > This option is not available on Windows. /// + /// opts(GIT_OPT_SET_ODB_PACKED_PRIORITY, int priority) + /// > Override the default priority of the packed ODB backend which + /// > is added when default backends are assigned to a repository + /// + /// opts(GIT_OPT_SET_ODB_LOOSE_PRIORITY, int priority) + /// > Override the default priority of the loose ODB backend which + /// > is added when default backends are assigned to a repository + /// /// @param option Option key /// @param ... value to set the option /// @return 0 on success, <0 on failure @@ -4991,35 +4999,6 @@ class Libgit2 { late final _dart_git_treebuilder_write _git_treebuilder_write = _git_treebuilder_write_ptr.asFunction<_dart_git_treebuilder_write>(); - /// Write the contents of the tree builder as a tree object - /// using a shared git_buf. - /// - /// @see git_treebuilder_write - /// - /// @param oid Pointer to store the OID of the newly written tree - /// @param bld Tree builder to write - /// @param tree Shared buffer for writing the tree. Will be grown as necessary. - /// @return 0 or an error code - int git_treebuilder_write_with_buffer( - ffi.Pointer oid, - ffi.Pointer bld, - ffi.Pointer tree, - ) { - return _git_treebuilder_write_with_buffer( - oid, - bld, - tree, - ); - } - - late final _git_treebuilder_write_with_buffer_ptr = - _lookup>( - 'git_treebuilder_write_with_buffer'); - late final _dart_git_treebuilder_write_with_buffer - _git_treebuilder_write_with_buffer = - _git_treebuilder_write_with_buffer_ptr - .asFunction<_dart_git_treebuilder_write_with_buffer>(); - /// Traverse the entries in a tree and its subtrees in post or pre order. /// /// The entries will be traversed in the specified order, children subtrees @@ -5276,6 +5255,9 @@ class Libgit2 { /// of updating does not match the one passed through `current_value` /// (i.e. if the ref has changed since the user read it). /// + /// If `current_value` is all zeros, this function will return GIT_EMODIFIED + /// if the ref already exists. + /// /// @param out Pointer to the newly created reference /// @param repo Repository where that reference will live /// @param name The name of the reference @@ -6308,22 +6290,25 @@ class Libgit2 { /// the characters '~', '^', ':', '\\', '?', '[', and '*', and the /// sequences ".." and "@{" which have special meaning to revparse. /// + /// @param valid output pointer to set with validity of given reference name /// @param refname name to be checked. - /// @return 1 if the reference name is acceptable; 0 if it isn't - int git_reference_is_valid_name( + /// @return 0 on success or an error code + int git_reference_name_is_valid( + ffi.Pointer valid, ffi.Pointer refname, ) { - return _git_reference_is_valid_name( + return _git_reference_name_is_valid( + valid, refname, ); } - late final _git_reference_is_valid_name_ptr = - _lookup>( - 'git_reference_is_valid_name'); - late final _dart_git_reference_is_valid_name _git_reference_is_valid_name = - _git_reference_is_valid_name_ptr - .asFunction<_dart_git_reference_is_valid_name>(); + late final _git_reference_name_is_valid_ptr = + _lookup>( + 'git_reference_name_is_valid'); + late final _dart_git_reference_name_is_valid _git_reference_name_is_valid = + _git_reference_name_is_valid_ptr + .asFunction<_dart_git_reference_name_is_valid>(); /// Get the reference's short name /// @@ -7508,6 +7493,40 @@ class Libgit2 { late final _dart_git_attr_get _git_attr_get = _git_attr_get_ptr.asFunction<_dart_git_attr_get>(); + /// Look up the value of one git attribute for path with extended options. + /// + /// @param value_out Output of the value of the attribute. Use the GIT_ATTR_... + /// macros to test for TRUE, FALSE, UNSPECIFIED, etc. or just + /// use the string value for attributes set to a value. You + /// should NOT modify or free this value. + /// @param repo The repository containing the path. + /// @param opts The `git_attr_options` to use when querying these attributes. + /// @param path The path to check for attributes. Relative paths are + /// interpreted relative to the repo root. The file does + /// not have to exist, but if it does not, then it will be + /// treated as a plain file (not a directory). + /// @param name The name of the attribute to look up. + int git_attr_get_ext( + ffi.Pointer> value_out, + ffi.Pointer repo, + ffi.Pointer opts, + ffi.Pointer path, + ffi.Pointer name, + ) { + return _git_attr_get_ext( + value_out, + repo, + opts, + path, + name, + ); + } + + late final _git_attr_get_ext_ptr = + _lookup>('git_attr_get_ext'); + late final _dart_git_attr_get_ext _git_attr_get_ext = + _git_attr_get_ext_ptr.asFunction<_dart_git_attr_get_ext>(); + /// Look up a list of git attributes for path. /// /// Use this if you have a known list of attributes that you want to @@ -7558,6 +7577,44 @@ class Libgit2 { late final _dart_git_attr_get_many _git_attr_get_many = _git_attr_get_many_ptr.asFunction<_dart_git_attr_get_many>(); + /// Look up a list of git attributes for path with extended options. + /// + /// @param values_out An array of num_attr entries that will have string + /// pointers written into it for the values of the attributes. + /// You should not modify or free the values that are written + /// into this array (although of course, you should free the + /// array itself if you allocated it). + /// @param repo The repository containing the path. + /// @param opts The `git_attr_options` to use when querying these attributes. + /// @param path The path inside the repo to check attributes. This + /// does not have to exist, but if it does not, then + /// it will be treated as a plain file (i.e. not a directory). + /// @param num_attr The number of attributes being looked up + /// @param names An array of num_attr strings containing attribute names. + int git_attr_get_many_ext( + ffi.Pointer> values_out, + ffi.Pointer repo, + ffi.Pointer opts, + ffi.Pointer path, + int num_attr, + ffi.Pointer> names, + ) { + return _git_attr_get_many_ext( + values_out, + repo, + opts, + path, + num_attr, + names, + ); + } + + late final _git_attr_get_many_ext_ptr = + _lookup>( + 'git_attr_get_many_ext'); + late final _dart_git_attr_get_many_ext _git_attr_get_many_ext = + _git_attr_get_many_ext_ptr.asFunction<_dart_git_attr_get_many_ext>(); + /// Loop over all the git attributes for a path. /// /// @param repo The repository containing the path. @@ -7590,6 +7647,39 @@ class Libgit2 { late final _dart_git_attr_foreach _git_attr_foreach = _git_attr_foreach_ptr.asFunction<_dart_git_attr_foreach>(); + /// Loop over all the git attributes for a path with extended options. + /// + /// @param repo The repository containing the path. + /// @param opts The `git_attr_options` to use when querying these attributes. + /// @param path Path inside the repo to check attributes. This does not have + /// to exist, but if it does not, then it will be treated as a + /// plain file (i.e. not a directory). + /// @param callback Function to invoke on each attribute name and value. + /// See git_attr_foreach_cb. + /// @param payload Passed on as extra parameter to callback function. + /// @return 0 on success, non-zero callback return value, or error code + int git_attr_foreach_ext( + ffi.Pointer repo, + ffi.Pointer opts, + ffi.Pointer path, + ffi.Pointer> callback, + ffi.Pointer payload, + ) { + return _git_attr_foreach_ext( + repo, + opts, + path, + callback, + payload, + ); + } + + late final _git_attr_foreach_ext_ptr = + _lookup>( + 'git_attr_foreach_ext'); + late final _dart_git_attr_foreach_ext _git_attr_foreach_ext = + _git_attr_foreach_ext_ptr.asFunction<_dart_git_attr_foreach_ext>(); + /// Flush the gitattributes cache. /// /// Call this if you have reason to believe that the attributes files on @@ -7755,7 +7845,7 @@ class Libgit2 { /// time. /// /// @param blob pointer to the blob - /// @return the pointer + /// @return the pointer, or NULL on error ffi.Pointer git_blob_rawcontent( ffi.Pointer blob, ) { @@ -8663,6 +8753,59 @@ class Libgit2 { _git_branch_upstream_remote_ptr .asFunction<_dart_git_branch_upstream_remote>(); + /// Retrieve the upstream merge of a local branch + /// + /// This will return the currently configured "branch.*.merge" for a given + /// branch. This branch must be local. + /// + /// @param buf the buffer into which to write the name + /// @param repo the repository in which to look + /// @param refname the full name of the branch + /// @return 0 or an error code + int git_branch_upstream_merge( + ffi.Pointer buf, + ffi.Pointer repo, + ffi.Pointer refname, + ) { + return _git_branch_upstream_merge( + buf, + repo, + refname, + ); + } + + late final _git_branch_upstream_merge_ptr = + _lookup>( + 'git_branch_upstream_merge'); + late final _dart_git_branch_upstream_merge _git_branch_upstream_merge = + _git_branch_upstream_merge_ptr + .asFunction<_dart_git_branch_upstream_merge>(); + + /// Determine whether a branch name is valid, meaning that (when prefixed + /// with `refs/heads/`) that it is a valid reference name, and that any + /// additional branch name restrictions are imposed (eg, it cannot start + /// with a `-`). + /// + /// @param valid output pointer to set with validity of given branch name + /// @param name a branch name to test + /// @return 0 on success or an error code + int git_branch_name_is_valid( + ffi.Pointer valid, + ffi.Pointer name, + ) { + return _git_branch_name_is_valid( + valid, + name, + ); + } + + late final _git_branch_name_is_valid_ptr = + _lookup>( + 'git_branch_name_is_valid'); + late final _dart_git_branch_name_is_valid _git_branch_name_is_valid = + _git_branch_name_is_valid_ptr + .asFunction<_dart_git_branch_name_is_valid>(); + /// Initialize git_checkout_options structure /// /// Initializes a `git_checkout_options` with default values. Equivalent to creating @@ -9794,7 +9937,7 @@ class Libgit2 { /// @param at_pos the address to which the position of the index entry is written (optional) /// @param index an existing index object /// @param path path to search - /// @return 0 with valid value in at_pos; an error code otherwise + /// @return 0 or an error code int git_index_find( ffi.Pointer at_pos, ffi.Pointer index, @@ -9818,7 +9961,7 @@ class Libgit2 { /// @param at_pos the address to which the position of the index entry is written (optional) /// @param index an existing index object /// @param prefix the prefix to search for - /// @return 0 with valid value in at_pos; an error code otherwise + /// @return 0 or an error code int git_index_find_prefix( ffi.Pointer at_pos, ffi.Pointer index, @@ -11725,7 +11868,8 @@ class Libgit2 { /// Get the remote's url /// /// If url.*.insteadOf has been configured for this URL, it will - /// return the modified URL. + /// return the modified URL. If `git_remote_set_instance_pushurl` + /// has been called for this remote, then that URL will be returned. /// /// @param remote the remote /// @return a pointer to the url @@ -11742,10 +11886,11 @@ class Libgit2 { late final _dart_git_remote_url _git_remote_url = _git_remote_url_ptr.asFunction<_dart_git_remote_url>(); - /// Get the remote's url for pushing + /// Get the remote's url for pushing. /// /// If url.*.pushInsteadOf has been configured for this URL, it - /// will return the modified URL. + /// will return the modified URL. If `git_remote_set_instance_pushurl` + /// has been called for this remote, then that URL will be returned. /// /// @param remote the remote /// @return a pointer to the url or NULL if no special url for pushing is set @@ -11797,6 +11942,7 @@ class Libgit2 { /// @param repo the repository in which to perform the change /// @param remote the remote's name /// @param url the url to set + /// @return 0, or an error code int git_remote_set_pushurl( ffi.Pointer repo, ffi.Pointer remote, @@ -11815,6 +11961,52 @@ class Libgit2 { late final _dart_git_remote_set_pushurl _git_remote_set_pushurl = _git_remote_set_pushurl_ptr.asFunction<_dart_git_remote_set_pushurl>(); + /// Set the url for this particular url instance. The URL in the + /// configuration will be ignored, and will not be changed. + /// + /// @param remote the remote's name + /// @param url the url to set + /// @return 0 or an error value + int git_remote_set_instance_url( + ffi.Pointer remote, + ffi.Pointer url, + ) { + return _git_remote_set_instance_url( + remote, + url, + ); + } + + late final _git_remote_set_instance_url_ptr = + _lookup>( + 'git_remote_set_instance_url'); + late final _dart_git_remote_set_instance_url _git_remote_set_instance_url = + _git_remote_set_instance_url_ptr + .asFunction<_dart_git_remote_set_instance_url>(); + + /// Set the push url for this particular url instance. The URL in the + /// configuration will be ignored, and will not be changed. + /// + /// @param remote the remote's name + /// @param url the url to set + /// @return 0 or an error value + int git_remote_set_instance_pushurl( + ffi.Pointer remote, + ffi.Pointer url, + ) { + return _git_remote_set_instance_pushurl( + remote, + url, + ); + } + + late final _git_remote_set_instance_pushurl_ptr = + _lookup>( + 'git_remote_set_instance_pushurl'); + late final _dart_git_remote_set_instance_pushurl + _git_remote_set_instance_pushurl = _git_remote_set_instance_pushurl_ptr + .asFunction<_dart_git_remote_set_instance_pushurl>(); + /// Add a fetch refspec to the remote's configuration /// /// Add the given refspec to the fetch list in the configuration. No @@ -12407,6 +12599,7 @@ class Libgit2 { /// @param repo the repository in which to make the change /// @param remote the name of the remote /// @param value the new value to take. + /// @return 0, or an error code. int git_remote_set_autotag( ffi.Pointer repo, ffi.Pointer remote, @@ -12482,22 +12675,25 @@ class Libgit2 { /// Ensure the remote name is well-formed. /// + /// @param valid output pointer to set with validity of given remote name /// @param remote_name name to be checked. - /// @return 1 if the reference name is acceptable; 0 if it isn't - int git_remote_is_valid_name( + /// @return 0 on success or an error code + int git_remote_name_is_valid( + ffi.Pointer valid, ffi.Pointer remote_name, ) { - return _git_remote_is_valid_name( + return _git_remote_name_is_valid( + valid, remote_name, ); } - late final _git_remote_is_valid_name_ptr = - _lookup>( - 'git_remote_is_valid_name'); - late final _dart_git_remote_is_valid_name _git_remote_is_valid_name = - _git_remote_is_valid_name_ptr - .asFunction<_dart_git_remote_is_valid_name>(); + late final _git_remote_name_is_valid_ptr = + _lookup>( + 'git_remote_name_is_valid'); + late final _dart_git_remote_name_is_valid _git_remote_name_is_valid = + _git_remote_name_is_valid_ptr + .asFunction<_dart_git_remote_name_is_valid>(); /// Delete an existing persisted remote. /// @@ -12532,7 +12728,7 @@ class Libgit2 { /// /// This function must only be called after connecting. /// - /// @param out the buffern in which to store the reference name + /// @param out the buffer in which to store the reference name /// @param remote the remote /// @return 0, GIT_ENOTFOUND if the remote does not have any references /// or none of them point to HEAD's commit, or an error message. @@ -14873,6 +15069,284 @@ class Libgit2 { late final _dart_git_error_set_oom _git_error_set_oom = _git_error_set_oom_ptr.asFunction<_dart_git_error_set_oom>(); + /// Load the filter list for a given path. + /// + /// This will return 0 (success) but set the output git_filter_list to NULL + /// if no filters are requested for the given file. + /// + /// @param filters Output newly created git_filter_list (or NULL) + /// @param repo Repository object that contains `path` + /// @param blob The blob to which the filter will be applied (if known) + /// @param path Relative path of the file to be filtered + /// @param mode Filtering direction (WT->ODB or ODB->WT) + /// @param flags Combination of `git_filter_flag_t` flags + /// @return 0 on success (which could still return NULL if no filters are + /// needed for the requested file), <0 on error + int git_filter_list_load( + ffi.Pointer> filters, + ffi.Pointer repo, + ffi.Pointer blob, + ffi.Pointer path, + int mode, + int flags, + ) { + return _git_filter_list_load( + filters, + repo, + blob, + path, + mode, + flags, + ); + } + + late final _git_filter_list_load_ptr = + _lookup>( + 'git_filter_list_load'); + late final _dart_git_filter_list_load _git_filter_list_load = + _git_filter_list_load_ptr.asFunction<_dart_git_filter_list_load>(); + + /// Load the filter list for a given path. + /// + /// This will return 0 (success) but set the output git_filter_list to NULL + /// if no filters are requested for the given file. + /// + /// @param filters Output newly created git_filter_list (or NULL) + /// @param repo Repository object that contains `path` + /// @param blob The blob to which the filter will be applied (if known) + /// @param path Relative path of the file to be filtered + /// @param mode Filtering direction (WT->ODB or ODB->WT) + /// @param opts The `git_filter_options` to use when loading filters + /// @return 0 on success (which could still return NULL if no filters are + /// needed for the requested file), <0 on error + int git_filter_list_load_ext( + ffi.Pointer> filters, + ffi.Pointer repo, + ffi.Pointer blob, + ffi.Pointer path, + int mode, + ffi.Pointer opts, + ) { + return _git_filter_list_load_ext( + filters, + repo, + blob, + path, + mode, + opts, + ); + } + + late final _git_filter_list_load_ext_ptr = + _lookup>( + 'git_filter_list_load_ext'); + late final _dart_git_filter_list_load_ext _git_filter_list_load_ext = + _git_filter_list_load_ext_ptr + .asFunction<_dart_git_filter_list_load_ext>(); + + /// Query the filter list to see if a given filter (by name) will run. + /// The built-in filters "crlf" and "ident" can be queried, otherwise this + /// is the name of the filter specified by the filter attribute. + /// + /// This will return 0 if the given filter is not in the list, or 1 if + /// the filter will be applied. + /// + /// @param filters A loaded git_filter_list (or NULL) + /// @param name The name of the filter to query + /// @return 1 if the filter is in the list, 0 otherwise + int git_filter_list_contains( + ffi.Pointer filters, + ffi.Pointer name, + ) { + return _git_filter_list_contains( + filters, + name, + ); + } + + late final _git_filter_list_contains_ptr = + _lookup>( + 'git_filter_list_contains'); + late final _dart_git_filter_list_contains _git_filter_list_contains = + _git_filter_list_contains_ptr + .asFunction<_dart_git_filter_list_contains>(); + + /// Apply filter list to a data buffer. + /// + /// @param out Buffer to store the result of the filtering + /// @param filters A loaded git_filter_list (or NULL) + /// @param in Buffer containing the data to filter + /// @param in_len The length of the input buffer + /// @return 0 on success, an error code otherwise + int git_filter_list_apply_to_buffer( + ffi.Pointer out, + ffi.Pointer filters, + ffi.Pointer in_1, + int in_len, + ) { + return _git_filter_list_apply_to_buffer( + out, + filters, + in_1, + in_len, + ); + } + + late final _git_filter_list_apply_to_buffer_ptr = + _lookup>( + 'git_filter_list_apply_to_buffer'); + late final _dart_git_filter_list_apply_to_buffer + _git_filter_list_apply_to_buffer = _git_filter_list_apply_to_buffer_ptr + .asFunction<_dart_git_filter_list_apply_to_buffer>(); + + /// Apply a filter list to the contents of a file on disk + /// + /// @param out buffer into which to store the filtered file + /// @param filters the list of filters to apply + /// @param repo the repository in which to perform the filtering + /// @param path the path of the file to filter, a relative path will be + /// taken as relative to the workdir + int git_filter_list_apply_to_file( + ffi.Pointer out, + ffi.Pointer filters, + ffi.Pointer repo, + ffi.Pointer path, + ) { + return _git_filter_list_apply_to_file( + out, + filters, + repo, + path, + ); + } + + late final _git_filter_list_apply_to_file_ptr = + _lookup>( + 'git_filter_list_apply_to_file'); + late final _dart_git_filter_list_apply_to_file + _git_filter_list_apply_to_file = _git_filter_list_apply_to_file_ptr + .asFunction<_dart_git_filter_list_apply_to_file>(); + + /// Apply a filter list to the contents of a blob + /// + /// @param out buffer into which to store the filtered file + /// @param filters the list of filters to apply + /// @param blob the blob to filter + int git_filter_list_apply_to_blob( + ffi.Pointer out, + ffi.Pointer filters, + ffi.Pointer blob, + ) { + return _git_filter_list_apply_to_blob( + out, + filters, + blob, + ); + } + + late final _git_filter_list_apply_to_blob_ptr = + _lookup>( + 'git_filter_list_apply_to_blob'); + late final _dart_git_filter_list_apply_to_blob + _git_filter_list_apply_to_blob = _git_filter_list_apply_to_blob_ptr + .asFunction<_dart_git_filter_list_apply_to_blob>(); + + /// Apply a filter list to an arbitrary buffer as a stream + /// + /// @param filters the list of filters to apply + /// @param buffer the buffer to filter + /// @param len the size of the buffer + /// @param target the stream into which the data will be written + int git_filter_list_stream_buffer( + ffi.Pointer filters, + ffi.Pointer buffer, + int len, + ffi.Pointer target, + ) { + return _git_filter_list_stream_buffer( + filters, + buffer, + len, + target, + ); + } + + late final _git_filter_list_stream_buffer_ptr = + _lookup>( + 'git_filter_list_stream_buffer'); + late final _dart_git_filter_list_stream_buffer + _git_filter_list_stream_buffer = _git_filter_list_stream_buffer_ptr + .asFunction<_dart_git_filter_list_stream_buffer>(); + + /// Apply a filter list to a file as a stream + /// + /// @param filters the list of filters to apply + /// @param repo the repository in which to perform the filtering + /// @param path the path of the file to filter, a relative path will be + /// taken as relative to the workdir + /// @param target the stream into which the data will be written + int git_filter_list_stream_file( + ffi.Pointer filters, + ffi.Pointer repo, + ffi.Pointer path, + ffi.Pointer target, + ) { + return _git_filter_list_stream_file( + filters, + repo, + path, + target, + ); + } + + late final _git_filter_list_stream_file_ptr = + _lookup>( + 'git_filter_list_stream_file'); + late final _dart_git_filter_list_stream_file _git_filter_list_stream_file = + _git_filter_list_stream_file_ptr + .asFunction<_dart_git_filter_list_stream_file>(); + + /// Apply a filter list to a blob as a stream + /// + /// @param filters the list of filters to apply + /// @param blob the blob to filter + /// @param target the stream into which the data will be written + int git_filter_list_stream_blob( + ffi.Pointer filters, + ffi.Pointer blob, + ffi.Pointer target, + ) { + return _git_filter_list_stream_blob( + filters, + blob, + target, + ); + } + + late final _git_filter_list_stream_blob_ptr = + _lookup>( + 'git_filter_list_stream_blob'); + late final _dart_git_filter_list_stream_blob _git_filter_list_stream_blob = + _git_filter_list_stream_blob_ptr + .asFunction<_dart_git_filter_list_stream_blob>(); + + /// Free a git_filter_list + /// + /// @param filters A git_filter_list created by `git_filter_list_load` + void git_filter_list_free( + ffi.Pointer filters, + ) { + return _git_filter_list_free( + filters, + ); + } + + late final _git_filter_list_free_ptr = + _lookup>( + 'git_filter_list_free'); + late final _dart_git_filter_list_free _git_filter_list_free = + _git_filter_list_free_ptr.asFunction<_dart_git_filter_list_free>(); + /// Initialize git_rebase_options structure /// /// Initializes a `git_rebase_options` with default values. Equivalent to @@ -15343,6 +15817,103 @@ class Libgit2 { late final _dart_git_revert _git_revert = _git_revert_ptr.asFunction<_dart_git_revert>(); + /// Find a single object, as specified by a revision string. + /// + /// See `man gitrevisions`, or + /// http://git-scm.com/docs/git-rev-parse.html#_specifying_revisions for + /// information on the syntax accepted. + /// + /// The returned object should be released with `git_object_free` when no + /// longer needed. + /// + /// @param out pointer to output object + /// @param repo the repository to search in + /// @param spec the textual specification for an object + /// @return 0 on success, GIT_ENOTFOUND, GIT_EAMBIGUOUS, GIT_EINVALIDSPEC or an error code + int git_revparse_single( + ffi.Pointer> out, + ffi.Pointer repo, + ffi.Pointer spec, + ) { + return _git_revparse_single( + out, + repo, + spec, + ); + } + + late final _git_revparse_single_ptr = + _lookup>( + 'git_revparse_single'); + late final _dart_git_revparse_single _git_revparse_single = + _git_revparse_single_ptr.asFunction<_dart_git_revparse_single>(); + + /// Find a single object and intermediate reference by a revision string. + /// + /// See `man gitrevisions`, or + /// http://git-scm.com/docs/git-rev-parse.html#_specifying_revisions for + /// information on the syntax accepted. + /// + /// In some cases (`@{<-n>}` or `@{upstream}`), the expression may + /// point to an intermediate reference. When such expressions are being passed + /// in, `reference_out` will be valued as well. + /// + /// The returned object should be released with `git_object_free` and the + /// returned reference with `git_reference_free` when no longer needed. + /// + /// @param object_out pointer to output object + /// @param reference_out pointer to output reference or NULL + /// @param repo the repository to search in + /// @param spec the textual specification for an object + /// @return 0 on success, GIT_ENOTFOUND, GIT_EAMBIGUOUS, GIT_EINVALIDSPEC + /// or an error code + int git_revparse_ext( + ffi.Pointer> object_out, + ffi.Pointer> reference_out, + ffi.Pointer repo, + ffi.Pointer spec, + ) { + return _git_revparse_ext( + object_out, + reference_out, + repo, + spec, + ); + } + + late final _git_revparse_ext_ptr = + _lookup>('git_revparse_ext'); + late final _dart_git_revparse_ext _git_revparse_ext = + _git_revparse_ext_ptr.asFunction<_dart_git_revparse_ext>(); + + /// Parse a revision string for `from`, `to`, and intent. + /// + /// See `man gitrevisions` or + /// http://git-scm.com/docs/git-rev-parse.html#_specifying_revisions for + /// information on the syntax accepted. + /// + /// @param revspec Pointer to an user-allocated git_revspec struct where + /// the result of the rev-parse will be stored + /// @param repo the repository to search in + /// @param spec the rev-parse spec to parse + /// @return 0 on success, GIT_INVALIDSPEC, GIT_ENOTFOUND, GIT_EAMBIGUOUS or an error code + int git_revparse( + ffi.Pointer revspec, + ffi.Pointer repo, + ffi.Pointer spec, + ) { + return _git_revparse( + revspec, + repo, + spec, + ); + } + + late final _git_revparse_ptr = + _lookup>('git_revparse'); + late final _dart_git_revparse _git_revparse = + _git_revparse_ptr.asFunction<_dart_git_revparse>(); + /// Save the local modifications to a new stash. /// /// @param out Object id of the commit containing the stashed state. @@ -15883,6 +16454,26 @@ class Libgit2 { late final _dart_git_submodule_lookup _git_submodule_lookup = _git_submodule_lookup_ptr.asFunction<_dart_git_submodule_lookup>(); + /// Create an in-memory copy of a submodule. The copy must be explicitly + /// free'd or it will leak. + /// + /// @param out Pointer to store the copy of the submodule. + /// @param source Original submodule to copy. + int git_submodule_dup( + ffi.Pointer> out, + ffi.Pointer source, + ) { + return _git_submodule_dup( + out, + source, + ); + } + + late final _git_submodule_dup_ptr = + _lookup>('git_submodule_dup'); + late final _dart_git_submodule_dup _git_submodule_dup = + _git_submodule_dup_ptr.asFunction<_dart_git_submodule_dup>(); + /// Release a submodule /// /// @param submodule Submodule object @@ -17022,15 +17613,6 @@ class Libgit2 { late final _dart_git_credential_userpass _git_credential_userpass = _git_credential_userpass_ptr.asFunction<_dart_git_credential_userpass>(); - /// @name Deprecated Blob Functions - /// - /// These functions are retained for backward compatibility. The newer - /// versions of these functions should be preferred in all new code. - /// - /// There is no plan to remove these backward compatibility values at - /// this time. - /// / - /// /**@{ int git_blob_create_fromworkdir( ffi.Pointer id, ffi.Pointer repo, @@ -17152,6 +17734,81 @@ class Libgit2 { _git_blob_filtered_content_ptr .asFunction<_dart_git_blob_filtered_content>(); + /// Deprecated in favor of `git_filter_list_stream_buffer`. + /// + /// @deprecated Use git_filter_list_stream_buffer + /// @see Use git_filter_list_stream_buffer + int git_filter_list_stream_data( + ffi.Pointer filters, + ffi.Pointer data, + ffi.Pointer target, + ) { + return _git_filter_list_stream_data( + filters, + data, + target, + ); + } + + late final _git_filter_list_stream_data_ptr = + _lookup>( + 'git_filter_list_stream_data'); + late final _dart_git_filter_list_stream_data _git_filter_list_stream_data = + _git_filter_list_stream_data_ptr + .asFunction<_dart_git_filter_list_stream_data>(); + + /// Deprecated in favor of `git_filter_list_apply_to_buffer`. + /// + /// @deprecated Use git_filter_list_apply_to_buffer + /// @see Use git_filter_list_apply_to_buffer + int git_filter_list_apply_to_data( + ffi.Pointer out, + ffi.Pointer filters, + ffi.Pointer in_1, + ) { + return _git_filter_list_apply_to_data( + out, + filters, + in_1, + ); + } + + late final _git_filter_list_apply_to_data_ptr = + _lookup>( + 'git_filter_list_apply_to_data'); + late final _dart_git_filter_list_apply_to_data + _git_filter_list_apply_to_data = _git_filter_list_apply_to_data_ptr + .asFunction<_dart_git_filter_list_apply_to_data>(); + + /// Write the contents of the tree builder as a tree object. + /// This is an alias of `git_treebuilder_write` and is preserved + /// for backward compatibility. + /// + /// This function is deprecated, but there is no plan to remove this + /// function at this time. + /// + /// @deprecated Use git_treebuilder_write + /// @see git_treebuilder_write + int git_treebuilder_write_with_buffer( + ffi.Pointer oid, + ffi.Pointer bld, + ffi.Pointer tree, + ) { + return _git_treebuilder_write_with_buffer( + oid, + bld, + tree, + ); + } + + late final _git_treebuilder_write_with_buffer_ptr = + _lookup>( + 'git_treebuilder_write_with_buffer'); + late final _dart_git_treebuilder_write_with_buffer + _git_treebuilder_write_with_buffer = + _git_treebuilder_write_with_buffer_ptr + .asFunction<_dart_git_treebuilder_write_with_buffer>(); + /// Free the memory referred to by the git_buf. This is an alias of /// `git_buf_dispose` and is preserved for backward compatibility. /// @@ -17292,6 +17949,54 @@ class Libgit2 { late final _dart_git_object__size _git_object__size = _git_object__size_ptr.asFunction<_dart_git_object__size>(); + /// Ensure the remote name is well-formed. + /// + /// @deprecated Use git_remote_name_is_valid + /// @param remote_name name to be checked. + /// @return 1 if the reference name is acceptable; 0 if it isn't + int git_remote_is_valid_name( + ffi.Pointer remote_name, + ) { + return _git_remote_is_valid_name( + remote_name, + ); + } + + late final _git_remote_is_valid_name_ptr = + _lookup>( + 'git_remote_is_valid_name'); + late final _dart_git_remote_is_valid_name _git_remote_is_valid_name = + _git_remote_is_valid_name_ptr + .asFunction<_dart_git_remote_is_valid_name>(); + + /// Ensure the reference name is well-formed. + /// + /// Valid reference names must follow one of two patterns: + /// + /// 1. Top-level names must contain only capital letters and underscores, + /// and must begin and end with a letter. (e.g. "HEAD", "ORIG_HEAD"). + /// 2. Names prefixed with "refs/" can be almost anything. You must avoid + /// the characters '~', '^', ':', '\\', '?', '[', and '*', and the + /// sequences ".." and "@{" which have special meaning to revparse. + /// + /// @deprecated Use git_reference_name_is_valid + /// @param refname name to be checked. + /// @return 1 if the reference name is acceptable; 0 if it isn't + int git_reference_is_valid_name( + ffi.Pointer refname, + ) { + return _git_reference_is_valid_name( + refname, + ); + } + + late final _git_reference_is_valid_name_ptr = + _lookup>( + 'git_reference_is_valid_name'); + late final _dart_git_reference_is_valid_name _git_reference_is_valid_name = + _git_reference_is_valid_name_ptr + .asFunction<_dart_git_reference_is_valid_name>(); + int git_tag_create_frombuffer( ffi.Pointer oid, ffi.Pointer repo, @@ -18018,252 +18723,6 @@ class Libgit2 { _git_worktree_prune_init_options = _git_worktree_prune_init_options_ptr .asFunction<_dart_git_worktree_prune_init_options>(); - /// Load the filter list for a given path. - /// - /// This will return 0 (success) but set the output git_filter_list to NULL - /// if no filters are requested for the given file. - /// - /// @param filters Output newly created git_filter_list (or NULL) - /// @param repo Repository object that contains `path` - /// @param blob The blob to which the filter will be applied (if known) - /// @param path Relative path of the file to be filtered - /// @param mode Filtering direction (WT->ODB or ODB->WT) - /// @param flags Combination of `git_filter_flag_t` flags - /// @return 0 on success (which could still return NULL if no filters are - /// needed for the requested file), <0 on error - int git_filter_list_load( - ffi.Pointer> filters, - ffi.Pointer repo, - ffi.Pointer blob, - ffi.Pointer path, - int mode, - int flags, - ) { - return _git_filter_list_load( - filters, - repo, - blob, - path, - mode, - flags, - ); - } - - late final _git_filter_list_load_ptr = - _lookup>( - 'git_filter_list_load'); - late final _dart_git_filter_list_load _git_filter_list_load = - _git_filter_list_load_ptr.asFunction<_dart_git_filter_list_load>(); - - /// Query the filter list to see if a given filter (by name) will run. - /// The built-in filters "crlf" and "ident" can be queried, otherwise this - /// is the name of the filter specified by the filter attribute. - /// - /// This will return 0 if the given filter is not in the list, or 1 if - /// the filter will be applied. - /// - /// @param filters A loaded git_filter_list (or NULL) - /// @param name The name of the filter to query - /// @return 1 if the filter is in the list, 0 otherwise - int git_filter_list_contains( - ffi.Pointer filters, - ffi.Pointer name, - ) { - return _git_filter_list_contains( - filters, - name, - ); - } - - late final _git_filter_list_contains_ptr = - _lookup>( - 'git_filter_list_contains'); - late final _dart_git_filter_list_contains _git_filter_list_contains = - _git_filter_list_contains_ptr - .asFunction<_dart_git_filter_list_contains>(); - - /// Apply filter list to a data buffer. - /// - /// See `git2/buffer.h` for background on `git_buf` objects. - /// - /// If the `in` buffer holds data allocated by libgit2 (i.e. `in->asize` is - /// not zero), then it will be overwritten when applying the filters. If - /// not, then it will be left untouched. - /// - /// If there are no filters to apply (or `filters` is NULL), then the `out` - /// buffer will reference the `in` buffer data (with `asize` set to zero) - /// instead of allocating data. This keeps allocations to a minimum, but - /// it means you have to be careful about freeing the `in` data since `out` - /// may be pointing to it! - /// - /// @param out Buffer to store the result of the filtering - /// @param filters A loaded git_filter_list (or NULL) - /// @param in Buffer containing the data to filter - /// @return 0 on success, an error code otherwise - int git_filter_list_apply_to_data( - ffi.Pointer out, - ffi.Pointer filters, - ffi.Pointer in_1, - ) { - return _git_filter_list_apply_to_data( - out, - filters, - in_1, - ); - } - - late final _git_filter_list_apply_to_data_ptr = - _lookup>( - 'git_filter_list_apply_to_data'); - late final _dart_git_filter_list_apply_to_data - _git_filter_list_apply_to_data = _git_filter_list_apply_to_data_ptr - .asFunction<_dart_git_filter_list_apply_to_data>(); - - /// Apply a filter list to the contents of a file on disk - /// - /// @param out buffer into which to store the filtered file - /// @param filters the list of filters to apply - /// @param repo the repository in which to perform the filtering - /// @param path the path of the file to filter, a relative path will be - /// taken as relative to the workdir - int git_filter_list_apply_to_file( - ffi.Pointer out, - ffi.Pointer filters, - ffi.Pointer repo, - ffi.Pointer path, - ) { - return _git_filter_list_apply_to_file( - out, - filters, - repo, - path, - ); - } - - late final _git_filter_list_apply_to_file_ptr = - _lookup>( - 'git_filter_list_apply_to_file'); - late final _dart_git_filter_list_apply_to_file - _git_filter_list_apply_to_file = _git_filter_list_apply_to_file_ptr - .asFunction<_dart_git_filter_list_apply_to_file>(); - - /// Apply a filter list to the contents of a blob - /// - /// @param out buffer into which to store the filtered file - /// @param filters the list of filters to apply - /// @param blob the blob to filter - int git_filter_list_apply_to_blob( - ffi.Pointer out, - ffi.Pointer filters, - ffi.Pointer blob, - ) { - return _git_filter_list_apply_to_blob( - out, - filters, - blob, - ); - } - - late final _git_filter_list_apply_to_blob_ptr = - _lookup>( - 'git_filter_list_apply_to_blob'); - late final _dart_git_filter_list_apply_to_blob - _git_filter_list_apply_to_blob = _git_filter_list_apply_to_blob_ptr - .asFunction<_dart_git_filter_list_apply_to_blob>(); - - /// Apply a filter list to an arbitrary buffer as a stream - /// - /// @param filters the list of filters to apply - /// @param data the buffer to filter - /// @param target the stream into which the data will be written - int git_filter_list_stream_data( - ffi.Pointer filters, - ffi.Pointer data, - ffi.Pointer target, - ) { - return _git_filter_list_stream_data( - filters, - data, - target, - ); - } - - late final _git_filter_list_stream_data_ptr = - _lookup>( - 'git_filter_list_stream_data'); - late final _dart_git_filter_list_stream_data _git_filter_list_stream_data = - _git_filter_list_stream_data_ptr - .asFunction<_dart_git_filter_list_stream_data>(); - - /// Apply a filter list to a file as a stream - /// - /// @param filters the list of filters to apply - /// @param repo the repository in which to perform the filtering - /// @param path the path of the file to filter, a relative path will be - /// taken as relative to the workdir - /// @param target the stream into which the data will be written - int git_filter_list_stream_file( - ffi.Pointer filters, - ffi.Pointer repo, - ffi.Pointer path, - ffi.Pointer target, - ) { - return _git_filter_list_stream_file( - filters, - repo, - path, - target, - ); - } - - late final _git_filter_list_stream_file_ptr = - _lookup>( - 'git_filter_list_stream_file'); - late final _dart_git_filter_list_stream_file _git_filter_list_stream_file = - _git_filter_list_stream_file_ptr - .asFunction<_dart_git_filter_list_stream_file>(); - - /// Apply a filter list to a blob as a stream - /// - /// @param filters the list of filters to apply - /// @param blob the blob to filter - /// @param target the stream into which the data will be written - int git_filter_list_stream_blob( - ffi.Pointer filters, - ffi.Pointer blob, - ffi.Pointer target, - ) { - return _git_filter_list_stream_blob( - filters, - blob, - target, - ); - } - - late final _git_filter_list_stream_blob_ptr = - _lookup>( - 'git_filter_list_stream_blob'); - late final _dart_git_filter_list_stream_blob _git_filter_list_stream_blob = - _git_filter_list_stream_blob_ptr - .asFunction<_dart_git_filter_list_stream_blob>(); - - /// Free a git_filter_list - /// - /// @param filters A git_filter_list created by `git_filter_list_load` - void git_filter_list_free( - ffi.Pointer filters, - ) { - return _git_filter_list_free( - filters, - ); - } - - late final _git_filter_list_free_ptr = - _lookup>( - 'git_filter_list_free'); - late final _dart_git_filter_list_free _git_filter_list_free = - _git_filter_list_free_ptr.asFunction<_dart_git_filter_list_free>(); - /// Init the global state /// /// This function must be called before any other libgit2 function in @@ -18341,8 +18800,9 @@ class Libgit2 { /// Note that a commit is not considered a descendant of itself, in contrast /// to `git merge-base --is-ancestor`. /// - /// @param commit a previously loaded commit. - /// @param ancestor a potential ancestor commit. + /// @param repo the repository where the commits exist + /// @param commit a previously loaded commit + /// @param ancestor a potential ancestor commit /// @return 1 if the given commit is a descendant of the potential ancestor, /// 0 if not, error code otherwise. int git_graph_descendant_of( @@ -18363,6 +18823,36 @@ class Libgit2 { late final _dart_git_graph_descendant_of _git_graph_descendant_of = _git_graph_descendant_of_ptr.asFunction<_dart_git_graph_descendant_of>(); + /// Determine if a commit is reachable from any of a list of commits by + /// following parent edges. + /// + /// @param repo the repository where the commits exist + /// @param commit a previously loaded commit + /// @param length the number of commits in the provided `descendant_array` + /// @param descendant_array oids of the commits + /// @return 1 if the given commit is an ancestor of any of the given potential + /// descendants, 0 if not, error code otherwise. + int git_graph_reachable_from_any( + ffi.Pointer repo, + ffi.Pointer commit, + ffi.Pointer descendant_array, + int length, + ) { + return _git_graph_reachable_from_any( + repo, + commit, + descendant_array, + length, + ); + } + + late final _git_graph_reachable_from_any_ptr = + _lookup>( + 'git_graph_reachable_from_any'); + late final _dart_git_graph_reachable_from_any _git_graph_reachable_from_any = + _git_graph_reachable_from_any_ptr + .asFunction<_dart_git_graph_reachable_from_any>(); + /// Add ignore rules for a repository. /// /// Excludesfile rules (i.e. .gitignore rules) are generally read from @@ -19761,6 +20251,30 @@ class Libgit2 { late final _dart_git_odb_write_pack _git_odb_write_pack = _git_odb_write_pack_ptr.asFunction<_dart_git_odb_write_pack>(); + /// Write a `multi-pack-index` file from all the `.pack` files in the ODB. + /// + /// If the ODB layer understands pack files, then this will create a file called + /// `multi-pack-index` next to the `.pack` and `.idx` files, which will contain + /// an index of all objects stored in `.pack` files. This will allow for + /// O(log n) lookup for n objects (regardless of how many packfiles there + /// exist). + /// + /// @param db object database where the `multi-pack-index` file will be written. + int git_odb_write_multi_pack_index( + ffi.Pointer db, + ) { + return _git_odb_write_multi_pack_index( + db, + ); + } + + late final _git_odb_write_multi_pack_index_ptr = + _lookup>( + 'git_odb_write_multi_pack_index'); + late final _dart_git_odb_write_multi_pack_index + _git_odb_write_multi_pack_index = _git_odb_write_multi_pack_index_ptr + .asFunction<_dart_git_odb_write_multi_pack_index>(); + /// Determine the object-ID (sha1 hash) of a data buffer /// /// The resulting SHA-1 OID will be the identifier for the data @@ -20050,6 +20564,34 @@ class Libgit2 { late final _dart_git_odb_get_backend _git_odb_get_backend = _git_odb_get_backend_ptr.asFunction<_dart_git_odb_get_backend>(); + /// Set the git commit-graph for the ODB. + /// + /// After a successfull call, the ownership of the cgraph parameter will be + /// transferred to libgit2, and the caller should not free it. + /// + /// The commit-graph can also be unset by explicitly passing NULL as the cgraph + /// parameter. + /// + /// @param odb object database + /// @param cgraph the git commit-graph + /// @return 0 on success; error code otherwise + int git_odb_set_commit_graph( + ffi.Pointer odb, + ffi.Pointer cgraph, + ) { + return _git_odb_set_commit_graph( + odb, + cgraph, + ); + } + + late final _git_odb_set_commit_graph_ptr = + _lookup>( + 'git_odb_set_commit_graph'); + late final _dart_git_odb_set_commit_graph _git_odb_set_commit_graph = + _git_odb_set_commit_graph_ptr + .asFunction<_dart_git_odb_set_commit_graph>(); + /// Create a backend for the packfiles. /// /// @param out location to store the odb backend pointer @@ -20132,6 +20674,23 @@ class Libgit2 { _git_odb_backend_one_pack_ptr .asFunction<_dart_git_odb_backend_one_pack>(); + /// Get the repository associated with this patch. May be NULL. + /// + /// @param patch the patch + /// @return a pointer to the repository + ffi.Pointer git_patch_owner( + ffi.Pointer patch, + ) { + return _git_patch_owner( + patch, + ); + } + + late final _git_patch_owner_ptr = + _lookup>('git_patch_owner'); + late final _dart_git_patch_owner _git_patch_owner = + _git_patch_owner_ptr.asFunction<_dart_git_patch_owner>(); + /// Return a patch for an entry in the diff list. /// /// The `git_patch` is a newly created object contains the text diffs @@ -21376,103 +21935,6 @@ class Libgit2 { late final _dart_git_reset_default _git_reset_default = _git_reset_default_ptr.asFunction<_dart_git_reset_default>(); - /// Find a single object, as specified by a revision string. - /// - /// See `man gitrevisions`, or - /// http://git-scm.com/docs/git-rev-parse.html#_specifying_revisions for - /// information on the syntax accepted. - /// - /// The returned object should be released with `git_object_free` when no - /// longer needed. - /// - /// @param out pointer to output object - /// @param repo the repository to search in - /// @param spec the textual specification for an object - /// @return 0 on success, GIT_ENOTFOUND, GIT_EAMBIGUOUS, GIT_EINVALIDSPEC or an error code - int git_revparse_single( - ffi.Pointer> out, - ffi.Pointer repo, - ffi.Pointer spec, - ) { - return _git_revparse_single( - out, - repo, - spec, - ); - } - - late final _git_revparse_single_ptr = - _lookup>( - 'git_revparse_single'); - late final _dart_git_revparse_single _git_revparse_single = - _git_revparse_single_ptr.asFunction<_dart_git_revparse_single>(); - - /// Find a single object and intermediate reference by a revision string. - /// - /// See `man gitrevisions`, or - /// http://git-scm.com/docs/git-rev-parse.html#_specifying_revisions for - /// information on the syntax accepted. - /// - /// In some cases (`@{<-n>}` or `@{upstream}`), the expression may - /// point to an intermediate reference. When such expressions are being passed - /// in, `reference_out` will be valued as well. - /// - /// The returned object should be released with `git_object_free` and the - /// returned reference with `git_reference_free` when no longer needed. - /// - /// @param object_out pointer to output object - /// @param reference_out pointer to output reference or NULL - /// @param repo the repository to search in - /// @param spec the textual specification for an object - /// @return 0 on success, GIT_ENOTFOUND, GIT_EAMBIGUOUS, GIT_EINVALIDSPEC - /// or an error code - int git_revparse_ext( - ffi.Pointer> object_out, - ffi.Pointer> reference_out, - ffi.Pointer repo, - ffi.Pointer spec, - ) { - return _git_revparse_ext( - object_out, - reference_out, - repo, - spec, - ); - } - - late final _git_revparse_ext_ptr = - _lookup>('git_revparse_ext'); - late final _dart_git_revparse_ext _git_revparse_ext = - _git_revparse_ext_ptr.asFunction<_dart_git_revparse_ext>(); - - /// Parse a revision string for `from`, `to`, and intent. - /// - /// See `man gitrevisions` or - /// http://git-scm.com/docs/git-rev-parse.html#_specifying_revisions for - /// information on the syntax accepted. - /// - /// @param revspec Pointer to an user-allocated git_revspec struct where - /// the result of the rev-parse will be stored - /// @param repo the repository to search in - /// @param spec the rev-parse spec to parse - /// @return 0 on success, GIT_INVALIDSPEC, GIT_ENOTFOUND, GIT_EAMBIGUOUS or an error code - int git_revparse( - ffi.Pointer revspec, - ffi.Pointer repo, - ffi.Pointer spec, - ) { - return _git_revparse( - revspec, - repo, - spec, - ); - } - - late final _git_revparse_ptr = - _lookup>('git_revparse'); - late final _dart_git_revparse _git_revparse = - _git_revparse_ptr.asFunction<_dart_git_revparse>(); - /// Allocate a new revision walker to iterate through a repo. /// /// This revision walker uses a custom memory pool and an internal @@ -22596,6 +23058,30 @@ class Libgit2 { late final _dart_git_tag_dup _git_tag_dup = _git_tag_dup_ptr.asFunction<_dart_git_tag_dup>(); + /// Determine whether a tag name is valid, meaning that (when prefixed + /// with `refs/tags/`) that it is a valid reference name, and that any + /// additional tag name restrictions are imposed (eg, it cannot start + /// with a `-`). + /// + /// @param valid output pointer to set with validity of given tag name + /// @param name a tag name to test + /// @return 0 on success or an error code + int git_tag_name_is_valid( + ffi.Pointer valid, + ffi.Pointer name, + ) { + return _git_tag_name_is_valid( + valid, + name, + ); + } + + late final _git_tag_name_is_valid_ptr = + _lookup>( + 'git_tag_name_is_valid'); + late final _dart_git_tag_name_is_valid _git_tag_name_is_valid = + _git_tag_name_is_valid_ptr.asFunction<_dart_git_tag_name_is_valid>(); + /// Create a new transaction object /// /// This does not lock anything, but sets up the transaction object to @@ -23193,6 +23679,8 @@ abstract class git_libgit2_opt_t { static const int GIT_OPT_ENABLE_HTTP_EXPECT_CONTINUE = 28; static const int GIT_OPT_GET_MWINDOW_FILE_LIMIT = 29; static const int GIT_OPT_SET_MWINDOW_FILE_LIMIT = 30; + static const int GIT_OPT_SET_ODB_PACKED_PRIORITY = 31; + static const int GIT_OPT_SET_ODB_LOOSE_PRIORITY = 32; } /// A data buffer for exporting data from libgit2 @@ -23346,10 +23834,16 @@ class git_odb_writepack extends ffi.Struct { external ffi.Pointer> free; } +class git_midx_writer extends ffi.Opaque {} + class git_refdb extends ffi.Opaque {} class git_refdb_backend extends ffi.Opaque {} +class git_commit_graph extends ffi.Opaque {} + +class git_commit_graph_writer extends ffi.Opaque {} + class git_repository extends ffi.Opaque {} class git_worktree extends ffi.Opaque {} @@ -23580,12 +24074,18 @@ class git_remote_callbacks extends ffi.Struct { /// to auto-detect. external ffi.Pointer> transport; + /// Callback when the remote is ready to connect. + external ffi.Pointer> remote_ready; + /// This will be passed to each of the callbacks in this struct /// as the last parameter. external ffi.Pointer payload; /// Resolve URL before connecting to remote. /// The returned URL will be used to connect to the remote instead. + /// + /// This callback is deprecated; users should use + /// git_remote_ready_cb and configure the instance URL instead. external ffi.Pointer> resolve_url; } @@ -24065,6 +24565,9 @@ abstract class git_diff_option_t { /// Include the necessary deflate / delta information so that `git-apply` /// can apply given diff information to binary files. static const int GIT_DIFF_SHOW_BINARY = 1073741824; + + /// Ignore blank lines + static const int GIT_DIFF_IGNORE_BLANK_LINES = -2147483648; } class git_diff extends ffi.Opaque {} @@ -24137,39 +24640,33 @@ abstract class git_delta_t { /// Although this is called a "file", it could represent a file, a symbolic /// link, a submodule commit id, or even a tree (although that only if you /// are tracking type changes or ignored/untracked directories). -/// -/// The `id` is the `git_oid` of the item. If the entry represents an -/// absent side of a diff (e.g. the `old_file` of a `GIT_DELTA_ADDED` delta), -/// then the oid will be zeroes. -/// -/// `path` is the NUL-terminated path to the entry relative to the working -/// directory of the repository. -/// -/// `size` is the size of the entry in bytes. -/// -/// `flags` is a combination of the `git_diff_flag_t` types -/// -/// `mode` is, roughly, the stat() `st_mode` value for the item. This will -/// be restricted to one of the `git_filemode_t` values. -/// -/// The `id_abbrev` represents the known length of the `id` field, when -/// converted to a hex string. It is generally `GIT_OID_HEXSZ`, unless this -/// delta was created from reading a patch file, in which case it may be -/// abbreviated to something reasonable, like 7 characters. class git_diff_file extends ffi.Struct { + /// The `git_oid` of the item. If the entry represents an + /// absent side of a diff (e.g. the `old_file` of a `GIT_DELTA_ADDED` delta), + /// then the oid will be zeroes. external git_oid id; + /// The NUL-terminated path to the entry relative to the working + /// directory of the repository. external ffi.Pointer path; + /// The size of the entry in bytes. @ffi.Uint64() external int size; + /// A combination of the `git_diff_flag_t` types @ffi.Uint32() external int flags; + /// Roughly, the stat() `st_mode` value for the item. This will + /// be restricted to one of the `git_filemode_t` values. @ffi.Uint16() external int mode; + /// Represents the known length of the `id` field, when + /// converted to a hex string. It is generally `GIT_OID_HEXSZ`, unless this + /// delta was created from reading a patch file, in which case it may be + /// abbreviated to something reasonable, like 7 characters. @ffi.Uint16() external int id_abbrev; } @@ -24743,6 +25240,20 @@ abstract class git_attr_value_t { static const int GIT_ATTR_VALUE_STRING = 3; } +/// An options structure for querying attributes. +class git_attr_options extends ffi.Struct { + @ffi.Uint32() + external int version; + + /// A combination of GIT_ATTR_CHECK flags + @ffi.Uint32() + external int flags; + + /// The commit to load attributes from, when + /// `GIT_ATTR_CHECK_INCLUDE_COMMIT` is specified. + external ffi.Pointer commit_id; +} + /// Flags to control the functionality of `git_blob_filter`. abstract class git_blob_filter_flag_t { /// When set, filters will not be applied to binary files. @@ -24754,7 +25265,11 @@ abstract class git_blob_filter_flag_t { /// When set, filters will be loaded from a `.gitattributes` file /// in the HEAD commit. - static const int GIT_BLOB_FILTER_ATTTRIBUTES_FROM_HEAD = 4; + static const int GIT_BLOB_FILTER_ATTRIBUTES_FROM_HEAD = 4; + + /// When set, filters will be loaded from a `.gitattributes` file + /// in the specified commit. + static const int GIT_BLOB_FILTER_ATTRIBUTES_FROM_COMMIT = 8; } /// The options used when applying filter options to a file. @@ -24768,6 +25283,10 @@ class git_blob_filter_options extends ffi.Struct { /// Flags to control the filtering process, see `git_blob_filter_flag_t` above @ffi.Uint32() external int flags; + + /// The commit to load attributes from, when + /// `GIT_BLOB_FILTER_ATTRIBUTES_FROM_COMMIT` is specified. + external ffi.Pointer commit_id; } /// Flags for indicating option behavior for git_blame APIs. @@ -24776,30 +25295,36 @@ abstract class git_blame_flag_t { static const int GIT_BLAME_NORMAL = 0; /// Track lines that have moved within a file (like `git blame -M`). - /// NOT IMPLEMENTED. + /// + /// This is not yet implemented and reserved for future use. static const int GIT_BLAME_TRACK_COPIES_SAME_FILE = 1; - /// Track lines that have moved across files in the same commit (like `git blame -C`). - /// NOT IMPLEMENTED. + /// Track lines that have moved across files in the same commit + /// (like `git blame -C`). + /// + /// This is not yet implemented and reserved for future use. static const int GIT_BLAME_TRACK_COPIES_SAME_COMMIT_MOVES = 2; - /// Track lines that have been copied from another file that exists in the - /// same commit (like `git blame -CC`). Implies SAME_FILE. - /// NOT IMPLEMENTED. + /// Track lines that have been copied from another file that exists + /// in the same commit (like `git blame -CC`). Implies SAME_FILE. + /// + /// This is not yet implemented and reserved for future use. static const int GIT_BLAME_TRACK_COPIES_SAME_COMMIT_COPIES = 4; - /// Track lines that have been copied from another file that exists in *any* - /// commit (like `git blame -CCC`). Implies SAME_COMMIT_COPIES. - /// NOT IMPLEMENTED. + /// Track lines that have been copied from another file that exists in + /// *any* commit (like `git blame -CCC`). Implies SAME_COMMIT_COPIES. + /// + /// This is not yet implemented and reserved for future use. static const int GIT_BLAME_TRACK_COPIES_ANY_COMMIT_COPIES = 8; - /// Restrict the search of commits to those reachable following only the - /// first parents. + /// Restrict the search of commits to those reachable following only + /// the first parents. static const int GIT_BLAME_FIRST_PARENT = 16; - /// Use mailmap file to map author and committer names and email addresses - /// to canonical real names and email addresses. The mailmap will be read - /// from the working directory, or HEAD in a bare repository. + /// Use mailmap file to map author and committer names and email + /// addresses to canonical real names and email addresses. The + /// mailmap will be read from the working directory, or HEAD in a + /// bare repository. static const int GIT_BLAME_USE_MAILMAP = 32; /// Ignore whitespace differences @@ -24818,9 +25343,11 @@ class git_blame_options extends ffi.Struct { @ffi.Uint32() external int flags; - /// The lower bound on the number of alphanumeric - /// characters that must be detected as moving/copying within a file for it to - /// associate those lines with the parent commit. The default value is 20. + /// The lower bound on the number of alphanumeric characters that + /// must be detected as moving/copying within a file for it to + /// associate those lines with the parent commit. The default value + /// is 20. + /// /// This value only takes effect if any of the `GIT_BLAME_TRACK_COPIES_*` /// flags are specified. @ffi.Uint16() @@ -24845,48 +25372,43 @@ class git_blame_options extends ffi.Struct { } /// Structure that represents a blame hunk. -/// -/// - `lines_in_hunk` is the number of lines in this hunk -/// - `final_commit_id` is the OID of the commit where this line was last -/// changed. -/// - `final_start_line_number` is the 1-based line number where this hunk -/// begins, in the final version of the file -/// - `final_signature` is the author of `final_commit_id`. If -/// `GIT_BLAME_USE_MAILMAP` has been specified, it will contain the canonical -/// real name and email address. -/// - `orig_commit_id` is the OID of the commit where this hunk was found. This -/// will usually be the same as `final_commit_id`, except when -/// `GIT_BLAME_TRACK_COPIES_ANY_COMMIT_COPIES` has been specified. -/// - `orig_path` is the path to the file where this hunk originated, as of the -/// commit specified by `orig_commit_id`. -/// - `orig_start_line_number` is the 1-based line number where this hunk begins -/// in the file named by `orig_path` in the commit specified by -/// `orig_commit_id`. -/// - `orig_signature` is the author of `orig_commit_id`. If -/// `GIT_BLAME_USE_MAILMAP` has been specified, it will contain the canonical -/// real name and email address. -/// - `boundary` is 1 iff the hunk has been tracked to a boundary commit (the -/// root, or the commit specified in git_blame_options.oldest_commit) class git_blame_hunk extends ffi.Struct { + /// The number of lines in this hunk. @ffi.Int32() external int lines_in_hunk; + /// The OID of the commit where this line was last changed. external git_oid final_commit_id; + /// The 1-based line number where this hunk begins, in the final version + /// of the file. @ffi.Int32() external int final_start_line_number; + /// The author of `final_commit_id`. If `GIT_BLAME_USE_MAILMAP` has been + /// specified, it will contain the canonical real name and email address. external ffi.Pointer final_signature; + /// The OID of the commit where this hunk was found. + /// This will usually be the same as `final_commit_id`, except when + /// `GIT_BLAME_TRACK_COPIES_ANY_COMMIT_COPIES` has been specified. external git_oid orig_commit_id; + /// The path to the file where this hunk originated, as of the commit + /// specified by `orig_commit_id`. external ffi.Pointer orig_path; + /// The 1-based line number where this hunk begins in the file named by + /// `orig_path` in the commit specified by `orig_commit_id`. @ffi.Int32() external int orig_start_line_number; + /// The author of `orig_commit_id`. If `GIT_BLAME_USE_MAILMAP` has been + /// specified, it will contain the canonical real name and email address. external ffi.Pointer orig_signature; + /// The 1 iff the hunk has been tracked to a boundary commit (the root, + /// or the commit specified in git_blame_options.oldest_commit) @ffi.Int8() external int boundary; } @@ -24926,6 +25448,32 @@ abstract class git_cert_ssh_t { /// SHA-256 is available static const int GIT_CERT_SSH_SHA256 = 4; + + /// Raw hostkey is available + static const int GIT_CERT_SSH_RAW = 8; +} + +abstract class git_cert_ssh_raw_type_t { + /// The raw key is of an unknown type. + static const int GIT_CERT_SSH_RAW_TYPE_UNKNOWN = 0; + + /// The raw key is an RSA key. + static const int GIT_CERT_SSH_RAW_TYPE_RSA = 1; + + /// The raw key is a DSS key. + static const int GIT_CERT_SSH_RAW_TYPE_DSS = 2; + + /// The raw key is a ECDSA 256 key. + static const int GIT_CERT_SSH_RAW_TYPE_KEY_ECDSA_256 = 3; + + /// The raw key is a ECDSA 384 key. + static const int GIT_CERT_SSH_RAW_TYPE_KEY_ECDSA_384 = 4; + + /// The raw key is a ECDSA 521 key. + static const int GIT_CERT_SSH_RAW_TYPE_KEY_ECDSA_521 = 5; + + /// The raw key is a ED25519 key. + static const int GIT_CERT_SSH_RAW_TYPE_KEY_ED25519 = 6; } /// Hostkey information taken from libssh2 @@ -24933,8 +25481,7 @@ class git_cert_hostkey extends ffi.Struct { /// < The parent cert external git_cert parent; - /// A hostkey type from libssh2, either - /// `GIT_CERT_SSH_MD5` or `GIT_CERT_SSH_SHA1` + /// A bitmask containing the available fields. @ffi.Int32() external int type; @@ -24946,6 +25493,20 @@ class git_cert_hostkey extends ffi.Struct { @ffi.Array.multi([32]) external ffi.Array hash_sha256; + + /// Raw hostkey type. If `type` has `GIT_CERT_SSH_RAW` set, this will + /// have the type of the raw hostkey. + @ffi.Int32() + external int raw_type; + + /// Pointer to the raw hostkey. If `type` has `GIT_CERT_SSH_RAW` set, + /// this will have the raw contents of the hostkey. + external ffi.Pointer hostkey; + + /// Raw hostkey length. If `type` has `GIT_CERT_SSH_RAW` set, this will + /// have the length of the raw contents of the hostkey. + @ffi.Int32() + external int hostkey_len; } /// X.509 certificate information @@ -25112,6 +25673,10 @@ abstract class git_checkout_strategy_t { /// Normally checkout writes the index upon completion; this prevents that. static const int GIT_CHECKOUT_DONT_WRITE_INDEX = 8388608; + /// Show what would be done by a checkout. Stop after sending + /// notifications; don't update the working directory or index. + static const int GIT_CHECKOUT_DRY_RUN = 16777216; + /// Recursively checkout submodules with same options (NOT IMPLEMENTED) static const int GIT_CHECKOUT_UPDATE_SUBMODULES = 65536; @@ -25124,18 +25689,6 @@ abstract class git_checkout_strategy_t { /// Checkout will invoke an options notification callback (`notify_cb`) for /// certain cases - you pick which ones via `notify_flags`: /// -/// - GIT_CHECKOUT_NOTIFY_CONFLICT invokes checkout on conflicting paths. -/// -/// - GIT_CHECKOUT_NOTIFY_DIRTY notifies about "dirty" files, i.e. those that -/// do not need an update but no longer match the baseline. Core git -/// displays these files when checkout runs, but won't stop the checkout. -/// -/// - GIT_CHECKOUT_NOTIFY_UPDATED sends notification for any file changed. -/// -/// - GIT_CHECKOUT_NOTIFY_UNTRACKED notifies about untracked files. -/// -/// - GIT_CHECKOUT_NOTIFY_IGNORED notifies about ignored files. -/// /// Returning a non-zero value from this callback will cancel the checkout. /// The non-zero return value will be propagated back and returned by the /// git_checkout_... call. @@ -25145,10 +25698,22 @@ abstract class git_checkout_strategy_t { /// being modified. abstract class git_checkout_notify_t { static const int GIT_CHECKOUT_NOTIFY_NONE = 0; + + /// Invokes checkout on conflicting paths. static const int GIT_CHECKOUT_NOTIFY_CONFLICT = 1; + + /// Notifies about "dirty" files, i.e. those that do not need an update + /// but no longer match the baseline. Core git displays these files when + /// checkout runs, but won't stop the checkout. static const int GIT_CHECKOUT_NOTIFY_DIRTY = 2; + + /// Sends notification for any file changed. static const int GIT_CHECKOUT_NOTIFY_UPDATED = 4; + + /// Notifies about untracked files. static const int GIT_CHECKOUT_NOTIFY_UNTRACKED = 8; + + /// Notifies about ignored files. static const int GIT_CHECKOUT_NOTIFY_IGNORED = 16; static const int GIT_CHECKOUT_NOTIFY_ALL = 65535; } @@ -26351,6 +26916,54 @@ abstract class git_error_t { static const int GIT_ERROR_INTERNAL = 35; } +/// Filters are applied in one of two directions: smudging - which is +/// exporting a file from the Git object database to the working directory, +/// and cleaning - which is importing a file from the working directory to +/// the Git object database. These values control which direction of +/// change is being applied. +abstract class git_filter_mode_t { + static const int GIT_FILTER_TO_WORKTREE = 0; + static const int GIT_FILTER_SMUDGE = 0; + static const int GIT_FILTER_TO_ODB = 1; + static const int GIT_FILTER_CLEAN = 1; +} + +/// Filter option flags. +abstract class git_filter_flag_t { + static const int GIT_FILTER_DEFAULT = 0; + + /// Don't error for `safecrlf` violations, allow them to continue. + static const int GIT_FILTER_ALLOW_UNSAFE = 1; + + /// Don't load `/etc/gitattributes` (or the system equivalent) + static const int GIT_FILTER_NO_SYSTEM_ATTRIBUTES = 2; + + /// Load attributes from `.gitattributes` in the root of HEAD + static const int GIT_FILTER_ATTRIBUTES_FROM_HEAD = 4; + + /// Load attributes from `.gitattributes` in a given commit. + /// This can only be specified in a `git_filter_options`. + static const int GIT_FILTER_ATTRIBUTES_FROM_COMMIT = 8; +} + +/// Filtering options +class git_filter_options extends ffi.Struct { + @ffi.Uint32() + external int version; + + /// See `git_filter_flag_t` above + @ffi.Uint32() + external int flags; + + /// The commit to load attributes from, when + /// `GIT_FILTER_ATTRIBUTES_FROM_COMMIT` is specified. + external ffi.Pointer commit_id; +} + +class git_filter extends ffi.Opaque {} + +class git_filter_list extends ffi.Opaque {} + /// Rebase options /// /// Use to tell the rebase machinery how to operate. @@ -26392,12 +27005,31 @@ class git_rebase_options extends ffi.Struct { /// `abort` to match git semantics. external git_checkout_options checkout_options; + /// Optional callback that allows users to override commit + /// creation in `git_rebase_commit`. If specified, users can + /// create their own commit and provide the commit ID, which + /// may be useful for signing commits or otherwise customizing + /// the commit creation. + /// + /// If this callback returns `GIT_PASSTHROUGH`, then + /// `git_rebase_commit` will continue to create the commit. + external ffi.Pointer> + commit_create_cb; + /// If provided, this will be called with the commit content, allowing /// a signature to be added to the rebase commit. Can be skipped with /// GIT_PASSTHROUGH. If GIT_PASSTHROUGH is returned, a commit will be made /// without a signature. + /// /// This field is only used when performing git_rebase_commit. - external ffi.Pointer> signing_cb; + /// + /// This callback is not invoked if a `git_commit_create_cb` is + /// specified. + /// + /// This callback is deprecated; users should provide a + /// creation callback as `commit_create_cb` that produces a + /// commit buffer, signs it, and commits it. + external ffi.Pointer> signing_cb; /// This will be passed to each of the callbacks in this struct /// as the last parameter. @@ -26490,6 +27122,32 @@ class git_revert_options extends ffi.Struct { external git_checkout_options checkout_opts; } +/// Revparse flags. These indicate the intended behavior of the spec passed to +/// git_revparse. +abstract class git_revspec_t { + /// The spec targeted a single object. + static const int GIT_REVSPEC_SINGLE = 1; + + /// The spec targeted a range of commits. + static const int GIT_REVSPEC_RANGE = 2; + + /// The spec used the '...' operator, which invokes special semantics. + static const int GIT_REVSPEC_MERGE_BASE = 4; +} + +/// Git Revision Spec: output of a `git_revparse` operation +class git_revspec extends ffi.Struct { + /// The left element of the revspec; must be freed by the user + external ffi.Pointer from; + + /// The right element of the revspec; must be freed by the user + external ffi.Pointer to; + + /// The intent of the revspec (i.e. `git_revspec_mode_t` flags) + @ffi.Uint32() + external int flags; +} + /// Stash flags abstract class git_stash_flags { /// No option, default @@ -26595,86 +27253,100 @@ abstract class git_status_t { /// With `git_status_foreach_ext`, this will control which changes get /// callbacks. With `git_status_list_new`, these will control which /// changes are included in the list. -/// -/// - GIT_STATUS_SHOW_INDEX_AND_WORKDIR is the default. This roughly -/// matches `git status --porcelain` regarding which files are -/// included and in what order. -/// - GIT_STATUS_SHOW_INDEX_ONLY only gives status based on HEAD to index -/// comparison, not looking at working directory changes. -/// - GIT_STATUS_SHOW_WORKDIR_ONLY only gives status based on index to -/// working directory comparison, not comparing the index to the HEAD. abstract class git_status_show_t { + /// The default. This roughly matches `git status --porcelain` regarding + /// which files are included and in what order. static const int GIT_STATUS_SHOW_INDEX_AND_WORKDIR = 0; + + /// Only gives status based on HEAD to index comparison, not looking at + /// working directory changes. static const int GIT_STATUS_SHOW_INDEX_ONLY = 1; + + /// Only gives status based on index to working directory comparison, + /// not comparing the index to the HEAD. static const int GIT_STATUS_SHOW_WORKDIR_ONLY = 2; } /// Flags to control status callbacks /// -/// - GIT_STATUS_OPT_INCLUDE_UNTRACKED says that callbacks should be made -/// on untracked files. These will only be made if the workdir files are -/// included in the status "show" option. -/// - GIT_STATUS_OPT_INCLUDE_IGNORED says that ignored files get callbacks. -/// Again, these callbacks will only be made if the workdir files are -/// included in the status "show" option. -/// - GIT_STATUS_OPT_INCLUDE_UNMODIFIED indicates that callback should be -/// made even on unmodified files. -/// - GIT_STATUS_OPT_EXCLUDE_SUBMODULES indicates that submodules should be -/// skipped. This only applies if there are no pending typechanges to -/// the submodule (either from or to another type). -/// - GIT_STATUS_OPT_RECURSE_UNTRACKED_DIRS indicates that all files in -/// untracked directories should be included. Normally if an entire -/// directory is new, then just the top-level directory is included (with -/// a trailing slash on the entry name). This flag says to include all -/// of the individual files in the directory instead. -/// - GIT_STATUS_OPT_DISABLE_PATHSPEC_MATCH indicates that the given path -/// should be treated as a literal path, and not as a pathspec pattern. -/// - GIT_STATUS_OPT_RECURSE_IGNORED_DIRS indicates that the contents of -/// ignored directories should be included in the status. This is like -/// doing `git ls-files -o -i --exclude-standard` with core git. -/// - GIT_STATUS_OPT_RENAMES_HEAD_TO_INDEX indicates that rename detection -/// should be processed between the head and the index and enables -/// the GIT_STATUS_INDEX_RENAMED as a possible status flag. -/// - GIT_STATUS_OPT_RENAMES_INDEX_TO_WORKDIR indicates that rename -/// detection should be run between the index and the working directory -/// and enabled GIT_STATUS_WT_RENAMED as a possible status flag. -/// - GIT_STATUS_OPT_SORT_CASE_SENSITIVELY overrides the native case -/// sensitivity for the file system and forces the output to be in -/// case-sensitive order -/// - GIT_STATUS_OPT_SORT_CASE_INSENSITIVELY overrides the native case -/// sensitivity for the file system and forces the output to be in -/// case-insensitive order -/// - GIT_STATUS_OPT_RENAMES_FROM_REWRITES indicates that rename detection -/// should include rewritten files -/// - GIT_STATUS_OPT_NO_REFRESH bypasses the default status behavior of -/// doing a "soft" index reload (i.e. reloading the index data if the -/// file on disk has been modified outside libgit2). -/// - GIT_STATUS_OPT_UPDATE_INDEX tells libgit2 to refresh the stat cache -/// in the index for files that are unchanged but have out of date stat -/// information in the index. It will result in less work being done on -/// subsequent calls to get status. This is mutually exclusive with the -/// NO_REFRESH option. -/// /// Calling `git_status_foreach()` is like calling the extended version /// with: GIT_STATUS_OPT_INCLUDE_IGNORED, GIT_STATUS_OPT_INCLUDE_UNTRACKED, /// and GIT_STATUS_OPT_RECURSE_UNTRACKED_DIRS. Those options are bundled /// together as `GIT_STATUS_OPT_DEFAULTS` if you want them as a baseline. abstract class git_status_opt_t { + /// Says that callbacks should be made on untracked files. + /// These will only be made if the workdir files are included in the status + /// "show" option. static const int GIT_STATUS_OPT_INCLUDE_UNTRACKED = 1; + + /// Says that ignored files get callbacks. + /// Again, these callbacks will only be made if the workdir files are + /// included in the status "show" option. static const int GIT_STATUS_OPT_INCLUDE_IGNORED = 2; + + /// Indicates that callback should be made even on unmodified files. static const int GIT_STATUS_OPT_INCLUDE_UNMODIFIED = 4; + + /// Indicates that submodules should be skipped. + /// This only applies if there are no pending typechanges to the submodule + /// (either from or to another type). static const int GIT_STATUS_OPT_EXCLUDE_SUBMODULES = 8; + + /// Indicates that all files in untracked directories should be included. + /// Normally if an entire directory is new, then just the top-level + /// directory is included (with a trailing slash on the entry name). + /// This flag says to include all of the individual files in the directory + /// instead. static const int GIT_STATUS_OPT_RECURSE_UNTRACKED_DIRS = 16; + + /// Indicates that the given path should be treated as a literal path, + /// and not as a pathspec pattern. static const int GIT_STATUS_OPT_DISABLE_PATHSPEC_MATCH = 32; + + /// Indicates that the contents of ignored directories should be included + /// in the status. This is like doing `git ls-files -o -i --exclude-standard` + /// with core git. static const int GIT_STATUS_OPT_RECURSE_IGNORED_DIRS = 64; + + /// Indicates that rename detection should be processed between the head and + /// the index and enables the GIT_STATUS_INDEX_RENAMED as a possible status + /// flag. static const int GIT_STATUS_OPT_RENAMES_HEAD_TO_INDEX = 128; + + /// Indicates that rename detection should be run between the index and the + /// working directory and enabled GIT_STATUS_WT_RENAMED as a possible status + /// flag. static const int GIT_STATUS_OPT_RENAMES_INDEX_TO_WORKDIR = 256; + + /// Overrides the native case sensitivity for the file system and forces + /// the output to be in case-sensitive order. static const int GIT_STATUS_OPT_SORT_CASE_SENSITIVELY = 512; + + /// Overrides the native case sensitivity for the file system and forces + /// the output to be in case-insensitive order. static const int GIT_STATUS_OPT_SORT_CASE_INSENSITIVELY = 1024; + + /// Iindicates that rename detection should include rewritten files. static const int GIT_STATUS_OPT_RENAMES_FROM_REWRITES = 2048; + + /// Bypasses the default status behavior of doing a "soft" index reload + /// (i.e. reloading the index data if the file on disk has been modified + /// outside libgit2). static const int GIT_STATUS_OPT_NO_REFRESH = 4096; + + /// Tells libgit2 to refresh the stat cache in the index for files that are + /// unchanged but have out of date stat einformation in the index. + /// It will result in less work being done on subsequent calls to get status. + /// This is mutually exclusive with the NO_REFRESH option. static const int GIT_STATUS_OPT_UPDATE_INDEX = 8192; + + /// Normally files that cannot be opened or read are ignored as + /// these are often transient files; this option will return + /// unreadable files as `GIT_STATUS_WT_UNREADABLE`. static const int GIT_STATUS_OPT_INCLUDE_UNREADABLE = 16384; + + /// Unreadable files will be detected and given the status + /// untracked instead of unreadable. static const int GIT_STATUS_OPT_INCLUDE_UNREADABLE_AS_UNTRACKED = 32768; } @@ -26683,7 +27355,7 @@ abstract class git_status_opt_t { /// Initialize with `GIT_STATUS_OPTIONS_INIT`. Alternatively, you can /// use `git_status_options_init`. class git_status_options extends ffi.Struct { - /// < The version + /// The struct version; pass `GIT_STATUS_OPTIONS_VERSION`. @ffi.Uint32() external int version; @@ -26692,18 +27364,19 @@ class git_status_options extends ffi.Struct { @ffi.Int32() external int show_1; - /// The `flags` value is an OR'ed combination of the `git_status_opt_t` - /// values above. + /// The `flags` value is an OR'ed combination of the + /// `git_status_opt_t` values above. @ffi.Uint32() external int flags; /// The `pathspec` is an array of path patterns to match (using - /// fnmatch-style matching), or just an array of paths to match exactly if - /// `GIT_STATUS_OPT_DISABLE_PATHSPEC_MATCH` is specified in the flags. + /// fnmatch-style matching), or just an array of paths to match + /// exactly if `GIT_STATUS_OPT_DISABLE_PATHSPEC_MATCH` is specified + /// in the flags. external git_strarray pathspec; - /// The `baseline` is the tree to be used for comparison to the working directory - /// and index; defaults to HEAD. + /// The `baseline` is the tree to be used for comparison to the + /// working directory and index; defaults to HEAD. external ffi.Pointer baseline; } @@ -26849,6 +27522,7 @@ class git_worktree_prune_options extends ffi.Struct { @ffi.Uint32() external int version; + /// A combination of `git_worktree_prune_t` @ffi.Uint32() external int flags; } @@ -26860,36 +27534,6 @@ class git_credential_userpass_payload extends ffi.Struct { external ffi.Pointer password; } -/// Filters are applied in one of two directions: smudging - which is -/// exporting a file from the Git object database to the working directory, -/// and cleaning - which is importing a file from the working directory to -/// the Git object database. These values control which direction of -/// change is being applied. -abstract class git_filter_mode_t { - static const int GIT_FILTER_TO_WORKTREE = 0; - static const int GIT_FILTER_SMUDGE = 0; - static const int GIT_FILTER_TO_ODB = 1; - static const int GIT_FILTER_CLEAN = 1; -} - -/// Filter option flags. -abstract class git_filter_flag_t { - static const int GIT_FILTER_DEFAULT = 0; - - /// Don't error for `safecrlf` violations, allow them to continue. - static const int GIT_FILTER_ALLOW_UNSAFE = 1; - - /// Don't load `/etc/gitattributes` (or the system equivalent) - static const int GIT_FILTER_NO_SYSTEM_ATTRIBUTES = 2; - - /// Load attributes from `.gitattributes` in the root of HEAD - static const int GIT_FILTER_ATTRIBUTES_FROM_HEAD = 4; -} - -class git_filter extends ffi.Opaque {} - -class git_filter_list extends ffi.Opaque {} - /// Represents a single git message trailer. class git_message_trailer extends ffi.Struct { external ffi.Pointer key; @@ -26989,32 +27633,6 @@ abstract class git_reset_t { static const int GIT_RESET_HARD = 3; } -/// Revparse flags. These indicate the intended behavior of the spec passed to -/// git_revparse. -abstract class git_revparse_mode_t { - /// The spec targeted a single object. - static const int GIT_REVPARSE_SINGLE = 1; - - /// The spec targeted a range of commits. - static const int GIT_REVPARSE_RANGE = 2; - - /// The spec used the '...' operator, which invokes special semantics. - static const int GIT_REVPARSE_MERGE_BASE = 4; -} - -/// Git Revision Spec: output of a `git_revparse` operation -class git_revspec extends ffi.Struct { - /// The left element of the revspec; must be freed by the user - external ffi.Pointer from; - - /// The right element of the revspec; must be freed by the user - external ffi.Pointer to; - - /// The intent of the revspec (i.e. `git_revparse_mode_t` flags) - @ffi.Uint32() - external int flags; -} - /// Flags to specify the sorting which a revwalk should perform. abstract class git_sort_t { /// Sort the output with the same default method from `git`: reverse @@ -27807,6 +28425,10 @@ const int GIT_ATTR_CHECK_NO_SYSTEM = 4; const int GIT_ATTR_CHECK_INCLUDE_HEAD = 8; +const int GIT_ATTR_CHECK_INCLUDE_COMMIT = 16; + +const int GIT_ATTR_OPTIONS_VERSION = 1; + const int GIT_BLOB_FILTER_OPTIONS_VERSION = 1; const int GIT_BLAME_OPTIONS_VERSION = 1; @@ -27853,6 +28475,8 @@ const int GIT_DESCRIBE_OPTIONS_VERSION = 1; const int GIT_DESCRIBE_FORMAT_OPTIONS_VERSION = 1; +const int GIT_FILTER_OPTIONS_VERSION = 1; + const int GIT_REBASE_OPTIONS_VERSION = 1; const int GIT_REBASE_NO_OPERATION = -1; @@ -27885,6 +28509,8 @@ const int GIT_ATTR_FALSE_T = 2; const int GIT_ATTR_VALUE_T = 3; +const int GIT_BLOB_FILTER_ATTTRIBUTES_FROM_HEAD = 4; + const int GIT_CVAR_FALSE = 0; const int GIT_CVAR_TRUE = 1; @@ -28043,6 +28669,12 @@ const int GIT_REF_FORMAT_REFSPEC_PATTERN = 2; const int GIT_REF_FORMAT_REFSPEC_SHORTHAND = 4; +const int GIT_REVPARSE_SINGLE = 1; + +const int GIT_REVPARSE_RANGE = 2; + +const int GIT_REVPARSE_MERGE_BASE = 4; + const int GIT_CREDTYPE_USERPASS_PLAINTEXT = 1; const int GIT_CREDTYPE_SSH_KEY = 2; @@ -28057,17 +28689,17 @@ const int GIT_CREDTYPE_USERNAME = 32; const int GIT_CREDTYPE_SSH_MEMORY = 64; -const String LIBGIT2_VERSION = '1.1.1'; +const String LIBGIT2_VERSION = '1.2.0'; const int LIBGIT2_VER_MAJOR = 1; -const int LIBGIT2_VER_MINOR = 1; +const int LIBGIT2_VER_MINOR = 2; -const int LIBGIT2_VER_REVISION = 1; +const int LIBGIT2_VER_REVISION = 0; const int LIBGIT2_VER_PATCH = 0; -const String LIBGIT2_SOVERSION = '1.1'; +const String LIBGIT2_SOVERSION = '1.2'; typedef _c_clock = ffi.Int64 Function(); @@ -30545,18 +31177,6 @@ typedef _dart_git_treebuilder_write = int Function( ffi.Pointer bld, ); -typedef _c_git_treebuilder_write_with_buffer = ffi.Int32 Function( - ffi.Pointer oid, - ffi.Pointer bld, - ffi.Pointer tree, -); - -typedef _dart_git_treebuilder_write_with_buffer = int Function( - ffi.Pointer oid, - ffi.Pointer bld, - ffi.Pointer tree, -); - typedef git_treewalk_cb = ffi.Int32 Function( ffi.Pointer, ffi.Pointer, @@ -31067,11 +31687,13 @@ typedef _dart_git_reference_peel = int Function( int type, ); -typedef _c_git_reference_is_valid_name = ffi.Int32 Function( +typedef _c_git_reference_name_is_valid = ffi.Int32 Function( + ffi.Pointer valid, ffi.Pointer refname, ); -typedef _dart_git_reference_is_valid_name = int Function( +typedef _dart_git_reference_name_is_valid = int Function( + ffi.Pointer valid, ffi.Pointer refname, ); @@ -31614,6 +32236,22 @@ typedef _dart_git_attr_get = int Function( ffi.Pointer name, ); +typedef _c_git_attr_get_ext = ffi.Int32 Function( + ffi.Pointer> value_out, + ffi.Pointer repo, + ffi.Pointer opts, + ffi.Pointer path, + ffi.Pointer name, +); + +typedef _dart_git_attr_get_ext = int Function( + ffi.Pointer> value_out, + ffi.Pointer repo, + ffi.Pointer opts, + ffi.Pointer path, + ffi.Pointer name, +); + typedef _c_git_attr_get_many = ffi.Int32 Function( ffi.Pointer> values_out, ffi.Pointer repo, @@ -31632,6 +32270,24 @@ typedef _dart_git_attr_get_many = int Function( ffi.Pointer> names, ); +typedef _c_git_attr_get_many_ext = ffi.Int32 Function( + ffi.Pointer> values_out, + ffi.Pointer repo, + ffi.Pointer opts, + ffi.Pointer path, + ffi.Int32 num_attr, + ffi.Pointer> names, +); + +typedef _dart_git_attr_get_many_ext = int Function( + ffi.Pointer> values_out, + ffi.Pointer repo, + ffi.Pointer opts, + ffi.Pointer path, + int num_attr, + ffi.Pointer> names, +); + typedef git_attr_foreach_cb = ffi.Int32 Function( ffi.Pointer, ffi.Pointer, @@ -31654,6 +32310,22 @@ typedef _dart_git_attr_foreach = int Function( ffi.Pointer payload, ); +typedef _c_git_attr_foreach_ext = ffi.Int32 Function( + ffi.Pointer repo, + ffi.Pointer opts, + ffi.Pointer path, + ffi.Pointer> callback, + ffi.Pointer payload, +); + +typedef _dart_git_attr_foreach_ext = int Function( + ffi.Pointer repo, + ffi.Pointer opts, + ffi.Pointer path, + ffi.Pointer> callback, + ffi.Pointer payload, +); + typedef _c_git_attr_cache_flush = ffi.Int32 Function( ffi.Pointer repo, ); @@ -32098,6 +32770,28 @@ typedef _dart_git_branch_upstream_remote = int Function( ffi.Pointer refname, ); +typedef _c_git_branch_upstream_merge = ffi.Int32 Function( + ffi.Pointer buf, + ffi.Pointer repo, + ffi.Pointer refname, +); + +typedef _dart_git_branch_upstream_merge = int Function( + ffi.Pointer buf, + ffi.Pointer repo, + ffi.Pointer refname, +); + +typedef _c_git_branch_name_is_valid = ffi.Int32 Function( + ffi.Pointer valid, + ffi.Pointer name, +); + +typedef _dart_git_branch_name_is_valid = int Function( + ffi.Pointer valid, + ffi.Pointer name, +); + typedef _c_git_checkout_options_init = ffi.Int32 Function( ffi.Pointer opts, ffi.Uint32 version, @@ -33520,6 +34214,26 @@ typedef _dart_git_remote_set_pushurl = int Function( ffi.Pointer url, ); +typedef _c_git_remote_set_instance_url = ffi.Int32 Function( + ffi.Pointer remote, + ffi.Pointer url, +); + +typedef _dart_git_remote_set_instance_url = int Function( + ffi.Pointer remote, + ffi.Pointer url, +); + +typedef _c_git_remote_set_instance_pushurl = ffi.Int32 Function( + ffi.Pointer remote, + ffi.Pointer url, +); + +typedef _dart_git_remote_set_instance_pushurl = int Function( + ffi.Pointer remote, + ffi.Pointer url, +); + typedef _c_git_remote_add_fetch = ffi.Int32 Function( ffi.Pointer repo, ffi.Pointer remote, @@ -33808,11 +34522,13 @@ typedef _dart_git_remote_rename = int Function( ffi.Pointer new_name, ); -typedef _c_git_remote_is_valid_name = ffi.Int32 Function( +typedef _c_git_remote_name_is_valid = ffi.Int32 Function( + ffi.Pointer valid, ffi.Pointer remote_name, ); -typedef _dart_git_remote_is_valid_name = int Function( +typedef _dart_git_remote_name_is_valid = int Function( + ffi.Pointer valid, ffi.Pointer remote_name, ); @@ -34795,6 +35511,140 @@ typedef _c_git_error_set_oom = ffi.Void Function(); typedef _dart_git_error_set_oom = void Function(); +typedef _c_git_filter_list_load = ffi.Int32 Function( + ffi.Pointer> filters, + ffi.Pointer repo, + ffi.Pointer blob, + ffi.Pointer path, + ffi.Int32 mode, + ffi.Uint32 flags, +); + +typedef _dart_git_filter_list_load = int Function( + ffi.Pointer> filters, + ffi.Pointer repo, + ffi.Pointer blob, + ffi.Pointer path, + int mode, + int flags, +); + +typedef _c_git_filter_list_load_ext = ffi.Int32 Function( + ffi.Pointer> filters, + ffi.Pointer repo, + ffi.Pointer blob, + ffi.Pointer path, + ffi.Int32 mode, + ffi.Pointer opts, +); + +typedef _dart_git_filter_list_load_ext = int Function( + ffi.Pointer> filters, + ffi.Pointer repo, + ffi.Pointer blob, + ffi.Pointer path, + int mode, + ffi.Pointer opts, +); + +typedef _c_git_filter_list_contains = ffi.Int32 Function( + ffi.Pointer filters, + ffi.Pointer name, +); + +typedef _dart_git_filter_list_contains = int Function( + ffi.Pointer filters, + ffi.Pointer name, +); + +typedef _c_git_filter_list_apply_to_buffer = ffi.Int32 Function( + ffi.Pointer out, + ffi.Pointer filters, + ffi.Pointer in_1, + ffi.Int32 in_len, +); + +typedef _dart_git_filter_list_apply_to_buffer = int Function( + ffi.Pointer out, + ffi.Pointer filters, + ffi.Pointer in_1, + int in_len, +); + +typedef _c_git_filter_list_apply_to_file = ffi.Int32 Function( + ffi.Pointer out, + ffi.Pointer filters, + ffi.Pointer repo, + ffi.Pointer path, +); + +typedef _dart_git_filter_list_apply_to_file = int Function( + ffi.Pointer out, + ffi.Pointer filters, + ffi.Pointer repo, + ffi.Pointer path, +); + +typedef _c_git_filter_list_apply_to_blob = ffi.Int32 Function( + ffi.Pointer out, + ffi.Pointer filters, + ffi.Pointer blob, +); + +typedef _dart_git_filter_list_apply_to_blob = int Function( + ffi.Pointer out, + ffi.Pointer filters, + ffi.Pointer blob, +); + +typedef _c_git_filter_list_stream_buffer = ffi.Int32 Function( + ffi.Pointer filters, + ffi.Pointer buffer, + ffi.Int32 len, + ffi.Pointer target, +); + +typedef _dart_git_filter_list_stream_buffer = int Function( + ffi.Pointer filters, + ffi.Pointer buffer, + int len, + ffi.Pointer target, +); + +typedef _c_git_filter_list_stream_file = ffi.Int32 Function( + ffi.Pointer filters, + ffi.Pointer repo, + ffi.Pointer path, + ffi.Pointer target, +); + +typedef _dart_git_filter_list_stream_file = int Function( + ffi.Pointer filters, + ffi.Pointer repo, + ffi.Pointer path, + ffi.Pointer target, +); + +typedef _c_git_filter_list_stream_blob = ffi.Int32 Function( + ffi.Pointer filters, + ffi.Pointer blob, + ffi.Pointer target, +); + +typedef _dart_git_filter_list_stream_blob = int Function( + ffi.Pointer filters, + ffi.Pointer blob, + ffi.Pointer target, +); + +typedef _c_git_filter_list_free = ffi.Void Function( + ffi.Pointer filters, +); + +typedef _dart_git_filter_list_free = void Function( + ffi.Pointer filters, +); + typedef _c_git_rebase_options_init = ffi.Int32 Function( ffi.Pointer opts, ffi.Uint32 version, @@ -35014,6 +35864,44 @@ typedef _dart_git_revert = int Function( ffi.Pointer given_opts, ); +typedef _c_git_revparse_single = ffi.Int32 Function( + ffi.Pointer> out, + ffi.Pointer repo, + ffi.Pointer spec, +); + +typedef _dart_git_revparse_single = int Function( + ffi.Pointer> out, + ffi.Pointer repo, + ffi.Pointer spec, +); + +typedef _c_git_revparse_ext = ffi.Int32 Function( + ffi.Pointer> object_out, + ffi.Pointer> reference_out, + ffi.Pointer repo, + ffi.Pointer spec, +); + +typedef _dart_git_revparse_ext = int Function( + ffi.Pointer> object_out, + ffi.Pointer> reference_out, + ffi.Pointer repo, + ffi.Pointer spec, +); + +typedef _c_git_revparse = ffi.Int32 Function( + ffi.Pointer revspec, + ffi.Pointer repo, + ffi.Pointer spec, +); + +typedef _dart_git_revparse = int Function( + ffi.Pointer revspec, + ffi.Pointer repo, + ffi.Pointer spec, +); + typedef _c_git_stash_save = ffi.Int32 Function( ffi.Pointer out, ffi.Pointer repo, @@ -35231,6 +36119,16 @@ typedef _dart_git_submodule_lookup = int Function( ffi.Pointer name, ); +typedef _c_git_submodule_dup = ffi.Int32 Function( + ffi.Pointer> out, + ffi.Pointer source, +); + +typedef _dart_git_submodule_dup = int Function( + ffi.Pointer> out, + ffi.Pointer source, +); + typedef _c_git_submodule_free = ffi.Void Function( ffi.Pointer submodule, ); @@ -35775,6 +36673,42 @@ typedef _dart_git_blob_filtered_content = int Function( int check_for_binary_data, ); +typedef _c_git_filter_list_stream_data = ffi.Int32 Function( + ffi.Pointer filters, + ffi.Pointer data, + ffi.Pointer target, +); + +typedef _dart_git_filter_list_stream_data = int Function( + ffi.Pointer filters, + ffi.Pointer data, + ffi.Pointer target, +); + +typedef _c_git_filter_list_apply_to_data = ffi.Int32 Function( + ffi.Pointer out, + ffi.Pointer filters, + ffi.Pointer in_1, +); + +typedef _dart_git_filter_list_apply_to_data = int Function( + ffi.Pointer out, + ffi.Pointer filters, + ffi.Pointer in_1, +); + +typedef _c_git_treebuilder_write_with_buffer = ffi.Int32 Function( + ffi.Pointer oid, + ffi.Pointer bld, + ffi.Pointer tree, +); + +typedef _dart_git_treebuilder_write_with_buffer = int Function( + ffi.Pointer oid, + ffi.Pointer bld, + ffi.Pointer tree, +); + typedef _c_git_buf_free = ffi.Void Function( ffi.Pointer buffer, ); @@ -35827,6 +36761,22 @@ typedef _dart_git_object__size = int Function( int type, ); +typedef _c_git_remote_is_valid_name = ffi.Int32 Function( + ffi.Pointer remote_name, +); + +typedef _dart_git_remote_is_valid_name = int Function( + ffi.Pointer remote_name, +); + +typedef _c_git_reference_is_valid_name = ffi.Int32 Function( + ffi.Pointer refname, +); + +typedef _dart_git_reference_is_valid_name = int Function( + ffi.Pointer refname, +); + typedef _c_git_tag_create_frombuffer = ffi.Int32 Function( ffi.Pointer oid, ffi.Pointer repo, @@ -36263,118 +37213,6 @@ typedef _dart_git_worktree_prune_init_options = int Function( int version, ); -typedef _c_git_filter_list_load = ffi.Int32 Function( - ffi.Pointer> filters, - ffi.Pointer repo, - ffi.Pointer blob, - ffi.Pointer path, - ffi.Int32 mode, - ffi.Uint32 flags, -); - -typedef _dart_git_filter_list_load = int Function( - ffi.Pointer> filters, - ffi.Pointer repo, - ffi.Pointer blob, - ffi.Pointer path, - int mode, - int flags, -); - -typedef _c_git_filter_list_contains = ffi.Int32 Function( - ffi.Pointer filters, - ffi.Pointer name, -); - -typedef _dart_git_filter_list_contains = int Function( - ffi.Pointer filters, - ffi.Pointer name, -); - -typedef _c_git_filter_list_apply_to_data = ffi.Int32 Function( - ffi.Pointer out, - ffi.Pointer filters, - ffi.Pointer in_1, -); - -typedef _dart_git_filter_list_apply_to_data = int Function( - ffi.Pointer out, - ffi.Pointer filters, - ffi.Pointer in_1, -); - -typedef _c_git_filter_list_apply_to_file = ffi.Int32 Function( - ffi.Pointer out, - ffi.Pointer filters, - ffi.Pointer repo, - ffi.Pointer path, -); - -typedef _dart_git_filter_list_apply_to_file = int Function( - ffi.Pointer out, - ffi.Pointer filters, - ffi.Pointer repo, - ffi.Pointer path, -); - -typedef _c_git_filter_list_apply_to_blob = ffi.Int32 Function( - ffi.Pointer out, - ffi.Pointer filters, - ffi.Pointer blob, -); - -typedef _dart_git_filter_list_apply_to_blob = int Function( - ffi.Pointer out, - ffi.Pointer filters, - ffi.Pointer blob, -); - -typedef _c_git_filter_list_stream_data = ffi.Int32 Function( - ffi.Pointer filters, - ffi.Pointer data, - ffi.Pointer target, -); - -typedef _dart_git_filter_list_stream_data = int Function( - ffi.Pointer filters, - ffi.Pointer data, - ffi.Pointer target, -); - -typedef _c_git_filter_list_stream_file = ffi.Int32 Function( - ffi.Pointer filters, - ffi.Pointer repo, - ffi.Pointer path, - ffi.Pointer target, -); - -typedef _dart_git_filter_list_stream_file = int Function( - ffi.Pointer filters, - ffi.Pointer repo, - ffi.Pointer path, - ffi.Pointer target, -); - -typedef _c_git_filter_list_stream_blob = ffi.Int32 Function( - ffi.Pointer filters, - ffi.Pointer blob, - ffi.Pointer target, -); - -typedef _dart_git_filter_list_stream_blob = int Function( - ffi.Pointer filters, - ffi.Pointer blob, - ffi.Pointer target, -); - -typedef _c_git_filter_list_free = ffi.Void Function( - ffi.Pointer filters, -); - -typedef _dart_git_filter_list_free = void Function( - ffi.Pointer filters, -); - typedef _c_git_libgit2_init = ffi.Int32 Function(); typedef _dart_git_libgit2_init = int Function(); @@ -36411,6 +37249,20 @@ typedef _dart_git_graph_descendant_of = int Function( ffi.Pointer ancestor, ); +typedef _c_git_graph_reachable_from_any = ffi.Int32 Function( + ffi.Pointer repo, + ffi.Pointer commit, + ffi.Pointer descendant_array, + ffi.Int32 length, +); + +typedef _dart_git_graph_reachable_from_any = int Function( + ffi.Pointer repo, + ffi.Pointer commit, + ffi.Pointer descendant_array, + int length, +); + typedef _c_git_ignore_add_rule = ffi.Int32 Function( ffi.Pointer repo, ffi.Pointer rules, @@ -37014,6 +37866,14 @@ typedef _dart_git_odb_write_pack = int Function( ffi.Pointer progress_payload, ); +typedef _c_git_odb_write_multi_pack_index = ffi.Int32 Function( + ffi.Pointer db, +); + +typedef _dart_git_odb_write_multi_pack_index = int Function( + ffi.Pointer db, +); + typedef _c_git_odb_hash = ffi.Int32 Function( ffi.Pointer out, ffi.Pointer data, @@ -37134,6 +37994,16 @@ typedef _dart_git_odb_get_backend = int Function( int pos, ); +typedef _c_git_odb_set_commit_graph = ffi.Int32 Function( + ffi.Pointer odb, + ffi.Pointer cgraph, +); + +typedef _dart_git_odb_set_commit_graph = int Function( + ffi.Pointer odb, + ffi.Pointer cgraph, +); + typedef _c_git_odb_backend_pack = ffi.Int32 Function( ffi.Pointer> out, ffi.Pointer objects_dir, @@ -37172,6 +38042,14 @@ typedef _dart_git_odb_backend_one_pack = int Function( ffi.Pointer index_file, ); +typedef _c_git_patch_owner = ffi.Pointer Function( + ffi.Pointer patch, +); + +typedef _dart_git_patch_owner = ffi.Pointer Function( + ffi.Pointer patch, +); + typedef _c_git_patch_from_diff = ffi.Int32 Function( ffi.Pointer> out, ffi.Pointer diff, @@ -37702,44 +38580,6 @@ typedef _dart_git_reset_default = int Function( ffi.Pointer pathspecs, ); -typedef _c_git_revparse_single = ffi.Int32 Function( - ffi.Pointer> out, - ffi.Pointer repo, - ffi.Pointer spec, -); - -typedef _dart_git_revparse_single = int Function( - ffi.Pointer> out, - ffi.Pointer repo, - ffi.Pointer spec, -); - -typedef _c_git_revparse_ext = ffi.Int32 Function( - ffi.Pointer> object_out, - ffi.Pointer> reference_out, - ffi.Pointer repo, - ffi.Pointer spec, -); - -typedef _dart_git_revparse_ext = int Function( - ffi.Pointer> object_out, - ffi.Pointer> reference_out, - ffi.Pointer repo, - ffi.Pointer spec, -); - -typedef _c_git_revparse = ffi.Int32 Function( - ffi.Pointer revspec, - ffi.Pointer repo, - ffi.Pointer spec, -); - -typedef _dart_git_revparse = int Function( - ffi.Pointer revspec, - ffi.Pointer repo, - ffi.Pointer spec, -); - typedef _c_git_revwalk_new = ffi.Int32 Function( ffi.Pointer> out, ffi.Pointer repo, @@ -38209,6 +39049,16 @@ typedef _dart_git_tag_dup = int Function( ffi.Pointer source, ); +typedef _c_git_tag_name_is_valid = ffi.Int32 Function( + ffi.Pointer valid, + ffi.Pointer name, +); + +typedef _dart_git_tag_name_is_valid = int Function( + ffi.Pointer valid, + ffi.Pointer name, +); + typedef _c_git_transaction_new = ffi.Int32 Function( ffi.Pointer> out, ffi.Pointer repo, @@ -38398,6 +39248,12 @@ typedef git_transport_cb = ffi.Int32 Function( ffi.Pointer, ); +typedef git_remote_ready_cb = ffi.Int32 Function( + ffi.Pointer, + ffi.Int32, + ffi.Pointer, +); + typedef git_url_resolve_cb = ffi.Int32 Function( ffi.Pointer, ffi.Pointer, @@ -38510,7 +39366,19 @@ typedef _typedefC_21 = ffi.Void Function( ffi.Pointer, ); -typedef git_commit_signing_cb = ffi.Int32 Function( +typedef git_commit_create_cb = ffi.Int32 Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Int32, + ffi.Pointer>, + ffi.Pointer, +); + +typedef _typedefC_22 = ffi.Int32 Function( ffi.Pointer, ffi.Pointer, ffi.Pointer, diff --git a/lib/src/util.dart b/lib/src/util.dart index 4218b3c..1ae944c 100644 --- a/lib/src/util.dart +++ b/lib/src/util.dart @@ -5,15 +5,15 @@ import 'bindings/libgit2_bindings.dart'; DynamicLibrary loadLibrary() { if (Platform.isLinux || Platform.isAndroid || Platform.isFuchsia) { return DynamicLibrary.open( - '${Directory.current.path}/libgit2/libgit2-1.1.1.so'); + '${Directory.current.path}/libgit2/libgit2-1.2.0.so'); } if (Platform.isMacOS) { return DynamicLibrary.open( - '${Directory.current.path}/libgit2/libgit2-1.1.1.dylib'); + '${Directory.current.path}/libgit2/libgit2-1.2.0.dylib'); } if (Platform.isWindows) { return DynamicLibrary.open( - '${Directory.current.path}/libgit2/libgit2-1.1.1.dll'); + '${Directory.current.path}/libgit2/libgit2-1.2.0.dll'); } throw Exception('Platform not implemented'); } diff --git a/libgit2/headers/git2/attr.h b/libgit2/headers/git2/attr.h index a3ab5a7..62c2ed6 100644 --- a/libgit2/headers/git2/attr.h +++ b/libgit2/headers/git2/attr.h @@ -130,9 +130,32 @@ GIT_EXTERN(git_attr_value_t) git_attr_value(const char *attr); * * Passing the `GIT_ATTR_CHECK_INCLUDE_HEAD` flag will use attributes * from a `.gitattributes` file in the repository at the HEAD revision. + * + * Passing the `GIT_ATTR_CHECK_INCLUDE_COMMIT` flag will use attributes + * from a `.gitattributes` file in a specific commit. */ #define GIT_ATTR_CHECK_NO_SYSTEM (1 << 2) #define GIT_ATTR_CHECK_INCLUDE_HEAD (1 << 3) +#define GIT_ATTR_CHECK_INCLUDE_COMMIT (1 << 4) + +/** +* An options structure for querying attributes. +*/ +typedef struct { + unsigned int version; + + /** A combination of GIT_ATTR_CHECK flags */ + unsigned int flags; + + /** + * The commit to load attributes from, when + * `GIT_ATTR_CHECK_INCLUDE_COMMIT` is specified. + */ + git_oid *commit_id; +} git_attr_options; + +#define GIT_ATTR_OPTIONS_VERSION 1 +#define GIT_ATTR_OPTIONS_INIT {GIT_ATTR_OPTIONS_VERSION} /** * Look up the value of one git attribute for path. @@ -156,6 +179,28 @@ GIT_EXTERN(int) git_attr_get( const char *path, const char *name); +/** + * Look up the value of one git attribute for path with extended options. + * + * @param value_out Output of the value of the attribute. Use the GIT_ATTR_... + * macros to test for TRUE, FALSE, UNSPECIFIED, etc. or just + * use the string value for attributes set to a value. You + * should NOT modify or free this value. + * @param repo The repository containing the path. + * @param opts The `git_attr_options` to use when querying these attributes. + * @param path The path to check for attributes. Relative paths are + * interpreted relative to the repo root. The file does + * not have to exist, but if it does not, then it will be + * treated as a plain file (not a directory). + * @param name The name of the attribute to look up. + */ +GIT_EXTERN(int) git_attr_get_ext( + const char **value_out, + git_repository *repo, + git_attr_options *opts, + const char *path, + const char *name); + /** * Look up a list of git attributes for path. * @@ -193,6 +238,30 @@ GIT_EXTERN(int) git_attr_get_many( size_t num_attr, const char **names); +/** + * Look up a list of git attributes for path with extended options. + * + * @param values_out An array of num_attr entries that will have string + * pointers written into it for the values of the attributes. + * You should not modify or free the values that are written + * into this array (although of course, you should free the + * array itself if you allocated it). + * @param repo The repository containing the path. + * @param opts The `git_attr_options` to use when querying these attributes. + * @param path The path inside the repo to check attributes. This + * does not have to exist, but if it does not, then + * it will be treated as a plain file (i.e. not a directory). + * @param num_attr The number of attributes being looked up + * @param names An array of num_attr strings containing attribute names. + */ +GIT_EXTERN(int) git_attr_get_many_ext( + const char **values_out, + git_repository *repo, + git_attr_options *opts, + const char *path, + size_t num_attr, + const char **names); + /** * The callback used with git_attr_foreach. * @@ -231,6 +300,26 @@ GIT_EXTERN(int) git_attr_foreach( git_attr_foreach_cb callback, void *payload); +/** + * Loop over all the git attributes for a path with extended options. + * + * @param repo The repository containing the path. + * @param opts The `git_attr_options` to use when querying these attributes. + * @param path Path inside the repo to check attributes. This does not have + * to exist, but if it does not, then it will be treated as a + * plain file (i.e. not a directory). + * @param callback Function to invoke on each attribute name and value. + * See git_attr_foreach_cb. + * @param payload Passed on as extra parameter to callback function. + * @return 0 on success, non-zero callback return value, or error code + */ +GIT_EXTERN(int) git_attr_foreach_ext( + git_repository *repo, + git_attr_options *opts, + const char *path, + git_attr_foreach_cb callback, + void *payload); + /** * Flush the gitattributes cache. * diff --git a/libgit2/headers/git2/blame.h b/libgit2/headers/git2/blame.h index f42c815..d193ce1 100644 --- a/libgit2/headers/git2/blame.h +++ b/libgit2/headers/git2/blame.h @@ -26,27 +26,52 @@ GIT_BEGIN_DECL typedef enum { /** Normal blame, the default */ GIT_BLAME_NORMAL = 0, - /** Track lines that have moved within a file (like `git blame -M`). - * NOT IMPLEMENTED. */ + + /** + * Track lines that have moved within a file (like `git blame -M`). + * + * This is not yet implemented and reserved for future use. + */ GIT_BLAME_TRACK_COPIES_SAME_FILE = (1<<0), - /** Track lines that have moved across files in the same commit (like `git blame -C`). - * NOT IMPLEMENTED. */ + + /** + * Track lines that have moved across files in the same commit + * (like `git blame -C`). + * + * This is not yet implemented and reserved for future use. + */ GIT_BLAME_TRACK_COPIES_SAME_COMMIT_MOVES = (1<<1), - /** Track lines that have been copied from another file that exists in the - * same commit (like `git blame -CC`). Implies SAME_FILE. - * NOT IMPLEMENTED. */ + + /** + * Track lines that have been copied from another file that exists + * in the same commit (like `git blame -CC`). Implies SAME_FILE. + * + * This is not yet implemented and reserved for future use. + */ GIT_BLAME_TRACK_COPIES_SAME_COMMIT_COPIES = (1<<2), - /** Track lines that have been copied from another file that exists in *any* - * commit (like `git blame -CCC`). Implies SAME_COMMIT_COPIES. - * NOT IMPLEMENTED. */ + + /** + * Track lines that have been copied from another file that exists in + * *any* commit (like `git blame -CCC`). Implies SAME_COMMIT_COPIES. + * + * This is not yet implemented and reserved for future use. + */ GIT_BLAME_TRACK_COPIES_ANY_COMMIT_COPIES = (1<<3), - /** Restrict the search of commits to those reachable following only the - * first parents. */ + + /** + * Restrict the search of commits to those reachable following only + * the first parents. + */ GIT_BLAME_FIRST_PARENT = (1<<4), - /** Use mailmap file to map author and committer names and email addresses - * to canonical real names and email addresses. The mailmap will be read - * from the working directory, or HEAD in a bare repository. */ + + /** + * Use mailmap file to map author and committer names and email + * addresses to canonical real names and email addresses. The + * mailmap will be read from the working directory, or HEAD in a + * bare repository. + */ GIT_BLAME_USE_MAILMAP = (1<<5), + /** Ignore whitespace differences */ GIT_BLAME_IGNORE_WHITESPACE = (1<<6), } git_blame_flag_t; @@ -63,25 +88,33 @@ typedef struct git_blame_options { /** A combination of `git_blame_flag_t` */ uint32_t flags; - /** The lower bound on the number of alphanumeric - * characters that must be detected as moving/copying within a file for it to - * associate those lines with the parent commit. The default value is 20. - * This value only takes effect if any of the `GIT_BLAME_TRACK_COPIES_*` - * flags are specified. + + /** + * The lower bound on the number of alphanumeric characters that + * must be detected as moving/copying within a file for it to + * associate those lines with the parent commit. The default value + * is 20. + * + * This value only takes effect if any of the `GIT_BLAME_TRACK_COPIES_*` + * flags are specified. */ uint16_t min_match_characters; + /** The id of the newest commit to consider. The default is HEAD. */ git_oid newest_commit; + /** * The id of the oldest commit to consider. * The default is the first commit encountered with a NULL parent. */ git_oid oldest_commit; + /** * The first line in the file to blame. * The default is 1 (line numbers start with 1). */ size_t min_line; + /** * The last line in the file to blame. * The default is the last line of the file. @@ -108,41 +141,59 @@ GIT_EXTERN(int) git_blame_options_init( /** * Structure that represents a blame hunk. - * - * - `lines_in_hunk` is the number of lines in this hunk - * - `final_commit_id` is the OID of the commit where this line was last - * changed. - * - `final_start_line_number` is the 1-based line number where this hunk - * begins, in the final version of the file - * - `final_signature` is the author of `final_commit_id`. If - * `GIT_BLAME_USE_MAILMAP` has been specified, it will contain the canonical - * real name and email address. - * - `orig_commit_id` is the OID of the commit where this hunk was found. This - * will usually be the same as `final_commit_id`, except when - * `GIT_BLAME_TRACK_COPIES_ANY_COMMIT_COPIES` has been specified. - * - `orig_path` is the path to the file where this hunk originated, as of the - * commit specified by `orig_commit_id`. - * - `orig_start_line_number` is the 1-based line number where this hunk begins - * in the file named by `orig_path` in the commit specified by - * `orig_commit_id`. - * - `orig_signature` is the author of `orig_commit_id`. If - * `GIT_BLAME_USE_MAILMAP` has been specified, it will contain the canonical - * real name and email address. - * - `boundary` is 1 iff the hunk has been tracked to a boundary commit (the - * root, or the commit specified in git_blame_options.oldest_commit) */ typedef struct git_blame_hunk { + /** + * The number of lines in this hunk. + */ size_t lines_in_hunk; + /** + * The OID of the commit where this line was last changed. + */ git_oid final_commit_id; + + /** + * The 1-based line number where this hunk begins, in the final version + * of the file. + */ size_t final_start_line_number; + + /** + * The author of `final_commit_id`. If `GIT_BLAME_USE_MAILMAP` has been + * specified, it will contain the canonical real name and email address. + */ git_signature *final_signature; + /** + * The OID of the commit where this hunk was found. + * This will usually be the same as `final_commit_id`, except when + * `GIT_BLAME_TRACK_COPIES_ANY_COMMIT_COPIES` has been specified. + */ git_oid orig_commit_id; + + /** + * The path to the file where this hunk originated, as of the commit + * specified by `orig_commit_id`. + */ const char *orig_path; + + /** + * The 1-based line number where this hunk begins in the file named by + * `orig_path` in the commit specified by `orig_commit_id`. + */ size_t orig_start_line_number; + + /** + * The author of `orig_commit_id`. If `GIT_BLAME_USE_MAILMAP` has been + * specified, it will contain the canonical real name and email address. + */ git_signature *orig_signature; + /** + * The 1 iff the hunk has been tracked to a boundary commit (the root, + * or the commit specified in git_blame_options.oldest_commit) + */ char boundary; } git_blame_hunk; diff --git a/libgit2/headers/git2/blob.h b/libgit2/headers/git2/blob.h index 1f7442e..fceb5c7 100644 --- a/libgit2/headers/git2/blob.h +++ b/libgit2/headers/git2/blob.h @@ -84,7 +84,7 @@ GIT_EXTERN(git_repository *) git_blob_owner(const git_blob *blob); * time. * * @param blob pointer to the blob - * @return the pointer + * @return the pointer, or NULL on error */ GIT_EXTERN(const void *) git_blob_rawcontent(const git_blob *blob); @@ -113,7 +113,13 @@ typedef enum { * When set, filters will be loaded from a `.gitattributes` file * in the HEAD commit. */ - GIT_BLOB_FILTER_ATTTRIBUTES_FROM_HEAD = (1 << 2), + GIT_BLOB_FILTER_ATTRIBUTES_FROM_HEAD = (1 << 2), + + /** + * When set, filters will be loaded from a `.gitattributes` file + * in the specified commit. + */ + GIT_BLOB_FILTER_ATTRIBUTES_FROM_COMMIT = (1 << 3), } git_blob_filter_flag_t; /** @@ -128,6 +134,12 @@ typedef struct { /** Flags to control the filtering process, see `git_blob_filter_flag_t` above */ uint32_t flags; + + /** + * The commit to load attributes from, when + * `GIT_BLOB_FILTER_ATTRIBUTES_FROM_COMMIT` is specified. + */ + git_oid *commit_id; } git_blob_filter_options; #define GIT_BLOB_FILTER_OPTIONS_VERSION 1 diff --git a/libgit2/headers/git2/branch.h b/libgit2/headers/git2/branch.h index ba62359..24ea7f7 100644 --- a/libgit2/headers/git2/branch.h +++ b/libgit2/headers/git2/branch.h @@ -304,6 +304,31 @@ GIT_EXTERN(int) git_branch_remote_name( */ GIT_EXTERN(int) git_branch_upstream_remote(git_buf *buf, git_repository *repo, const char *refname); +/** + * Retrieve the upstream merge of a local branch + * + * This will return the currently configured "branch.*.merge" for a given + * branch. This branch must be local. + * + * @param buf the buffer into which to write the name + * @param repo the repository in which to look + * @param refname the full name of the branch + * @return 0 or an error code + */ + GIT_EXTERN(int) git_branch_upstream_merge(git_buf *buf, git_repository *repo, const char *refname); + +/** + * Determine whether a branch name is valid, meaning that (when prefixed + * with `refs/heads/`) that it is a valid reference name, and that any + * additional branch name restrictions are imposed (eg, it cannot start + * with a `-`). + * + * @param valid output pointer to set with validity of given branch name + * @param name a branch name to test + * @return 0 on success or an error code + */ +GIT_EXTERN(int) git_branch_name_is_valid(int *valid, const char *name); + /** @} */ GIT_END_DECL #endif diff --git a/libgit2/headers/git2/cert.h b/libgit2/headers/git2/cert.h index e8cd2d1..0ed38ff 100644 --- a/libgit2/headers/git2/cert.h +++ b/libgit2/headers/git2/cert.h @@ -8,6 +8,7 @@ #define INCLUDE_git_cert_h__ #include "common.h" +#include "types.h" /** * @file git2/cert.h @@ -80,8 +81,27 @@ typedef enum { GIT_CERT_SSH_SHA1 = (1 << 1), /** SHA-256 is available */ GIT_CERT_SSH_SHA256 = (1 << 2), + /** Raw hostkey is available */ + GIT_CERT_SSH_RAW = (1 << 3), } git_cert_ssh_t; +typedef enum { + /** The raw key is of an unknown type. */ + GIT_CERT_SSH_RAW_TYPE_UNKNOWN = 0, + /** The raw key is an RSA key. */ + GIT_CERT_SSH_RAW_TYPE_RSA = 1, + /** The raw key is a DSS key. */ + GIT_CERT_SSH_RAW_TYPE_DSS = 2, + /** The raw key is a ECDSA 256 key. */ + GIT_CERT_SSH_RAW_TYPE_KEY_ECDSA_256 = 3, + /** The raw key is a ECDSA 384 key. */ + GIT_CERT_SSH_RAW_TYPE_KEY_ECDSA_384 = 4, + /** The raw key is a ECDSA 521 key. */ + GIT_CERT_SSH_RAW_TYPE_KEY_ECDSA_521 = 5, + /** The raw key is a ED25519 key. */ + GIT_CERT_SSH_RAW_TYPE_KEY_ED25519 = 6 +} git_cert_ssh_raw_type_t; + /** * Hostkey information taken from libssh2 */ @@ -89,28 +109,45 @@ typedef struct { git_cert parent; /**< The parent cert */ /** - * A hostkey type from libssh2, either - * `GIT_CERT_SSH_MD5` or `GIT_CERT_SSH_SHA1` + * A bitmask containing the available fields. */ git_cert_ssh_t type; /** - * Hostkey hash. If type has `GIT_CERT_SSH_MD5` set, this will + * Hostkey hash. If `type` has `GIT_CERT_SSH_MD5` set, this will * have the MD5 hash of the hostkey. */ unsigned char hash_md5[16]; /** - * Hostkey hash. If type has `GIT_CERT_SSH_SHA1` set, this will + * Hostkey hash. If `type` has `GIT_CERT_SSH_SHA1` set, this will * have the SHA-1 hash of the hostkey. */ unsigned char hash_sha1[20]; /** - * Hostkey hash. If type has `GIT_CERT_SSH_SHA256` set, this will + * Hostkey hash. If `type` has `GIT_CERT_SSH_SHA256` set, this will * have the SHA-256 hash of the hostkey. */ unsigned char hash_sha256[32]; + + /** + * Raw hostkey type. If `type` has `GIT_CERT_SSH_RAW` set, this will + * have the type of the raw hostkey. + */ + git_cert_ssh_raw_type_t raw_type; + + /** + * Pointer to the raw hostkey. If `type` has `GIT_CERT_SSH_RAW` set, + * this will have the raw contents of the hostkey. + */ + const char *hostkey; + + /** + * Raw hostkey length. If `type` has `GIT_CERT_SSH_RAW` set, this will + * have the length of the raw contents of the hostkey. + */ + size_t hostkey_len; } git_cert_hostkey; /** diff --git a/libgit2/headers/git2/checkout.h b/libgit2/headers/git2/checkout.h index 3c87001..c7aeee4 100644 --- a/libgit2/headers/git2/checkout.h +++ b/libgit2/headers/git2/checkout.h @@ -177,6 +177,12 @@ typedef enum { /** Normally checkout writes the index upon completion; this prevents that. */ GIT_CHECKOUT_DONT_WRITE_INDEX = (1u << 23), + /** + * Show what would be done by a checkout. Stop after sending + * notifications; don't update the working directory or index. + */ + GIT_CHECKOUT_DRY_RUN = (1u << 24), + /** * THE FOLLOWING OPTIONS ARE NOT YET IMPLEMENTED */ @@ -194,18 +200,6 @@ typedef enum { * Checkout will invoke an options notification callback (`notify_cb`) for * certain cases - you pick which ones via `notify_flags`: * - * - GIT_CHECKOUT_NOTIFY_CONFLICT invokes checkout on conflicting paths. - * - * - GIT_CHECKOUT_NOTIFY_DIRTY notifies about "dirty" files, i.e. those that - * do not need an update but no longer match the baseline. Core git - * displays these files when checkout runs, but won't stop the checkout. - * - * - GIT_CHECKOUT_NOTIFY_UPDATED sends notification for any file changed. - * - * - GIT_CHECKOUT_NOTIFY_UNTRACKED notifies about untracked files. - * - * - GIT_CHECKOUT_NOTIFY_IGNORED notifies about ignored files. - * * Returning a non-zero value from this callback will cancel the checkout. * The non-zero return value will be propagated back and returned by the * git_checkout_... call. @@ -216,10 +210,32 @@ typedef enum { */ typedef enum { GIT_CHECKOUT_NOTIFY_NONE = 0, + + /** + * Invokes checkout on conflicting paths. + */ GIT_CHECKOUT_NOTIFY_CONFLICT = (1u << 0), + + /** + * Notifies about "dirty" files, i.e. those that do not need an update + * but no longer match the baseline. Core git displays these files when + * checkout runs, but won't stop the checkout. + */ GIT_CHECKOUT_NOTIFY_DIRTY = (1u << 1), + + /** + * Sends notification for any file changed. + */ GIT_CHECKOUT_NOTIFY_UPDATED = (1u << 2), + + /** + * Notifies about untracked files. + */ GIT_CHECKOUT_NOTIFY_UNTRACKED = (1u << 3), + + /** + * Notifies about ignored files. + */ GIT_CHECKOUT_NOTIFY_IGNORED = (1u << 4), GIT_CHECKOUT_NOTIFY_ALL = 0x0FFFFu diff --git a/libgit2/headers/git2/commit.h b/libgit2/headers/git2/commit.h index e6c4656..4d74b89 100644 --- a/libgit2/headers/git2/commit.h +++ b/libgit2/headers/git2/commit.h @@ -503,25 +503,41 @@ GIT_EXTERN(int) git_commit_create_with_signature( GIT_EXTERN(int) git_commit_dup(git_commit **out, git_commit *source); /** - * Commit signing callback. + * Commit creation callback: used when a function is going to create + * commits (for example, in `git_rebase_commit`) to allow callers to + * override the commit creation behavior. For example, users may + * wish to sign commits by providing this information to + * `git_commit_create_buffer`, signing that buffer, then calling + * `git_commit_create_with_signature`. The resultant commit id + * should be set in the `out` object id parameter. * - * The callback will be called with the commit content, giving a user an - * opportunity to sign the commit content. The signature_field - * buf may be left empty to specify the default field "gpgsig". - * - * Signatures can take the form of any string, and can be created on an arbitrary - * header field. Signatures are most commonly used for verifying authorship of a - * commit using GPG or a similar cryptographically secure signing algorithm. - * See https://git-scm.com/book/en/v2/Git-Tools-Signing-Your-Work for more - * details. - * - * When the callback: - * - returns GIT_PASSTHROUGH, no signature will be added to the commit. - * - returns < 0, commit creation will be aborted. - * - returns GIT_OK, the signature parameter is expected to be filled. + * @param out pointer that this callback will populate with the object + * id of the commit that is created + * @param author the author name and time of the commit + * @param committer the committer name and time of the commit + * @param message_encoding the encoding of the given message, or NULL + * to assume UTF8 + * @param message the commit message + * @param tree the tree to be committed + * @param parent_count the number of parents for this commit + * @param parents the commit parents + * @param payload the payload pointer in the rebase options + * @return 0 if this callback has created the commit and populated the out + * parameter, GIT_PASSTHROUGH if the callback has not created a + * commit and wants the calling function to create the commit as + * if no callback had been specified, any other value to stop + * and return a failure */ -typedef int (*git_commit_signing_cb)( - git_buf *signature, git_buf *signature_field, const char *commit_content, void *payload); +typedef int (*git_commit_create_cb)( + git_oid *out, + const git_signature *author, + const git_signature *committer, + const char *message_encoding, + const char *message, + const git_tree *tree, + size_t parent_count, + const git_commit *parents[], + void *payload); /** @} */ GIT_END_DECL diff --git a/libgit2/headers/git2/common.h b/libgit2/headers/git2/common.h index dee260e..d278c01 100644 --- a/libgit2/headers/git2/common.h +++ b/libgit2/headers/git2/common.h @@ -91,10 +91,10 @@ GIT_BEGIN_DECL /** * The separator used in path list strings (ie like in the PATH - * environment variable). A semi-colon ";" is used on Windows, and - * a colon ":" for all other systems. + * environment variable). A semi-colon ";" is used on Windows and + * AmigaOS, and a colon ":" for all other systems. */ -#ifdef GIT_WIN32 +#if defined(GIT_WIN32) || defined(AMIGA) #define GIT_PATH_LIST_SEPARATOR ';' #else #define GIT_PATH_LIST_SEPARATOR ':' @@ -207,7 +207,9 @@ typedef enum { GIT_OPT_DISABLE_PACK_KEEP_FILE_CHECKS, GIT_OPT_ENABLE_HTTP_EXPECT_CONTINUE, GIT_OPT_GET_MWINDOW_FILE_LIMIT, - GIT_OPT_SET_MWINDOW_FILE_LIMIT + GIT_OPT_SET_MWINDOW_FILE_LIMIT, + GIT_OPT_SET_ODB_PACKED_PRIORITY, + GIT_OPT_SET_ODB_LOOSE_PRIORITY } git_libgit2_opt_t; /** @@ -421,6 +423,14 @@ typedef enum { * > authentication, use expect/continue when POSTing data. * > This option is not available on Windows. * + * opts(GIT_OPT_SET_ODB_PACKED_PRIORITY, int priority) + * > Override the default priority of the packed ODB backend which + * > is added when default backends are assigned to a repository + * + * opts(GIT_OPT_SET_ODB_LOOSE_PRIORITY, int priority) + * > Override the default priority of the loose ODB backend which + * > is added when default backends are assigned to a repository + * * @param option Option key * @param ... value to set the option * @return 0 on success, <0 on failure diff --git a/libgit2/headers/git2/deprecated.h b/libgit2/headers/git2/deprecated.h index 3f28501..a2b117f 100644 --- a/libgit2/headers/git2/deprecated.h +++ b/libgit2/headers/git2/deprecated.h @@ -18,6 +18,7 @@ #include "describe.h" #include "diff.h" #include "errors.h" +#include "filter.h" #include "index.h" #include "indexer.h" #include "merge.h" @@ -29,6 +30,7 @@ #include "trace.h" #include "repository.h" #include "revert.h" +#include "revparse.h" #include "stash.h" #include "status.h" #include "submodule.h" @@ -80,16 +82,19 @@ typedef git_attr_value_t git_attr_t; /**@}*/ -/** @name Deprecated Blob Functions +/** @name Deprecated Blob Functions and Constants * - * These functions are retained for backward compatibility. The newer - * versions of these functions should be preferred in all new code. + * These functions and enumeration values are retained for backward + * compatibility. The newer versions of these functions and values + * should be preferred in all new code. * * There is no plan to remove these backward compatibility values at * this time. */ /**@{*/ +#define GIT_BLOB_FILTER_ATTTRIBUTES_FROM_HEAD GIT_BLOB_FILTER_ATTRIBUTES_FROM_HEAD + GIT_EXTERN(int) git_blob_create_fromworkdir(git_oid *id, git_repository *repo, const char *relative_path); GIT_EXTERN(int) git_blob_create_fromdisk(git_oid *id, git_repository *repo, const char *path); GIT_EXTERN(int) git_blob_create_fromstream( @@ -115,6 +120,66 @@ GIT_EXTERN(int) git_blob_filtered_content( /**@}*/ +/** @name Deprecated Filter Functions + * + * These functions are retained for backward compatibility. The + * newer versions of these functions should be preferred in all + * new code. + * + * There is no plan to remove these backward compatibility values at + * this time. + */ +/**@{*/ + +/** Deprecated in favor of `git_filter_list_stream_buffer`. + * + * @deprecated Use git_filter_list_stream_buffer + * @see Use git_filter_list_stream_buffer + */ +GIT_EXTERN(int) git_filter_list_stream_data( + git_filter_list *filters, + git_buf *data, + git_writestream *target); + +/** Deprecated in favor of `git_filter_list_apply_to_buffer`. + * + * @deprecated Use git_filter_list_apply_to_buffer + * @see Use git_filter_list_apply_to_buffer + */ +GIT_EXTERN(int) git_filter_list_apply_to_data( + git_buf *out, + git_filter_list *filters, + git_buf *in); + +/**@}*/ + +/** @name Deprecated Tree Functions + * + * These functions are retained for backward compatibility. The + * newer versions of these functions and values should be preferred + * in all new code. + * + * There is no plan to remove these backward compatibility values at + * this time. + */ +/**@{*/ + +/** + * Write the contents of the tree builder as a tree object. + * This is an alias of `git_treebuilder_write` and is preserved + * for backward compatibility. + * + * This function is deprecated, but there is no plan to remove this + * function at this time. + * + * @deprecated Use git_treebuilder_write + * @see git_treebuilder_write + */ +GIT_EXTERN(int) git_treebuilder_write_with_buffer( + git_oid *oid, git_treebuilder *bld, git_buf *tree); + +/**@}*/ + /** @name Deprecated Buffer Functions * * These functions and enumeration values are retained for backward @@ -126,6 +191,61 @@ GIT_EXTERN(int) git_blob_filtered_content( */ /**@{*/ +/** + * Static initializer for git_buf from static buffer + */ +#define GIT_BUF_INIT_CONST(STR,LEN) { (char *)(STR), 0, (size_t)(LEN) } + +/** + * Resize the buffer allocation to make more space. + * + * This will attempt to grow the buffer to accommodate the target size. + * + * If the buffer refers to memory that was not allocated by libgit2 (i.e. + * the `asize` field is zero), then `ptr` will be replaced with a newly + * allocated block of data. Be careful so that memory allocated by the + * caller is not lost. As a special variant, if you pass `target_size` as + * 0 and the memory is not allocated by libgit2, this will allocate a new + * buffer of size `size` and copy the external data into it. + * + * Currently, this will never shrink a buffer, only expand it. + * + * If the allocation fails, this will return an error and the buffer will be + * marked as invalid for future operations, invaliding the contents. + * + * @param buffer The buffer to be resized; may or may not be allocated yet + * @param target_size The desired available size + * @return 0 on success, -1 on allocation failure + */ +GIT_EXTERN(int) git_buf_grow(git_buf *buffer, size_t target_size); + +/** + * Set buffer to a copy of some raw data. + * + * @param buffer The buffer to set + * @param data The data to copy into the buffer + * @param datalen The length of the data to copy into the buffer + * @return 0 on success, -1 on allocation failure + */ +GIT_EXTERN(int) git_buf_set( + git_buf *buffer, const void *data, size_t datalen); + +/** +* Check quickly if buffer looks like it contains binary data +* +* @param buf Buffer to check +* @return 1 if buffer looks like non-text data +*/ +GIT_EXTERN(int) git_buf_is_binary(const git_buf *buf); + +/** +* Check quickly if buffer contains a NUL byte +* +* @param buf Buffer to check +* @return 1 if buffer contains a NUL byte +*/ +GIT_EXTERN(int) git_buf_contains_nul(const git_buf *buf); + /** * Free the memory referred to by the git_buf. This is an alias of * `git_buf_dispose` and is preserved for backward compatibility. @@ -140,6 +260,27 @@ GIT_EXTERN(void) git_buf_free(git_buf *buffer); /**@}*/ +/** @name Deprecated Commit Definitions + */ +/**@{*/ + +/** + * Provide a commit signature during commit creation. + * + * Callers should instead define a `git_commit_create_cb` that + * generates a commit buffer using `git_commit_create_buffer`, sign + * that buffer and call `git_commit_create_with_signature`. + * + * @deprecated use a `git_commit_create_cb` instead + */ +typedef int (*git_commit_signing_cb)( + git_buf *signature, + git_buf *signature_field, + const char *commit_content, + void *payload); + +/**@}*/ + /** @name Deprecated Config Functions and Constants */ /**@{*/ @@ -340,10 +481,32 @@ GIT_EXTERN(size_t) git_object__size(git_object_t type); /**@}*/ -/** @name Deprecated Reference Constants +/** @name Deprecated Remote Functions * - * These enumeration values are retained for backward compatibility. The - * newer versions of these values should be preferred in all new code. + * These functions are retained for backward compatibility. The newer + * versions of these functions should be preferred in all new code. + * + * There is no plan to remove these backward compatibility functions at + * this time. + */ +/**@{*/ + +/** + * Ensure the remote name is well-formed. + * + * @deprecated Use git_remote_name_is_valid + * @param remote_name name to be checked. + * @return 1 if the reference name is acceptable; 0 if it isn't + */ +GIT_EXTERN(int) git_remote_is_valid_name(const char *remote_name); + +/**@}*/ + +/** @name Deprecated Reference Functions and Constants + * + * These functions and enumeration values are retained for backward + * compatibility. The newer versions of these values should be + * preferred in all new code. * * There is no plan to remove these backward compatibility values at * this time. @@ -364,6 +527,23 @@ GIT_EXTERN(size_t) git_object__size(git_object_t type); #define GIT_REF_FORMAT_REFSPEC_PATTERN GIT_REFERENCE_FORMAT_REFSPEC_PATTERN #define GIT_REF_FORMAT_REFSPEC_SHORTHAND GIT_REFERENCE_FORMAT_REFSPEC_SHORTHAND +/** + * Ensure the reference name is well-formed. + * + * Valid reference names must follow one of two patterns: + * + * 1. Top-level names must contain only capital letters and underscores, + * and must begin and end with a letter. (e.g. "HEAD", "ORIG_HEAD"). + * 2. Names prefixed with "refs/" can be almost anything. You must avoid + * the characters '~', '^', ':', '\\', '?', '[', and '*', and the + * sequences ".." and "@{" which have special meaning to revparse. + * + * @deprecated Use git_reference_name_is_valid + * @param refname name to be checked. + * @return 1 if the reference name is acceptable; 0 if it isn't + */ +GIT_EXTERN(int) git_reference_is_valid_name(const char *refname); + GIT_EXTERN(int) git_tag_create_frombuffer( git_oid *oid, git_repository *repo, @@ -372,6 +552,25 @@ GIT_EXTERN(int) git_tag_create_frombuffer( /**@}*/ +/** @name Deprecated Revspec Constants + * + * These enumeration values are retained for backward compatibility. + * The newer versions of these values should be preferred in all new + * code. + * + * There is no plan to remove these backward compatibility values at + * this time. + */ +/**@{*/ + +typedef git_revspec_t git_revparse_mode_t; + +#define GIT_REVPARSE_SINGLE GIT_REVSPEC_SINGLE +#define GIT_REVPARSE_RANGE GIT_REVSPEC_RANGE +#define GIT_REVPARSE_MERGE_BASE GIT_REVSPEC_MERGE_BASE + +/**@}*/ + /** @name Deprecated Credential Types * * These types are retained for backward compatibility. The newer @@ -380,6 +579,7 @@ GIT_EXTERN(int) git_tag_create_frombuffer( * There is no plan to remove these backward compatibility values at * this time. */ +/**@{*/ typedef git_credential git_cred; typedef git_credential_userpass_plaintext git_cred_userpass_plaintext; diff --git a/libgit2/headers/git2/diff.h b/libgit2/headers/git2/diff.h index e105555..9497793 100644 --- a/libgit2/headers/git2/diff.h +++ b/libgit2/headers/git2/diff.h @@ -168,6 +168,10 @@ typedef enum { * can apply given diff information to binary files. */ GIT_DIFF_SHOW_BINARY = (1u << 30), + + /** Ignore blank lines */ + GIT_DIFF_IGNORE_BLANK_LINES = (1u << 31), + } git_diff_option_t; /** @@ -237,32 +241,43 @@ typedef enum { * Although this is called a "file", it could represent a file, a symbolic * link, a submodule commit id, or even a tree (although that only if you * are tracking type changes or ignored/untracked directories). - * - * The `id` is the `git_oid` of the item. If the entry represents an - * absent side of a diff (e.g. the `old_file` of a `GIT_DELTA_ADDED` delta), - * then the oid will be zeroes. - * - * `path` is the NUL-terminated path to the entry relative to the working - * directory of the repository. - * - * `size` is the size of the entry in bytes. - * - * `flags` is a combination of the `git_diff_flag_t` types - * - * `mode` is, roughly, the stat() `st_mode` value for the item. This will - * be restricted to one of the `git_filemode_t` values. - * - * The `id_abbrev` represents the known length of the `id` field, when - * converted to a hex string. It is generally `GIT_OID_HEXSZ`, unless this - * delta was created from reading a patch file, in which case it may be - * abbreviated to something reasonable, like 7 characters. */ typedef struct { + /** + * The `git_oid` of the item. If the entry represents an + * absent side of a diff (e.g. the `old_file` of a `GIT_DELTA_ADDED` delta), + * then the oid will be zeroes. + */ git_oid id; + + /** + * The NUL-terminated path to the entry relative to the working + * directory of the repository. + */ const char *path; + + /** + * The size of the entry in bytes. + */ git_object_size_t size; + + /** + * A combination of the `git_diff_flag_t` types + */ uint32_t flags; + + /** + * Roughly, the stat() `st_mode` value for the item. This will + * be restricted to one of the `git_filemode_t` values. + */ uint16_t mode; + + /** + * Represents the known length of the `id` field, when + * converted to a hex string. It is generally `GIT_OID_HEXSZ`, unless this + * delta was created from reading a patch file, in which case it may be + * abbreviated to something reasonable, like 7 characters. + */ uint16_t id_abbrev; } git_diff_file; diff --git a/libgit2/headers/git2/errors.h b/libgit2/headers/git2/errors.h index 8887b32..de51582 100644 --- a/libgit2/headers/git2/errors.h +++ b/libgit2/headers/git2/errors.h @@ -42,14 +42,14 @@ typedef enum { GIT_ECONFLICT = -13, /**< Checkout conflicts prevented operation */ GIT_ELOCKED = -14, /**< Lock file prevented operation */ GIT_EMODIFIED = -15, /**< Reference value does not match expected */ - GIT_EAUTH = -16, /**< Authentication error */ - GIT_ECERTIFICATE = -17, /**< Server certificate is invalid */ + GIT_EAUTH = -16, /**< Authentication error */ + GIT_ECERTIFICATE = -17, /**< Server certificate is invalid */ GIT_EAPPLIED = -18, /**< Patch/merge has already been applied */ - GIT_EPEEL = -19, /**< The requested peel operation is not possible */ - GIT_EEOF = -20, /**< Unexpected EOF */ - GIT_EINVALID = -21, /**< Invalid operation or input */ + GIT_EPEEL = -19, /**< The requested peel operation is not possible */ + GIT_EEOF = -20, /**< Unexpected EOF */ + GIT_EINVALID = -21, /**< Invalid operation or input */ GIT_EUNCOMMITTED = -22, /**< Uncommitted changes in index prevented operation */ - GIT_EDIRECTORY = -23, /**< The operation is not valid for a directory */ + GIT_EDIRECTORY = -23, /**< The operation is not valid for a directory */ GIT_EMERGECONFLICT = -24, /**< A merge conflict exists and cannot continue */ GIT_PASSTHROUGH = -30, /**< A user-configured callback refused to act */ diff --git a/libgit2/headers/git2/filter.h b/libgit2/headers/git2/filter.h index 8860590..044c3b8 100644 --- a/libgit2/headers/git2/filter.h +++ b/libgit2/headers/git2/filter.h @@ -49,8 +49,33 @@ typedef enum { /** Load attributes from `.gitattributes` in the root of HEAD */ GIT_FILTER_ATTRIBUTES_FROM_HEAD = (1u << 2), + + /** + * Load attributes from `.gitattributes` in a given commit. + * This can only be specified in a `git_filter_options`. + */ + GIT_FILTER_ATTRIBUTES_FROM_COMMIT = (1u << 3), } git_filter_flag_t; +/** + * Filtering options + */ +typedef struct { + unsigned int version; + + /** See `git_filter_flag_t` above */ + uint32_t flags; + + /** + * The commit to load attributes from, when + * `GIT_FILTER_ATTRIBUTES_FROM_COMMIT` is specified. + */ + git_oid *commit_id; +} git_filter_options; + + #define GIT_FILTER_OPTIONS_VERSION 1 + #define GIT_FILTER_OPTIONS_INIT {GIT_FILTER_OPTIONS_VERSION} + /** * A filter that can transform file data * @@ -103,6 +128,29 @@ GIT_EXTERN(int) git_filter_list_load( git_filter_mode_t mode, uint32_t flags); +/** + * Load the filter list for a given path. + * + * This will return 0 (success) but set the output git_filter_list to NULL + * if no filters are requested for the given file. + * + * @param filters Output newly created git_filter_list (or NULL) + * @param repo Repository object that contains `path` + * @param blob The blob to which the filter will be applied (if known) + * @param path Relative path of the file to be filtered + * @param mode Filtering direction (WT->ODB or ODB->WT) + * @param opts The `git_filter_options` to use when loading filters + * @return 0 on success (which could still return NULL if no filters are + * needed for the requested file), <0 on error + */ +GIT_EXTERN(int) git_filter_list_load_ext( + git_filter_list **filters, + git_repository *repo, + git_blob *blob, + const char *path, + git_filter_mode_t mode, + git_filter_options *opts); + /** * Query the filter list to see if a given filter (by name) will run. * The built-in filters "crlf" and "ident" can be queried, otherwise this @@ -122,27 +170,17 @@ GIT_EXTERN(int) git_filter_list_contains( /** * Apply filter list to a data buffer. * - * See `git2/buffer.h` for background on `git_buf` objects. - * - * If the `in` buffer holds data allocated by libgit2 (i.e. `in->asize` is - * not zero), then it will be overwritten when applying the filters. If - * not, then it will be left untouched. - * - * If there are no filters to apply (or `filters` is NULL), then the `out` - * buffer will reference the `in` buffer data (with `asize` set to zero) - * instead of allocating data. This keeps allocations to a minimum, but - * it means you have to be careful about freeing the `in` data since `out` - * may be pointing to it! - * * @param out Buffer to store the result of the filtering * @param filters A loaded git_filter_list (or NULL) * @param in Buffer containing the data to filter + * @param in_len The length of the input buffer * @return 0 on success, an error code otherwise */ -GIT_EXTERN(int) git_filter_list_apply_to_data( +GIT_EXTERN(int) git_filter_list_apply_to_buffer( git_buf *out, git_filter_list *filters, - git_buf *in); + const char *in, + size_t in_len); /** * Apply a filter list to the contents of a file on disk @@ -175,12 +213,14 @@ GIT_EXTERN(int) git_filter_list_apply_to_blob( * Apply a filter list to an arbitrary buffer as a stream * * @param filters the list of filters to apply - * @param data the buffer to filter + * @param buffer the buffer to filter + * @param len the size of the buffer * @param target the stream into which the data will be written */ -GIT_EXTERN(int) git_filter_list_stream_data( +GIT_EXTERN(int) git_filter_list_stream_buffer( git_filter_list *filters, - git_buf *data, + const char *buffer, + size_t len, git_writestream *target); /** diff --git a/libgit2/headers/git2/graph.h b/libgit2/headers/git2/graph.h index 213ae97..712ae47 100644 --- a/libgit2/headers/git2/graph.h +++ b/libgit2/headers/git2/graph.h @@ -43,8 +43,9 @@ GIT_EXTERN(int) git_graph_ahead_behind(size_t *ahead, size_t *behind, git_reposi * Note that a commit is not considered a descendant of itself, in contrast * to `git merge-base --is-ancestor`. * - * @param commit a previously loaded commit. - * @param ancestor a potential ancestor commit. + * @param repo the repository where the commits exist + * @param commit a previously loaded commit + * @param ancestor a potential ancestor commit * @return 1 if the given commit is a descendant of the potential ancestor, * 0 if not, error code otherwise. */ @@ -53,6 +54,23 @@ GIT_EXTERN(int) git_graph_descendant_of( const git_oid *commit, const git_oid *ancestor); +/** + * Determine if a commit is reachable from any of a list of commits by + * following parent edges. + * + * @param repo the repository where the commits exist + * @param commit a previously loaded commit + * @param length the number of commits in the provided `descendant_array` + * @param descendant_array oids of the commits + * @return 1 if the given commit is an ancestor of any of the given potential + * descendants, 0 if not, error code otherwise. + */ +GIT_EXTERN(int) git_graph_reachable_from_any( + git_repository *repo, + const git_oid *commit, + const git_oid descendant_array[], + size_t length); + /** @} */ GIT_END_DECL #endif diff --git a/libgit2/headers/git2/index.h b/libgit2/headers/git2/index.h index dd92277..532a520 100644 --- a/libgit2/headers/git2/index.h +++ b/libgit2/headers/git2/index.h @@ -702,7 +702,7 @@ GIT_EXTERN(int) git_index_update_all( * @param at_pos the address to which the position of the index entry is written (optional) * @param index an existing index object * @param path path to search - * @return 0 with valid value in at_pos; an error code otherwise + * @return 0 or an error code */ GIT_EXTERN(int) git_index_find(size_t *at_pos, git_index *index, const char *path); @@ -713,7 +713,7 @@ GIT_EXTERN(int) git_index_find(size_t *at_pos, git_index *index, const char *pat * @param at_pos the address to which the position of the index entry is written (optional) * @param index an existing index object * @param prefix the prefix to search for - * @return 0 with valid value in at_pos; an error code otherwise + * @return 0 or an error code */ GIT_EXTERN(int) git_index_find_prefix(size_t *at_pos, git_index *index, const char *prefix); diff --git a/libgit2/headers/git2/odb.h b/libgit2/headers/git2/odb.h index 62100d5..dd48455 100644 --- a/libgit2/headers/git2/odb.h +++ b/libgit2/headers/git2/odb.h @@ -390,6 +390,20 @@ GIT_EXTERN(int) git_odb_write_pack( git_indexer_progress_cb progress_cb, void *progress_payload); +/** + * Write a `multi-pack-index` file from all the `.pack` files in the ODB. + * + * If the ODB layer understands pack files, then this will create a file called + * `multi-pack-index` next to the `.pack` and `.idx` files, which will contain + * an index of all objects stored in `.pack` files. This will allow for + * O(log n) lookup for n objects (regardless of how many packfiles there + * exist). + * + * @param db object database where the `multi-pack-index` file will be written. + */ +GIT_EXTERN(int) git_odb_write_multi_pack_index( + git_odb *db); + /** * Determine the object-ID (sha1 hash) of a data buffer * @@ -539,6 +553,21 @@ GIT_EXTERN(size_t) git_odb_num_backends(git_odb *odb); */ GIT_EXTERN(int) git_odb_get_backend(git_odb_backend **out, git_odb *odb, size_t pos); +/** + * Set the git commit-graph for the ODB. + * + * After a successfull call, the ownership of the cgraph parameter will be + * transferred to libgit2, and the caller should not free it. + * + * The commit-graph can also be unset by explicitly passing NULL as the cgraph + * parameter. + * + * @param odb object database + * @param cgraph the git commit-graph + * @return 0 on success; error code otherwise + */ +GIT_EXTERN(int) git_odb_set_commit_graph(git_odb *odb, git_commit_graph *cgraph); + /** @} */ GIT_END_DECL #endif diff --git a/libgit2/headers/git2/patch.h b/libgit2/headers/git2/patch.h index b177798..fde9659 100644 --- a/libgit2/headers/git2/patch.h +++ b/libgit2/headers/git2/patch.h @@ -28,6 +28,14 @@ GIT_BEGIN_DECL */ typedef struct git_patch git_patch; +/** + * Get the repository associated with this patch. May be NULL. + * + * @param patch the patch + * @return a pointer to the repository + */ +GIT_EXTERN(git_repository *) git_patch_owner(const git_patch *patch); + /** * Return a patch for an entry in the diff list. * diff --git a/libgit2/headers/git2/rebase.h b/libgit2/headers/git2/rebase.h index 99a02fe..11e452c 100644 --- a/libgit2/headers/git2/rebase.h +++ b/libgit2/headers/git2/rebase.h @@ -74,14 +74,38 @@ typedef struct { */ git_checkout_options checkout_options; + /** + * Optional callback that allows users to override commit + * creation in `git_rebase_commit`. If specified, users can + * create their own commit and provide the commit ID, which + * may be useful for signing commits or otherwise customizing + * the commit creation. + * + * If this callback returns `GIT_PASSTHROUGH`, then + * `git_rebase_commit` will continue to create the commit. + */ + git_commit_create_cb commit_create_cb; + +#ifdef GIT_DEPRECATE_HARD + void *reserved; +#else /** * If provided, this will be called with the commit content, allowing * a signature to be added to the rebase commit. Can be skipped with * GIT_PASSTHROUGH. If GIT_PASSTHROUGH is returned, a commit will be made * without a signature. + * * This field is only used when performing git_rebase_commit. + * + * This callback is not invoked if a `git_commit_create_cb` is + * specified. + * + * This callback is deprecated; users should provide a + * creation callback as `commit_create_cb` that produces a + * commit buffer, signs it, and commits it. */ - git_commit_signing_cb signing_cb; + int (*signing_cb)(git_buf *, git_buf *, const char *, void *); +#endif /** * This will be passed to each of the callbacks in this struct diff --git a/libgit2/headers/git2/refs.h b/libgit2/headers/git2/refs.h index 66970c5..7ebb209 100644 --- a/libgit2/headers/git2/refs.h +++ b/libgit2/headers/git2/refs.h @@ -97,6 +97,9 @@ GIT_EXTERN(int) git_reference_dwim(git_reference **out, git_repository *repo, co * of updating does not match the one passed through `current_value` * (i.e. if the ref has changed since the user read it). * + * If `current_value` is all zeros, this function will return GIT_EMODIFIED + * if the ref already exists. + * * @param out Pointer to the newly created reference * @param repo Repository where that reference will live * @param name The name of the reference @@ -743,10 +746,11 @@ GIT_EXTERN(int) git_reference_peel( * the characters '~', '^', ':', '\\', '?', '[', and '*', and the * sequences ".." and "@{" which have special meaning to revparse. * + * @param valid output pointer to set with validity of given reference name * @param refname name to be checked. - * @return 1 if the reference name is acceptable; 0 if it isn't + * @return 0 on success or an error code */ -GIT_EXTERN(int) git_reference_is_valid_name(const char *refname); +GIT_EXTERN(int) git_reference_name_is_valid(int *valid, const char *refname); /** * Get the reference's short name diff --git a/libgit2/headers/git2/remote.h b/libgit2/headers/git2/remote.h index 51d9c72..1f52fcd 100644 --- a/libgit2/headers/git2/remote.h +++ b/libgit2/headers/git2/remote.h @@ -212,7 +212,8 @@ GIT_EXTERN(const char *) git_remote_name(const git_remote *remote); * Get the remote's url * * If url.*.insteadOf has been configured for this URL, it will - * return the modified URL. + * return the modified URL. If `git_remote_set_instance_pushurl` + * has been called for this remote, then that URL will be returned. * * @param remote the remote * @return a pointer to the url @@ -220,10 +221,11 @@ GIT_EXTERN(const char *) git_remote_name(const git_remote *remote); GIT_EXTERN(const char *) git_remote_url(const git_remote *remote); /** - * Get the remote's url for pushing + * Get the remote's url for pushing. * * If url.*.pushInsteadOf has been configured for this URL, it - * will return the modified URL. + * will return the modified URL. If `git_remote_set_instance_pushurl` + * has been called for this remote, then that URL will be returned. * * @param remote the remote * @return a pointer to the url or NULL if no special url for pushing is set @@ -253,9 +255,30 @@ GIT_EXTERN(int) git_remote_set_url(git_repository *repo, const char *remote, con * @param repo the repository in which to perform the change * @param remote the remote's name * @param url the url to set + * @return 0, or an error code */ GIT_EXTERN(int) git_remote_set_pushurl(git_repository *repo, const char *remote, const char* url); +/** + * Set the url for this particular url instance. The URL in the + * configuration will be ignored, and will not be changed. + * + * @param remote the remote's name + * @param url the url to set + * @return 0 or an error value + */ +GIT_EXTERN(int) git_remote_set_instance_url(git_remote *remote, const char *url); + +/** + * Set the push url for this particular url instance. The URL in the + * configuration will be ignored, and will not be changed. + * + * @param remote the remote's name + * @param url the url to set + * @return 0 or an error value + */ +GIT_EXTERN(int) git_remote_set_instance_pushurl(git_remote *remote, const char *url); + /** * Add a fetch refspec to the remote's configuration * @@ -476,6 +499,7 @@ typedef int GIT_CALLBACK(git_push_negotiation)(const git_push_update **updates, */ typedef int GIT_CALLBACK(git_push_update_reference_cb)(const char *refname, const char *status, void *data); +#ifndef GIT_DEPRECATE_HARD /** * Callback to resolve URLs before connecting to remote * @@ -487,8 +511,22 @@ typedef int GIT_CALLBACK(git_push_update_reference_cb)(const char *refname, cons * @param direction GIT_DIRECTION_FETCH or GIT_DIRECTION_PUSH * @param payload Payload provided by the caller * @return 0 on success, GIT_PASSTHROUGH or an error + * @deprecated Use `git_remote_set_instance_url` */ typedef int GIT_CALLBACK(git_url_resolve_cb)(git_buf *url_resolved, const char *url, int direction, void *payload); +#endif + +/** + * Callback invoked immediately before we attempt to connect to the + * given url. Callers may change the URL before the connection by + * calling `git_remote_set_instance_url` in the callback. + * + * @param remote The remote to be connected + * @param direction GIT_DIRECTION_FETCH or GIT_DIRECTION_PUSH + * @param payload Payload provided by the caller + * @return 0 on success, or an error + */ +typedef int GIT_CALLBACK(git_remote_ready_cb)(git_remote *remote, int direction, void *payload); /** * The callback settings structure @@ -574,17 +612,29 @@ struct git_remote_callbacks { */ git_transport_cb transport; + /** + * Callback when the remote is ready to connect. + */ + git_remote_ready_cb remote_ready; + /** * This will be passed to each of the callbacks in this struct * as the last parameter. */ void *payload; +#ifdef GIT_DEPRECATE_HARD + void *reserved; +#else /** * Resolve URL before connecting to remote. * The returned URL will be used to connect to the remote instead. + * + * This callback is deprecated; users should use + * git_remote_ready_cb and configure the instance URL instead. */ git_url_resolve_cb resolve_url; +#endif }; #define GIT_REMOTE_CALLBACKS_VERSION 1 @@ -876,8 +926,10 @@ GIT_EXTERN(git_remote_autotag_option_t) git_remote_autotag(const git_remote *rem * @param repo the repository in which to make the change * @param remote the name of the remote * @param value the new value to take. + * @return 0, or an error code. */ GIT_EXTERN(int) git_remote_set_autotag(git_repository *repo, const char *remote, git_remote_autotag_option_t value); + /** * Retrieve the ref-prune setting * @@ -915,10 +967,11 @@ GIT_EXTERN(int) git_remote_rename( /** * Ensure the remote name is well-formed. * + * @param valid output pointer to set with validity of given remote name * @param remote_name name to be checked. - * @return 1 if the reference name is acceptable; 0 if it isn't + * @return 0 on success or an error code */ -GIT_EXTERN(int) git_remote_is_valid_name(const char *remote_name); +int git_remote_name_is_valid(int *valid, const char *remote_name); /** * Delete an existing persisted remote. @@ -943,7 +996,7 @@ GIT_EXTERN(int) git_remote_delete(git_repository *repo, const char *name); * * This function must only be called after connecting. * - * @param out the buffern in which to store the reference name + * @param out the buffer in which to store the reference name * @param remote the remote * @return 0, GIT_ENOTFOUND if the remote does not have any references * or none of them point to HEAD's commit, or an error message. diff --git a/libgit2/headers/git2/revparse.h b/libgit2/headers/git2/revparse.h index d170e16..e14ddee 100644 --- a/libgit2/headers/git2/revparse.h +++ b/libgit2/headers/git2/revparse.h @@ -70,12 +70,12 @@ GIT_EXTERN(int) git_revparse_ext( */ typedef enum { /** The spec targeted a single object. */ - GIT_REVPARSE_SINGLE = 1 << 0, + GIT_REVSPEC_SINGLE = 1 << 0, /** The spec targeted a range of commits. */ - GIT_REVPARSE_RANGE = 1 << 1, + GIT_REVSPEC_RANGE = 1 << 1, /** The spec used the '...' operator, which invokes special semantics. */ - GIT_REVPARSE_MERGE_BASE = 1 << 2, -} git_revparse_mode_t; + GIT_REVSPEC_MERGE_BASE = 1 << 2, +} git_revspec_t; /** * Git Revision Spec: output of a `git_revparse` operation @@ -85,7 +85,7 @@ typedef struct { git_object *from; /** The right element of the revspec; must be freed by the user */ git_object *to; - /** The intent of the revspec (i.e. `git_revparse_mode_t` flags) */ + /** The intent of the revspec (i.e. `git_revspec_mode_t` flags) */ unsigned int flags; } git_revspec; diff --git a/libgit2/headers/git2/status.h b/libgit2/headers/git2/status.h index 9693cc4..543e3fa 100644 --- a/libgit2/headers/git2/status.h +++ b/libgit2/headers/git2/status.h @@ -69,89 +69,141 @@ typedef int GIT_CALLBACK(git_status_cb)( * With `git_status_foreach_ext`, this will control which changes get * callbacks. With `git_status_list_new`, these will control which * changes are included in the list. - * - * - GIT_STATUS_SHOW_INDEX_AND_WORKDIR is the default. This roughly - * matches `git status --porcelain` regarding which files are - * included and in what order. - * - GIT_STATUS_SHOW_INDEX_ONLY only gives status based on HEAD to index - * comparison, not looking at working directory changes. - * - GIT_STATUS_SHOW_WORKDIR_ONLY only gives status based on index to - * working directory comparison, not comparing the index to the HEAD. */ typedef enum { + /** + * The default. This roughly matches `git status --porcelain` regarding + * which files are included and in what order. + */ GIT_STATUS_SHOW_INDEX_AND_WORKDIR = 0, + + /** + * Only gives status based on HEAD to index comparison, not looking at + * working directory changes. + */ GIT_STATUS_SHOW_INDEX_ONLY = 1, + + /** + * Only gives status based on index to working directory comparison, + * not comparing the index to the HEAD. + */ GIT_STATUS_SHOW_WORKDIR_ONLY = 2, } git_status_show_t; /** * Flags to control status callbacks * - * - GIT_STATUS_OPT_INCLUDE_UNTRACKED says that callbacks should be made - * on untracked files. These will only be made if the workdir files are - * included in the status "show" option. - * - GIT_STATUS_OPT_INCLUDE_IGNORED says that ignored files get callbacks. - * Again, these callbacks will only be made if the workdir files are - * included in the status "show" option. - * - GIT_STATUS_OPT_INCLUDE_UNMODIFIED indicates that callback should be - * made even on unmodified files. - * - GIT_STATUS_OPT_EXCLUDE_SUBMODULES indicates that submodules should be - * skipped. This only applies if there are no pending typechanges to - * the submodule (either from or to another type). - * - GIT_STATUS_OPT_RECURSE_UNTRACKED_DIRS indicates that all files in - * untracked directories should be included. Normally if an entire - * directory is new, then just the top-level directory is included (with - * a trailing slash on the entry name). This flag says to include all - * of the individual files in the directory instead. - * - GIT_STATUS_OPT_DISABLE_PATHSPEC_MATCH indicates that the given path - * should be treated as a literal path, and not as a pathspec pattern. - * - GIT_STATUS_OPT_RECURSE_IGNORED_DIRS indicates that the contents of - * ignored directories should be included in the status. This is like - * doing `git ls-files -o -i --exclude-standard` with core git. - * - GIT_STATUS_OPT_RENAMES_HEAD_TO_INDEX indicates that rename detection - * should be processed between the head and the index and enables - * the GIT_STATUS_INDEX_RENAMED as a possible status flag. - * - GIT_STATUS_OPT_RENAMES_INDEX_TO_WORKDIR indicates that rename - * detection should be run between the index and the working directory - * and enabled GIT_STATUS_WT_RENAMED as a possible status flag. - * - GIT_STATUS_OPT_SORT_CASE_SENSITIVELY overrides the native case - * sensitivity for the file system and forces the output to be in - * case-sensitive order - * - GIT_STATUS_OPT_SORT_CASE_INSENSITIVELY overrides the native case - * sensitivity for the file system and forces the output to be in - * case-insensitive order - * - GIT_STATUS_OPT_RENAMES_FROM_REWRITES indicates that rename detection - * should include rewritten files - * - GIT_STATUS_OPT_NO_REFRESH bypasses the default status behavior of - * doing a "soft" index reload (i.e. reloading the index data if the - * file on disk has been modified outside libgit2). - * - GIT_STATUS_OPT_UPDATE_INDEX tells libgit2 to refresh the stat cache - * in the index for files that are unchanged but have out of date stat - * information in the index. It will result in less work being done on - * subsequent calls to get status. This is mutually exclusive with the - * NO_REFRESH option. - * * Calling `git_status_foreach()` is like calling the extended version * with: GIT_STATUS_OPT_INCLUDE_IGNORED, GIT_STATUS_OPT_INCLUDE_UNTRACKED, * and GIT_STATUS_OPT_RECURSE_UNTRACKED_DIRS. Those options are bundled * together as `GIT_STATUS_OPT_DEFAULTS` if you want them as a baseline. */ typedef enum { + /** + * Says that callbacks should be made on untracked files. + * These will only be made if the workdir files are included in the status + * "show" option. + */ GIT_STATUS_OPT_INCLUDE_UNTRACKED = (1u << 0), + + /** + * Says that ignored files get callbacks. + * Again, these callbacks will only be made if the workdir files are + * included in the status "show" option. + */ GIT_STATUS_OPT_INCLUDE_IGNORED = (1u << 1), + + /** + * Indicates that callback should be made even on unmodified files. + */ GIT_STATUS_OPT_INCLUDE_UNMODIFIED = (1u << 2), + + /** + * Indicates that submodules should be skipped. + * This only applies if there are no pending typechanges to the submodule + * (either from or to another type). + */ GIT_STATUS_OPT_EXCLUDE_SUBMODULES = (1u << 3), + + /** + * Indicates that all files in untracked directories should be included. + * Normally if an entire directory is new, then just the top-level + * directory is included (with a trailing slash on the entry name). + * This flag says to include all of the individual files in the directory + * instead. + */ GIT_STATUS_OPT_RECURSE_UNTRACKED_DIRS = (1u << 4), + + /** + * Indicates that the given path should be treated as a literal path, + * and not as a pathspec pattern. + */ GIT_STATUS_OPT_DISABLE_PATHSPEC_MATCH = (1u << 5), + + /** + * Indicates that the contents of ignored directories should be included + * in the status. This is like doing `git ls-files -o -i --exclude-standard` + * with core git. + */ GIT_STATUS_OPT_RECURSE_IGNORED_DIRS = (1u << 6), + + /** + * Indicates that rename detection should be processed between the head and + * the index and enables the GIT_STATUS_INDEX_RENAMED as a possible status + * flag. + */ GIT_STATUS_OPT_RENAMES_HEAD_TO_INDEX = (1u << 7), + + /** + * Indicates that rename detection should be run between the index and the + * working directory and enabled GIT_STATUS_WT_RENAMED as a possible status + * flag. + */ GIT_STATUS_OPT_RENAMES_INDEX_TO_WORKDIR = (1u << 8), + + /** + * Overrides the native case sensitivity for the file system and forces + * the output to be in case-sensitive order. + */ GIT_STATUS_OPT_SORT_CASE_SENSITIVELY = (1u << 9), + + /** + * Overrides the native case sensitivity for the file system and forces + * the output to be in case-insensitive order. + */ GIT_STATUS_OPT_SORT_CASE_INSENSITIVELY = (1u << 10), + + /** + * Iindicates that rename detection should include rewritten files. + */ GIT_STATUS_OPT_RENAMES_FROM_REWRITES = (1u << 11), + + /** + * Bypasses the default status behavior of doing a "soft" index reload + * (i.e. reloading the index data if the file on disk has been modified + * outside libgit2). + */ GIT_STATUS_OPT_NO_REFRESH = (1u << 12), + + /** + * Tells libgit2 to refresh the stat cache in the index for files that are + * unchanged but have out of date stat einformation in the index. + * It will result in less work being done on subsequent calls to get status. + * This is mutually exclusive with the NO_REFRESH option. + */ GIT_STATUS_OPT_UPDATE_INDEX = (1u << 13), + + /** + * Normally files that cannot be opened or read are ignored as + * these are often transient files; this option will return + * unreadable files as `GIT_STATUS_WT_UNREADABLE`. + */ GIT_STATUS_OPT_INCLUDE_UNREADABLE = (1u << 14), + + /** + * Unreadable files will be detected and given the status + * untracked instead of unreadable. + */ GIT_STATUS_OPT_INCLUDE_UNREADABLE_AS_UNTRACKED = (1u << 15), } git_status_opt_t; @@ -168,7 +220,10 @@ typedef enum { * */ typedef struct { - unsigned int version; /**< The version */ + /** + * The struct version; pass `GIT_STATUS_OPTIONS_VERSION`. + */ + unsigned int version; /** * The `show` value is one of the `git_status_show_t` constants that @@ -177,21 +232,22 @@ typedef struct { git_status_show_t show; /** - * The `flags` value is an OR'ed combination of the `git_status_opt_t` - * values above. + * The `flags` value is an OR'ed combination of the + * `git_status_opt_t` values above. */ unsigned int flags; /** * The `pathspec` is an array of path patterns to match (using - * fnmatch-style matching), or just an array of paths to match exactly if - * `GIT_STATUS_OPT_DISABLE_PATHSPEC_MATCH` is specified in the flags. + * fnmatch-style matching), or just an array of paths to match + * exactly if `GIT_STATUS_OPT_DISABLE_PATHSPEC_MATCH` is specified + * in the flags. */ git_strarray pathspec; /** - * The `baseline` is the tree to be used for comparison to the working directory - * and index; defaults to HEAD. + * The `baseline` is the tree to be used for comparison to the + * working directory and index; defaults to HEAD. */ git_tree *baseline; } git_status_options; diff --git a/libgit2/headers/git2/submodule.h b/libgit2/headers/git2/submodule.h index bedd76d..29d8bc1 100644 --- a/libgit2/headers/git2/submodule.h +++ b/libgit2/headers/git2/submodule.h @@ -223,6 +223,15 @@ GIT_EXTERN(int) git_submodule_lookup( git_repository *repo, const char *name); +/** + * Create an in-memory copy of a submodule. The copy must be explicitly + * free'd or it will leak. + * + * @param out Pointer to store the copy of the submodule. + * @param source Original submodule to copy. + */ +GIT_EXTERN(int) git_submodule_dup(git_submodule **out, git_submodule *source); + /** * Release a submodule * diff --git a/libgit2/headers/git2/sys/commit_graph.h b/libgit2/headers/git2/sys/commit_graph.h new file mode 100644 index 0000000..f6c0fc4 --- /dev/null +++ b/libgit2/headers/git2/sys/commit_graph.h @@ -0,0 +1,174 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#ifndef INCLUDE_sys_git_commit_graph_h__ +#define INCLUDE_sys_git_commit_graph_h__ + +#include "git2/common.h" +#include "git2/types.h" + +/** + * @file git2/sys/commit_graph.h + * @brief Git commit-graph + * @defgroup git_commit_graph Git commit-graph APIs + * @ingroup Git + * @{ + */ +GIT_BEGIN_DECL + +/** + * Opens a `git_commit_graph` from a path to an objects directory. + * + * This finds, opens, and validates the `commit-graph` file. + * + * @param cgraph_out the `git_commit_graph` struct to initialize. + * @param objects_dir the path to a git objects directory. + * @return Zero on success; -1 on failure. + */ +GIT_EXTERN(int) git_commit_graph_open(git_commit_graph **cgraph_out, const char *objects_dir); + +/** + * Frees commit-graph data. This should only be called when memory allocated + * using `git_commit_graph_open` is not returned to libgit2 because it was not + * associated with the ODB through a successful call to + * `git_odb_set_commit_graph`. + * + * @param cgraph the commit-graph object to free. If NULL, no action is taken. + */ +GIT_EXTERN(void) git_commit_graph_free(git_commit_graph *cgraph); + +/** + * Create a new writer for `commit-graph` files. + * + * @param out Location to store the writer pointer. + * @param objects_info_dir The `objects/info` directory. + * The `commit-graph` file will be written in this directory. + * @return 0 or an error code + */ +GIT_EXTERN(int) git_commit_graph_writer_new( + git_commit_graph_writer **out, + const char *objects_info_dir); + +/** + * Free the commit-graph writer and its resources. + * + * @param w The writer to free. If NULL no action is taken. + */ +GIT_EXTERN(void) git_commit_graph_writer_free(git_commit_graph_writer *w); + +/** + * Add an `.idx` file (associated to a packfile) to the writer. + * + * @param w The writer. + * @param repo The repository that owns the `.idx` file. + * @param idx_path The path of an `.idx` file. + * @return 0 or an error code + */ +GIT_EXTERN(int) git_commit_graph_writer_add_index_file( + git_commit_graph_writer *w, + git_repository *repo, + const char *idx_path); + +/** + * Add a revwalk to the writer. This will add all the commits from the revwalk + * to the commit-graph. + * + * @param w The writer. + * @param walk The git_revwalk. + * @return 0 or an error code + */ +GIT_EXTERN(int) git_commit_graph_writer_add_revwalk( + git_commit_graph_writer *w, + git_revwalk *walk); + + +/** + * The strategy to use when adding a new set of commits to a pre-existing + * commit-graph chain. + */ +typedef enum { + /** + * Do not split commit-graph files. The other split strategy-related option + * fields are ignored. + */ + GIT_COMMIT_GRAPH_SPLIT_STRATEGY_SINGLE_FILE = 0, +} git_commit_graph_split_strategy_t; + +/** + * Options structure for + * `git_commit_graph_writer_commit`/`git_commit_graph_writer_dump`. + * + * Initialize with `GIT_COMMIT_GRAPH_WRITER_OPTIONS_INIT`. Alternatively, you + * can use `git_commit_graph_writer_options_init`. + */ +typedef struct { + unsigned int version; + + /** + * The strategy to use when adding new commits to a pre-existing commit-graph + * chain. + */ + git_commit_graph_split_strategy_t split_strategy; + + /** + * The number of commits in level N is less than X times the number of + * commits in level N + 1. Default is 2. + */ + float size_multiple; + + /** + * The number of commits in level N + 1 is more than C commits. + * Default is 64000. + */ + size_t max_commits; +} git_commit_graph_writer_options; + +#define GIT_COMMIT_GRAPH_WRITER_OPTIONS_VERSION 1 +#define GIT_COMMIT_GRAPH_WRITER_OPTIONS_INIT { \ + GIT_COMMIT_GRAPH_WRITER_OPTIONS_VERSION \ + } + +/** + * Initialize git_commit_graph_writer_options structure + * + * Initializes a `git_commit_graph_writer_options` with default values. Equivalent to + * creating an instance with `GIT_COMMIT_GRAPH_WRITER_OPTIONS_INIT`. + * + * @param opts The `git_commit_graph_writer_options` struct to initialize. + * @param version The struct version; pass `GIT_COMMIT_GRAPH_WRITER_OPTIONS_VERSION`. + * @return Zero on success; -1 on failure. + */ +GIT_EXTERN(int) git_commit_graph_writer_options_init( + git_commit_graph_writer_options *opts, + unsigned int version); + +/** + * Write a `commit-graph` file to a file. + * + * @param w The writer + * @param opts Pointer to git_commit_graph_writer_options struct. + * @return 0 or an error code + */ +GIT_EXTERN(int) git_commit_graph_writer_commit( + git_commit_graph_writer *w, + git_commit_graph_writer_options *opts); + +/** + * Dump the contents of the `commit-graph` to an in-memory buffer. + * + * @param buffer Buffer where to store the contents of the `commit-graph`. + * @param w The writer. + * @param opts Pointer to git_commit_graph_writer_options struct. + * @return 0 or an error code + */ +GIT_EXTERN(int) git_commit_graph_writer_dump( + git_buf *buffer, + git_commit_graph_writer *w, + git_commit_graph_writer_options *opts); + +/** @} */ +GIT_END_DECL +#endif diff --git a/libgit2/headers/git2/sys/filter.h b/libgit2/headers/git2/sys/filter.h index e43fde5..b375941 100644 --- a/libgit2/headers/git2/sys/filter.h +++ b/libgit2/headers/git2/sys/filter.h @@ -167,17 +167,18 @@ typedef void GIT_CALLBACK(git_filter_shutdown_fn)(git_filter *self); * * The `payload` will be a pointer to a reference payload for the filter. * This will start as NULL, but `check` can assign to this pointer for - * later use by the `apply` callback. Note that the value should be heap - * allocated (not stack), so that it doesn't go away before the `apply` + * later use by the `stream` callback. Note that the value should be heap + * allocated (not stack), so that it doesn't go away before the `stream` * callback can use it. If a filter allocates and assigns a value to the * `payload`, it will need a `cleanup` callback to free the payload. */ typedef int GIT_CALLBACK(git_filter_check_fn)( - git_filter *self, - void **payload, /* points to NULL ptr on entry, may be set */ + git_filter *self, + void **payload, /* NULL on entry, may be set */ const git_filter_source *src, - const char **attr_values); + const char **attr_values); +#ifndef GIT_DEPRECATE_HARD /** * Callback to actually perform the data filtering * @@ -189,32 +190,45 @@ typedef int GIT_CALLBACK(git_filter_check_fn)( * * The `payload` value will refer to any payload that was set by the * `check` callback. It may be read from or written to as needed. + * + * @deprecated use git_filter_stream_fn */ typedef int GIT_CALLBACK(git_filter_apply_fn)( - git_filter *self, - void **payload, /* may be read and/or set */ - git_buf *to, - const git_buf *from, + git_filter *self, + void **payload, /* may be read and/or set */ + git_buf *to, + const git_buf *from, const git_filter_source *src); +#endif +/** + * Callback to perform the data filtering. + * + * Specified as `filter.stream`, this is a callback that filters data + * in a streaming manner. This function will provide a + * `git_writestream` that will the original data will be written to; + * with that data, the `git_writestream` will then perform the filter + * translation and stream the filtered data out to the `next` location. + */ typedef int GIT_CALLBACK(git_filter_stream_fn)( - git_writestream **out, - git_filter *self, - void **payload, + git_writestream **out, + git_filter *self, + void **payload, const git_filter_source *src, - git_writestream *next); + git_writestream *next); /** * Callback to clean up after filtering has been applied * * Specified as `filter.cleanup`, this is an optional callback invoked - * after the filter has been applied. If the `check` or `apply` callbacks - * allocated a `payload` to keep per-source filter state, use this - * callback to free that payload and release resources as required. + * after the filter has been applied. If the `check`, `apply`, or + * `stream` callbacks allocated a `payload` to keep per-source filter + * state, use this callback to free that payload and release resources + * as required. */ typedef void GIT_CALLBACK(git_filter_cleanup_fn)( - git_filter *self, - void *payload); + git_filter *self, + void *payload); /** * Filter structure used to register custom filters. @@ -248,21 +262,28 @@ struct git_filter { /** * Called to determine whether the filter should be invoked for a * given file. If this function returns `GIT_PASSTHROUGH` then the - * `apply` function will not be invoked and the contents will be passed - * through unmodified. + * `stream` or `apply` functions will not be invoked and the + * contents will be passed through unmodified. */ git_filter_check_fn check; +#ifdef GIT_DEPRECATE_HARD + void *reserved; +#else /** - * Called to actually apply the filter to file contents. If this - * function returns `GIT_PASSTHROUGH` then the contents will be passed - * through unmodified. + * Provided for backward compatibility; this will apply the + * filter to the given contents in a `git_buf`. Callers should + * provide a `stream` function instead. */ git_filter_apply_fn apply; +#endif /** - * Called to apply the filter in a streaming manner. If this is not - * specified then the system will call `apply` with the whole buffer. + * Called to apply the filter, this function will provide a + * `git_writestream` that will the original data will be + * written to; with that data, the `git_writestream` will then + * perform the filter translation and stream the filtered data + * out to the `next` location. */ git_filter_stream_fn stream; @@ -289,9 +310,9 @@ GIT_EXTERN(int) git_filter_init(git_filter *filter, unsigned int version); * As mentioned elsewhere, the initialize callback will not be invoked * immediately. It is deferred until the filter is used in some way. * - * A filter's attribute checks and `check` and `apply` callbacks will be - * issued in order of `priority` on smudge (to workdir), and in reverse - * order of `priority` on clean (to odb). + * A filter's attribute checks and `check` and `stream` (or `apply`) + * callbacks will be issued in order of `priority` on smudge (to + * workdir), and in reverse order of `priority` on clean (to odb). * * Two filters are preregistered with libgit2: * - GIT_FILTER_CRLF with priority 0 diff --git a/libgit2/headers/git2/sys/midx.h b/libgit2/headers/git2/sys/midx.h new file mode 100644 index 0000000..e3d7498 --- /dev/null +++ b/libgit2/headers/git2/sys/midx.h @@ -0,0 +1,74 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#ifndef INCLUDE_sys_git_midx_h__ +#define INCLUDE_sys_git_midx_h__ + +#include "git2/common.h" +#include "git2/types.h" + +/** + * @file git2/midx.h + * @brief Git multi-pack-index routines + * @defgroup git_midx Git multi-pack-index routines + * @ingroup Git + * @{ + */ +GIT_BEGIN_DECL + +/** + * Create a new writer for `multi-pack-index` files. + * + * @param out location to store the writer pointer. + * @param pack_dir the directory where the `.pack` and `.idx` files are. The + * `multi-pack-index` file will be written in this directory, too. + * @return 0 or an error code + */ +GIT_EXTERN(int) git_midx_writer_new( + git_midx_writer **out, + const char *pack_dir); + +/** + * Free the multi-pack-index writer and its resources. + * + * @param w the writer to free. If NULL no action is taken. + */ +GIT_EXTERN(void) git_midx_writer_free(git_midx_writer *w); + +/** + * Add an `.idx` file to the writer. + * + * @param w the writer + * @param idx_path the path of an `.idx` file. + * @return 0 or an error code + */ +GIT_EXTERN(int) git_midx_writer_add( + git_midx_writer *w, + const char *idx_path); + +/** + * Write a `multi-pack-index` file to a file. + * + * @param w the writer + * @return 0 or an error code + */ +GIT_EXTERN(int) git_midx_writer_commit( + git_midx_writer *w); + +/** + * Dump the contents of the `multi-pack-index` to an in-memory buffer. + * + * @param midx Buffer where to store the contents of the `multi-pack-index`. + * @param w the writer + * @return 0 or an error code + */ +GIT_EXTERN(int) git_midx_writer_dump( + git_buf *midx, + git_midx_writer *w); + +/** @} */ +GIT_END_DECL +#endif diff --git a/libgit2/headers/git2/sys/odb_backend.h b/libgit2/headers/git2/sys/odb_backend.h index 4dba460..9ae0ed9 100644 --- a/libgit2/headers/git2/sys/odb_backend.h +++ b/libgit2/headers/git2/sys/odb_backend.h @@ -84,6 +84,13 @@ struct git_odb_backend { git_odb_writepack **, git_odb_backend *, git_odb *odb, git_indexer_progress_cb progress_cb, void *progress_payload); + /** + * If the backend supports pack files, this will create a + * `multi-pack-index` file which will contain an index of all objects + * across all the `.pack` files. + */ + int GIT_CALLBACK(writemidx)(git_odb_backend *); + /** * "Freshens" an already existing object, updating its last-used * time. This occurs when `git_odb_write` was called, but the diff --git a/libgit2/headers/git2/sys/transport.h b/libgit2/headers/git2/sys/transport.h index 6cee42f..fee3454 100644 --- a/libgit2/headers/git2/sys/transport.h +++ b/libgit2/headers/git2/sys/transport.h @@ -9,6 +9,7 @@ #define INCLUDE_sys_git_transport_h #include "git2/net.h" +#include "git2/transport.h" #include "git2/types.h" #include "git2/strarray.h" #include "git2/proxy.h" diff --git a/libgit2/headers/git2/tag.h b/libgit2/headers/git2/tag.h index 4e5fe1d..a392136 100644 --- a/libgit2/headers/git2/tag.h +++ b/libgit2/headers/git2/tag.h @@ -365,6 +365,18 @@ GIT_EXTERN(int) git_tag_peel( */ GIT_EXTERN(int) git_tag_dup(git_tag **out, git_tag *source); +/** + * Determine whether a tag name is valid, meaning that (when prefixed + * with `refs/tags/`) that it is a valid reference name, and that any + * additional tag name restrictions are imposed (eg, it cannot start + * with a `-`). + * + * @param valid output pointer to set with validity of given tag name + * @param name a tag name to test + * @return 0 on success or an error code + */ +GIT_EXTERN(int) git_tag_name_is_valid(int *valid, const char *name); + /** @} */ GIT_END_DECL #endif diff --git a/libgit2/headers/git2/tree.h b/libgit2/headers/git2/tree.h index 60dec72..f2289fc 100644 --- a/libgit2/headers/git2/tree.h +++ b/libgit2/headers/git2/tree.h @@ -379,20 +379,6 @@ GIT_EXTERN(int) git_treebuilder_filter( GIT_EXTERN(int) git_treebuilder_write( git_oid *id, git_treebuilder *bld); -/** - * Write the contents of the tree builder as a tree object - * using a shared git_buf. - * - * @see git_treebuilder_write - * - * @param oid Pointer to store the OID of the newly written tree - * @param bld Tree builder to write - * @param tree Shared buffer for writing the tree. Will be grown as necessary. - * @return 0 or an error code - */ -GIT_EXTERN(int) git_treebuilder_write_with_buffer( - git_oid *oid, git_treebuilder *bld, git_buf *tree); - /** Callback for the tree traversal method */ typedef int GIT_CALLBACK(git_treewalk_cb)( const char *root, const git_tree_entry *entry, void *payload); diff --git a/libgit2/headers/git2/types.h b/libgit2/headers/git2/types.h index ade0c7d..aac8e42 100644 --- a/libgit2/headers/git2/types.h +++ b/libgit2/headers/git2/types.h @@ -96,12 +96,21 @@ typedef struct git_odb_stream git_odb_stream; /** A stream to write a packfile to the ODB */ typedef struct git_odb_writepack git_odb_writepack; +/** a writer for multi-pack-index files. */ +typedef struct git_midx_writer git_midx_writer; + /** An open refs database handle. */ typedef struct git_refdb git_refdb; /** A custom backend for refs */ typedef struct git_refdb_backend git_refdb_backend; +/** A git commit-graph */ +typedef struct git_commit_graph git_commit_graph; + +/** a writer for commit-graph files. */ +typedef struct git_commit_graph_writer git_commit_graph_writer; + /** * Representation of an existing git repository, * including all its object contents diff --git a/libgit2/headers/git2/version.h b/libgit2/headers/git2/version.h index 7b549b0..46adfec 100644 --- a/libgit2/headers/git2/version.h +++ b/libgit2/headers/git2/version.h @@ -7,12 +7,12 @@ #ifndef INCLUDE_git_version_h__ #define INCLUDE_git_version_h__ -#define LIBGIT2_VERSION "1.1.1" +#define LIBGIT2_VERSION "1.2.0" #define LIBGIT2_VER_MAJOR 1 -#define LIBGIT2_VER_MINOR 1 -#define LIBGIT2_VER_REVISION 1 +#define LIBGIT2_VER_MINOR 2 +#define LIBGIT2_VER_REVISION 0 #define LIBGIT2_VER_PATCH 0 -#define LIBGIT2_SOVERSION "1.1" +#define LIBGIT2_SOVERSION "1.2" #endif diff --git a/libgit2/headers/git2/worktree.h b/libgit2/headers/git2/worktree.h index 049511d..23084d8 100644 --- a/libgit2/headers/git2/worktree.h +++ b/libgit2/headers/git2/worktree.h @@ -198,6 +198,7 @@ typedef enum { typedef struct git_worktree_prune_options { unsigned int version; + /** A combination of `git_worktree_prune_t` */ uint32_t flags; } git_worktree_prune_options; diff --git a/libgit2/libgit2-1.1.1.so b/libgit2/libgit2-1.1.1.so deleted file mode 100755 index 266d2fc..0000000 Binary files a/libgit2/libgit2-1.1.1.so and /dev/null differ diff --git a/libgit2/libgit2-1.2.0.so b/libgit2/libgit2-1.2.0.so new file mode 100755 index 0000000..446c3f7 Binary files /dev/null and b/libgit2/libgit2-1.2.0.so differ