libgit2 v0.21.0
Final release of 0.21.0 after two release candidates. Go get it.
Changed since last version:
- Top-level Improvements
- We've dropped support for Windows XP. We're evil like that.
- Added a new config snapshotting API to fix race issues when different applications (e.g. Git and a libgit2 client) access the same repository simultaneously.
- Added reflog support to all APIs that could alter a reference. These APIs gained two new parameters:
const git_signature *signatureandconst char *log_messageto control what is written to the reflog. Passing NULL for these values will use defaults from the user's configuration. - Avoided race conditions when updating references. Any function that alters a reference will check if the underlying reference data has been changed since libgit2 looked up the data and cancel the operation with error
GIT_EMODIFIEDif the reference has been changed. - Converted all APIs that output string data to use
git_bufobjects for the return value. Previously these would typically take a pointer to an output buffer and a size, and generate an error if the output buffer was not large enough. - Added standard
git_<object>_init_optionsfunctions to initialize options structures when static initialization is not possible, and renamed options structures to standardgit_<object>_options(replacing_optssuffix used in some places) - Improved use of
conston pointers in many APIs (which may affect some bindings). - Replaced use of
oidwith simplyidfor references togit_oidvalue.s - Previously, when a callback function returned an error value (i.e. non-zero), libgit2 converted it to
GIT_EUSERfor the parent function's return value. Now, libgit2 tries to pass through the callback's return value all the way back to the caller. To disambiguate between an error generated by the callback vs. an error generated internally by libgit2, a callback can still explicitly return theGIT_EUSERvalue -- libgit2 will never use that error code for errors that it raises. - All inline functions were eliminated from the public libgit2 API
- Removed all Apache licensed code from library
- CRLF handling is much improved in the platforms where it matters (Windows)
- Attributes
- Improved compatability with core Git for filename patterns including support for
**matches - Cache validation improvements
- Faster attribute checks
- Improved compatability with core Git for filename patterns including support for
- Blame
- Added
GIT_BLAME_FIRST_PARENTto simplify search
- Added
- Clone
- Local clones are now supported. Rejoice!
- Checkout
- Added ability to write out conflict data using either MERGE or DIFF3 style
- Improved support for
core.autocrlfandcore.safecrlf - Improved handling of empty and ignored directories (impacts
git_resetAPIs, too)
- Cherry Pick
- Completely new API
- New API:
git_cherry_pick_commitgenerates a newgit_index *with result - New API:
git_cherry_pickupdates existing index and working directory
- Commit
- Faster commit parsing
- New API:
git_commit_summaryreturns first paragraph of commit message with whitespace trimmed and squashed - New API:
git_commit_amendcreates a new commit that is a clone of an existing commit with selected fields overwritten - New API:
git_commit_create_from_callbackallows creating a new commit using a callback to provide parent information (ininclude/git2/sys/commit.h) - When given a reference to update,
git_commit_createnow checks that the first parent is the current value of said reference and checks that the old value of the reference is correct when updating it. - The comment character can now be specified when parsing commit messages.
- Diff
- Faster diffs due to reduced calculation of SHAs for unknown files on disk
- Added flag
GIT_DIFF_UPDATE_INDEXto optionally update the index stat cache while performing index-to-workdir diffs. This can yield performance improvements when doing repeated diffs (or status checks) - Added support for builtin diff drivers that is compatible (and derived from) core Git (e.g. setting attribute "*.html diff=html" will now change diff output in libgit2, whereas previously the "html" diff driver was not internally defined)
git_diff_find_similarwill now fall back to thediff.renamesconfig setting if no explicit options are passed ingit_diff_find_similargainedGIT_DIFF_FIND_REMOVE_UNMODIFIEDflag to removeGIT_DELTA_UNMODIFIEDrecords from a diff after rename detection is done. This allows you to generate a diff that includes UNMODIFIED records (so they can be considered as possible sources forCOPIEDfiles) and then remove unused ones from the final diff.- New API:
git_diff_buffersruns diff on two in-memory buffers - New API:
git_diff_get_statscreatesgit_diff_statsto emulate--stat,--numstat, and--shortstatoutput - New API:
git_diff_stats_freeto freegit_diff_statsobject - New API:
git_diff_stats_to_bufoutputsgit_diff_statsin formats like Git - New APIs:
git_diff_stats_files_changed,git_diff_stats_insertions, andgit_diff_stats_deletionsare accessors forgit_diff_statsobject - New API:
git_diff_format_emailto generate an email patch (in agit_buf) from agit_diffusinggit_diff_format_email_optionssettings - New API:
git_diff_commit_as_emailto generate an email-ready patch from agit_commit - New API:
git_diff_print_callback__to_bufhelper function for use withgit_diff_printandgit_patch_printto accumulate output into agit_buf *(ininclude/git2/sys/diff.h) - New API:
git_diff_print_callback__to_file_handlehelper function for use withgit_diff_printandgit_patch_printto send output to aFILE *(ininclude/git2/sys/diff.h) - New API:
git_diff_get_perfdatagets low-level performance data for agit_diff(ininclude/git2/sys/diff.h)
- Errors
- New error code:
GIT_EMODIFIEDreturned when a reference-modifying operation finds that the underlying reference was changed underneath the libgit2 call
- New error code:
- Graph
- New API:
git_graph_descendant_ofchecks if one commit is the descendant of another
- New API:
- Ignores
- Lots of bug fixes
- Improved compatability with core Git for filename patterns including support for
**matches - Cache validation improvements
- Index
- The index no longer allows tree and blob path collisions.
- Mempack
- Completely new API (in
include/git2/sys/mempack.h) - Custom ODB backend to pack objects in memory
- Completely new API (in
- Merge
- Major changes to how the Merge APIs work
git_mergepreviously produced a new commit, now stages a new commit, including writing conflicts to the index and working tree; has new function signature.- New API:
git_merge_analysischecks if an array of merge heads can be merged, fast-forwarded, are up-to-date, or otherwise - New API:
git_merge_base_octopusfinds a merge base for an octopus merge - New API:
git_merge_head_idreturns the commit id that agit_merge_headobject refers to - New API:
git_merge_commitsmerges two commits and generates new index representing merge result - New API:
git_merge_filemerges two files in memory, producing agit_merge_file_resultobject - New API:
git_merge_file_from_indexmerges two index entries in memory, producing agit_merge_file_resultobject - New API:
git_merge_file_result_freefrees angit_merge_file_resultobject
- Object
- New API:
git_object_short_idreturns unambiguous abbreviated ID string for object
- New API:
- ODB
- New API:
git_odb_exists_prefixchecks for existence of object by partialgit_oid
- New API:
- Pack
- New API:
git_packbuilder_write_bufwrites packfile togit_buf *in memory - Delta resolution now happens iteratively instead of recursively, so no more stack overflows.
- Deflate buffer usage is now more efficient
- New API:
- Patch
- New API:
git_patch_from_bufferscreatesgit_patchobject from the diff of two in-memory buffers - Added support for deflated binary patches.
- New API:
- References
- New API:
git_reference_create_matchingsafely creates a direct reference to update from an expected oldconst git_oid *value - New API:
git_reference_symbolic_create_matchingsafely creates a symbolic reference to update from an expected oldconst char *value - New API:
git_reference_removeremoves a reference by name - New API:
git_reference_ensure_logmakes sure there is a log file for a reference - New API:
git_reference_is_notechecks if reference lives inrefs/notesnamespace
- New API:
- Remotes
- New API:
git_remote_dupcopies an existing remote (except for callback functions) - New API:
git_remote_get_callbacksgets callbacks struct from existing remote
- New API:
- Revert
- Completely new API
- New API:
git_revert_commitgenerates newgit_indexwith result of reverting commit - New API:
git_revertreverts commit in working directory
- Revwalk
- APIs that previous tooks commits or references to commits can now take a "committish" (i.e. tags will be peeled to reach a commit)
git_revwalk_{push,hide}_globnow ignores a reference if it is not a commitish instead of erroring out.- New API:
git_revwalk_add_hide_cbenables callback to make decisions about hiding commits during a revwalk
- Status
- Faster status due to reduced calculation of SHAs for unknown files on disk
- Added flag
GIT_STATUS_OPT_UPDATE_INDEXto optionally update the index stat cache while performing status. This can yield performance improvements when doing repeated status checks. - New API:
git_status_list_get_perfdatagets low-level performance data for agit_status_list(ininclude/git2/sys/diff.h)
- Submodules
git_submoduleobjects are now reference counted and must be used withgit_submodule_freewhen done- Submodules will now automatically refresh if the underlying data changes; explicit reloading is rarely required
- New API:
git_submodule_resolve_urlresolves relative URLs using parent repository - New API:
git_submodule_branchgets the branch for the submodule git_submodule_fetch_recursenow uses a newgit_submodule_recurse_ttype that includes aGIT_SUBMODULE_RECURSE_ONDEMANDvalue (as well asNOandYES) instead just true or false
- Transport
- New credential option
GIT_CREDTYPE_SSH_INTERACTIVEwithgit_cred_ssh_interactivetype andgit_cred_sss_interactive_callbackcallback type - New API:
git_cred_ssh_interactive_newto create agit_cred *for keyboard-interactive credentials - New API:
git_cred_ssh_key_from_agentto create agit_cred *by querying an ssh-agent - On Windows: support for NTLM/Kerberos auth
- New credential option
- Build & Portability Improvements
- More precise flag setting for controlling build warnings
- Much better threading support in Windows
- Better support for Android
- Better support for Solaris
- Better support for FreeBSD
- Iconv support can now be enabled in non-Mac OS X platforms, if you're weird like that.
- On Windows: better support for reparse points, better path handling, added automatic retries on some file operations
- BREAKING CHANGES TO EXISTING APIS (Highlighted to make life easier for binding authors)
- Changes from non-const to const pointers are not included in this list
- Any place where a binding was explicitly looking for
GIT_EUSERwill have to revisited because libgit2 no longer converts callback return values intoGIT_EUSERfor you git_blame_buffertakes asize_t buffer_lenwhere it used to take auint32_t buffer_lengit_branch_createaddedconst git_signature *andconst char *log_messageparamsgit_branch_moveaddedconst git_signature *andconst char *log_messageparamsgit_branch_upstream_namenow outputs name to agit_buf *git_branch_remote_namenow outputs name to agit_buf *git_checkout_optsstruct was renamed togit_checkout_optionsand added anancestor_labelfield (in the middle of the struct!)git_clone_optionsgained agit_signature *signaturefield used for reflog updates and the type of the existingcheckout_optsfield was changed fromgit_checkout_optstogit_checkout_optionsgit_clone_intochanged type ofco_optstoconst git_checkout_options *and addedconst git_signature *signatureparamgit_commit_createchanged type ofparent_countfrominttosize_tgit_commit_create_vchanged type ofparent_countfrominttosize_tgit_commit_create_from_idschanged type ofparent_countfrominttosize_tgit_cap_ttype andGIT_CAP_...values renamed togit_feature_tandGIT_FEATURE_...git_libgit2_capabilitiesrenamed togit_libgit2_features(for checking compile options at run time)- The
git_libgit2_optsparameters toGIT_OPT_GET_SEARCH_PATHandGIT_OPT_GET_TEMPLATE_PATHwere changes to take agit_buf *instead ofchar *andsize_tpair git_config_find_globalnow outputs path to agit_buf *git_config_find_xdgnow outputs path to agit_buf *git_config_find_systemnow outputs path to agit_buf *git_cred_ssh_customstruct changed type ofsign_callbackfield togit_cred_sign_callbackgit_cred_ssh_customstruct renamedsign_datafield topayloadGIT_DIFF_FLAG_VALID_OIDflag on diff files renamed toGIT_DIFF_FLAG_VALID_IDgit_diff_filefieldoidrenamed toidgit_diff_optionsfieldoid_abbrevrenamed toid_abbrevgit_diff_options_initAPI renamed togit_diff_init_optionsas part of standardization- In
git_index_entry, theoidfield was renamed toidand thepathfield changed from achar *to aconst char * git_indexcap_tchanged its underlying type from unsigned to signedgit_index_capsreturns anintinstead of anunsigned intgit_index_set_capstakes anint capsinstead ofunsigned int capsgit_index_clearnow returns an error code where before it was avoidfunction (it can return an error if another thread is using index data and a memory allocation fails while preserving data for deferred deletion)git_index_conflict_cleanupnow returns an error code where before it was avoidfunction (seegit_index_clearfor explanation)git_indexer_newchanged type ofprogress_cbtogit_transfer_progress_cbgit_merge_automerge_flagsrenamed togit_merge_file_favor_tandGIT_MERGE_AUTOMERGE_...renamed toGIT_MERGE_FILE_FAVOR_...(with additional changes to specific values)git_merge_tree_optsrenamed togit_merge_optionswithautomerge_flagsfield replaced withfile_favorgit_merge_optsremoved (in favor of passing explicitgit_checkout_optionsto updatedgit_mergefunction)git_merge_head_from_oidrenamed togit_merge_head_from_idgit_merge_treestakesconst git_merge_options *instead ofconst git_merge_tree_opts *git_mergeis essentially a different function with different parameters and a different effectgit_merge_resulttype removedgit_merge_result_is_uptodateremoved (usegit_merge_analysisinstead)git_merge_result_is_fastforwardremoved (usegit_merge_analysisinstead)git_merge_result_fastforward_oidremovedgit_merge_result_freeremovedgit_message_prettifynow outputs message to agit_buf *git_note_oidrenamed togit_note_idgit_odb_write_packchanged type ofprogress_cbtogit_transfer_progress_cbgit_odb_backendstruct addedexists_prefixcallbackgit_odb_backendstructwritepackcallback changed type ofprogress_cbtogit_transfer_progress_cbgit_oid_equalis no longer an inline functiongit_packbuilder_writechanged type ofprogress_cbtogit_transfer_progress_cbgit_patch_to_strreplaced withgit_patch_to_bufwhich writes togit_buf *instead of allocating a stringgit_push_update_tipsaddedconst git_signature *andconst char *log_messageparamsgit_refdb_backendstructwritecallback addedconst git_signature *,const char *log_message,const git_oid *old_id, andconst char *old_targetparamsgit_refdb_backendstructrenamecallback addedconst git_signature *andconst char *log_messageparamsgit_refdb_backendstructdelcallback addedconst git_oid *old_idandconst char *old_targetparamsgit_refdb_backendstruct addedhas_logcallbackgit_refdb_backendstruct addedensure_logcallbackgit_reflog_append_toremoved - reflog writing moved into individual ref updating functionsgit_reference_createaddedconst git_signature *andconst char *log_messageparamsgit_reference_symbolic_createaddedconst git_signature *andconst char *log_messageparamsgit_reference_set_targetaddedconst git_signature *andconst char *log_messageparamsgit_reference_symbolic_set_targetaddedconst git_signature *andconst char *log_messageparamsgit_reference_renameaddedconst git_signature *andconst char *log_messageparamsgit_reference_has_lognow takes agit_repository *andconst char *instead of a `git_reference *~git_refspec_transformnow outputs spec to agit_buf *git_refspec_rtransformnow outputs spec to agit_buf *git_remote_create_inmemoryreplaced withgit_remote_create_anonymouswith the order of theurlandfetchparameters switchedgit_remote_update_tipsaddedconst git_signature *andconst char *log_messageparamsgit_remote_fetchaddedconst git_signature *andconst char *log_messageparams- In
git_remote_callbacksstruct,progresscallback was renamedsideband_progressand type changed togit_transport_message_cb,credentialscallback type changed togit_cred_acquire_cb,transfer_progresstype changed togit_transfer_progress_cb git_repository_discovernow outputs to agit_buf *git_repository_messagenow outputs to agit_buf *git_repository_merge_cleanuprenamed togit_repository_state_cleanupgit_repository_set_headaddedconst git_signature *andconst char *log_messageparamsgit_repository_set_head_detachedaddedconst git_signature *andconst char *log_messageparamsgit_repository_detach_headaddedconst git_signature *andconst char *log_messageparamsgit_resetaddedconst git_signature *andconst char *log_messageparamsgit_signature_dupnow returns an error code and allocates the new signature via an output param- The object returned from
git_submodule_lookupmust now havegit_submodule_freecalled it when you are done with it (i.e. it is reference counted now) git_submodule_fetch_recurse_submodulesreturns agit_submodule_recurse_tinstead of anintgit_submodule_set_fetch_recurse_submodulestakes agit_submodule_recurse_tinstead of anintgit_submodule_reloadtakes a newforceflag to override up-to-date checksgit_submodule_reload_alltakes a newforceflag to override up-to-date checksgit_transfer_progress_callbacktype was renamed togit_transfer_progress_cbgit_transportstructdownload_packcallback changed type ofprogress_cbtogit_transfer_progress_cbgit_tree_entry_byoidrenamed togit_tree_entry_byidgit_tree_entry_dupnow returns an error code and allocates the newgit_tree_entryvia an output param