纯C语言实现的 Git 核心开发包, libgit2 v0.21.4/v0.22.0 发布
libgit2 是一个可移植、纯C语言实现的 Git 核心开发包,你可以使用它来编写自定义的 Git 应用。
libgit2已被广泛应用在许多应用程序上,包括GitHub网站,还被应用在Plastic SCM和强大的微软Visual Studio工具箱。
主要功能:
-
SHA转换、格式化和缩略词
-
抽象的ODB后端系统
-
提交、标签、树和BLOB解析、编辑、blob解析和回写
-
树遍历
-
revision walking
-
索引文件(临时区域)操作
-
引用管理(包括包引用)
-
配置文件管理
-
高级仓库管理
-
线程安全和可重入
-
错误信息描述非常详细
-
更多(超过175个不同的API调用)
-
bce9484 Fix assert when receiving uncommon sideband packet
-
4f2d272 ignore: don't leak rules into higher directories
-
8fce79b ignore: match git's rule negation rules
-
f888185 ignore: adjust test for negating inside a dir
-
b38fe6f Fix build of tests with mingw
-
4058f1c Fix ming32 compilation
-
04da236 Fix public header on sys/refs.h
-
dc39d23 Plug possible leak in the openssl locks
-
3a2c60e ssl: clear the OpenSSL locking function
-
9c04635 Fix segmentation fault observed on OpenBSD/sparc64
同时还发布了 libgit2 v0.22.0 正式版,此版本包括许多新特性和 bug 修复,主要更新内容如下:
改进:
-
git_signature_new()now requires a non-empty email address.
-
Use CommonCrypto libraries for SHA-1 calculation on Mac OS X.
-
Disable SSL compression and SSLv2 and SSLv3 ciphers in favor of TLSv1
in OpenSSL. -
The fetch behavior of remotes with autotag set toGIT_REMOTE_DOWNLOAD_TAGS_ALL
has been changed to match git 1.9.0 and later. In this mode, libgit2 now
fetches all tags in addition to whatever else needs to be fetched. -
git_checkout()now handles case-changing renames correctly on
case-insensitive filesystems; for example renaming "readme" to "README". -
The search for libssh2 is now done via pkg-config instead of a
custom search of a few directories. -
Add support for core.protectHFS and core.protectNTFS. Add more
validation for filenames which we write such as references. -
The local transport now generates textual progress output like
git-upload-pack does ("counting objects"). -
git_checkout_index()can now check out an in-memory index that is not
necessarily the repository's index, so you may check out an index
that was produced by git_merge and friends while retaining the cached
information. -
Remove the default timeout for receiving / sending data over HTTP using
the WinHTTP transport layer. -
Add SPNEGO (Kerberos) authentication using GSSAPI on Unix systems.
-
Provide built-in objects for the empty blob (e69de29) and empty
tree (4b825dc) objects. -
The index' tree cache is now filled upon read-tree and write-tree
and the cache is written to disk. -
LF -> CRLF filter refuses to handle mixed-EOL files
-
LF -> CRLF filter now runs when * text = auto (with Git for Windows 1.9.4)
-
File unlocks are atomic again via rename. Read-only files on Windows are
made read-write if necessary. -
Share open packfiles across repositories to share descriptors and mmaps.
-
Use a map for the treebuilder, making insertion O(1)
-
The build system now accepts an option EMBED_SSH_PATH which when set
tells it to include a copy of libssh2 at the given location. This is
enabled for MSVC. -
Add support for refspecs with the asterisk in the middle of a
pattern. -
Fetching now performs opportunistic updates. To achieve this, we
introduce a difference between active and passive refspecs, which
makegit_remote_download()andgit_remote_fetch()to take a list of
resfpecs to be the active list, similarly to how git fetch accepts a
list on the command-line. -
The THREADSAFE option to build libgit2 with threading support has
been flipped to be on by default. -
The remote object has learnt to prune remote-tracking branches. If
the remote is configured to do so, this will happen via
git_remote_fetch(). You can also callgit_remote_prune()after
connecting or fetching to perform the prune.
API additions
-
Introducegit_buf_text_is_binary()andgit_buf_text_contains_nul()for
consumers to perform binary detection on a git_buf. -
git_branch_upstream_remote()has been introduced to provide the
branch..remote configuration value. -
Introducegit_describe_commit()andgit_describe_workdir()to provide
a description of the current commit (and working tree, respectively)
based on the nearest tag or reference -
Introducegit_merge_bases()and thegit_oidarraytype to expose all
merge bases between two commits. -
Introducegit_merge_bases_many()to expose all merge bases between
multiple commits. -
Introduce rebase functionality (using the merge algorithm only).
Introducegit_rebase_init()to begin a new rebase session,
git_rebase_open()to open an in-progress rebase session,
git_rebase_commit()to commit the current rebase operation,
git_rebase_next()to apply the next rebase operation,
git_rebase_abort()to abort an in-progress rebase andgit_rebase_finish()
to complete a rebase operation. -
Introducegit_note_author()andgit_note_committer()to get the author
and committer information on agit_note, respectively. -
A factory function for ssh has been added which allows to change the
path of the programs to execute for receive-pack and upload-pack on
the server,git_transport_ssh_with_paths(). -
The ssh transport supports asking the remote host for accepted
credential types as well as multiple challeges using a single
connection. This requires to know which username you want to connect
as, so this introduces the USERNAME credential type which the ssh
transport will use to ask for the username. -
TheGIT_EPEELerror code has been introduced when we cannot peel a tag
to the requested object type; if the given object otherwise cannot be
peeled,GIT_EINVALIDSPECis returned. -
IntroduceGIT_REPOSITORY_INIT_RELATIVE_GITLINKto use relative paths
when writing gitlinks, as is used by git core for submodules. -
git_remote_prune()has been added. See above for description.
-
Introduce reference transactions, which allow multiple references to
be locked at the same time and updates be queued. This also allows
us to safely update a reflog with arbitrary contents, as we need to
do for stash.
API removals
-
git_remote_supported_url()andgit_remote_is_valid_url()have been
removed as they have become essentially useless with rsync-style ssh paths. -
git_clone_into()andgit_clone_local_into()have been removed from the
public API in favour ofgit_clone callbacks. -
The option to ignore certificate errors viagit_remote_cert_check()
is no longer present. Instead,git_remote_callbackshas gained a new
entry which lets the user perform their own certificate checks.
Breaking API changes
-
git_cherry_pick()is nowgit_cherrypick().
-
Thegit_submodule_update()function was renamed to
git_submodule_update_strategy().git_submodule_update()is now used to
provide functionalty similar to "git submodule update". -
git_treebuilder_create()was renamed togit_treebuilder_new()to better
reflect it being a constructor rather than something which writes to
disk. -
git_treebuilder_new()(wasgit_treebuilder_create()) now takes a
repository so that it can query repository configuration.
Subsequently,git_treebuilder_write()no longer takes a repository. -
git_threads_init()andgit_threads_shutdown()have been renamed to
git_libgit2_init()andgit_libgit2_shutdown()to better explain what
their purpose is, as it's grown to be more than just about threads. -
git_libgit2_init()andgit_libgit2_shutdown()now return the number of
initializations of the library, so consumers may schedule work on the
first initialization. -
Thegit_transport_register()function no longer takes a priority and takes
a URL scheme name (eg "http") instead of a prefix like "http://" -
git_index_name_entrycount()andgit_index_reuc_entrycount()now
return size_t instead of unsigned int. -
Thecontext_linesandinterhunk_linesfields ingit_diff_options are
nowuint32_tinstead ofuint16_t. This allows to set them toUINT_MAX,
in effect asking for "infinite" context e.g. to iterate over all the
unmodified lines of a diff. -
git_status_file()now takes an exact path. Usegit_status_list_new()if
pathspec searching is needed. -
git_note_create()has changed the position of the notes reference
name to matchgit_note_remove(). -
Renamegit_remote_load()togit_remote_lookup()to bring it in line
with the rest of the lookup functions. -
git_remote_rename()now takes the repository and the remote's
current name. Accepting a remote indicates we want to change it,
which we only did partially. It is much clearer if we accept a name
and no loaded objects are changed. -
git_remote_delete()now accepts the repository and the remote's name
instead of a loaded remote. -
git_merge_headis nowgit_annotated_commit, to better reflect its usage
for multiple functions (including rebase) -
Thegit_clone_optionsstruct no longer provides theignore_cert_errorsor
remote_namemembers for remote customization.Instead, thegit_clone_optionsstruct has two new members,remote_cband
remote_cb_payload, which allow the caller to completely override the remote
creation process. If needed, the caller can use this callback to give their
remote a name other than the default (origin) or disable cert checking.Theremote_callbacksmember has been preserved for convenience, although it
is not used when a remote creation callback is supplied. -
Thegit_clone_options struct now providesrepository_cband
repository_cb_payloadto allow the user to create a repository with
custom options. -
Thegit_pushstruct to perform a push has been replaced with
git_remote_upload(). The refspecs and options are passed as a
function argument.git_push_update_tips()is now also
git_remote_update_tips()and the callbacks are in the same struct as
the rest. -
Thegit_remote_set_transport()function now sets a transport factory function,
rather than a pre-existing transport instance. -
Thegit_transportstructure definition has moved into the sys/transport.h
file. -
libgit2 no longer automatically sets the OpenSSL locking
functions. This is not something which we can know to do. A
last-resort convenience function is provided in sys/openssl.h,
git_openssl_set_locking()which can be used to set the locking.