summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@edwardthomson.com>2022-02-26 15:10:42 -0500
committerGitHub <noreply@github.com>2022-02-26 15:10:42 -0500
commit1327dbcf2a4273a8ba6fd978db5f0882530af94d (patch)
treec153c0661c61b575aeaca1007a53f9595a5390fc
parenteca9e1cfec2be5a55401290de9eb944bcb54c867 (diff)
parente427d0a1589c67bea3c1e822cd9edd83e0705f74 (diff)
downloadlibgit2-1327dbcf2a4273a8ba6fd978db5f0882530af94d.tar.gz
Merge pull request #6133 from libgit2/ethomson/cli_redux
CLI (redux)
-rw-r--r--CMakeLists.txt6
-rwxr-xr-xci/test.sh18
-rw-r--r--cmake/AddClarTest.cmake7
-rw-r--r--cmake/SelectHashes.cmake3
-rw-r--r--examples/CMakeLists.txt6
-rw-r--r--fuzzers/CMakeLists.txt2
-rw-r--r--include/git2/errors.h18
-rw-r--r--src/CMakeLists.txt315
-rw-r--r--src/README.md12
-rw-r--r--src/cli/CMakeLists.txt53
-rw-r--r--src/cli/README.md26
-rw-r--r--src/cli/cli.h19
-rw-r--r--src/cli/cmd.c21
-rw-r--r--src/cli/cmd.h32
-rw-r--r--src/cli/cmd_cat_file.c204
-rw-r--r--src/cli/cmd_hash_object.c135
-rw-r--r--src/cli/cmd_help.c86
-rw-r--r--src/cli/error.h51
-rw-r--r--src/cli/main.c105
-rw-r--r--src/cli/opt.c669
-rw-r--r--src/cli/opt.h349
-rw-r--r--src/cli/opt_usage.c194
-rw-r--r--src/cli/opt_usage.h35
-rw-r--r--src/cli/win32/precompiled.c (renamed from src/win32/precompiled.c)0
-rw-r--r--src/cli/win32/precompiled.h3
-rw-r--r--src/libgit2/CMakeLists.txt131
-rw-r--r--src/libgit2/annotated_commit.c (renamed from src/annotated_commit.c)0
-rw-r--r--src/libgit2/annotated_commit.h (renamed from src/annotated_commit.h)0
-rw-r--r--src/libgit2/apply.c (renamed from src/apply.c)0
-rw-r--r--src/libgit2/apply.h (renamed from src/apply.h)0
-rw-r--r--src/libgit2/attr.c (renamed from src/attr.c)0
-rw-r--r--src/libgit2/attr.h (renamed from src/attr.h)0
-rw-r--r--src/libgit2/attr_file.c (renamed from src/attr_file.c)0
-rw-r--r--src/libgit2/attr_file.h (renamed from src/attr_file.h)0
-rw-r--r--src/libgit2/attrcache.c (renamed from src/attrcache.c)0
-rw-r--r--src/libgit2/attrcache.h (renamed from src/attrcache.h)0
-rw-r--r--src/libgit2/blame.c (renamed from src/blame.c)0
-rw-r--r--src/libgit2/blame.h (renamed from src/blame.h)0
-rw-r--r--src/libgit2/blame_git.c (renamed from src/blame_git.c)0
-rw-r--r--src/libgit2/blame_git.h (renamed from src/blame_git.h)0
-rw-r--r--src/libgit2/blob.c (renamed from src/blob.c)2
-rw-r--r--src/libgit2/blob.h (renamed from src/blob.h)0
-rw-r--r--src/libgit2/branch.c (renamed from src/branch.c)0
-rw-r--r--src/libgit2/branch.h (renamed from src/branch.h)0
-rw-r--r--src/libgit2/buf.c (renamed from src/buf.c)0
-rw-r--r--src/libgit2/buf.h (renamed from src/buf.h)0
-rw-r--r--src/libgit2/cache.c (renamed from src/cache.c)0
-rw-r--r--src/libgit2/cache.h (renamed from src/cache.h)0
-rw-r--r--src/libgit2/checkout.c (renamed from src/checkout.c)0
-rw-r--r--src/libgit2/checkout.h (renamed from src/checkout.h)0
-rw-r--r--src/libgit2/cherrypick.c (renamed from src/cherrypick.c)0
-rw-r--r--src/libgit2/clone.c (renamed from src/clone.c)0
-rw-r--r--src/libgit2/clone.h (renamed from src/clone.h)0
-rw-r--r--src/libgit2/commit.c (renamed from src/commit.c)0
-rw-r--r--src/libgit2/commit.h (renamed from src/commit.h)0
-rw-r--r--src/libgit2/commit_graph.c (renamed from src/commit_graph.c)0
-rw-r--r--src/libgit2/commit_graph.h (renamed from src/commit_graph.h)0
-rw-r--r--src/libgit2/commit_list.c (renamed from src/commit_list.c)0
-rw-r--r--src/libgit2/commit_list.h (renamed from src/commit_list.h)0
-rw-r--r--src/libgit2/common.h55
-rw-r--r--src/libgit2/config.c (renamed from src/config.c)0
-rw-r--r--src/libgit2/config.h (renamed from src/config.h)0
-rw-r--r--src/libgit2/config_backend.h (renamed from src/config_backend.h)0
-rw-r--r--src/libgit2/config_cache.c (renamed from src/config_cache.c)0
-rw-r--r--src/libgit2/config_entries.c (renamed from src/config_entries.c)0
-rw-r--r--src/libgit2/config_entries.h (renamed from src/config_entries.h)0
-rw-r--r--src/libgit2/config_file.c (renamed from src/config_file.c)0
-rw-r--r--src/libgit2/config_mem.c (renamed from src/config_mem.c)0
-rw-r--r--src/libgit2/config_parse.c (renamed from src/config_parse.c)0
-rw-r--r--src/libgit2/config_parse.h (renamed from src/config_parse.h)0
-rw-r--r--src/libgit2/config_snapshot.c (renamed from src/config_snapshot.c)0
-rw-r--r--src/libgit2/crlf.c (renamed from src/crlf.c)0
-rw-r--r--src/libgit2/delta.c (renamed from src/delta.c)0
-rw-r--r--src/libgit2/delta.h (renamed from src/delta.h)0
-rw-r--r--src/libgit2/describe.c (renamed from src/describe.c)0
-rw-r--r--src/libgit2/diff.c (renamed from src/diff.c)0
-rw-r--r--src/libgit2/diff.h (renamed from src/diff.h)0
-rw-r--r--src/libgit2/diff_driver.c (renamed from src/diff_driver.c)0
-rw-r--r--src/libgit2/diff_driver.h (renamed from src/diff_driver.h)0
-rw-r--r--src/libgit2/diff_file.c (renamed from src/diff_file.c)0
-rw-r--r--src/libgit2/diff_file.h (renamed from src/diff_file.h)0
-rw-r--r--src/libgit2/diff_generate.c (renamed from src/diff_generate.c)0
-rw-r--r--src/libgit2/diff_generate.h (renamed from src/diff_generate.h)0
-rw-r--r--src/libgit2/diff_parse.c (renamed from src/diff_parse.c)0
-rw-r--r--src/libgit2/diff_parse.h (renamed from src/diff_parse.h)0
-rw-r--r--src/libgit2/diff_print.c (renamed from src/diff_print.c)0
-rw-r--r--src/libgit2/diff_stats.c (renamed from src/diff_stats.c)0
-rw-r--r--src/libgit2/diff_stats.h (renamed from src/diff_stats.h)0
-rw-r--r--src/libgit2/diff_tform.c (renamed from src/diff_tform.c)0
-rw-r--r--src/libgit2/diff_tform.h (renamed from src/diff_tform.h)0
-rw-r--r--src/libgit2/diff_xdiff.c (renamed from src/diff_xdiff.c)1
-rw-r--r--src/libgit2/diff_xdiff.h (renamed from src/diff_xdiff.h)0
-rw-r--r--src/libgit2/email.c (renamed from src/email.c)0
-rw-r--r--src/libgit2/email.h (renamed from src/email.h)0
-rw-r--r--src/libgit2/errors.c (renamed from src/errors.c)0
-rw-r--r--src/libgit2/errors.h (renamed from src/errors.h)3
-rw-r--r--src/libgit2/fetch.c (renamed from src/fetch.c)0
-rw-r--r--src/libgit2/fetch.h (renamed from src/fetch.h)0
-rw-r--r--src/libgit2/fetchhead.c (renamed from src/fetchhead.c)0
-rw-r--r--src/libgit2/fetchhead.h (renamed from src/fetchhead.h)0
-rw-r--r--src/libgit2/filter.c (renamed from src/filter.c)2
-rw-r--r--src/libgit2/filter.h (renamed from src/filter.h)0
-rw-r--r--src/libgit2/git2.rc (renamed from src/win32/git2.rc)0
-rw-r--r--src/libgit2/graph.c (renamed from src/graph.c)0
-rw-r--r--src/libgit2/hashsig.c (renamed from src/hashsig.c)0
-rw-r--r--src/libgit2/ident.c (renamed from src/ident.c)0
-rw-r--r--src/libgit2/idxmap.c (renamed from src/idxmap.c)0
-rw-r--r--src/libgit2/idxmap.h (renamed from src/idxmap.h)0
-rw-r--r--src/libgit2/ignore.c (renamed from src/ignore.c)0
-rw-r--r--src/libgit2/ignore.h (renamed from src/ignore.h)0
-rw-r--r--src/libgit2/index.c (renamed from src/index.c)0
-rw-r--r--src/libgit2/index.h (renamed from src/index.h)0
-rw-r--r--src/libgit2/indexer.c (renamed from src/indexer.c)0
-rw-r--r--src/libgit2/indexer.h (renamed from src/indexer.h)0
-rw-r--r--src/libgit2/iterator.c (renamed from src/iterator.c)0
-rw-r--r--src/libgit2/iterator.h (renamed from src/iterator.h)0
-rw-r--r--src/libgit2/libgit2.c (renamed from src/libgit2.c)0
-rw-r--r--src/libgit2/libgit2.h (renamed from src/libgit2.h)0
-rw-r--r--src/libgit2/mailmap.c (renamed from src/mailmap.c)0
-rw-r--r--src/libgit2/mailmap.h (renamed from src/mailmap.h)0
-rw-r--r--src/libgit2/merge.c (renamed from src/merge.c)0
-rw-r--r--src/libgit2/merge.h (renamed from src/merge.h)0
-rw-r--r--src/libgit2/merge_driver.c (renamed from src/merge_driver.c)0
-rw-r--r--src/libgit2/merge_driver.h (renamed from src/merge_driver.h)0
-rw-r--r--src/libgit2/merge_file.c (renamed from src/merge_file.c)0
-rw-r--r--src/libgit2/message.c (renamed from src/message.c)0
-rw-r--r--src/libgit2/midx.c (renamed from src/midx.c)0
-rw-r--r--src/libgit2/midx.h (renamed from src/midx.h)0
-rw-r--r--src/libgit2/mwindow.c (renamed from src/mwindow.c)0
-rw-r--r--src/libgit2/mwindow.h (renamed from src/mwindow.h)0
-rw-r--r--src/libgit2/netops.c (renamed from src/netops.c)1
-rw-r--r--src/libgit2/netops.h (renamed from src/netops.h)0
-rw-r--r--src/libgit2/notes.c (renamed from src/notes.c)0
-rw-r--r--src/libgit2/notes.h (renamed from src/notes.h)0
-rw-r--r--src/libgit2/object.c (renamed from src/object.c)0
-rw-r--r--src/libgit2/object.h (renamed from src/object.h)0
-rw-r--r--src/libgit2/object_api.c (renamed from src/object_api.c)0
-rw-r--r--src/libgit2/odb.c (renamed from src/odb.c)4
-rw-r--r--src/libgit2/odb.h (renamed from src/odb.h)0
-rw-r--r--src/libgit2/odb_loose.c (renamed from src/odb_loose.c)0
-rw-r--r--src/libgit2/odb_mempack.c (renamed from src/odb_mempack.c)0
-rw-r--r--src/libgit2/odb_pack.c (renamed from src/odb_pack.c)0
-rw-r--r--src/libgit2/offmap.c (renamed from src/offmap.c)0
-rw-r--r--src/libgit2/offmap.h (renamed from src/offmap.h)0
-rw-r--r--src/libgit2/oid.c (renamed from src/oid.c)0
-rw-r--r--src/libgit2/oid.h (renamed from src/oid.h)0
-rw-r--r--src/libgit2/oidarray.c (renamed from src/oidarray.c)0
-rw-r--r--src/libgit2/oidarray.h (renamed from src/oidarray.h)0
-rw-r--r--src/libgit2/oidmap.c (renamed from src/oidmap.c)0
-rw-r--r--src/libgit2/oidmap.h (renamed from src/oidmap.h)0
-rw-r--r--src/libgit2/pack-objects.c (renamed from src/pack-objects.c)0
-rw-r--r--src/libgit2/pack-objects.h (renamed from src/pack-objects.h)0
-rw-r--r--src/libgit2/pack.c (renamed from src/pack.c)0
-rw-r--r--src/libgit2/pack.h (renamed from src/pack.h)0
-rw-r--r--src/libgit2/parse.c (renamed from src/parse.c)0
-rw-r--r--src/libgit2/parse.h (renamed from src/parse.h)0
-rw-r--r--src/libgit2/patch.c (renamed from src/patch.c)0
-rw-r--r--src/libgit2/patch.h (renamed from src/patch.h)0
-rw-r--r--src/libgit2/patch_generate.c (renamed from src/patch_generate.c)0
-rw-r--r--src/libgit2/patch_generate.h (renamed from src/patch_generate.h)0
-rw-r--r--src/libgit2/patch_parse.c (renamed from src/patch_parse.c)0
-rw-r--r--src/libgit2/patch_parse.h (renamed from src/patch_parse.h)0
-rw-r--r--src/libgit2/path.c (renamed from src/path.c)1
-rw-r--r--src/libgit2/path.h (renamed from src/path.h)0
-rw-r--r--src/libgit2/pathspec.c (renamed from src/pathspec.c)0
-rw-r--r--src/libgit2/pathspec.h (renamed from src/pathspec.h)0
-rw-r--r--src/libgit2/proxy.c (renamed from src/proxy.c)0
-rw-r--r--src/libgit2/proxy.h (renamed from src/proxy.h)0
-rw-r--r--src/libgit2/push.c (renamed from src/push.c)0
-rw-r--r--src/libgit2/push.h (renamed from src/push.h)0
-rw-r--r--src/libgit2/reader.c (renamed from src/reader.c)0
-rw-r--r--src/libgit2/reader.h (renamed from src/reader.h)0
-rw-r--r--src/libgit2/rebase.c (renamed from src/rebase.c)0
-rw-r--r--src/libgit2/refdb.c (renamed from src/refdb.c)0
-rw-r--r--src/libgit2/refdb.h (renamed from src/refdb.h)0
-rw-r--r--src/libgit2/refdb_fs.c (renamed from src/refdb_fs.c)0
-rw-r--r--src/libgit2/reflog.c (renamed from src/reflog.c)0
-rw-r--r--src/libgit2/reflog.h (renamed from src/reflog.h)0
-rw-r--r--src/libgit2/refs.c (renamed from src/refs.c)0
-rw-r--r--src/libgit2/refs.h (renamed from src/refs.h)0
-rw-r--r--src/libgit2/refspec.c (renamed from src/refspec.c)0
-rw-r--r--src/libgit2/refspec.h (renamed from src/refspec.h)0
-rw-r--r--src/libgit2/remote.c (renamed from src/remote.c)0
-rw-r--r--src/libgit2/remote.h (renamed from src/remote.h)0
-rw-r--r--src/libgit2/repo_template.h (renamed from src/repo_template.h)0
-rw-r--r--src/libgit2/repository.c (renamed from src/repository.c)0
-rw-r--r--src/libgit2/repository.h (renamed from src/repository.h)0
-rw-r--r--src/libgit2/reset.c (renamed from src/reset.c)0
-rw-r--r--src/libgit2/revert.c (renamed from src/revert.c)0
-rw-r--r--src/libgit2/revparse.c (renamed from src/revparse.c)0
-rw-r--r--src/libgit2/revwalk.c (renamed from src/revwalk.c)0
-rw-r--r--src/libgit2/revwalk.h (renamed from src/revwalk.h)0
-rw-r--r--src/libgit2/settings.h (renamed from src/settings.h)0
-rw-r--r--src/libgit2/signature.c (renamed from src/signature.c)0
-rw-r--r--src/libgit2/signature.h (renamed from src/signature.h)0
-rw-r--r--src/libgit2/stash.c (renamed from src/stash.c)0
-rw-r--r--src/libgit2/status.c (renamed from src/status.c)0
-rw-r--r--src/libgit2/status.h (renamed from src/status.h)0
-rw-r--r--src/libgit2/strarray.c (renamed from src/strarray.c)0
-rw-r--r--src/libgit2/stream.h (renamed from src/stream.h)0
-rw-r--r--src/libgit2/streams/mbedtls.c (renamed from src/streams/mbedtls.c)0
-rw-r--r--src/libgit2/streams/mbedtls.h (renamed from src/streams/mbedtls.h)0
-rw-r--r--src/libgit2/streams/openssl.c (renamed from src/streams/openssl.c)0
-rw-r--r--src/libgit2/streams/openssl.h (renamed from src/streams/openssl.h)0
-rw-r--r--src/libgit2/streams/openssl_dynamic.c (renamed from src/streams/openssl_dynamic.c)0
-rw-r--r--src/libgit2/streams/openssl_dynamic.h (renamed from src/streams/openssl_dynamic.h)0
-rw-r--r--src/libgit2/streams/openssl_legacy.c (renamed from src/streams/openssl_legacy.c)0
-rw-r--r--src/libgit2/streams/openssl_legacy.h (renamed from src/streams/openssl_legacy.h)0
-rw-r--r--src/libgit2/streams/registry.c (renamed from src/streams/registry.c)0
-rw-r--r--src/libgit2/streams/registry.h (renamed from src/streams/registry.h)0
-rw-r--r--src/libgit2/streams/socket.c (renamed from src/streams/socket.c)0
-rw-r--r--src/libgit2/streams/socket.h (renamed from src/streams/socket.h)0
-rw-r--r--src/libgit2/streams/stransport.c (renamed from src/streams/stransport.c)0
-rw-r--r--src/libgit2/streams/stransport.h (renamed from src/streams/stransport.h)0
-rw-r--r--src/libgit2/streams/tls.c (renamed from src/streams/tls.c)0
-rw-r--r--src/libgit2/streams/tls.h (renamed from src/streams/tls.h)0
-rw-r--r--src/libgit2/submodule.c (renamed from src/submodule.c)0
-rw-r--r--src/libgit2/submodule.h (renamed from src/submodule.h)0
-rw-r--r--src/libgit2/sysdir.c (renamed from src/sysdir.c)0
-rw-r--r--src/libgit2/sysdir.h (renamed from src/sysdir.h)0
-rw-r--r--src/libgit2/tag.c (renamed from src/tag.c)0
-rw-r--r--src/libgit2/tag.h (renamed from src/tag.h)0
-rw-r--r--src/libgit2/threadstate.c (renamed from src/threadstate.c)0
-rw-r--r--src/libgit2/threadstate.h (renamed from src/threadstate.h)0
-rw-r--r--src/libgit2/trace.c (renamed from src/trace.c)0
-rw-r--r--src/libgit2/trace.h (renamed from src/trace.h)0
-rw-r--r--src/libgit2/trailer.c (renamed from src/trailer.c)0
-rw-r--r--src/libgit2/transaction.c (renamed from src/transaction.c)0
-rw-r--r--src/libgit2/transaction.h (renamed from src/transaction.h)0
-rw-r--r--src/libgit2/transport.c (renamed from src/transport.c)0
-rw-r--r--src/libgit2/transports/auth.c (renamed from src/transports/auth.c)0
-rw-r--r--src/libgit2/transports/auth.h (renamed from src/transports/auth.h)0
-rw-r--r--src/libgit2/transports/auth_negotiate.c (renamed from src/transports/auth_negotiate.c)0
-rw-r--r--src/libgit2/transports/auth_negotiate.h (renamed from src/transports/auth_negotiate.h)0
-rw-r--r--src/libgit2/transports/auth_ntlm.c (renamed from src/transports/auth_ntlm.c)0
-rw-r--r--src/libgit2/transports/auth_ntlm.h (renamed from src/transports/auth_ntlm.h)0
-rw-r--r--src/libgit2/transports/credential.c (renamed from src/transports/credential.c)0
-rw-r--r--src/libgit2/transports/credential_helpers.c (renamed from src/transports/credential_helpers.c)0
-rw-r--r--src/libgit2/transports/git.c (renamed from src/transports/git.c)0
-rw-r--r--src/libgit2/transports/http.c (renamed from src/transports/http.c)0
-rw-r--r--src/libgit2/transports/http.h (renamed from src/transports/http.h)0
-rw-r--r--src/libgit2/transports/httpclient.c (renamed from src/transports/httpclient.c)0
-rw-r--r--src/libgit2/transports/httpclient.h (renamed from src/transports/httpclient.h)0
-rw-r--r--src/libgit2/transports/local.c (renamed from src/transports/local.c)0
-rw-r--r--src/libgit2/transports/smart.c (renamed from src/transports/smart.c)0
-rw-r--r--src/libgit2/transports/smart.h (renamed from src/transports/smart.h)0
-rw-r--r--src/libgit2/transports/smart_pkt.c (renamed from src/transports/smart_pkt.c)0
-rw-r--r--src/libgit2/transports/smart_protocol.c (renamed from src/transports/smart_protocol.c)0
-rw-r--r--src/libgit2/transports/ssh.c (renamed from src/transports/ssh.c)0
-rw-r--r--src/libgit2/transports/ssh.h (renamed from src/transports/ssh.h)0
-rw-r--r--src/libgit2/transports/winhttp.c (renamed from src/transports/winhttp.c)0
-rw-r--r--src/libgit2/tree-cache.c (renamed from src/tree-cache.c)0
-rw-r--r--src/libgit2/tree-cache.h (renamed from src/tree-cache.h)0
-rw-r--r--src/libgit2/tree.c (renamed from src/tree.c)0
-rw-r--r--src/libgit2/tree.h (renamed from src/tree.h)0
-rw-r--r--src/libgit2/userdiff.h (renamed from src/userdiff.h)0
-rw-r--r--src/libgit2/worktree.c (renamed from src/worktree.c)0
-rw-r--r--src/libgit2/worktree.h (renamed from src/worktree.h)0
-rw-r--r--src/libgit2/xdiff/git-xdiff.h (renamed from src/xdiff/git-xdiff.h)0
-rw-r--r--src/libgit2/xdiff/xdiff.h (renamed from src/xdiff/xdiff.h)0
-rw-r--r--src/libgit2/xdiff/xdiffi.c (renamed from src/xdiff/xdiffi.c)0
-rw-r--r--src/libgit2/xdiff/xdiffi.h (renamed from src/xdiff/xdiffi.h)0
-rw-r--r--src/libgit2/xdiff/xemit.c (renamed from src/xdiff/xemit.c)0
-rw-r--r--src/libgit2/xdiff/xemit.h (renamed from src/xdiff/xemit.h)0
-rw-r--r--src/libgit2/xdiff/xhistogram.c (renamed from src/xdiff/xhistogram.c)0
-rw-r--r--src/libgit2/xdiff/xinclude.h (renamed from src/xdiff/xinclude.h)0
-rw-r--r--src/libgit2/xdiff/xmacros.h (renamed from src/xdiff/xmacros.h)0
-rw-r--r--src/libgit2/xdiff/xmerge.c (renamed from src/xdiff/xmerge.c)0
-rw-r--r--src/libgit2/xdiff/xpatience.c (renamed from src/xdiff/xpatience.c)0
-rw-r--r--src/libgit2/xdiff/xprepare.c (renamed from src/xdiff/xprepare.c)0
-rw-r--r--src/libgit2/xdiff/xprepare.h (renamed from src/xdiff/xprepare.h)0
-rw-r--r--src/libgit2/xdiff/xtypes.h (renamed from src/xdiff/xtypes.h)0
-rw-r--r--src/libgit2/xdiff/xutils.c (renamed from src/xdiff/xutils.c)0
-rw-r--r--src/libgit2/xdiff/xutils.h (renamed from src/xdiff/xutils.h)0
-rw-r--r--src/util/CMakeLists.txt60
-rw-r--r--src/util/alloc.c (renamed from src/alloc.c)0
-rw-r--r--src/util/alloc.h (renamed from src/alloc.h)0
-rw-r--r--src/util/allocators/failalloc.c (renamed from src/allocators/failalloc.c)0
-rw-r--r--src/util/allocators/failalloc.h (renamed from src/allocators/failalloc.h)2
-rw-r--r--src/util/allocators/stdalloc.c (renamed from src/allocators/stdalloc.c)0
-rw-r--r--src/util/allocators/stdalloc.h (renamed from src/allocators/stdalloc.h)2
-rw-r--r--src/util/allocators/win32_leakcheck.c (renamed from src/allocators/win32_leakcheck.c)0
-rw-r--r--src/util/allocators/win32_leakcheck.h (renamed from src/allocators/win32_leakcheck.h)2
-rw-r--r--src/util/array.h (renamed from src/array.h)2
-rw-r--r--src/util/assert_safe.h (renamed from src/assert_safe.h)0
-rw-r--r--src/util/bitvec.h (renamed from src/bitvec.h)0
-rw-r--r--src/util/cc-compat.h (renamed from src/cc-compat.h)0
-rw-r--r--src/util/date.c (renamed from src/date.c)7
-rw-r--r--src/util/date.h (renamed from src/date.h)0
-rw-r--r--src/util/filebuf.c (renamed from src/filebuf.c)2
-rw-r--r--src/util/filebuf.h (renamed from src/filebuf.h)2
-rw-r--r--src/util/fs_path.c (renamed from src/fs_path.c)18
-rw-r--r--src/util/fs_path.h (renamed from src/fs_path.h)2
-rw-r--r--src/util/futils.c (renamed from src/futils.c)46
-rw-r--r--src/util/futils.h (renamed from src/futils.h)3
-rw-r--r--src/util/git2_util.h (renamed from src/common.h)72
-rw-r--r--src/util/hash.c (renamed from src/hash.c)0
-rw-r--r--src/util/hash.h (renamed from src/hash.h)2
-rw-r--r--src/util/hash/sha1.h (renamed from src/hash/sha1.h)2
-rw-r--r--src/util/hash/sha1/collisiondetect.c (renamed from src/hash/sha1/collisiondetect.c)0
-rw-r--r--src/util/hash/sha1/collisiondetect.h (renamed from src/hash/sha1/collisiondetect.h)0
-rw-r--r--src/util/hash/sha1/common_crypto.c (renamed from src/hash/sha1/common_crypto.c)0
-rw-r--r--src/util/hash/sha1/common_crypto.h (renamed from src/hash/sha1/common_crypto.h)0
-rw-r--r--src/util/hash/sha1/generic.c (renamed from src/hash/sha1/generic.c)0
-rw-r--r--src/util/hash/sha1/generic.h (renamed from src/hash/sha1/generic.h)0
-rw-r--r--src/util/hash/sha1/mbedtls.c (renamed from src/hash/sha1/mbedtls.c)0
-rw-r--r--src/util/hash/sha1/mbedtls.h (renamed from src/hash/sha1/mbedtls.h)0
-rw-r--r--src/util/hash/sha1/openssl.c (renamed from src/hash/sha1/openssl.c)0
-rw-r--r--src/util/hash/sha1/openssl.h (renamed from src/hash/sha1/openssl.h)0
-rw-r--r--src/util/hash/sha1/sha1dc/sha1.c (renamed from src/hash/sha1/sha1dc/sha1.c)0
-rw-r--r--src/util/hash/sha1/sha1dc/sha1.h (renamed from src/hash/sha1/sha1dc/sha1.h)0
-rw-r--r--src/util/hash/sha1/sha1dc/ubc_check.c (renamed from src/hash/sha1/sha1dc/ubc_check.c)0
-rw-r--r--src/util/hash/sha1/sha1dc/ubc_check.h (renamed from src/hash/sha1/sha1dc/ubc_check.h)0
-rw-r--r--src/util/hash/sha1/win32.c (renamed from src/hash/sha1/win32.c)0
-rw-r--r--src/util/hash/sha1/win32.h (renamed from src/hash/sha1/win32.h)0
-rw-r--r--src/util/integer.h (renamed from src/integer.h)0
-rw-r--r--src/util/khash.h (renamed from src/khash.h)0
-rw-r--r--src/util/map.h (renamed from src/map.h)2
-rw-r--r--src/util/net.c (renamed from src/net.c)1
-rw-r--r--src/util/net.h (renamed from src/net.h)2
-rw-r--r--src/util/pool.c (renamed from src/pool.c)0
-rw-r--r--src/util/pool.h (renamed from src/pool.h)2
-rw-r--r--src/util/posix.c (renamed from src/posix.c)0
-rw-r--r--src/util/posix.h (renamed from src/posix.h)2
-rw-r--r--src/util/pqueue.c (renamed from src/pqueue.c)0
-rw-r--r--src/util/pqueue.h (renamed from src/pqueue.h)2
-rw-r--r--src/util/rand.c (renamed from src/rand.c)2
-rw-r--r--src/util/rand.h (renamed from src/rand.h)2
-rw-r--r--src/util/regexp.c (renamed from src/regexp.c)0
-rw-r--r--src/util/regexp.h (renamed from src/regexp.h)2
-rw-r--r--src/util/runtime.c (renamed from src/runtime.c)2
-rw-r--r--src/util/runtime.h (renamed from src/runtime.h)2
-rw-r--r--src/util/sortedcache.c (renamed from src/sortedcache.c)0
-rw-r--r--src/util/sortedcache.h (renamed from src/sortedcache.h)2
-rw-r--r--src/util/str.c (renamed from src/str.c)0
-rw-r--r--src/util/str.h (renamed from src/str.h)2
-rw-r--r--src/util/strmap.c (renamed from src/strmap.c)0
-rw-r--r--src/util/strmap.h (renamed from src/strmap.h)2
-rw-r--r--src/util/strnlen.h (renamed from src/strnlen.h)0
-rw-r--r--src/util/thread.c (renamed from src/thread.c)2
-rw-r--r--src/util/thread.h (renamed from src/thread.h)0
-rw-r--r--src/util/tsort.c (renamed from src/tsort.c)2
-rw-r--r--src/util/unix/map.c (renamed from src/unix/map.c)2
-rw-r--r--src/util/unix/posix.h (renamed from src/unix/posix.h)2
-rw-r--r--src/util/unix/pthread.h (renamed from src/unix/pthread.h)0
-rw-r--r--src/util/unix/realpath.c (renamed from src/unix/realpath.c)2
-rw-r--r--src/util/utf8.c (renamed from src/utf8.c)2
-rw-r--r--src/util/utf8.h (renamed from src/utf8.h)2
-rw-r--r--src/util/util.c (renamed from src/util.c)2
-rw-r--r--src/util/util.h (renamed from src/util.h)2
-rw-r--r--src/util/varint.c (renamed from src/varint.c)0
-rw-r--r--src/util/varint.h (renamed from src/varint.h)2
-rw-r--r--src/util/vector.c (renamed from src/vector.c)0
-rw-r--r--src/util/vector.h (renamed from src/vector.h)2
-rw-r--r--src/util/wildmatch.c (renamed from src/wildmatch.c)0
-rw-r--r--src/util/wildmatch.h (renamed from src/wildmatch.h)2
-rw-r--r--src/util/win32/dir.c (renamed from src/win32/dir.c)0
-rw-r--r--src/util/win32/dir.h (renamed from src/win32/dir.h)2
-rw-r--r--src/util/win32/error.c (renamed from src/win32/error.c)0
-rw-r--r--src/util/win32/error.h (renamed from src/win32/error.h)2
-rw-r--r--src/util/win32/findfile.c (renamed from src/win32/findfile.c)0
-rw-r--r--src/util/win32/findfile.h (renamed from src/win32/findfile.h)2
-rw-r--r--src/util/win32/map.c (renamed from src/win32/map.c)2
-rw-r--r--src/util/win32/mingw-compat.h (renamed from src/win32/mingw-compat.h)0
-rw-r--r--src/util/win32/msvc-compat.h (renamed from src/win32/msvc-compat.h)0
-rw-r--r--src/util/win32/path_w32.c (renamed from src/win32/path_w32.c)0
-rw-r--r--src/util/win32/path_w32.h (renamed from src/win32/path_w32.h)2
-rw-r--r--src/util/win32/posix.h (renamed from src/win32/posix.h)2
-rw-r--r--src/util/win32/posix_w32.c (renamed from src/win32/posix_w32.c)2
-rw-r--r--src/util/win32/precompiled.c (renamed from tests/precompiled.c)0
-rw-r--r--src/util/win32/precompiled.h (renamed from src/win32/precompiled.h)2
-rw-r--r--src/util/win32/reparse.h (renamed from src/win32/reparse.h)0
-rw-r--r--src/util/win32/thread.c (renamed from src/win32/thread.c)0
-rw-r--r--src/util/win32/thread.h (renamed from src/win32/thread.h)2
-rw-r--r--src/util/win32/utf-conv.c (renamed from src/win32/utf-conv.c)0
-rw-r--r--src/util/win32/utf-conv.h (renamed from src/win32/utf-conv.h)2
-rw-r--r--src/util/win32/version.h (renamed from src/win32/version.h)0
-rw-r--r--src/util/win32/w32_buffer.c (renamed from src/win32/w32_buffer.c)0
-rw-r--r--src/util/win32/w32_buffer.h (renamed from src/win32/w32_buffer.h)2
-rw-r--r--src/util/win32/w32_common.h (renamed from src/win32/w32_common.h)0
-rw-r--r--src/util/win32/w32_leakcheck.c (renamed from src/win32/w32_leakcheck.c)0
-rw-r--r--src/util/win32/w32_leakcheck.h (renamed from src/win32/w32_leakcheck.h)2
-rw-r--r--src/util/win32/w32_util.c (renamed from src/win32/w32_util.c)0
-rw-r--r--src/util/win32/w32_util.h (renamed from src/win32/w32_util.h)2
-rw-r--r--src/util/win32/win32-compat.h (renamed from src/win32/win32-compat.h)0
-rw-r--r--src/util/zstream.c (renamed from src/zstream.c)0
-rw-r--r--src/util/zstream.h (renamed from src/zstream.h)2
-rw-r--r--tests/CMakeLists.txt100
-rw-r--r--tests/README.md89
-rw-r--r--tests/clar/clar.c (renamed from tests/clar.c)0
-rw-r--r--tests/clar/clar.h (renamed from tests/clar.h)0
-rw-r--r--tests/clar/clar/fixtures.h (renamed from tests/clar/fixtures.h)0
-rw-r--r--tests/clar/clar/fs.h (renamed from tests/clar/fs.h)0
-rw-r--r--tests/clar/clar/print.h (renamed from tests/clar/print.h)0
-rw-r--r--tests/clar/clar/sandbox.h (renamed from tests/clar/sandbox.h)0
-rw-r--r--tests/clar/clar/summary.h (renamed from tests/clar/summary.h)0
-rw-r--r--tests/clar/clar_libgit2.c (renamed from tests/clar_libgit2.c)0
-rw-r--r--tests/clar/clar_libgit2.h (renamed from tests/clar_libgit2.h)0
-rw-r--r--tests/clar/clar_libgit2_timer.c (renamed from tests/clar_libgit2_timer.c)0
-rw-r--r--tests/clar/clar_libgit2_timer.h (renamed from tests/clar_libgit2_timer.h)0
-rw-r--r--tests/clar/clar_libgit2_trace.c (renamed from tests/clar_libgit2_trace.c)0
-rw-r--r--tests/clar/clar_libgit2_trace.h (renamed from tests/clar_libgit2_trace.h)0
-rw-r--r--tests/clar/generate.py (renamed from tests/generate.py)0
-rw-r--r--tests/clar/main.c (renamed from tests/main.c)0
-rw-r--r--tests/headertest/CMakeLists.txt14
-rw-r--r--tests/headertest/headertest.c (renamed from tests/headertest.c)0
-rw-r--r--tests/libgit2/CMakeLists.txt75
-rw-r--r--tests/libgit2/apply/apply_helpers.c (renamed from tests/apply/apply_helpers.c)0
-rw-r--r--tests/libgit2/apply/apply_helpers.h (renamed from tests/apply/apply_helpers.h)0
-rw-r--r--tests/libgit2/apply/both.c (renamed from tests/apply/both.c)0
-rw-r--r--tests/libgit2/apply/callbacks.c (renamed from tests/apply/callbacks.c)0
-rw-r--r--tests/libgit2/apply/check.c (renamed from tests/apply/check.c)0
-rw-r--r--tests/libgit2/apply/fromdiff.c (renamed from tests/apply/fromdiff.c)0
-rw-r--r--tests/libgit2/apply/fromfile.c (renamed from tests/apply/fromfile.c)0
-rw-r--r--tests/libgit2/apply/index.c (renamed from tests/apply/index.c)0
-rw-r--r--tests/libgit2/apply/partial.c (renamed from tests/apply/partial.c)0
-rw-r--r--tests/libgit2/apply/tree.c (renamed from tests/apply/tree.c)0
-rw-r--r--tests/libgit2/apply/workdir.c (renamed from tests/apply/workdir.c)0
-rw-r--r--tests/libgit2/attr/attr_expect.h (renamed from tests/attr/attr_expect.h)0
-rw-r--r--tests/libgit2/attr/file.c (renamed from tests/attr/file.c)0
-rw-r--r--tests/libgit2/attr/flags.c (renamed from tests/attr/flags.c)0
-rw-r--r--tests/libgit2/attr/lookup.c (renamed from tests/attr/lookup.c)0
-rw-r--r--tests/libgit2/attr/macro.c (renamed from tests/attr/macro.c)0
-rw-r--r--tests/libgit2/attr/repo.c (renamed from tests/attr/repo.c)0
-rw-r--r--tests/libgit2/blame/blame_helpers.c (renamed from tests/blame/blame_helpers.c)0
-rw-r--r--tests/libgit2/blame/blame_helpers.h (renamed from tests/blame/blame_helpers.h)0
-rw-r--r--tests/libgit2/blame/buffer.c (renamed from tests/blame/buffer.c)0
-rw-r--r--tests/libgit2/blame/getters.c (renamed from tests/blame/getters.c)0
-rw-r--r--tests/libgit2/blame/harder.c (renamed from tests/blame/harder.c)0
-rw-r--r--tests/libgit2/blame/simple.c (renamed from tests/blame/simple.c)0
-rw-r--r--tests/libgit2/checkout/binaryunicode.c (renamed from tests/checkout/binaryunicode.c)0
-rw-r--r--tests/libgit2/checkout/checkout_helpers.c (renamed from tests/checkout/checkout_helpers.c)0
-rw-r--r--tests/libgit2/checkout/checkout_helpers.h (renamed from tests/checkout/checkout_helpers.h)0
-rw-r--r--tests/libgit2/checkout/conflict.c (renamed from tests/checkout/conflict.c)0
-rw-r--r--tests/libgit2/checkout/crlf.c (renamed from tests/checkout/crlf.c)0
-rw-r--r--tests/libgit2/checkout/head.c (renamed from tests/checkout/head.c)0
-rw-r--r--tests/libgit2/checkout/icase.c (renamed from tests/checkout/icase.c)0
-rw-r--r--tests/libgit2/checkout/index.c (renamed from tests/checkout/index.c)0
-rw-r--r--tests/libgit2/checkout/nasty.c (renamed from tests/checkout/nasty.c)0
-rw-r--r--tests/libgit2/checkout/tree.c (renamed from tests/checkout/tree.c)0
-rw-r--r--tests/libgit2/checkout/typechange.c (renamed from tests/checkout/typechange.c)0
-rw-r--r--tests/libgit2/cherrypick/bare.c (renamed from tests/cherrypick/bare.c)0
-rw-r--r--tests/libgit2/cherrypick/workdir.c (renamed from tests/cherrypick/workdir.c)0
-rw-r--r--tests/libgit2/clone/empty.c (renamed from tests/clone/empty.c)0
-rw-r--r--tests/libgit2/clone/local.c (renamed from tests/clone/local.c)0
-rw-r--r--tests/libgit2/clone/nonetwork.c (renamed from tests/clone/nonetwork.c)0
-rw-r--r--tests/libgit2/clone/transport.c (renamed from tests/clone/transport.c)0
-rw-r--r--tests/libgit2/commit/commit.c (renamed from tests/commit/commit.c)0
-rw-r--r--tests/libgit2/commit/parent.c (renamed from tests/commit/parent.c)0
-rw-r--r--tests/libgit2/commit/parse.c (renamed from tests/commit/parse.c)0
-rw-r--r--tests/libgit2/commit/signature.c (renamed from tests/commit/signature.c)0
-rw-r--r--tests/libgit2/commit/write.c (renamed from tests/commit/write.c)0
-rw-r--r--tests/libgit2/config/add.c (renamed from tests/config/add.c)0
-rw-r--r--tests/libgit2/config/backend.c (renamed from tests/config/backend.c)0
-rw-r--r--tests/libgit2/config/conditionals.c (renamed from tests/config/conditionals.c)0
-rw-r--r--tests/libgit2/config/config_helpers.c (renamed from tests/config/config_helpers.c)0
-rw-r--r--tests/libgit2/config/config_helpers.h (renamed from tests/config/config_helpers.h)0
-rw-r--r--tests/libgit2/config/configlevel.c (renamed from tests/config/configlevel.c)0
-rw-r--r--tests/libgit2/config/global.c (renamed from tests/config/global.c)0
-rw-r--r--tests/libgit2/config/include.c (renamed from tests/config/include.c)0
-rw-r--r--tests/libgit2/config/memory.c (renamed from tests/config/memory.c)0
-rw-r--r--tests/libgit2/config/multivar.c (renamed from tests/config/multivar.c)0
-rw-r--r--tests/libgit2/config/new.c (renamed from tests/config/new.c)0
-rw-r--r--tests/libgit2/config/read.c (renamed from tests/config/read.c)0
-rw-r--r--tests/libgit2/config/readonly.c (renamed from tests/config/readonly.c)0
-rw-r--r--tests/libgit2/config/rename.c (renamed from tests/config/rename.c)0
-rw-r--r--tests/libgit2/config/snapshot.c (renamed from tests/config/snapshot.c)0
-rw-r--r--tests/libgit2/config/stress.c (renamed from tests/config/stress.c)0
-rw-r--r--tests/libgit2/config/validkeyname.c (renamed from tests/config/validkeyname.c)0
-rw-r--r--tests/libgit2/config/write.c (renamed from tests/config/write.c)0
-rw-r--r--tests/libgit2/core/buf.c (renamed from tests/core/buf.c)0
-rw-r--r--tests/libgit2/core/env.c (renamed from tests/core/env.c)0
-rw-r--r--tests/libgit2/core/features.c (renamed from tests/core/features.c)0
-rw-r--r--tests/libgit2/core/hashsig.c182
-rw-r--r--tests/libgit2/core/oid.c (renamed from tests/core/oid.c)0
-rw-r--r--tests/libgit2/core/oidmap.c (renamed from tests/core/oidmap.c)0
-rw-r--r--tests/libgit2/core/opts.c (renamed from tests/core/opts.c)0
-rw-r--r--tests/libgit2/core/pool.c33
-rw-r--r--tests/libgit2/core/structinit.c (renamed from tests/core/structinit.c)0
-rw-r--r--tests/libgit2/core/useragent.c (renamed from tests/core/useragent.c)0
-rw-r--r--tests/libgit2/date/date.c (renamed from tests/date/date.c)0
-rw-r--r--tests/libgit2/date/rfc2822.c (renamed from tests/date/rfc2822.c)0
-rw-r--r--tests/libgit2/delta/apply.c (renamed from tests/delta/apply.c)0
-rw-r--r--tests/libgit2/describe/describe.c (renamed from tests/describe/describe.c)0
-rw-r--r--tests/libgit2/describe/describe_helpers.c (renamed from tests/describe/describe_helpers.c)0
-rw-r--r--tests/libgit2/describe/describe_helpers.h (renamed from tests/describe/describe_helpers.h)0
-rw-r--r--tests/libgit2/describe/t6120.c (renamed from tests/describe/t6120.c)0
-rw-r--r--tests/libgit2/diff/binary.c (renamed from tests/diff/binary.c)0
-rw-r--r--tests/libgit2/diff/blob.c (renamed from tests/diff/blob.c)0
-rw-r--r--tests/libgit2/diff/diff_helpers.c (renamed from tests/diff/diff_helpers.c)0
-rw-r--r--tests/libgit2/diff/diff_helpers.h (renamed from tests/diff/diff_helpers.h)0
-rw-r--r--tests/libgit2/diff/diffiter.c (renamed from tests/diff/diffiter.c)0
-rw-r--r--tests/libgit2/diff/drivers.c (renamed from tests/diff/drivers.c)0
-rw-r--r--tests/libgit2/diff/externalmodifications.c (renamed from tests/diff/externalmodifications.c)0
-rw-r--r--tests/libgit2/diff/format_email.c (renamed from tests/diff/format_email.c)0
-rw-r--r--tests/libgit2/diff/index.c (renamed from tests/diff/index.c)0
-rw-r--r--tests/libgit2/diff/notify.c (renamed from tests/diff/notify.c)0
-rw-r--r--tests/libgit2/diff/parse.c (renamed from tests/diff/parse.c)0
-rw-r--r--tests/libgit2/diff/patch.c (renamed from tests/diff/patch.c)0
-rw-r--r--tests/libgit2/diff/patchid.c (renamed from tests/diff/patchid.c)0
-rw-r--r--tests/libgit2/diff/pathspec.c (renamed from tests/diff/pathspec.c)0
-rw-r--r--tests/libgit2/diff/racediffiter.c (renamed from tests/diff/racediffiter.c)0
-rw-r--r--tests/libgit2/diff/rename.c (renamed from tests/diff/rename.c)0
-rw-r--r--tests/libgit2/diff/stats.c (renamed from tests/diff/stats.c)0
-rw-r--r--tests/libgit2/diff/submodules.c (renamed from tests/diff/submodules.c)0
-rw-r--r--tests/libgit2/diff/tree.c (renamed from tests/diff/tree.c)0
-rw-r--r--tests/libgit2/diff/userdiff.c25
-rw-r--r--tests/libgit2/diff/workdir.c (renamed from tests/diff/workdir.c)0
-rw-r--r--tests/libgit2/email/create.c (renamed from tests/email/create.c)0
-rw-r--r--tests/libgit2/email/create.c.bak (renamed from tests/email/create.c.bak)0
-rw-r--r--tests/libgit2/fetch/local.c (renamed from tests/fetch/local.c)0
-rw-r--r--tests/libgit2/fetchhead/fetchhead_data.h (renamed from tests/fetchhead/fetchhead_data.h)0
-rw-r--r--tests/libgit2/fetchhead/nonetwork.c (renamed from tests/fetchhead/nonetwork.c)0
-rw-r--r--tests/libgit2/filter/bare.c (renamed from tests/filter/bare.c)0
-rw-r--r--tests/libgit2/filter/blob.c (renamed from tests/filter/blob.c)0
-rw-r--r--tests/libgit2/filter/crlf.c (renamed from tests/filter/crlf.c)0
-rw-r--r--tests/libgit2/filter/crlf.h (renamed from tests/filter/crlf.h)0
-rw-r--r--tests/libgit2/filter/custom.c (renamed from tests/filter/custom.c)0
-rw-r--r--tests/libgit2/filter/custom_helpers.c (renamed from tests/filter/custom_helpers.c)0
-rw-r--r--tests/libgit2/filter/custom_helpers.h (renamed from tests/filter/custom_helpers.h)0
-rw-r--r--tests/libgit2/filter/file.c (renamed from tests/filter/file.c)0
-rw-r--r--tests/libgit2/filter/ident.c (renamed from tests/filter/ident.c)0
-rw-r--r--tests/libgit2/filter/query.c (renamed from tests/filter/query.c)0
-rw-r--r--tests/libgit2/filter/stream.c (renamed from tests/filter/stream.c)0
-rw-r--r--tests/libgit2/filter/systemattrs.c (renamed from tests/filter/systemattrs.c)0
-rw-r--r--tests/libgit2/filter/wildcard.c (renamed from tests/filter/wildcard.c)0
-rw-r--r--tests/libgit2/graph/ahead_behind.c (renamed from tests/graph/ahead_behind.c)0
-rw-r--r--tests/libgit2/graph/commitgraph.c (renamed from tests/graph/commitgraph.c)0
-rw-r--r--tests/libgit2/graph/descendant_of.c (renamed from tests/graph/descendant_of.c)0
-rw-r--r--tests/libgit2/graph/reachable_from_any.c (renamed from tests/graph/reachable_from_any.c)0
-rw-r--r--tests/libgit2/ignore/path.c (renamed from tests/ignore/path.c)0
-rw-r--r--tests/libgit2/ignore/status.c (renamed from tests/ignore/status.c)0
-rw-r--r--tests/libgit2/index/add.c (renamed from tests/index/add.c)0
-rw-r--r--tests/libgit2/index/addall.c (renamed from tests/index/addall.c)0
-rw-r--r--tests/libgit2/index/bypath.c (renamed from tests/index/bypath.c)0
-rw-r--r--tests/libgit2/index/cache.c (renamed from tests/index/cache.c)0
-rw-r--r--tests/libgit2/index/collision.c (renamed from tests/index/collision.c)0
-rw-r--r--tests/libgit2/index/conflicts.c (renamed from tests/index/conflicts.c)0
-rw-r--r--tests/libgit2/index/conflicts.h (renamed from tests/index/conflicts.h)0
-rw-r--r--tests/libgit2/index/crlf.c (renamed from tests/index/crlf.c)0
-rw-r--r--tests/libgit2/index/filemodes.c (renamed from tests/index/filemodes.c)0
-rw-r--r--tests/libgit2/index/inmemory.c (renamed from tests/index/inmemory.c)0
-rw-r--r--tests/libgit2/index/names.c (renamed from tests/index/names.c)0
-rw-r--r--tests/libgit2/index/nsec.c (renamed from tests/index/nsec.c)0
-rw-r--r--tests/libgit2/index/racy.c (renamed from tests/index/racy.c)0
-rw-r--r--tests/libgit2/index/read_index.c (renamed from tests/index/read_index.c)0
-rw-r--r--tests/libgit2/index/read_tree.c (renamed from tests/index/read_tree.c)0
-rw-r--r--tests/libgit2/index/rename.c (renamed from tests/index/rename.c)0
-rw-r--r--tests/libgit2/index/reuc.c (renamed from tests/index/reuc.c)0
-rw-r--r--tests/libgit2/index/splitindex.c (renamed from tests/index/splitindex.c)0
-rw-r--r--tests/libgit2/index/stage.c (renamed from tests/index/stage.c)0
-rw-r--r--tests/libgit2/index/tests.c (renamed from tests/index/tests.c)0
-rw-r--r--tests/libgit2/index/version.c (renamed from tests/index/version.c)0
-rw-r--r--tests/libgit2/iterator/index.c (renamed from tests/iterator/index.c)0
-rw-r--r--tests/libgit2/iterator/iterator_helpers.c (renamed from tests/iterator/iterator_helpers.c)0
-rw-r--r--tests/libgit2/iterator/iterator_helpers.h (renamed from tests/iterator/iterator_helpers.h)0
-rw-r--r--tests/libgit2/iterator/tree.c (renamed from tests/iterator/tree.c)0
-rw-r--r--tests/libgit2/iterator/workdir.c (renamed from tests/iterator/workdir.c)0
-rw-r--r--tests/libgit2/mailmap/basic.c (renamed from tests/mailmap/basic.c)0
-rw-r--r--tests/libgit2/mailmap/blame.c (renamed from tests/mailmap/blame.c)0
-rw-r--r--tests/libgit2/mailmap/mailmap_testdata.h (renamed from tests/mailmap/mailmap_testdata.h)0
-rw-r--r--tests/libgit2/mailmap/parsing.c (renamed from tests/mailmap/parsing.c)0
-rw-r--r--tests/libgit2/merge/analysis.c (renamed from tests/merge/analysis.c)0
-rw-r--r--tests/libgit2/merge/annotated_commit.c (renamed from tests/merge/annotated_commit.c)0
-rw-r--r--tests/libgit2/merge/conflict_data.h (renamed from tests/merge/conflict_data.h)0
-rw-r--r--tests/libgit2/merge/driver.c (renamed from tests/merge/driver.c)0
-rw-r--r--tests/libgit2/merge/files.c (renamed from tests/merge/files.c)0
-rw-r--r--tests/libgit2/merge/merge_helpers.c (renamed from tests/merge/merge_helpers.c)0
-rw-r--r--tests/libgit2/merge/merge_helpers.h (renamed from tests/merge/merge_helpers.h)0
-rw-r--r--tests/libgit2/merge/trees/automerge.c (renamed from tests/merge/trees/automerge.c)0
-rw-r--r--tests/libgit2/merge/trees/commits.c (renamed from tests/merge/trees/commits.c)0
-rw-r--r--tests/libgit2/merge/trees/modeconflict.c (renamed from tests/merge/trees/modeconflict.c)0
-rw-r--r--tests/libgit2/merge/trees/recursive.c (renamed from tests/merge/trees/recursive.c)0
-rw-r--r--tests/libgit2/merge/trees/renames.c (renamed from tests/merge/trees/renames.c)0
-rw-r--r--tests/libgit2/merge/trees/treediff.c (renamed from tests/merge/trees/treediff.c)0
-rw-r--r--tests/libgit2/merge/trees/trivial.c (renamed from tests/merge/trees/trivial.c)0
-rw-r--r--tests/libgit2/merge/trees/whitespace.c (renamed from tests/merge/trees/whitespace.c)0
-rw-r--r--tests/libgit2/merge/workdir/dirty.c (renamed from tests/merge/workdir/dirty.c)0
-rw-r--r--tests/libgit2/merge/workdir/recursive.c (renamed from tests/merge/workdir/recursive.c)0
-rw-r--r--tests/libgit2/merge/workdir/renames.c (renamed from tests/merge/workdir/renames.c)0
-rw-r--r--tests/libgit2/merge/workdir/setup.c (renamed from tests/merge/workdir/setup.c)0
-rw-r--r--tests/libgit2/merge/workdir/simple.c (renamed from tests/merge/workdir/simple.c)0
-rw-r--r--tests/libgit2/merge/workdir/submodules.c (renamed from tests/merge/workdir/submodules.c)0
-rw-r--r--tests/libgit2/merge/workdir/trivial.c (renamed from tests/merge/workdir/trivial.c)0
-rw-r--r--tests/libgit2/message/trailer.c (renamed from tests/message/trailer.c)0
-rw-r--r--tests/libgit2/network/cred.c (renamed from tests/network/cred.c)0
-rw-r--r--tests/libgit2/network/fetchlocal.c (renamed from tests/network/fetchlocal.c)0
-rw-r--r--tests/libgit2/network/matchhost.c (renamed from tests/network/matchhost.c)0
-rw-r--r--tests/libgit2/network/refspecs.c (renamed from tests/network/refspecs.c)0
-rw-r--r--tests/libgit2/network/remote/defaultbranch.c (renamed from tests/network/remote/defaultbranch.c)0
-rw-r--r--tests/libgit2/network/remote/delete.c (renamed from tests/network/remote/delete.c)0
-rw-r--r--tests/libgit2/network/remote/isvalidname.c (renamed from tests/network/remote/isvalidname.c)0
-rw-r--r--tests/libgit2/network/remote/local.c (renamed from tests/network/remote/local.c)0
-rw-r--r--tests/libgit2/network/remote/push.c (renamed from tests/network/remote/push.c)0
-rw-r--r--tests/libgit2/network/remote/remotes.c (renamed from tests/network/remote/remotes.c)0
-rw-r--r--tests/libgit2/network/remote/rename.c (renamed from tests/network/remote/rename.c)0
-rw-r--r--tests/libgit2/network/url/joinpath.c (renamed from tests/network/url/joinpath.c)0
-rw-r--r--tests/libgit2/network/url/parse.c (renamed from tests/network/url/parse.c)0
-rw-r--r--tests/libgit2/network/url/pattern.c (renamed from tests/network/url/pattern.c)0
-rw-r--r--tests/libgit2/network/url/redirect.c (renamed from tests/network/url/redirect.c)0
-rw-r--r--tests/libgit2/network/url/scp.c (renamed from tests/network/url/scp.c)0
-rw-r--r--tests/libgit2/network/url/valid.c (renamed from tests/network/url/valid.c)0
-rw-r--r--tests/libgit2/notes/notes.c (renamed from tests/notes/notes.c)0
-rw-r--r--tests/libgit2/notes/notesref.c (renamed from tests/notes/notesref.c)0
-rw-r--r--tests/libgit2/object/blob/filter.c (renamed from tests/object/blob/filter.c)0
-rw-r--r--tests/libgit2/object/blob/fromstream.c (renamed from tests/object/blob/fromstream.c)0
-rw-r--r--tests/libgit2/object/blob/write.c (renamed from tests/object/blob/write.c)0
-rw-r--r--tests/libgit2/object/cache.c (renamed from tests/object/cache.c)0
-rw-r--r--tests/libgit2/object/commit/commitstagedfile.c (renamed from tests/object/commit/commitstagedfile.c)0
-rw-r--r--tests/libgit2/object/commit/parse.c (renamed from tests/object/commit/parse.c)0
-rw-r--r--tests/libgit2/object/lookup.c (renamed from tests/object/lookup.c)0
-rw-r--r--tests/libgit2/object/lookupbypath.c (renamed from tests/object/lookupbypath.c)0
-rw-r--r--tests/libgit2/object/message.c (renamed from tests/object/message.c)0
-rw-r--r--tests/libgit2/object/peel.c (renamed from tests/object/peel.c)0
-rw-r--r--tests/libgit2/object/raw/chars.c (renamed from tests/object/raw/chars.c)0
-rw-r--r--tests/libgit2/object/raw/compare.c (renamed from tests/object/raw/compare.c)0
-rw-r--r--tests/libgit2/object/raw/convert.c (renamed from tests/object/raw/convert.c)0
-rw-r--r--tests/libgit2/object/raw/data.h (renamed from tests/object/raw/data.h)0
-rw-r--r--tests/libgit2/object/raw/fromstr.c (renamed from tests/object/raw/fromstr.c)0
-rw-r--r--tests/libgit2/object/raw/hash.c (renamed from tests/object/raw/hash.c)0
-rw-r--r--tests/libgit2/object/raw/short.c (renamed from tests/object/raw/short.c)0
-rw-r--r--tests/libgit2/object/raw/size.c (renamed from tests/object/raw/size.c)0
-rw-r--r--tests/libgit2/object/raw/type2string.c (renamed from tests/object/raw/type2string.c)0
-rw-r--r--tests/libgit2/object/raw/write.c (renamed from tests/object/raw/write.c)0
-rw-r--r--tests/libgit2/object/shortid.c (renamed from tests/object/shortid.c)0
-rw-r--r--tests/libgit2/object/tag/list.c (renamed from tests/object/tag/list.c)0
-rw-r--r--tests/libgit2/object/tag/parse.c (renamed from tests/object/tag/parse.c)0
-rw-r--r--tests/libgit2/object/tag/peel.c (renamed from tests/object/tag/peel.c)0
-rw-r--r--tests/libgit2/object/tag/read.c (renamed from tests/object/tag/read.c)0
-rw-r--r--tests/libgit2/object/tag/write.c (renamed from tests/object/tag/write.c)0
-rw-r--r--tests/libgit2/object/tree/attributes.c (renamed from tests/object/tree/attributes.c)0
-rw-r--r--tests/libgit2/object/tree/duplicateentries.c (renamed from tests/object/tree/duplicateentries.c)0
-rw-r--r--tests/libgit2/object/tree/frompath.c (renamed from tests/object/tree/frompath.c)0
-rw-r--r--tests/libgit2/object/tree/parse.c (renamed from tests/object/tree/parse.c)0
-rw-r--r--tests/libgit2/object/tree/read.c (renamed from tests/object/tree/read.c)0
-rw-r--r--tests/libgit2/object/tree/update.c (renamed from tests/object/tree/update.c)0
-rw-r--r--tests/libgit2/object/tree/walk.c (renamed from tests/object/tree/walk.c)0
-rw-r--r--tests/libgit2/object/tree/write.c (renamed from tests/object/tree/write.c)0
-rw-r--r--tests/libgit2/object/validate.c (renamed from tests/object/validate.c)0
-rw-r--r--tests/libgit2/odb/alternates.c (renamed from tests/odb/alternates.c)0
-rw-r--r--tests/libgit2/odb/backend/backend_helpers.c (renamed from tests/odb/backend/backend_helpers.c)0
-rw-r--r--tests/libgit2/odb/backend/backend_helpers.h (renamed from tests/odb/backend/backend_helpers.h)0
-rw-r--r--tests/libgit2/odb/backend/mempack.c (renamed from tests/odb/backend/mempack.c)0
-rw-r--r--tests/libgit2/odb/backend/multiple.c (renamed from tests/odb/backend/multiple.c)0
-rw-r--r--tests/libgit2/odb/backend/nobackend.c (renamed from tests/odb/backend/nobackend.c)0
-rw-r--r--tests/libgit2/odb/backend/nonrefreshing.c (renamed from tests/odb/backend/nonrefreshing.c)0
-rw-r--r--tests/libgit2/odb/backend/refreshing.c (renamed from tests/odb/backend/refreshing.c)0
-rw-r--r--tests/libgit2/odb/backend/simple.c (renamed from tests/odb/backend/simple.c)0
-rw-r--r--tests/libgit2/odb/emptyobjects.c (renamed from tests/odb/emptyobjects.c)0
-rw-r--r--tests/libgit2/odb/foreach.c (renamed from tests/odb/foreach.c)0
-rw-r--r--tests/libgit2/odb/freshen.c (renamed from tests/odb/freshen.c)0
-rw-r--r--tests/libgit2/odb/largefiles.c (renamed from tests/odb/largefiles.c)0
-rw-r--r--tests/libgit2/odb/loose.c (renamed from tests/odb/loose.c)0
-rw-r--r--tests/libgit2/odb/loose_data.h (renamed from tests/odb/loose_data.h)0
-rw-r--r--tests/libgit2/odb/mixed.c (renamed from tests/odb/mixed.c)0
-rw-r--r--tests/libgit2/odb/pack_data.h (renamed from tests/odb/pack_data.h)0
-rw-r--r--tests/libgit2/odb/pack_data_one.h (renamed from tests/odb/pack_data_one.h)0
-rw-r--r--tests/libgit2/odb/packed.c (renamed from tests/odb/packed.c)0
-rw-r--r--tests/libgit2/odb/packed_one.c (renamed from tests/odb/packed_one.c)0
-rw-r--r--tests/libgit2/odb/sorting.c (renamed from tests/odb/sorting.c)0
-rw-r--r--tests/libgit2/odb/streamwrite.c (renamed from tests/odb/streamwrite.c)0
-rw-r--r--tests/libgit2/online/badssl.c (renamed from tests/online/badssl.c)0
-rw-r--r--tests/libgit2/online/clone.c (renamed from tests/online/clone.c)0
-rw-r--r--tests/libgit2/online/customcert.c (renamed from tests/online/customcert.c)0
-rw-r--r--tests/libgit2/online/fetch.c (renamed from tests/online/fetch.c)0
-rw-r--r--tests/libgit2/online/fetchhead.c (renamed from tests/online/fetchhead.c)0
-rw-r--r--tests/libgit2/online/push.c (renamed from tests/online/push.c)0
-rw-r--r--tests/libgit2/online/push_util.c (renamed from tests/online/push_util.c)0
-rw-r--r--tests/libgit2/online/push_util.h (renamed from tests/online/push_util.h)0
-rw-r--r--tests/libgit2/online/remotes.c (renamed from tests/online/remotes.c)0
-rw-r--r--tests/libgit2/pack/filelimit.c (renamed from tests/pack/filelimit.c)0
-rw-r--r--tests/libgit2/pack/indexer.c (renamed from tests/pack/indexer.c)0
-rw-r--r--tests/libgit2/pack/midx.c (renamed from tests/pack/midx.c)0
-rw-r--r--tests/libgit2/pack/packbuilder.c (renamed from tests/pack/packbuilder.c)0
-rw-r--r--tests/libgit2/pack/sharing.c (renamed from tests/pack/sharing.c)0
-rw-r--r--tests/libgit2/pack/threadsafety.c (renamed from tests/pack/threadsafety.c)0
-rw-r--r--tests/libgit2/patch/parse.c (renamed from tests/patch/parse.c)0
-rw-r--r--tests/libgit2/patch/patch_common.h (renamed from tests/patch/patch_common.h)0
-rw-r--r--tests/libgit2/patch/print.c (renamed from tests/patch/print.c)0
-rw-r--r--tests/libgit2/path/validate.c63
-rw-r--r--tests/libgit2/perf/helper__perf__do_merge.c (renamed from tests/perf/helper__perf__do_merge.c)0
-rw-r--r--tests/libgit2/perf/helper__perf__do_merge.h (renamed from tests/perf/helper__perf__do_merge.h)0
-rw-r--r--tests/libgit2/perf/helper__perf__timer.c (renamed from tests/perf/helper__perf__timer.c)0
-rw-r--r--tests/libgit2/perf/helper__perf__timer.h (renamed from tests/perf/helper__perf__timer.h)0
-rw-r--r--tests/libgit2/perf/merge.c (renamed from tests/perf/merge.c)0
-rw-r--r--tests/libgit2/precompiled.c1
-rw-r--r--tests/libgit2/precompiled.h (renamed from tests/precompiled.h)0
-rw-r--r--tests/libgit2/rebase/abort.c (renamed from tests/rebase/abort.c)0
-rw-r--r--tests/libgit2/rebase/inmemory.c (renamed from tests/rebase/inmemory.c)0
-rw-r--r--tests/libgit2/rebase/iterator.c (renamed from tests/rebase/iterator.c)0
-rw-r--r--tests/libgit2/rebase/merge.c (renamed from tests/rebase/merge.c)0
-rw-r--r--tests/libgit2/rebase/setup.c (renamed from tests/rebase/setup.c)0
-rw-r--r--tests/libgit2/rebase/sign.c (renamed from tests/rebase/sign.c)0
-rw-r--r--tests/libgit2/rebase/submodule.c (renamed from tests/rebase/submodule.c)0
-rw-r--r--tests/libgit2/refs/basic.c (renamed from tests/refs/basic.c)0
-rw-r--r--tests/libgit2/refs/branches/checkedout.c (renamed from tests/refs/branches/checkedout.c)0
-rw-r--r--tests/libgit2/refs/branches/create.c (renamed from tests/refs/branches/create.c)0
-rw-r--r--tests/libgit2/refs/branches/delete.c (renamed from tests/refs/branches/delete.c)0
-rw-r--r--tests/libgit2/refs/branches/ishead.c (renamed from tests/refs/branches/ishead.c)0
-rw-r--r--tests/libgit2/refs/branches/iterator.c (renamed from tests/refs/branches/iterator.c)0
-rw-r--r--tests/libgit2/refs/branches/lookup.c (renamed from tests/refs/branches/lookup.c)0
-rw-r--r--tests/libgit2/refs/branches/move.c (renamed from tests/refs/branches/move.c)0
-rw-r--r--tests/libgit2/refs/branches/name.c (renamed from tests/refs/branches/name.c)0
-rw-r--r--tests/libgit2/refs/branches/remote.c (renamed from tests/refs/branches/remote.c)0
-rw-r--r--tests/libgit2/refs/branches/upstream.c (renamed from tests/refs/branches/upstream.c)0
-rw-r--r--tests/libgit2/refs/branches/upstreamname.c (renamed from tests/refs/branches/upstreamname.c)0
-rw-r--r--tests/libgit2/refs/crashes.c (renamed from tests/refs/crashes.c)0
-rw-r--r--tests/libgit2/refs/create.c (renamed from tests/refs/create.c)0
-rw-r--r--tests/libgit2/refs/delete.c (renamed from tests/refs/delete.c)0
-rw-r--r--tests/libgit2/refs/dup.c (renamed from tests/refs/dup.c)0
-rw-r--r--tests/libgit2/refs/foreachglob.c (renamed from tests/refs/foreachglob.c)0
-rw-r--r--tests/libgit2/refs/isvalidname.c (renamed from tests/refs/isvalidname.c)0
-rw-r--r--tests/libgit2/refs/iterator.c (renamed from tests/refs/iterator.c)0
-rw-r--r--tests/libgit2/refs/list.c (renamed from tests/refs/list.c)0
-rw-r--r--tests/libgit2/refs/listall.c (renamed from tests/refs/listall.c)0
-rw-r--r--tests/libgit2/refs/lookup.c (renamed from tests/refs/lookup.c)0
-rw-r--r--tests/libgit2/refs/namespaces.c (renamed from tests/refs/namespaces.c)0
-rw-r--r--tests/libgit2/refs/normalize.c (renamed from tests/refs/normalize.c)0
-rw-r--r--tests/libgit2/refs/overwrite.c (renamed from tests/refs/overwrite.c)0
-rw-r--r--tests/libgit2/refs/pack.c (renamed from tests/refs/pack.c)0
-rw-r--r--tests/libgit2/refs/peel.c (renamed from tests/refs/peel.c)0
-rw-r--r--tests/libgit2/refs/races.c (renamed from tests/refs/races.c)0
-rw-r--r--tests/libgit2/refs/read.c (renamed from tests/refs/read.c)0
-rw-r--r--tests/libgit2/refs/ref_helpers.c (renamed from tests/refs/ref_helpers.c)0
-rw-r--r--tests/libgit2/refs/ref_helpers.h (renamed from tests/refs/ref_helpers.h)0
-rw-r--r--tests/libgit2/refs/reflog/drop.c (renamed from tests/refs/reflog/drop.c)0
-rw-r--r--tests/libgit2/refs/reflog/messages.c (renamed from tests/refs/reflog/messages.c)0
-rw-r--r--tests/libgit2/refs/reflog/reflog.c (renamed from tests/refs/reflog/reflog.c)0
-rw-r--r--tests/libgit2/refs/reflog/reflog_helpers.c (renamed from tests/refs/reflog/reflog_helpers.c)0
-rw-r--r--tests/libgit2/refs/reflog/reflog_helpers.h (renamed from tests/refs/reflog/reflog_helpers.h)0
-rw-r--r--tests/libgit2/refs/rename.c (renamed from tests/refs/rename.c)0
-rw-r--r--tests/libgit2/refs/revparse.c (renamed from tests/refs/revparse.c)0
-rw-r--r--tests/libgit2/refs/setter.c (renamed from tests/refs/setter.c)0
-rw-r--r--tests/libgit2/refs/shorthand.c (renamed from tests/refs/shorthand.c)0
-rw-r--r--tests/libgit2/refs/tags/name.c (renamed from tests/refs/tags/name.c)0
-rw-r--r--tests/libgit2/refs/transactions.c (renamed from tests/refs/transactions.c)0
-rw-r--r--tests/libgit2/refs/unicode.c (renamed from tests/refs/unicode.c)0
-rw-r--r--tests/libgit2/refs/update.c (renamed from tests/refs/update.c)0
-rw-r--r--tests/libgit2/remote/create.c (renamed from tests/remote/create.c)0
-rw-r--r--tests/libgit2/remote/fetch.c (renamed from tests/remote/fetch.c)8
-rw-r--r--tests/libgit2/remote/httpproxy.c (renamed from tests/remote/httpproxy.c)0
-rw-r--r--tests/libgit2/remote/insteadof.c (renamed from tests/remote/insteadof.c)0
-rw-r--r--tests/libgit2/remote/list.c (renamed from tests/remote/list.c)0
-rw-r--r--tests/libgit2/repo/config.c (renamed from tests/repo/config.c)0
-rw-r--r--tests/libgit2/repo/discover.c (renamed from tests/repo/discover.c)0
-rw-r--r--tests/libgit2/repo/env.c (renamed from tests/repo/env.c)0
-rw-r--r--tests/libgit2/repo/extensions.c (renamed from tests/repo/extensions.c)0
-rw-r--r--tests/libgit2/repo/getters.c (renamed from tests/repo/getters.c)0
-rw-r--r--tests/libgit2/repo/hashfile.c (renamed from tests/repo/hashfile.c)0
-rw-r--r--tests/libgit2/repo/head.c (renamed from tests/repo/head.c)0
-rw-r--r--tests/libgit2/repo/headtree.c (renamed from tests/repo/headtree.c)0
-rw-r--r--tests/libgit2/repo/init.c (renamed from tests/repo/init.c)0
-rw-r--r--tests/libgit2/repo/message.c (renamed from tests/repo/message.c)0
-rw-r--r--tests/libgit2/repo/new.c (renamed from tests/repo/new.c)0
-rw-r--r--tests/libgit2/repo/open.c (renamed from tests/repo/open.c)0
-rw-r--r--tests/libgit2/repo/pathspec.c (renamed from tests/repo/pathspec.c)0
-rw-r--r--tests/libgit2/repo/repo_helpers.c (renamed from tests/repo/repo_helpers.c)0
-rw-r--r--tests/libgit2/repo/repo_helpers.h (renamed from tests/repo/repo_helpers.h)0
-rw-r--r--tests/libgit2/repo/reservedname.c (renamed from tests/repo/reservedname.c)0
-rw-r--r--tests/libgit2/repo/setters.c (renamed from tests/repo/setters.c)0
-rw-r--r--tests/libgit2/repo/shallow.c (renamed from tests/repo/shallow.c)0
-rw-r--r--tests/libgit2/repo/state.c (renamed from tests/repo/state.c)0
-rw-r--r--tests/libgit2/repo/template.c (renamed from tests/repo/template.c)0
-rw-r--r--tests/libgit2/reset/default.c (renamed from tests/reset/default.c)0
-rw-r--r--tests/libgit2/reset/hard.c (renamed from tests/reset/hard.c)0
-rw-r--r--tests/libgit2/reset/mixed.c (renamed from tests/reset/mixed.c)0
-rw-r--r--tests/libgit2/reset/reset_helpers.c (renamed from tests/reset/reset_helpers.c)0
-rw-r--r--tests/libgit2/reset/reset_helpers.h (renamed from tests/reset/reset_helpers.h)0
-rw-r--r--tests/libgit2/reset/soft.c (renamed from tests/reset/soft.c)0
-rw-r--r--tests/libgit2/revert/bare.c (renamed from tests/revert/bare.c)0
-rw-r--r--tests/libgit2/revert/rename.c (renamed from tests/revert/rename.c)0
-rw-r--r--tests/libgit2/revert/workdir.c (renamed from tests/revert/workdir.c)0
-rw-r--r--tests/libgit2/revwalk/basic.c (renamed from tests/revwalk/basic.c)0
-rw-r--r--tests/libgit2/revwalk/hidecb.c (renamed from tests/revwalk/hidecb.c)0
-rw-r--r--tests/libgit2/revwalk/mergebase.c (renamed from tests/revwalk/mergebase.c)0
-rw-r--r--tests/libgit2/revwalk/signatureparsing.c (renamed from tests/revwalk/signatureparsing.c)0
-rw-r--r--tests/libgit2/revwalk/simplify.c (renamed from tests/revwalk/simplify.c)0
-rw-r--r--tests/libgit2/stash/apply.c (renamed from tests/stash/apply.c)0
-rw-r--r--tests/libgit2/stash/drop.c (renamed from tests/stash/drop.c)0
-rw-r--r--tests/libgit2/stash/foreach.c (renamed from tests/stash/foreach.c)0
-rw-r--r--tests/libgit2/stash/save.c (renamed from tests/stash/save.c)0
-rw-r--r--tests/libgit2/stash/stash_helpers.c (renamed from tests/stash/stash_helpers.c)0
-rw-r--r--tests/libgit2/stash/stash_helpers.h (renamed from tests/stash/stash_helpers.h)0
-rw-r--r--tests/libgit2/stash/submodules.c (renamed from tests/stash/submodules.c)0
-rw-r--r--tests/libgit2/status/renames.c (renamed from tests/status/renames.c)0
-rw-r--r--tests/libgit2/status/single.c (renamed from tests/status/single.c)0
-rw-r--r--tests/libgit2/status/status_data.h (renamed from tests/status/status_data.h)0
-rw-r--r--tests/libgit2/status/status_helpers.c (renamed from tests/status/status_helpers.c)0
-rw-r--r--tests/libgit2/status/status_helpers.h (renamed from tests/status/status_helpers.h)0
-rw-r--r--tests/libgit2/status/submodules.c (renamed from tests/status/submodules.c)0
-rw-r--r--tests/libgit2/status/worktree.c (renamed from tests/status/worktree.c)0
-rw-r--r--tests/libgit2/status/worktree_init.c (renamed from tests/status/worktree_init.c)0
-rw-r--r--tests/libgit2/stream/deprecated.c (renamed from tests/stream/deprecated.c)0
-rw-r--r--tests/libgit2/stream/registration.c (renamed from tests/stream/registration.c)0
-rw-r--r--tests/libgit2/stress/diff.c (renamed from tests/stress/diff.c)0
-rw-r--r--tests/libgit2/submodule/add.c (renamed from tests/submodule/add.c)0
-rw-r--r--tests/libgit2/submodule/escape.c (renamed from tests/submodule/escape.c)0
-rw-r--r--tests/libgit2/submodule/init.c (renamed from tests/submodule/init.c)0
-rw-r--r--tests/libgit2/submodule/inject_option.c (renamed from tests/submodule/inject_option.c)0
-rw-r--r--tests/libgit2/submodule/lookup.c (renamed from tests/submodule/lookup.c)0
-rw-r--r--tests/libgit2/submodule/modify.c (renamed from tests/submodule/modify.c)0
-rw-r--r--tests/libgit2/submodule/nosubs.c (renamed from tests/submodule/nosubs.c)0
-rw-r--r--tests/libgit2/submodule/open.c (renamed from tests/submodule/open.c)0
-rw-r--r--tests/libgit2/submodule/repository_init.c (renamed from tests/submodule/repository_init.c)0
-rw-r--r--tests/libgit2/submodule/status.c (renamed from tests/submodule/status.c)0
-rw-r--r--tests/libgit2/submodule/submodule_helpers.c (renamed from tests/submodule/submodule_helpers.c)0
-rw-r--r--tests/libgit2/submodule/submodule_helpers.h (renamed from tests/submodule/submodule_helpers.h)0
-rw-r--r--tests/libgit2/submodule/update.c (renamed from tests/submodule/update.c)0
-rw-r--r--tests/libgit2/threads/atomic.c (renamed from tests/threads/atomic.c)0
-rw-r--r--tests/libgit2/threads/basic.c (renamed from tests/threads/basic.c)0
-rw-r--r--tests/libgit2/threads/diff.c (renamed from tests/threads/diff.c)0
-rw-r--r--tests/libgit2/threads/iterator.c (renamed from tests/threads/iterator.c)0
-rw-r--r--tests/libgit2/threads/refdb.c (renamed from tests/threads/refdb.c)0
-rw-r--r--tests/libgit2/threads/thread_helpers.c (renamed from tests/threads/thread_helpers.c)0
-rw-r--r--tests/libgit2/threads/thread_helpers.h (renamed from tests/threads/thread_helpers.h)0
-rw-r--r--tests/libgit2/threads/tlsdata.c (renamed from tests/threads/tlsdata.c)0
-rw-r--r--tests/libgit2/trace/trace.c (renamed from tests/trace/trace.c)0
-rw-r--r--tests/libgit2/trace/windows/stacktrace.c (renamed from tests/trace/windows/stacktrace.c)0
-rw-r--r--tests/libgit2/transport/register.c (renamed from tests/transport/register.c)0
-rw-r--r--tests/libgit2/transports/smart/packet.c (renamed from tests/transports/smart/packet.c)0
-rw-r--r--tests/libgit2/valgrind-supp-mac.txt (renamed from tests/valgrind-supp-mac.txt)0
-rw-r--r--tests/libgit2/win32/forbidden.c (renamed from tests/win32/forbidden.c)0
-rw-r--r--tests/libgit2/win32/longpath.c (renamed from tests/win32/longpath.c)0
-rw-r--r--tests/libgit2/win32/systemdir.c (renamed from tests/win32/systemdir.c)0
-rw-r--r--tests/libgit2/worktree/bare.c (renamed from tests/worktree/bare.c)0
-rw-r--r--tests/libgit2/worktree/config.c (renamed from tests/worktree/config.c)0
-rw-r--r--tests/libgit2/worktree/merge.c (renamed from tests/worktree/merge.c)0
-rw-r--r--tests/libgit2/worktree/open.c (renamed from tests/worktree/open.c)0
-rw-r--r--tests/libgit2/worktree/reflog.c (renamed from tests/worktree/reflog.c)0
-rw-r--r--tests/libgit2/worktree/refs.c (renamed from tests/worktree/refs.c)0
-rw-r--r--tests/libgit2/worktree/repository.c (renamed from tests/worktree/repository.c)0
-rw-r--r--tests/libgit2/worktree/submodule.c (renamed from tests/worktree/submodule.c)0
-rw-r--r--tests/libgit2/worktree/worktree.c (renamed from tests/worktree/worktree.c)0
-rw-r--r--tests/libgit2/worktree/worktree_helpers.c (renamed from tests/worktree/worktree_helpers.c)0
-rw-r--r--tests/libgit2/worktree/worktree_helpers.h (renamed from tests/worktree/worktree_helpers.h)0
-rw-r--r--tests/path/dotgit.c206
-rw-r--r--tests/util/CMakeLists.txt68
-rw-r--r--tests/util/array.c (renamed from tests/core/array.c)2
-rw-r--r--tests/util/assert.c (renamed from tests/core/assert.c)8
-rw-r--r--tests/util/bitvec.c (renamed from tests/core/bitvec.c)2
-rw-r--r--tests/util/copy.c (renamed from tests/core/copy.c)6
-rw-r--r--tests/util/crlf.h30
-rw-r--r--tests/util/dirent.c (renamed from tests/core/dirent.c)18
-rw-r--r--tests/util/encoding.c (renamed from tests/core/encoding.c)4
-rw-r--r--tests/util/errors.c (renamed from tests/core/errors.c)16
-rw-r--r--tests/util/filebuf.c (renamed from tests/core/filebuf.c)24
-rw-r--r--tests/util/ftruncate.c (renamed from tests/core/ftruncate.c)8
-rw-r--r--tests/util/futils.c (renamed from tests/core/futils.c)12
-rw-r--r--tests/util/gitstr.c (renamed from tests/core/gitstr.c)235
-rw-r--r--tests/util/hex.c (renamed from tests/core/hex.c)2
-rw-r--r--tests/util/iconv.c (renamed from tests/core/iconv.c)10
-rw-r--r--tests/util/init.c (renamed from tests/core/init.c)6
-rw-r--r--tests/util/integer.c (renamed from tests/core/integer.c)6
-rw-r--r--tests/util/link.c (renamed from tests/core/link.c)50
-rw-r--r--tests/util/memmem.c (renamed from tests/core/memmem.c)6
-rw-r--r--tests/util/mkdir.c (renamed from tests/core/mkdir.c)12
-rw-r--r--tests/util/path.c (renamed from tests/core/path.c)36
-rw-r--r--tests/util/path/core.c (renamed from tests/path/core.c)62
-rw-r--r--tests/util/path/win32.c (renamed from tests/path/win32.c)0
-rw-r--r--tests/util/pool.c (renamed from tests/core/pool.c)36
-rw-r--r--tests/util/posix.c (renamed from tests/core/posix.c)14
-rw-r--r--tests/util/pqueue.c (renamed from tests/core/pqueue.c)10
-rw-r--r--tests/util/precompiled.c1
-rw-r--r--tests/util/precompiled.h3
-rw-r--r--tests/util/qsort.c (renamed from tests/core/qsort.c)12
-rw-r--r--tests/util/regexp.c (renamed from tests/core/regexp.c)46
-rw-r--r--tests/util/rmdir.c (renamed from tests/core/rmdir.c)14
-rw-r--r--tests/util/sha1.c (renamed from tests/core/sha1.c)8
-rw-r--r--tests/util/sortedcache.c (renamed from tests/core/sortedcache.c)6
-rw-r--r--tests/util/stat.c (renamed from tests/core/stat.c)8
-rw-r--r--tests/util/str/basic.c (renamed from tests/str/basic.c)0
-rw-r--r--tests/util/str/oom.c (renamed from tests/str/oom.c)4
-rw-r--r--tests/util/str/percent.c (renamed from tests/str/percent.c)0
-rw-r--r--tests/util/str/quote.c (renamed from tests/str/quote.c)0
-rw-r--r--tests/util/str/splice.c (renamed from tests/str/splice.c)0
-rw-r--r--tests/util/string.c (renamed from tests/core/string.c)16
-rw-r--r--tests/util/strmap.c (renamed from tests/core/strmap.c)26
-rw-r--r--tests/util/strtol.c (renamed from tests/core/strtol.c)16
-rw-r--r--tests/util/utf8.c (renamed from tests/core/utf8.c)2
-rw-r--r--tests/util/vector.c (renamed from tests/core/vector.c)20
-rw-r--r--tests/util/wildmatch.c (renamed from tests/core/wildmatch.c)16
-rw-r--r--tests/util/zstream.c (renamed from tests/core/zstream.c)8
882 files changed, 3332 insertions, 1225 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index eb137ecdd..763bd437b 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,5 +1,8 @@
-# CMake build script for the libgit2 project
+# libgit2: the cross-platform, linkable library implementation of git.
# See `README.md` for build instructions.
+#
+# This top-level CMakeLists.txt sets up configuration options and
+# determines which subprojects to build.
cmake_minimum_required(VERSION 3.5.1)
@@ -15,6 +18,7 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/cmake")
# Optional subsystems
option(BUILD_SHARED_LIBS "Build Shared Library (OFF for Static)" ON)
option(BUILD_TESTS "Build Tests using the Clar suite" ON)
+option(BUILD_CLI "Build the command-line interface" ON)
option(BUILD_EXAMPLES "Build library usage example apps" OFF)
option(BUILD_FUZZERS "Build the fuzz targets" OFF)
diff --git a/ci/test.sh b/ci/test.sh
index a94839778..0815522a9 100755
--- a/ci/test.sh
+++ b/ci/test.sh
@@ -159,10 +159,18 @@ fi
if [ -z "$SKIP_OFFLINE_TESTS" ]; then
echo ""
echo "##############################################################################"
- echo "## Running (offline) tests"
+ echo "## Running core tests"
echo "##############################################################################"
+ echo ""
+ echo "Running libgit2 integration (offline) tests"
+ echo ""
run_test offline
+
+ echo ""
+ echo "Running utility tests"
+ echo ""
+ run_test util
fi
if [ -n "$RUN_INVASIVE_TESTS" ]; then
@@ -186,7 +194,7 @@ if [ -z "$SKIP_ONLINE_TESTS" ]; then
echo ""
echo "##############################################################################"
- echo "## Running (online) tests"
+ echo "## Running networking (online) tests"
echo "##############################################################################"
export GITTEST_REMOTE_REDIRECT_INITIAL="http://localhost:9000/initial-redirect/libgit2/TestGitRepository"
@@ -198,9 +206,9 @@ if [ -z "$SKIP_ONLINE_TESTS" ]; then
# Run the online tests that immutably change global state separately
# to avoid polluting the test environment.
echo ""
- echo "##############################################################################"
- echo "## Running (online_customcert) tests"
- echo "##############################################################################"
+ echo "Running custom certificate (online_customcert) tests"
+ echo ""
+
run_test online_customcert
fi
diff --git a/cmake/AddClarTest.cmake b/cmake/AddClarTest.cmake
new file mode 100644
index 000000000..743941638
--- /dev/null
+++ b/cmake/AddClarTest.cmake
@@ -0,0 +1,7 @@
+function(ADD_CLAR_TEST project name)
+ if(NOT USE_LEAK_CHECKER STREQUAL "OFF")
+ add_test(${name} "${PROJECT_SOURCE_DIR}/script/${USE_LEAK_CHECKER}.sh" "${PROJECT_BINARY_DIR}/${project}" ${ARGN})
+ else()
+ add_test(${name} "${PROJECT_BINARY_DIR}/${project}" ${ARGN})
+ endif()
+endfunction(ADD_CLAR_TEST)
diff --git a/cmake/SelectHashes.cmake b/cmake/SelectHashes.cmake
index bedd8c4e3..575ae8f8d 100644
--- a/cmake/SelectHashes.cmake
+++ b/cmake/SelectHashes.cmake
@@ -21,9 +21,6 @@ endif()
if(USE_SHA1 STREQUAL "CollisionDetection")
set(GIT_SHA1_COLLISIONDETECT 1)
- add_definitions(-DSHA1DC_NO_STANDARD_INCLUDES=1)
- add_definitions(-DSHA1DC_CUSTOM_INCLUDE_SHA1_C=\"common.h\")
- add_definitions(-DSHA1DC_CUSTOM_INCLUDE_UBC_CHECK_C=\"common.h\")
elseif(USE_SHA1 STREQUAL "OpenSSL")
# OPENSSL_FOUND should already be set, we're checking USE_HTTPS
diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt
index 235e72ada..8e38c7d4e 100644
--- a/examples/CMakeLists.txt
+++ b/examples/CMakeLists.txt
@@ -1,3 +1,5 @@
+# examples: code usage examples of libgit2
+
file(GLOB SRC_EXAMPLES *.c *.h)
add_executable(lg2 ${SRC_EXAMPLES})
@@ -10,7 +12,7 @@ target_include_directories(lg2 PRIVATE ${LIBGIT2_INCLUDES} ${LIBGIT2_DEPENDENCY_
target_include_directories(lg2 SYSTEM PRIVATE ${LIBGIT2_SYSTEM_INCLUDES})
if(WIN32 OR ANDROID)
- target_link_libraries(lg2 git2)
+ target_link_libraries(lg2 libgit2package)
else()
- target_link_libraries(lg2 git2 pthread)
+ target_link_libraries(lg2 libgit2package pthread)
endif()
diff --git a/fuzzers/CMakeLists.txt b/fuzzers/CMakeLists.txt
index eaa490fd9..a2c19ed40 100644
--- a/fuzzers/CMakeLists.txt
+++ b/fuzzers/CMakeLists.txt
@@ -1,3 +1,5 @@
+# fuzzers: libFuzzer and standalone fuzzing utilities
+
if(BUILD_FUZZERS AND NOT USE_STANDALONE_FUZZERS)
set(CMAKE_REQUIRED_FLAGS "-fsanitize=fuzzer-no-link")
add_c_flag(-fsanitize=fuzzer)
diff --git a/include/git2/errors.h b/include/git2/errors.h
index 5a5f8c5a2..62f363507 100644
--- a/include/git2/errors.h
+++ b/include/git2/errors.h
@@ -130,7 +130,8 @@ GIT_EXTERN(const git_error *) git_error_last(void);
GIT_EXTERN(void) git_error_clear(void);
/**
- * Set the error message string for this thread.
+ * Set the error message string for this thread, using `printf`-style
+ * formatting.
*
* This function is public so that custom ODB backends and the like can
* relay an error message through libgit2. Most regular users of libgit2
@@ -143,7 +144,20 @@ GIT_EXTERN(void) git_error_clear(void);
*
* @param error_class One of the `git_error_t` enum above describing the
* general subsystem that is responsible for the error.
- * @param string The formatted error message to keep
+ * @param fmt The `printf`-style format string; subsequent arguments must
+ * be the arguments for the format string.
+ */
+GIT_EXTERN(void) git_error_set(int error_class, const char *fmt, ...)
+ GIT_FORMAT_PRINTF(2, 3);
+
+/**
+ * Set the error message string for this thread. This function is like
+ * `git_error_set` but takes a static string instead of a `printf`-style
+ * format.
+ *
+ * @param error_class One of the `git_error_t` enum above describing the
+ * general subsystem that is responsible for the error.
+ * @param string The error message to keep
* @return 0 on success or -1 on failure
*/
GIT_EXTERN(int) git_error_set_str(int error_class, const char *string);
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index e7b54d036..72ec410fc 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -1,12 +1,22 @@
-add_library(git2internal OBJECT)
-set_target_properties(git2internal PROPERTIES C_STANDARD 90)
-set_target_properties(git2internal PROPERTIES C_EXTENSIONS OFF)
+# The main libgit2 source tree: this CMakeLists.txt identifies platform
+# support and includes the subprojects that make up core libgit2 support.
+#
+# Optional build configuration settings
+#
if(DEPRECATE_HARD)
add_definitions(-DGIT_DEPRECATE_HARD)
endif()
+if(USE_LEAK_CHECKER STREQUAL "valgrind")
+ add_definitions(-DVALGRIND)
+endif()
+
+#
+# Optional debugging functionality
+#
+
if(DEBUG_POOL)
set(GIT_DEBUG_POOL 1)
endif()
@@ -22,29 +32,32 @@ if(DEBUG_STRICT_OPEN)
endif()
add_feature_info(debugopen GIT_DEBUG_STRICT_OPEN "path validation in open")
+#
+# Optional feature enablement
+#
-include(PkgBuildConfig)
-include(SanitizeBool)
+include(SelectGSSAPI)
+include(SelectHTTPSBackend)
+include(SelectHashes)
+include(SelectHTTPParser)
+include(SelectRegex)
+include(SelectSSH)
+include(SelectWinHTTP)
+include(SelectZlib)
-# This variable will contain the libraries we need to put into
-# libgit2.pc's Requires.private. That is, what we're linking to or
-# what someone who's statically linking us needs to link to.
-set(LIBGIT2_PC_REQUIRES "")
-# This will be set later if we use the system's http-parser library or
-# use iconv (OSX) and will be written to the Libs.private field in the
-# pc file.
-set(LIBGIT2_PC_LIBS "")
+#
+# Platform support
+#
-set(LIBGIT2_INCLUDES
- "${CMAKE_CURRENT_BINARY_DIR}"
- "${PROJECT_SOURCE_DIR}/src"
- "${PROJECT_SOURCE_DIR}/include")
+# futimes/futimens
if(HAVE_FUTIMENS)
set(GIT_USE_FUTIMENS 1)
endif ()
add_feature_info(futimens GIT_USE_FUTIMENS "futimens support")
+# qsort
+
check_prototype_definition(qsort_r
"void qsort_r(void *base, size_t nmemb, size_t size, void *thunk, int (*compar)(void *, const void *, const void *))"
"" "stdlib.h" GIT_QSORT_R_BSD)
@@ -55,69 +68,80 @@ check_prototype_definition(qsort_r
check_function_exists(qsort_s GIT_QSORT_S)
-check_function_exists(getentropy GIT_RAND_GETENTROPY)
+# determine architecture of the machine
-# Find required dependencies
+if(CMAKE_SIZEOF_VOID_P EQUAL 8)
+ set(GIT_ARCH_64 1)
+elseif(CMAKE_SIZEOF_VOID_P EQUAL 4)
+ set(GIT_ARCH_32 1)
+elseif(CMAKE_SIZEOF_VOID_P)
+ message(FATAL_ERROR "Unsupported architecture (pointer size is ${CMAKE_SIZEOF_VOID_P} bytes)")
+else()
+ message(FATAL_ERROR "Unsupported architecture (CMAKE_SIZEOF_VOID_P is unset)")
+endif()
-if(WIN32)
- list(APPEND LIBGIT2_SYSTEM_LIBS ws2_32)
-elseif(CMAKE_SYSTEM_NAME MATCHES "(Solaris|SunOS)")
- list(APPEND LIBGIT2_SYSTEM_LIBS socket nsl)
- list(APPEND LIBGIT2_PC_LIBS "-lsocket" "-lnsl")
-elseif(CMAKE_SYSTEM_NAME MATCHES "Haiku")
- list(APPEND LIBGIT2_SYSTEM_LIBS network)
- list(APPEND LIBGIT2_PC_LIBS "-lnetwork")
+# nanosecond mtime/ctime support
+
+if(USE_NSEC)
+ set(GIT_USE_NSEC 1)
endif()
+# high-resolution stat support
+
+if(HAVE_STRUCT_STAT_ST_MTIM)
+ set(GIT_USE_STAT_MTIM 1)
+elseif(HAVE_STRUCT_STAT_ST_MTIMESPEC)
+ set(GIT_USE_STAT_MTIMESPEC 1)
+elseif(HAVE_STRUCT_STAT_ST_MTIME_NSEC)
+ set(GIT_USE_STAT_MTIME_NSEC 1)
+endif()
+
+# realtime support
+
check_library_exists(rt clock_gettime "time.h" NEED_LIBRT)
if(NEED_LIBRT)
list(APPEND LIBGIT2_SYSTEM_LIBS rt)
list(APPEND LIBGIT2_PC_LIBS "-lrt")
endif()
-if(USE_THREADS)
- list(APPEND LIBGIT2_SYSTEM_LIBS ${CMAKE_THREAD_LIBS_INIT})
- list(APPEND LIBGIT2_PC_LIBS ${CMAKE_THREAD_LIBS_INIT})
+# platform libraries
+
+if(WIN32)
+ list(APPEND LIBGIT2_SYSTEM_LIBS ws2_32)
endif()
-add_feature_info(threadsafe USE_THREADS "threadsafe support")
+if(CMAKE_SYSTEM_NAME MATCHES "(Solaris|SunOS)")
+ list(APPEND LIBGIT2_SYSTEM_LIBS socket nsl)
+ list(APPEND LIBGIT2_PC_LIBS "-lsocket" "-lnsl")
+endif()
-if(WIN32 AND EMBED_SSH_PATH)
- file(GLOB SRC_SSH "${EMBED_SSH_PATH}/src/*.c")
- list(SORT SRC_SSH)
- target_sources(git2internal PRIVATE ${SRC_SSH})
+if(CMAKE_SYSTEM_NAME MATCHES "Haiku")
+ list(APPEND LIBGIT2_SYSTEM_LIBS network)
+ list(APPEND LIBGIT2_PC_LIBS "-lnetwork")
+endif()
- list(APPEND LIBGIT2_SYSTEM_INCLUDES "${EMBED_SSH_PATH}/include")
- file(WRITE "${EMBED_SSH_PATH}/src/libssh2_config.h" "#define HAVE_WINCNG\n#define LIBSSH2_WINCNG\n#include \"../win32/libssh2_config.h\"")
- set(GIT_SSH 1)
+if(AMIGA)
+ add_definitions(-DNO_ADDRINFO -DNO_READDIR_R -DNO_MMAP)
endif()
-include(SelectHTTPSBackend)
-include(SelectHashes)
-include(SelectHTTPParser)
-include(SelectRegex)
-include(SelectSSH)
-include(SelectWinHTTP)
-include(SelectZlib)
+# threads
+if(USE_THREADS)
+ if(NOT WIN32)
+ find_package(Threads REQUIRED)
+ list(APPEND LIBGIT2_SYSTEM_LIBS ${CMAKE_THREAD_LIBS_INIT})
+ list(APPEND LIBGIT2_PC_LIBS ${CMAKE_THREAD_LIBS_INIT})
+ endif()
-if(USE_SHA1 STREQUAL "CollisionDetection")
- file(GLOB SRC_SHA1 hash/sha1/collisiondetect.* hash/sha1/sha1dc/*)
-elseif(USE_SHA1 STREQUAL "OpenSSL")
- file(GLOB SRC_SHA1 hash/sha1/openssl.*)
-elseif(USE_SHA1 STREQUAL "CommonCrypto")
- file(GLOB SRC_SHA1 hash/sha1/common_crypto.*)
-elseif(USE_SHA1 STREQUAL "mbedTLS")
- file(GLOB SRC_SHA1 hash/sha1/mbedtls.*)
-elseif(USE_SHA1 STREQUAL "Win32")
- file(GLOB SRC_SHA1 hash/sha1/win32.*)
-elseif(USE_SHA1 STREQUAL "Generic")
- file(GLOB SRC_SHA1 hash/sha1/generic.*)
+ set(GIT_THREADS 1)
endif()
-list(APPEND SRC_SHA1 "hash/sha1.h")
-target_sources(git2internal PRIVATE ${SRC_SHA1})
+add_feature_info(threadsafe USE_THREADS "threadsafe support")
-# Optional external dependency: ntlmclient
+#
+# Optional bundled features
+#
+
+# ntlmclient
if(USE_NTLMCLIENT)
set(GIT_NTLM 1)
add_subdirectory("${PROJECT_SOURCE_DIR}/deps/ntlmclient" "${PROJECT_BINARY_DIR}/deps/ntlmclient")
@@ -126,11 +150,10 @@ if(USE_NTLMCLIENT)
endif()
add_feature_info(ntlmclient GIT_NTLM "NTLM authentication support for Unix")
-# Optional external dependency: GSSAPI
-
-include(SelectGSSAPI)
+#
+# Optional external dependencies
-# Optional external dependency: iconv
+# iconv
if(USE_ICONV)
find_package(Iconv)
endif()
@@ -142,166 +165,28 @@ if(ICONV_FOUND)
endif()
add_feature_info(iconv GIT_USE_ICONV "iconv encoding conversion support")
+#
+# Configure support
+#
-if(USE_THREADS)
- if(NOT WIN32)
- find_package(Threads REQUIRED)
- endif()
-
- set(GIT_THREADS 1)
-endif()
-
-if(USE_NSEC)
- set(GIT_USE_NSEC 1)
-endif()
-
-if(HAVE_STRUCT_STAT_ST_MTIM)
- set(GIT_USE_STAT_MTIM 1)
-elseif(HAVE_STRUCT_STAT_ST_MTIMESPEC)
- set(GIT_USE_STAT_MTIMESPEC 1)
-elseif(HAVE_STRUCT_STAT_ST_MTIME_NSEC)
- set(GIT_USE_STAT_MTIME_NSEC 1)
-endif()
-
-target_compile_definitions(git2internal PRIVATE _FILE_OFFSET_BITS=64)
-
-# Collect sourcefiles
-file(GLOB SRC_H
- "${PROJECT_SOURCE_DIR}/include/git2.h"
- "${PROJECT_SOURCE_DIR}/include/git2/*.h"
- "${PROJECT_SOURCE_DIR}/include/git2/sys/*.h")
-list(SORT SRC_H)
-target_sources(git2internal PRIVATE ${SRC_H})
-
-# On Windows use specific platform sources
-if(WIN32 AND NOT CYGWIN)
- set(WIN_RC "win32/git2.rc")
-
- file(GLOB SRC_OS win32/*.c win32/*.h)
- list(SORT SRC_OS)
- target_sources(git2internal PRIVATE ${SRC_OS})
-elseif(AMIGA)
- target_compile_definitions(git2internal PRIVATE NO_ADDRINFO NO_READDIR_R NO_MMAP)
-else()
- file(GLOB SRC_OS unix/*.c unix/*.h)
- list(SORT SRC_OS)
- target_sources(git2internal PRIVATE ${SRC_OS})
-endif()
-
-if(USE_LEAK_CHECKER STREQUAL "valgrind")
- target_compile_definitions(git2internal PRIVATE VALGRIND)
-endif()
+configure_file(features.h.in git2/sys/features.h)
-file(GLOB SRC_GIT2 *.c *.h
- allocators/*.c allocators/*.h
- streams/*.c streams/*.h
- transports/*.c transports/*.h
- xdiff/*.c xdiff/*.h)
-list(SORT SRC_GIT2)
-target_sources(git2internal PRIVATE ${SRC_GIT2})
-
-if(APPLE)
- # The old Secure Transport API has been deprecated in macOS 10.15.
- set_source_files_properties(streams/stransport.c PROPERTIES COMPILE_FLAGS -Wno-deprecated)
-endif()
+#
+# Include child projects
+#
-# the xdiff dependency is not (yet) warning-free, disable warnings as
-# errors for the xdiff sources until we've sorted them out
-if(MSVC)
- set_source_files_properties(xdiff/xdiffi.c PROPERTIES COMPILE_FLAGS -WX-)
- set_source_files_properties(xdiff/xemit.c PROPERTIES COMPILE_FLAGS -WX-)
- set_source_files_properties(xdiff/xhistogram.c PROPERTIES COMPILE_FLAGS -WX-)
- set_source_files_properties(xdiff/xmerge.c PROPERTIES COMPILE_FLAGS -WX-)
- set_source_files_properties(xdiff/xutils.c PROPERTIES COMPILE_FLAGS -WX-)
- set_source_files_properties(xdiff/xpatience.c PROPERTIES COMPILE_FLAGS -WX-)
-else()
- set_source_files_properties(xdiff/xdiffi.c PROPERTIES COMPILE_FLAGS "-Wno-sign-compare -Wno-unused-parameter")
- set_source_files_properties(xdiff/xemit.c PROPERTIES COMPILE_FLAGS "-Wno-sign-compare -Wno-unused-parameter")
- set_source_files_properties(xdiff/xhistogram.c PROPERTIES COMPILE_FLAGS "-Wno-sign-compare")
- set_source_files_properties(xdiff/xutils.c PROPERTIES COMPILE_FLAGS "-Wno-sign-compare")
- set_source_files_properties(xdiff/xpatience.c PROPERTIES COMPILE_FLAGS "-Wno-sign-compare")
-endif()
+add_subdirectory(libgit2)
+add_subdirectory(util)
-# Determine architecture of the machine
-if(CMAKE_SIZEOF_VOID_P EQUAL 8)
- set(GIT_ARCH_64 1)
-elseif(CMAKE_SIZEOF_VOID_P EQUAL 4)
- set(GIT_ARCH_32 1)
-elseif(CMAKE_SIZEOF_VOID_P)
- message(FATAL_ERROR "Unsupported architecture (pointer size is ${CMAKE_SIZEOF_VOID_P} bytes)")
-else()
- message(FATAL_ERROR "Unsupported architecture (CMAKE_SIZEOF_VOID_P is unset)")
+if(BUILD_CLI)
+ add_subdirectory(cli)
endif()
-configure_file(features.h.in git2/sys/features.h)
-
-ide_split_sources(git2internal)
-list(APPEND LIBGIT2_OBJECTS $<TARGET_OBJECTS:git2internal> ${LIBGIT2_DEPENDENCY_OBJECTS})
-
-target_include_directories(git2internal PRIVATE ${LIBGIT2_INCLUDES} ${LIBGIT2_DEPENDENCY_INCLUDES} PUBLIC ${PROJECT_SOURCE_DIR}/include)
-target_include_directories(git2internal SYSTEM PRIVATE ${LIBGIT2_SYSTEM_INCLUDES})
-
+# re-export these to the root so that peer projects (tests, fuzzers,
+# examples) can use them
set(LIBGIT2_INCLUDES ${LIBGIT2_INCLUDES} PARENT_SCOPE)
set(LIBGIT2_OBJECTS ${LIBGIT2_OBJECTS} PARENT_SCOPE)
set(LIBGIT2_DEPENDENCY_INCLUDES ${LIBGIT2_DEPENDENCY_INCLUDES} PARENT_SCOPE)
set(LIBGIT2_DEPENDENCY_OBJECTS ${LIBGIT2_DEPENDENCY_OBJECTS} PARENT_SCOPE)
set(LIBGIT2_SYSTEM_INCLUDES ${LIBGIT2_SYSTEM_INCLUDES} PARENT_SCOPE)
set(LIBGIT2_SYSTEM_LIBS ${LIBGIT2_SYSTEM_LIBS} PARENT_SCOPE)
-
-if(XCODE_VERSION)
- # This is required for Xcode to actually link the libgit2 library
- # when using only object libraries.
- file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/dummy.c "")
- list(APPEND LIBGIT2_OBJECTS ${CMAKE_CURRENT_BINARY_DIR}/dummy.c)
-endif()
-
-# Compile and link libgit2
-add_library(git2 ${WIN_RC} ${LIBGIT2_OBJECTS})
-target_link_libraries(git2 ${LIBGIT2_SYSTEM_LIBS})
-
-set_target_properties(git2 PROPERTIES C_STANDARD 90)
-set_target_properties(git2 PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR})
-set_target_properties(git2 PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR})
-set_target_properties(git2 PROPERTIES ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR})
-
-# Workaround for Cmake bug #0011240 (see http://public.kitware.com/Bug/view.php?id=11240)
-# Win64+MSVC+static libs = linker error
-if(MSVC AND GIT_ARCH_64 AND NOT BUILD_SHARED_LIBS)
- set_target_properties(git2 PROPERTIES STATIC_LIBRARY_FLAGS "/MACHINE:x64")
-endif()
-
-ide_split_sources(git2)
-
-if(SONAME)
- set_target_properties(git2 PROPERTIES VERSION ${libgit2_VERSION})
- set_target_properties(git2 PROPERTIES SOVERSION "${libgit2_VERSION_MAJOR}.${libgit2_VERSION_MINOR}")
- if(LIBGIT2_FILENAME)
- target_compile_definitions(git2 PRIVATE LIBGIT2_FILENAME=\"${LIBGIT2_FILENAME}\")
- set_target_properties(git2 PROPERTIES OUTPUT_NAME ${LIBGIT2_FILENAME})
- elseif(DEFINED LIBGIT2_PREFIX)
- set_target_properties(git2 PROPERTIES PREFIX "${LIBGIT2_PREFIX}")
- endif()
-endif()
-
-pkg_build_config(NAME libgit2
- VERSION ${libgit2_VERSION}
- DESCRIPTION "The git library, take 2"
- LIBS_SELF git2
- PRIVATE_LIBS ${LIBGIT2_PC_LIBS}
- REQUIRES ${LIBGIT2_PC_REQUIRES}
-)
-
-if(MSVC_IDE)
- # Precompiled headers
- set_target_properties(git2 PROPERTIES COMPILE_FLAGS "/Yuprecompiled.h /FIprecompiled.h")
- set_source_files_properties(win32/precompiled.c COMPILE_FLAGS "/Ycprecompiled.h")
-endif()
-
-# Install
-install(TARGETS git2
- RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
- LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
- ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
-)
-install(DIRECTORY ${PROJECT_SOURCE_DIR}/include/git2 DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
-install(FILES ${PROJECT_SOURCE_DIR}/include/git2.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
diff --git a/src/README.md b/src/README.md
new file mode 100644
index 000000000..10b86c1dc
--- /dev/null
+++ b/src/README.md
@@ -0,0 +1,12 @@
+# libgit2 sources
+
+This is the source that makes up the core of libgit2 and its related
+projects.
+
+* `cli`
+ A git-compatible command-line interface that uses libgit2.
+* `libgit2`
+ This is the libgit2 project, a cross-platform, linkable library
+ implementation of Git that you can use in your application.
+* `util`
+ A shared utility library for these projects.
diff --git a/src/cli/CMakeLists.txt b/src/cli/CMakeLists.txt
new file mode 100644
index 000000000..4f347e93f
--- /dev/null
+++ b/src/cli/CMakeLists.txt
@@ -0,0 +1,53 @@
+set(CLI_INCLUDES
+ "${libgit2_BINARY_DIR}/src"
+ "${libgit2_SOURCE_DIR}/src/util"
+ "${libgit2_SOURCE_DIR}/src/cli"
+ "${libgit2_SOURCE_DIR}/include")
+
+if(WIN32 AND NOT CYGWIN)
+ file(GLOB CLI_SRC_OS win32/*.c)
+ list(SORT CLI_SRC_OS)
+else()
+ file(GLOB CLI_SRC_OS unix/*.c)
+ list(SORT CLI_SRC_OS)
+endif()
+
+file(GLOB CLI_SRC_C *.c *.h)
+list(SORT CLI_SRC_C)
+
+#
+# The CLI currently needs to be statically linked against libgit2 because
+# the utility library uses libgit2's thread-local error buffers. TODO:
+# remove this dependency and allow us to dynamically link against libgit2.
+#
+
+if(BUILD_CLI STREQUAL "dynamic")
+ set(CLI_LIBGIT2_LIBRARY libgit2package)
+else()
+ set(CLI_LIBGIT2_OBJECTS $<TARGET_OBJECTS:libgit2>)
+endif()
+
+#
+# Compile and link the CLI
+#
+
+add_executable(git2_cli ${CLI_SRC_C} ${CLI_SRC_OS} ${CLI_OBJECTS}
+ $<TARGET_OBJECTS:util>
+ ${CLI_LIBGIT2_OBJECTS}
+ ${LIBGIT2_DEPENDENCY_OBJECTS})
+target_link_libraries(git2_cli ${CLI_LIBGIT2_LIBRARY} ${LIBGIT2_SYSTEM_LIBS})
+
+set_target_properties(git2_cli PROPERTIES C_STANDARD 90)
+set_target_properties(git2_cli PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${libgit2_BINARY_DIR})
+
+ide_split_sources(git2_cli)
+
+target_include_directories(git2_cli PRIVATE ${CLI_INCLUDES})
+
+if(MSVC_IDE)
+ # Precompiled headers
+ set_target_properties(git2_cli PROPERTIES COMPILE_FLAGS "/Yuprecompiled.h /FIprecompiled.h")
+ set_source_files_properties(win32/precompiled.c COMPILE_FLAGS "/Ycprecompiled.h")
+endif()
+
+install(TARGETS git2_cli RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
diff --git a/src/cli/README.md b/src/cli/README.md
new file mode 100644
index 000000000..3087c39c4
--- /dev/null
+++ b/src/cli/README.md
@@ -0,0 +1,26 @@
+# cli
+
+A git-compatible command-line interface that uses libgit2.
+
+## Adding commands
+
+1. Individual commands have a `main`-like top-level entrypoint. For example:
+
+ ```c
+ int cmd_help(int argc, char **argv)
+ ```
+
+ Although this is the same signature as `main`, commands are not built as
+ individual standalone executables, they'll be linked into the main cli.
+ (Though there may be an option for command executables to be built as
+ standalone executables in the future.)
+
+2. Commands are prototyped in `cmd.h` and added to `main.c`'s list of
+ commands (`cli_cmds[]`). Commands should be specified with their name,
+ entrypoint and a brief description that can be printed in `git help`.
+ This is done because commands are linked into the main cli.
+
+3. Commands should accept a `--help` option that displays their help
+ information. This will be shown when a user runs `<command> --help` and
+ when a user runs `help <command>`.
+
diff --git a/src/cli/cli.h b/src/cli/cli.h
new file mode 100644
index 000000000..222d53a74
--- /dev/null
+++ b/src/cli/cli.h
@@ -0,0 +1,19 @@
+/*
+ * 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 CLI_cli_h__
+#define CLI_cli_h__
+
+#define PROGRAM_NAME "git2"
+
+#include "git2_util.h"
+
+#include "error.h"
+#include "opt.h"
+#include "opt_usage.h"
+
+#endif /* CLI_cli_h__ */
diff --git a/src/cli/cmd.c b/src/cli/cmd.c
new file mode 100644
index 000000000..2a7e71cdb
--- /dev/null
+++ b/src/cli/cmd.c
@@ -0,0 +1,21 @@
+/*
+ * 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.
+ */
+
+#include "cli.h"
+#include "cmd.h"
+
+const cli_cmd_spec *cli_cmd_spec_byname(const char *name)
+{
+ const cli_cmd_spec *cmd;
+
+ for (cmd = cli_cmds; cmd->name; cmd++) {
+ if (!strcmp(cmd->name, name))
+ return cmd;
+ }
+
+ return NULL;
+}
diff --git a/src/cli/cmd.h b/src/cli/cmd.h
new file mode 100644
index 000000000..664b5021a
--- /dev/null
+++ b/src/cli/cmd.h
@@ -0,0 +1,32 @@
+/*
+ * 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 CLI_cmd_h__
+#define CLI_cmd_h__
+
+/* Command definitions */
+typedef struct {
+ const char *name;
+ int (*fn)(int argc, char **argv);
+ const char *desc;
+} cli_cmd_spec;
+
+/* Options that are common to all commands (eg --help, --git-dir) */
+extern const cli_opt_spec cli_common_opts[];
+
+/* All the commands supported by the CLI */
+extern const cli_cmd_spec cli_cmds[];
+
+/* Find a command by name */
+extern const cli_cmd_spec *cli_cmd_spec_byname(const char *name);
+
+/* Commands */
+extern int cmd_cat_file(int argc, char **argv);
+extern int cmd_hash_object(int argc, char **argv);
+extern int cmd_help(int argc, char **argv);
+
+#endif /* CLI_cmd_h__ */
diff --git a/src/cli/cmd_cat_file.c b/src/cli/cmd_cat_file.c
new file mode 100644
index 000000000..fb53a722b
--- /dev/null
+++ b/src/cli/cmd_cat_file.c
@@ -0,0 +1,204 @@
+/*
+ * 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.
+ */
+
+#include <git2.h>
+#include "cli.h"
+#include "cmd.h"
+
+#define COMMAND_NAME "cat-file"
+
+typedef enum {
+ DISPLAY_CONTENT = 0,
+ DISPLAY_EXISTS,
+ DISPLAY_PRETTY,
+ DISPLAY_SIZE,
+ DISPLAY_TYPE
+} display_t;
+
+static int show_help;
+static int display = DISPLAY_CONTENT;
+static char *type_name, *object_spec;
+
+static const cli_opt_spec opts[] = {
+ { CLI_OPT_TYPE_SWITCH, "help", 0, &show_help, 1,
+ CLI_OPT_USAGE_HIDDEN | CLI_OPT_USAGE_STOP_PARSING, NULL,
+ "display help about the " COMMAND_NAME " command" },
+
+ { CLI_OPT_TYPE_SWITCH, NULL, 't', &display, DISPLAY_TYPE,
+ CLI_OPT_USAGE_REQUIRED, NULL, "display the type of the object" },
+ { CLI_OPT_TYPE_SWITCH, NULL, 's', &display, DISPLAY_SIZE,
+ CLI_OPT_USAGE_CHOICE, NULL, "display the size of the object" },
+ { CLI_OPT_TYPE_SWITCH, NULL, 'e', &display, DISPLAY_EXISTS,
+ CLI_OPT_USAGE_CHOICE, NULL, "displays nothing unless the object is corrupt" },
+ { CLI_OPT_TYPE_SWITCH, NULL, 'p', &display, DISPLAY_PRETTY,
+ CLI_OPT_USAGE_CHOICE, NULL, "pretty-print the object" },
+ { CLI_OPT_TYPE_ARG, "type", 0, &type_name, 0,
+ CLI_OPT_USAGE_CHOICE, "type", "the type of object to display" },
+ { CLI_OPT_TYPE_ARG, "object", 0, &object_spec, 0,
+ CLI_OPT_USAGE_REQUIRED, "object", "the object to display" },
+ { 0 },
+};
+
+static void print_help(void)
+{
+ cli_opt_usage_fprint(stdout, PROGRAM_NAME, COMMAND_NAME, opts);
+ printf("\n");
+
+ printf("Display the content for the given object in the repository.\n");
+ printf("\n");
+
+ printf("Options:\n");
+
+ cli_opt_help_fprint(stdout, opts);
+}
+
+static int print_odb(git_object *object, display_t display)
+{
+ git_odb *odb = NULL;
+ git_odb_object *odb_object = NULL;
+ const unsigned char *content;
+ git_object_size_t size;
+ int ret = 0;
+
+ /*
+ * Our parsed blobs retain the raw content; all other objects are
+ * parsed into a working representation. To get the raw content,
+ * we need to do an ODB lookup. (Thankfully, this should be cached
+ * in-memory from our last call.)
+ */
+ if (git_object_type(object) == GIT_OBJECT_BLOB) {
+ content = git_blob_rawcontent((git_blob *)object);
+ size = git_blob_rawsize((git_blob *)object);
+ } else {
+ if (git_repository_odb(&odb, git_object_owner(object)) < 0 ||
+ git_odb_read(&odb_object, odb, git_object_id(object)) < 0) {
+ ret = cli_error_git();
+ goto done;
+ }
+
+ content = git_odb_object_data(odb_object);
+ size = git_odb_object_size(odb_object);
+ }
+
+ switch (display) {
+ case DISPLAY_SIZE:
+ if (printf("%" PRIu64 "\n", size) < 0)
+ ret = cli_error_os();
+ break;
+ case DISPLAY_CONTENT:
+ if (p_write(fileno(stdout), content, (size_t)size) < 0)
+ ret = cli_error_os();
+ break;
+ default:
+ GIT_ASSERT(0);
+ }
+
+done:
+ git_odb_object_free(odb_object);
+ git_odb_free(odb);
+ return ret;
+}
+
+static int print_type(git_object *object)
+{
+ if (printf("%s\n", git_object_type2string(git_object_type(object))) < 0)
+ return cli_error_os();
+
+ return 0;
+}
+
+static int print_pretty(git_object *object)
+{
+ const git_tree_entry *entry;
+ size_t i, count;
+
+ /*
+ * Only trees are stored in an unreadable format and benefit from
+ * pretty-printing.
+ */
+ if (git_object_type(object) != GIT_OBJECT_TREE)
+ return print_odb(object, DISPLAY_CONTENT);
+
+ for (i = 0, count = git_tree_entrycount((git_tree *)object); i < count; i++) {
+ entry = git_tree_entry_byindex((git_tree *)object, i);
+
+ if (printf("%06o %s %s\t%s\n",
+ git_tree_entry_filemode_raw(entry),
+ git_object_type2string(git_tree_entry_type(entry)),
+ git_oid_tostr_s(git_tree_entry_id(entry)),
+ git_tree_entry_name(entry)) < 0)
+ return cli_error_os();
+ }
+
+ return 0;
+}
+
+int cmd_cat_file(int argc, char **argv)
+{
+ git_repository *repo = NULL;
+ git_object *object = NULL;
+ git_object_t type;
+ cli_opt invalid_opt;
+ int giterr, ret = 0;
+
+ if (cli_opt_parse(&invalid_opt, opts, argv + 1, argc - 1, CLI_OPT_PARSE_GNU))
+ return cli_opt_usage_error(COMMAND_NAME, opts, &invalid_opt);
+
+ if (show_help) {
+ print_help();
+ return 0;
+ }
+
+ if (git_repository_open_ext(&repo, ".", GIT_REPOSITORY_OPEN_FROM_ENV, NULL) < 0)
+ return cli_error_git();
+
+ if ((giterr = git_revparse_single(&object, repo, object_spec)) < 0) {
+ if (display == DISPLAY_EXISTS && giterr == GIT_ENOTFOUND)
+ ret = 1;
+ else
+ ret = cli_error_git();
+
+ goto done;
+ }
+
+ if (type_name) {
+ git_object *peeled;
+
+ if ((type = git_object_string2type(type_name)) == GIT_OBJECT_INVALID) {
+ ret = cli_error_usage("invalid object type '%s'", type_name);
+ goto done;
+ }
+
+ if (git_object_peel(&peeled, object, type) < 0) {
+ ret = cli_error_git();
+ goto done;
+ }
+
+ git_object_free(object);
+ object = peeled;
+ }
+
+ switch (display) {
+ case DISPLAY_EXISTS:
+ ret = 0;
+ break;
+ case DISPLAY_TYPE:
+ ret = print_type(object);
+ break;
+ case DISPLAY_PRETTY:
+ ret = print_pretty(object);
+ break;
+ default:
+ ret = print_odb(object, display);
+ break;
+ }
+
+done:
+ git_object_free(object);
+ git_repository_free(repo);
+ return ret;
+}
diff --git a/src/cli/cmd_hash_object.c b/src/cli/cmd_hash_object.c
new file mode 100644
index 000000000..5cfe9146a
--- /dev/null
+++ b/src/cli/cmd_hash_object.c
@@ -0,0 +1,135 @@
+/*
+ * 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.
+ */
+
+#include <git2.h>
+#include "cli.h"
+#include "cmd.h"
+
+#include "futils.h"
+
+#define COMMAND_NAME "hash-object"
+
+static int show_help;
+static char *type_name;
+static int write_object, read_stdin, literally;
+static char **filenames;
+
+static const cli_opt_spec opts[] = {
+ { CLI_OPT_TYPE_SWITCH, "help", 0, &show_help, 1,
+ CLI_OPT_USAGE_HIDDEN | CLI_OPT_USAGE_STOP_PARSING, NULL,
+ "display help about the " COMMAND_NAME " command" },
+
+ { CLI_OPT_TYPE_VALUE, NULL, 't', &type_name, 0,
+ CLI_OPT_USAGE_DEFAULT, "type", "the type of object to hash (default: \"blob\")" },
+ { CLI_OPT_TYPE_SWITCH, NULL, 'w', &write_object, 1,
+ CLI_OPT_USAGE_DEFAULT, NULL, "write the object to the object database" },
+ { CLI_OPT_TYPE_SWITCH, "literally", 0, &literally, 1,
+ CLI_OPT_USAGE_DEFAULT, NULL, "do not validate the object contents" },
+ { CLI_OPT_TYPE_SWITCH, "stdin", 0, &read_stdin, 1,
+ CLI_OPT_USAGE_REQUIRED, NULL, "read content from stdin" },
+ { CLI_OPT_TYPE_ARGS, "file", 0, &filenames, 0,
+ CLI_OPT_USAGE_CHOICE, "file", "the file (or files) to read and hash" },
+ { 0 },
+};
+
+static void print_help(void)
+{
+ cli_opt_usage_fprint(stdout, PROGRAM_NAME, COMMAND_NAME, opts);
+ printf("\n");
+
+ printf("Compute the object ID for a given file and optionally write that file\nto the object database.\n");
+ printf("\n");
+
+ printf("Options:\n");
+
+ cli_opt_help_fprint(stdout, opts);
+}
+
+static int hash_buf(git_odb *odb, git_str *buf, git_object_t type)
+{
+ git_oid oid;
+
+ if (!literally) {
+ int valid = 0;
+
+ if (git_object_rawcontent_is_valid(&valid, buf->ptr, buf->size, type) < 0 || !valid)
+ return cli_error_git();
+ }
+
+ if (write_object) {
+ if (git_odb_write(&oid, odb, buf->ptr, buf->size, type) < 0)
+ return cli_error_git();
+ } else {
+ if (git_odb_hash(&oid, buf->ptr, buf->size, type) < 0)
+ return cli_error_git();
+ }
+
+ if (printf("%s\n", git_oid_tostr_s(&oid)) < 0)
+ return cli_error_os();
+
+ return 0;
+}
+
+int cmd_hash_object(int argc, char **argv)
+{
+ git_repository *repo = NULL;
+ git_odb *odb = NULL;
+ git_str buf = GIT_STR_INIT;
+ cli_opt invalid_opt;
+ git_object_t type = GIT_OBJECT_BLOB;
+ char **filename;
+ int ret = 0;
+
+ if (cli_opt_parse(&invalid_opt, opts, argv + 1, argc - 1, CLI_OPT_PARSE_GNU))
+ return cli_opt_usage_error(COMMAND_NAME, opts, &invalid_opt);
+
+ if (show_help) {
+ print_help();
+ return 0;
+ }
+
+ if (type_name && (type = git_object_string2type(type_name)) == GIT_OBJECT_INVALID)
+ return cli_error_usage("invalid object type '%s'", type_name);
+
+ if (write_object &&
+ (git_repository_open_ext(&repo, ".", GIT_REPOSITORY_OPEN_FROM_ENV, NULL) < 0 ||
+ git_repository_odb(&odb, repo) < 0)) {
+ ret = cli_error_git();
+ goto done;
+ }
+
+ /*
+ * TODO: we're reading blobs, we shouldn't pull them all into main
+ * memory, we should just stream them into the odb instead.
+ * (Or create a `git_odb_writefile` API.)
+ */
+ if (read_stdin) {
+ if (git_futils_readbuffer_fd_full(&buf, fileno(stdin)) < 0) {
+ ret = cli_error_git();
+ goto done;
+ }
+
+ if ((ret = hash_buf(odb, &buf, type)) != 0)
+ goto done;
+ } else {
+ for (filename = filenames; *filename; filename++) {
+ if (git_futils_readbuffer(&buf, *filename) < 0) {
+ ret = cli_error_git();
+ goto done;
+ }
+
+ if ((ret = hash_buf(odb, &buf, type)) != 0)
+ goto done;
+ }
+ }
+
+done:
+ git_str_dispose(&buf);
+ git_odb_free(odb);
+ git_repository_free(repo);
+ return ret;
+}
diff --git a/src/cli/cmd_help.c b/src/cli/cmd_help.c
new file mode 100644
index 000000000..7ee982242
--- /dev/null
+++ b/src/cli/cmd_help.c
@@ -0,0 +1,86 @@
+/*
+ * 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.
+ */
+
+#include <stdio.h>
+#include <git2.h>
+#include "cli.h"
+#include "cmd.h"
+
+#define COMMAND_NAME "help"
+
+static char *command;
+static int show_help;
+
+static const cli_opt_spec opts[] = {
+ { CLI_OPT_TYPE_SWITCH, "help", 0, &show_help, 1,
+ CLI_OPT_USAGE_HIDDEN, NULL, "display help about the help command" },
+ { CLI_OPT_TYPE_ARG, "command", 0, &command, 0,
+ CLI_OPT_USAGE_DEFAULT, "command", "the command to show help for" },
+ { 0 },
+};
+
+static int print_help(void)
+{
+ cli_opt_usage_fprint(stdout, PROGRAM_NAME, COMMAND_NAME, opts);
+ printf("\n");
+
+ printf("Display help information about %s. If a command is specified, help\n", PROGRAM_NAME);
+ printf("about that command will be shown. Otherwise, general information about\n");
+ printf("%s will be shown, including the commands available.\n", PROGRAM_NAME);
+
+ return 0;
+}
+
+static int print_commands(void)
+{
+ const cli_cmd_spec *cmd;
+
+ cli_opt_usage_fprint(stdout, PROGRAM_NAME, NULL, cli_common_opts);
+ printf("\n");
+
+ printf("These are the %s commands available:\n\n", PROGRAM_NAME);
+
+ for (cmd = cli_cmds; cmd->name; cmd++)
+ printf(" %-11s %s\n", cmd->name, cmd->desc);
+
+ printf("\nSee '%s help <command>' for more information on a specific command.\n", PROGRAM_NAME);
+
+ return 0;
+}
+
+int cmd_help(int argc, char **argv)
+{
+ char *fake_args[2];
+ const cli_cmd_spec *cmd;
+ cli_opt invalid_opt;
+
+ if (cli_opt_parse(&invalid_opt, opts, argv + 1, argc - 1, CLI_OPT_PARSE_GNU))
+ return cli_opt_usage_error(COMMAND_NAME, opts, &invalid_opt);
+
+ /* Show the meta-help */
+ if (show_help)
+ return print_help();
+
+ /* We were not asked to show help for a specific command. */
+ if (!command)
+ return print_commands();
+
+ /*
+ * If we were asked for help for a command (eg, `help <command>`),
+ * delegate back to that command's `--help` option. This lets
+ * commands own their help. Emulate the command-line arguments
+ * that would invoke `<command> --help` and invoke that command.
+ */
+ fake_args[0] = command;
+ fake_args[1] = "--help";
+
+ if ((cmd = cli_cmd_spec_byname(command)) == NULL)
+ return cli_error("'%s' is not a %s command. See '%s help'.",
+ command, PROGRAM_NAME, PROGRAM_NAME);
+
+ return cmd->fn(2, fake_args);
+}
diff --git a/src/cli/error.h b/src/cli/error.h
new file mode 100644
index 000000000..cce7a54c0
--- /dev/null
+++ b/src/cli/error.h
@@ -0,0 +1,51 @@
+/*
+ * 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 CLI_error_h__
+#define CLI_error_h__
+
+#include "cli.h"
+#include <stdio.h>
+
+#define CLI_EXIT_OK 0
+#define CLI_EXIT_ERROR 1
+#define CLI_EXIT_OS 128
+#define CLI_EXIT_GIT 128
+#define CLI_EXIT_USAGE 129
+
+#define cli_error__print(fmt) do { \
+ va_list ap; \
+ va_start(ap, fmt); \
+ fprintf(stderr, "%s: ", PROGRAM_NAME); \
+ vfprintf(stderr, fmt, ap); \
+ fprintf(stderr, "\n"); \
+ va_end(ap); \
+ } while(0)
+
+GIT_INLINE(int) cli_error(const char *fmt, ...)
+{
+ cli_error__print(fmt);
+ return CLI_EXIT_ERROR;
+}
+
+GIT_INLINE(int) cli_error_usage(const char *fmt, ...)
+{
+ cli_error__print(fmt);
+ return CLI_EXIT_USAGE;
+}
+
+GIT_INLINE(int) cli_error_git(void)
+{
+ const git_error *err = git_error_last();
+ fprintf(stderr, "%s: %s\n", PROGRAM_NAME,
+ err ? err->message : "unknown error");
+ return CLI_EXIT_GIT;
+}
+
+#define cli_error_os() (perror(PROGRAM_NAME), CLI_EXIT_OS)
+
+#endif /* CLI_error_h__ */
diff --git a/src/cli/main.c b/src/cli/main.c
new file mode 100644
index 000000000..08abb324f
--- /dev/null
+++ b/src/cli/main.c
@@ -0,0 +1,105 @@
+/*
+ * 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.
+ */
+
+#include <stdio.h>
+#include <git2.h>
+#include "cli.h"
+#include "cmd.h"
+
+static int show_help = 0;
+static int show_version = 0;
+static char *command = NULL;
+static char **args = NULL;
+
+const cli_opt_spec cli_common_opts[] = {
+ { CLI_OPT_TYPE_SWITCH, "help", 0, &show_help, 1,
+ CLI_OPT_USAGE_DEFAULT, NULL, "display help information" },
+ { CLI_OPT_TYPE_SWITCH, "version", 0, &show_version, 1,
+ CLI_OPT_USAGE_DEFAULT, NULL, "display the version" },
+ { CLI_OPT_TYPE_ARG, "command", 0, &command, 0,
+ CLI_OPT_USAGE_REQUIRED, "command", "the command to run" },
+ { CLI_OPT_TYPE_ARGS, "args", 0, &args, 0,
+ CLI_OPT_USAGE_DEFAULT, "args", "arguments for the command" },
+ { 0 }
+};
+
+const cli_cmd_spec cli_cmds[] = {
+ { "cat-file", cmd_cat_file, "Display an object in the repository" },
+ { "hash-object", cmd_hash_object, "Hash a raw object and product its object ID" },
+ { "help", cmd_help, "Display help information" },
+ { NULL }
+};
+
+int main(int argc, char **argv)
+{
+ const cli_cmd_spec *cmd;
+ cli_opt_parser optparser;
+ cli_opt opt;
+ char *help_args[3] = { NULL };
+ int help_args_len;
+ int args_len = 0;
+ int ret = 0;
+
+ if (git_libgit2_init() < 0) {
+ cli_error("failed to initialize libgit2");
+ exit(CLI_EXIT_GIT);
+ }
+
+ cli_opt_parser_init(&optparser, cli_common_opts, argv + 1, argc - 1, CLI_OPT_PARSE_GNU);
+
+ /* Parse the top-level (common) options and command information */
+ while (cli_opt_parser_next(&opt, &optparser)) {
+ if (!opt.spec) {
+ cli_opt_status_fprint(stderr, PROGRAM_NAME, &opt);
+ cli_opt_usage_fprint(stderr, PROGRAM_NAME, NULL, cli_common_opts);
+ ret = CLI_EXIT_USAGE;
+ goto done;
+ }
+
+ /*
+ * When we see a command, stop parsing and capture the
+ * remaining arguments as args for the command itself.
+ */
+ if (command) {
+ args = &argv[optparser.idx];
+ args_len = (int)(argc - optparser.idx);
+ break;
+ }
+ }
+
+ if (show_version) {
+ printf("%s version %s\n", PROGRAM_NAME, LIBGIT2_VERSION);
+ goto done;
+ }
+
+ /*
+ * If `--help <command>` is specified, delegate to that command's
+ * `--help` option. If no command is specified, run the `help`
+ * command. Do this by updating the args to emulate that behavior.
+ */
+ if (!command || show_help) {
+ help_args[0] = command ? (char *)command : "help";
+ help_args[1] = command ? "--help" : NULL;
+ help_args_len = command ? 2 : 1;
+
+ command = help_args[0];
+ args = help_args;
+ args_len = help_args_len;
+ }
+
+ if ((cmd = cli_cmd_spec_byname(command)) == NULL) {
+ ret = cli_error("'%s' is not a %s command. See '%s help'.",
+ command, PROGRAM_NAME, PROGRAM_NAME);
+ goto done;
+ }
+
+ ret = cmd->fn(args_len, args);
+
+done:
+ git_libgit2_shutdown();
+ return ret;
+}
diff --git a/src/cli/opt.c b/src/cli/opt.c
new file mode 100644
index 000000000..72df5877f
--- /dev/null
+++ b/src/cli/opt.c
@@ -0,0 +1,669 @@
+/*
+ * Copyright (c), Edward Thomson <ethomson@edwardthomson.com>
+ * All rights reserved.
+ *
+ * This file is part of adopt, distributed under the MIT license.
+ * For full terms and conditions, see the included LICENSE file.
+ *
+ * THIS FILE IS AUTOMATICALLY GENERATED; DO NOT EDIT.
+ *
+ * This file was produced by using the `rename.pl` script included with
+ * adopt. The command-line specified was:
+ *
+ * ./rename.pl cli_opt --filename=opt --include=cli.h --inline=GIT_INLINE --header-guard=CLI_opt_h__ --lowercase-status --without-usage
+ */
+
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+#include <limits.h>
+#include <assert.h>
+
+#include "cli.h"
+#include "opt.h"
+
+#ifdef _WIN32
+# include <Windows.h>
+#else
+# include <fcntl.h>
+# include <sys/ioctl.h>
+#endif
+
+#ifdef _MSC_VER
+# define alloca _alloca
+#endif
+
+#define spec_is_option_type(x) \
+ ((x)->type == CLI_OPT_TYPE_BOOL || \
+ (x)->type == CLI_OPT_TYPE_SWITCH || \
+ (x)->type == CLI_OPT_TYPE_VALUE)
+
+GIT_INLINE(const cli_opt_spec *) spec_for_long(
+ int *is_negated,
+ int *has_value,
+ const char **value,
+ const cli_opt_parser *parser,
+ const char *arg)
+{
+ const cli_opt_spec *spec;
+ char *eql;
+ size_t eql_pos;
+
+ eql = strchr(arg, '=');
+ eql_pos = (eql = strchr(arg, '=')) ? (size_t)(eql - arg) : strlen(arg);
+
+ for (spec = parser->specs; spec->type; ++spec) {
+ /* Handle -- (everything after this is literal) */
+ if (spec->type == CLI_OPT_TYPE_LITERAL && arg[0] == '\0')
+ return spec;
+
+ /* Handle --no-option arguments for bool types */
+ if (spec->type == CLI_OPT_TYPE_BOOL &&
+ strncmp(arg, "no-", 3) == 0 &&
+ strcmp(arg + 3, spec->name) == 0) {
+ *is_negated = 1;
+ return spec;
+ }
+
+ /* Handle the typical --option arguments */
+ if (spec_is_option_type(spec) &&
+ spec->name &&
+ strcmp(arg, spec->name) == 0)
+ return spec;
+
+ /* Handle --option=value arguments */
+ if (spec->type == CLI_OPT_TYPE_VALUE &&
+ eql &&
+ strncmp(arg, spec->name, eql_pos) == 0 &&
+ spec->name[eql_pos] == '\0') {
+ *has_value = 1;
+ *value = arg[eql_pos + 1] ? &arg[eql_pos + 1] : NULL;
+ return spec;
+ }
+ }
+
+ return NULL;
+}
+
+GIT_INLINE(const cli_opt_spec *) spec_for_short(
+ const char **value,
+ const cli_opt_parser *parser,
+ const char *arg)
+{
+ const cli_opt_spec *spec;
+
+ for (spec = parser->specs; spec->type; ++spec) {
+ /* Handle -svalue short options with a value */
+ if (spec->type == CLI_OPT_TYPE_VALUE &&
+ arg[0] == spec->alias &&
+ arg[1] != '\0') {
+ *value = &arg[1];
+ return spec;
+ }
+
+ /* Handle typical -s short options */
+ if (arg[0] == spec->alias) {
+ *value = NULL;
+ return spec;
+ }
+ }
+
+ return NULL;
+}
+
+GIT_INLINE(const cli_opt_spec *) spec_for_arg(cli_opt_parser *parser)
+{
+ const cli_opt_spec *spec;
+ size_t args = 0;
+
+ for (spec = parser->specs; spec->type; ++spec) {
+ if (spec->type == CLI_OPT_TYPE_ARG) {
+ if (args == parser->arg_idx) {
+ parser->arg_idx++;
+ return spec;
+ }
+
+ args++;
+ }
+
+ if (spec->type == CLI_OPT_TYPE_ARGS && args == parser->arg_idx)
+ return spec;
+ }
+
+ return NULL;
+}
+
+GIT_INLINE(int) spec_is_choice(const cli_opt_spec *spec)
+{
+ return ((spec + 1)->type &&
+ ((spec + 1)->usage & CLI_OPT_USAGE_CHOICE));
+}
+
+/*
+ * If we have a choice with switches and bare arguments, and we see
+ * the switch, then we no longer expect the bare argument.
+ */
+GIT_INLINE(void) consume_choices(const cli_opt_spec *spec, cli_opt_parser *parser)
+{
+ /* back up to the beginning of the choices */
+ while (spec->type && (spec->usage & CLI_OPT_USAGE_CHOICE))
+ --spec;
+
+ if (!spec_is_choice(spec))
+ return;
+
+ do {
+ if (spec->type == CLI_OPT_TYPE_ARG)
+ parser->arg_idx++;
+ ++spec;
+ } while(spec->type && (spec->usage & CLI_OPT_USAGE_CHOICE));
+}
+
+static cli_opt_status_t parse_long(cli_opt *opt, cli_opt_parser *parser)
+{
+ const cli_opt_spec *spec;
+ char *arg = parser->args[parser->idx++];
+ const char *value = NULL;
+ int is_negated = 0, has_value = 0;
+
+ opt->arg = arg;
+
+ if ((spec = spec_for_long(&is_negated, &has_value, &value, parser, &arg[2])) == NULL) {
+ opt->spec = NULL;
+ opt->status = CLI_OPT_STATUS_UNKNOWN_OPTION;
+ goto done;
+ }
+
+ opt->spec = spec;
+
+ /* Future options parsed as literal */
+ if (spec->type == CLI_OPT_TYPE_LITERAL)
+ parser->in_literal = 1;
+
+ /* --bool or --no-bool */
+ else if (spec->type == CLI_OPT_TYPE_BOOL && spec->value)
+ *((int *)spec->value) = !is_negated;
+
+ /* --accumulate */
+ else if (spec->type == CLI_OPT_TYPE_ACCUMULATOR && spec->value)
+ *((int *)spec->value) += spec->switch_value ? spec->switch_value : 1;
+
+ /* --switch */
+ else if (spec->type == CLI_OPT_TYPE_SWITCH && spec->value)
+ *((int *)spec->value) = spec->switch_value;
+
+ /* Parse values as "--foo=bar" or "--foo bar" */
+ else if (spec->type == CLI_OPT_TYPE_VALUE) {
+ if (has_value)
+ opt->value = (char *)value;
+ else if ((parser->idx + 1) <= parser->args_len)
+ opt->value = parser->args[parser->idx++];
+
+ if (spec->value)
+ *((char **)spec->value) = opt->value;
+ }
+
+ /* Required argument was not provided */
+ if (spec->type == CLI_OPT_TYPE_VALUE &&
+ !opt->value &&
+ !(spec->usage & CLI_OPT_USAGE_VALUE_OPTIONAL))
+ opt->status = CLI_OPT_STATUS_MISSING_VALUE;
+ else
+ opt->status = CLI_OPT_STATUS_OK;
+
+ consume_choices(opt->spec, parser);
+
+done:
+ return opt->status;
+}
+
+static cli_opt_status_t parse_short(cli_opt *opt, cli_opt_parser *parser)
+{
+ const cli_opt_spec *spec;
+ char *arg = parser->args[parser->idx++];
+ const char *value;
+
+ opt->arg = arg;
+
+ if ((spec = spec_for_short(&value, parser, &arg[1 + parser->in_short])) == NULL) {
+ opt->spec = NULL;
+ opt->status = CLI_OPT_STATUS_UNKNOWN_OPTION;
+ goto done;
+ }
+
+ opt->spec = spec;
+
+ if (spec->type == CLI_OPT_TYPE_BOOL && spec->value)
+ *((int *)spec->value) = 1;
+
+ else if (spec->type == CLI_OPT_TYPE_ACCUMULATOR && spec->value)
+ *((int *)spec->value) += spec->switch_value ? spec->switch_value : 1;
+
+ else if (spec->type == CLI_OPT_TYPE_SWITCH && spec->value)
+ *((int *)spec->value) = spec->switch_value;
+
+ /* Parse values as "-ifoo" or "-i foo" */
+ else if (spec->type == CLI_OPT_TYPE_VALUE) {
+ if (value)
+ opt->value = (char *)value;
+ else if ((parser->idx + 1) <= parser->args_len)
+ opt->value = parser->args[parser->idx++];
+
+ if (spec->value)
+ *((char **)spec->value) = opt->value;
+ }
+
+ /*
+ * Handle compressed short arguments, like "-fbcd"; see if there's
+ * another character after the one we processed. If not, advance
+ * the parser index.
+ */
+ if (spec->type != CLI_OPT_TYPE_VALUE && arg[2 + parser->in_short] != '\0') {
+ parser->in_short++;
+ parser->idx--;
+ } else {
+ parser->in_short = 0;
+ }
+
+ /* Required argument was not provided */
+ if (spec->type == CLI_OPT_TYPE_VALUE && !opt->value)
+ opt->status = CLI_OPT_STATUS_MISSING_VALUE;
+ else
+ opt->status = CLI_OPT_STATUS_OK;
+
+ consume_choices(opt->spec, parser);
+
+done:
+ return opt->status;
+}
+
+static cli_opt_status_t parse_arg(cli_opt *opt, cli_opt_parser *parser)
+{
+ const cli_opt_spec *spec = spec_for_arg(parser);
+
+ opt->spec = spec;
+ opt->arg = parser->args[parser->idx];
+
+ if (!spec) {
+ parser->idx++;
+ opt->status = CLI_OPT_STATUS_UNKNOWN_OPTION;
+ } else if (spec->type == CLI_OPT_TYPE_ARGS) {
+ if (spec->value)
+ *((char ***)spec->value) = &parser->args[parser->idx];
+
+ /*
+ * We have started a list of arguments; the remainder of
+ * given arguments need not be examined.
+ */
+ parser->in_args = (parser->args_len - parser->idx);
+ parser->idx = parser->args_len;
+ opt->args_len = parser->in_args;
+ opt->status = CLI_OPT_STATUS_OK;
+ } else {
+ if (spec->value)
+ *((char **)spec->value) = parser->args[parser->idx];
+
+ parser->idx++;
+ opt->status = CLI_OPT_STATUS_OK;
+ }
+
+ return opt->status;
+}
+
+static int support_gnu_style(unsigned int flags)
+{
+ if ((flags & CLI_OPT_PARSE_FORCE_GNU) != 0)
+ return 1;
+
+ if ((flags & CLI_OPT_PARSE_GNU) == 0)
+ return 0;
+
+ /* TODO: Windows */
+#if defined(_WIN32) && defined(UNICODE)
+ if (_wgetenv(L"POSIXLY_CORRECT") != NULL)
+ return 0;
+#else
+ if (getenv("POSIXLY_CORRECT") != NULL)
+ return 0;
+#endif
+
+ return 1;
+}
+
+void cli_opt_parser_init(
+ cli_opt_parser *parser,
+ const cli_opt_spec specs[],
+ char **args,
+ size_t args_len,
+ unsigned int flags)
+{
+ assert(parser);
+
+ memset(parser, 0x0, sizeof(cli_opt_parser));
+
+ parser->specs = specs;
+ parser->args = args;
+ parser->args_len = args_len;
+ parser->flags = flags;
+
+ parser->needs_sort = support_gnu_style(flags);
+}
+
+GIT_INLINE(const cli_opt_spec *) spec_for_sort(
+ int *needs_value,
+ const cli_opt_parser *parser,
+ const char *arg)
+{
+ int is_negated, has_value = 0;
+ const char *value;
+ const cli_opt_spec *spec = NULL;
+ size_t idx = 0;
+
+ *needs_value = 0;
+
+ if (strncmp(arg, "--", 2) == 0) {
+ spec = spec_for_long(&is_negated, &has_value, &value, parser, &arg[2]);
+ *needs_value = !has_value;
+ }
+
+ else if (strncmp(arg, "-", 1) == 0) {
+ spec = spec_for_short(&value, parser, &arg[1]);
+
+ /*
+ * Advance through compressed short arguments to see if
+ * the last one has a value, eg "-xvffilename".
+ */
+ while (spec && !value && arg[1 + ++idx] != '\0')
+ spec = spec_for_short(&value, parser, &arg[1 + idx]);
+
+ *needs_value = (value == NULL);
+ }
+
+ return spec;
+}
+
+/*
+ * Some parsers allow for handling arguments like "file1 --help file2";
+ * this is done by re-sorting the arguments in-place; emulate that.
+ */
+static int sort_gnu_style(cli_opt_parser *parser)
+{
+ size_t i, j, insert_idx = parser->idx, offset;
+ const cli_opt_spec *spec;
+ char *option, *value;
+ int needs_value, changed = 0;
+
+ parser->needs_sort = 0;
+
+ for (i = parser->idx; i < parser->args_len; i++) {
+ spec = spec_for_sort(&needs_value, parser, parser->args[i]);
+
+ /* Not a "-" or "--" prefixed option. No change. */
+ if (!spec)
+ continue;
+
+ /* A "--" alone means remaining args are literal. */
+ if (spec->type == CLI_OPT_TYPE_LITERAL)
+ break;
+
+ option = parser->args[i];
+
+ /*
+ * If the argument is a value type and doesn't already
+ * have a value (eg "--foo=bar" or "-fbar") then we need
+ * to copy the next argument as its value.
+ */
+ if (spec->type == CLI_OPT_TYPE_VALUE && needs_value) {
+ /*
+ * A required value is not provided; set parser
+ * index to this value so that we fail on it.
+ */
+ if (i + 1 >= parser->args_len) {
+ parser->idx = i;
+ return 1;
+ }
+
+ value = parser->args[i + 1];
+ offset = 1;
+ } else {
+ value = NULL;
+ offset = 0;
+ }
+
+ /* Caller error if args[0] is an option. */
+ if (i == 0)
+ return 0;
+
+ /* Shift args up one (or two) and insert the option */
+ for (j = i; j > insert_idx; j--)
+ parser->args[j + offset] = parser->args[j - 1];
+
+ parser->args[insert_idx] = option;
+
+ if (value)
+ parser->args[insert_idx + 1] = value;
+
+ insert_idx += (1 + offset);
+ i += offset;
+
+ changed = 1;
+ }
+
+ return changed;
+}
+
+cli_opt_status_t cli_opt_parser_next(cli_opt *opt, cli_opt_parser *parser)
+{
+ assert(opt && parser);
+
+ memset(opt, 0x0, sizeof(cli_opt));
+
+ if (parser->idx >= parser->args_len) {
+ opt->args_len = parser->in_args;
+ return CLI_OPT_STATUS_DONE;
+ }
+
+ /* Handle options in long form, those beginning with "--" */
+ if (strncmp(parser->args[parser->idx], "--", 2) == 0 &&
+ !parser->in_short &&
+ !parser->in_literal)
+ return parse_long(opt, parser);
+
+ /* Handle options in short form, those beginning with "-" */
+ else if (parser->in_short ||
+ (strncmp(parser->args[parser->idx], "-", 1) == 0 &&
+ !parser->in_literal))
+ return parse_short(opt, parser);
+
+ /*
+ * We've reached the first "bare" argument. In POSIX mode, all
+ * remaining items on the command line are arguments. In GNU
+ * mode, there may be long or short options after this. Sort any
+ * options up to this position then re-parse the current position.
+ */
+ if (parser->needs_sort && sort_gnu_style(parser))
+ return cli_opt_parser_next(opt, parser);
+
+ return parse_arg(opt, parser);
+}
+
+GIT_INLINE(int) spec_included(const cli_opt_spec **specs, const cli_opt_spec *spec)
+{
+ const cli_opt_spec **i;
+
+ for (i = specs; *i; ++i) {
+ if (spec == *i)
+ return 1;
+ }
+
+ return 0;
+}
+
+static cli_opt_status_t validate_required(
+ cli_opt *opt,
+ const cli_opt_spec specs[],
+ const cli_opt_spec **given_specs)
+{
+ const cli_opt_spec *spec, *required;
+ int given;
+
+ /*
+ * Iterate over the possible specs to identify requirements and
+ * ensure that those have been given on the command-line.
+ * Note that we can have required *choices*, where one in a
+ * list of choices must be specified.
+ */
+ for (spec = specs, required = NULL, given = 0; spec->type; ++spec) {
+ if (!required && (spec->usage & CLI_OPT_USAGE_REQUIRED)) {
+ required = spec;
+ given = 0;
+ } else if (!required) {
+ continue;
+ }
+
+ if (!given)
+ given = spec_included(given_specs, spec);
+
+ /*
+ * Validate the requirement unless we're in a required
+ * choice. In that case, keep the required state and
+ * validate at the end of the choice list.
+ */
+ if (!spec_is_choice(spec)) {
+ if (!given) {
+ opt->spec = required;
+ opt->status = CLI_OPT_STATUS_MISSING_ARGUMENT;
+ break;
+ }
+
+ required = NULL;
+ given = 0;
+ }
+ }
+
+ return opt->status;
+}
+
+cli_opt_status_t cli_opt_parse(
+ cli_opt *opt,
+ const cli_opt_spec specs[],
+ char **args,
+ size_t args_len,
+ unsigned int flags)
+{
+ cli_opt_parser parser;
+ const cli_opt_spec **given_specs;
+ size_t given_idx = 0;
+
+ cli_opt_parser_init(&parser, specs, args, args_len, flags);
+
+ given_specs = alloca(sizeof(const cli_opt_spec *) * (args_len + 1));
+
+ while (cli_opt_parser_next(opt, &parser)) {
+ if (opt->status != CLI_OPT_STATUS_OK &&
+ opt->status != CLI_OPT_STATUS_DONE)
+ return opt->status;
+
+ if ((opt->spec->usage & CLI_OPT_USAGE_STOP_PARSING))
+ return (opt->status = CLI_OPT_STATUS_DONE);
+
+ given_specs[given_idx++] = opt->spec;
+ }
+
+ given_specs[given_idx] = NULL;
+
+ return validate_required(opt, specs, given_specs);
+}
+
+static int spec_name_fprint(FILE *file, const cli_opt_spec *spec)
+{
+ int error;
+
+ if (spec->type == CLI_OPT_TYPE_ARG)
+ error = fprintf(file, "%s", spec->value_name);
+ else if (spec->type == CLI_OPT_TYPE_ARGS)
+ error = fprintf(file, "%s", spec->value_name);
+ else if (spec->alias && !(spec->usage & CLI_OPT_USAGE_SHOW_LONG))
+ error = fprintf(file, "-%c", spec->alias);
+ else
+ error = fprintf(file, "--%s", spec->name);
+
+ return error;
+}
+
+int cli_opt_status_fprint(
+ FILE *file,
+ const char *command,
+ const cli_opt *opt)
+{
+ const cli_opt_spec *choice;
+ int error;
+
+ if (command && (error = fprintf(file, "%s: ", command)) < 0)
+ return error;
+
+ switch (opt->status) {
+ case CLI_OPT_STATUS_DONE:
+ error = fprintf(file, "finished processing arguments (no error)\n");
+ break;
+ case CLI_OPT_STATUS_OK:
+ error = fprintf(file, "no error\n");
+ break;
+ case CLI_OPT_STATUS_UNKNOWN_OPTION:
+ error = fprintf(file, "unknown option: %s\n", opt->arg);
+ break;
+ case CLI_OPT_STATUS_MISSING_VALUE:
+ if ((error = fprintf(file, "argument '")) < 0 ||
+ (error = spec_name_fprint(file, opt->spec)) < 0 ||
+ (error = fprintf(file, "' requires a value.\n")) < 0)
+ break;
+ break;
+ case CLI_OPT_STATUS_MISSING_ARGUMENT:
+ if (spec_is_choice(opt->spec)) {
+ int is_choice = 1;
+
+ if (spec_is_choice((opt->spec)+1))
+ error = fprintf(file, "one of");
+ else
+ error = fprintf(file, "either");
+
+ if (error < 0)
+ break;
+
+ for (choice = opt->spec; is_choice; ++choice) {
+ is_choice = spec_is_choice(choice);
+
+ if (!is_choice)
+ error = fprintf(file, " or");
+ else if (choice != opt->spec)
+ error = fprintf(file, ",");
+
+ if ((error < 0) ||
+ (error = fprintf(file, " '")) < 0 ||
+ (error = spec_name_fprint(file, choice)) < 0 ||
+ (error = fprintf(file, "'")) < 0)
+ break;
+
+ if (!spec_is_choice(choice))
+ break;
+ }
+
+ if ((error < 0) ||
+ (error = fprintf(file, " is required.\n")) < 0)
+ break;
+ } else {
+ if ((error = fprintf(file, "argument '")) < 0 ||
+ (error = spec_name_fprint(file, opt->spec)) < 0 ||
+ (error = fprintf(file, "' is required.\n")) < 0)
+ break;
+ }
+
+ break;
+ default:
+ error = fprintf(file, "unknown status: %d\n", opt->status);
+ break;
+ }
+
+ return error;
+}
+
diff --git a/src/cli/opt.h b/src/cli/opt.h
new file mode 100644
index 000000000..6c1d4603e
--- /dev/null
+++ b/src/cli/opt.h
@@ -0,0 +1,349 @@
+/*
+ * Copyright (c), Edward Thomson <ethomson@edwardthomson.com>
+ * All rights reserved.
+ *
+ * This file is part of adopt, distributed under the MIT license.
+ * For full terms and conditions, see the included LICENSE file.
+ *
+ * THIS FILE IS AUTOMATICALLY GENERATED; DO NOT EDIT.
+ *
+ * This file was produced by using the `rename.pl` script included with
+ * adopt. The command-line specified was:
+ *
+ * ./rename.pl cli_opt --filename=opt --include=cli.h --inline=GIT_INLINE --header-guard=CLI_opt_h__ --lowercase-status --without-usage
+ */
+
+#ifndef CLI_opt_h__
+#define CLI_opt_h__
+
+#include <stdio.h>
+#include <stdint.h>
+
+/**
+ * The type of argument to be parsed.
+ */
+typedef enum {
+ CLI_OPT_TYPE_NONE = 0,
+
+ /**
+ * An option that, when specified, sets a given value to true.
+ * This is useful for options like "--debug". A negation
+ * option (beginning with "no-") is implicitly specified; for
+ * example "--no-debug". The `value` pointer in the returned
+ * option will be set to `1` when this is specified, and set to
+ * `0` when the negation "no-" option is specified.
+ */
+ CLI_OPT_TYPE_BOOL,
+
+ /**
+ * An option that, when specified, sets the given `value` pointer
+ * to the specified `switch_value`. This is useful for booleans
+ * where you do not want the implicit negation that comes with an
+ * `CLI_OPT_TYPE_BOOL`, or for switches that multiplex a value, like
+ * setting a mode. For example, `--read` may set the `value` to
+ * `MODE_READ` and `--write` may set the `value` to `MODE_WRITE`.
+ */
+ CLI_OPT_TYPE_SWITCH,
+
+ /**
+ * An option that, when specified, increments the given
+ * `value` by the given `switch_value`. This can be specified
+ * multiple times to continue to increment the `value`.
+ * (For example, "-vvv" to set verbosity to 3.)
+ */
+ CLI_OPT_TYPE_ACCUMULATOR,
+
+ /**
+ * An option that takes a value, for example `-n value`,
+ * `-nvalue`, `--name value` or `--name=value`.
+ */
+ CLI_OPT_TYPE_VALUE,
+
+ /**
+ * A bare "--" that indicates that arguments following this are
+ * literal. This allows callers to specify things that might
+ * otherwise look like options, for example to operate on a file
+ * named "-rf" then you can invoke "program -- -rf" to treat
+ * "-rf" as an argument not an option.
+ */
+ CLI_OPT_TYPE_LITERAL,
+
+ /**
+ * A single argument, not an option. When options are exhausted,
+ * arguments will be matches in the order that they're specified
+ * in the spec list. For example, if two `CLI_OPT_TYPE_ARGS` are
+ * specified, `input_file` and `output_file`, then the first bare
+ * argument on the command line will be `input_file` and the
+ * second will be `output_file`.
+ */
+ CLI_OPT_TYPE_ARG,
+
+ /**
+ * A collection of arguments. This is useful when you want to take
+ * a list of arguments, for example, multiple paths. When specified,
+ * the value will be set to the first argument in the list.
+ */
+ CLI_OPT_TYPE_ARGS,
+} cli_opt_type_t;
+
+/**
+ * Additional information about an option, including parsing
+ * restrictions and usage information to be displayed to the end-user.
+ */
+typedef enum {
+ /** Defaults for the argument. */
+ CLI_OPT_USAGE_DEFAULT = 0,
+
+ /** This argument is required. */
+ CLI_OPT_USAGE_REQUIRED = (1u << 0),
+
+ /**
+ * This is a multiple choice argument, combined with the previous
+ * argument. For example, when the previous argument is `-f` and
+ * this optional is applied to an argument of type `-b` then one
+ * of `-f` or `-b` may be specified.
+ */
+ CLI_OPT_USAGE_CHOICE = (1u << 1),
+
+ /**
+ * This argument short-circuits the remainder of parsing.
+ * Useful for arguments like `--help`.
+ */
+ CLI_OPT_USAGE_STOP_PARSING = (1u << 2),
+
+ /** The argument's value is optional ("-n" or "-n foo") */
+ CLI_OPT_USAGE_VALUE_OPTIONAL = (1u << 3),
+
+ /** This argument should not be displayed in usage. */
+ CLI_OPT_USAGE_HIDDEN = (1u << 4),
+
+ /** In usage, show the long format instead of the abbreviated format. */
+ CLI_OPT_USAGE_SHOW_LONG = (1u << 5),
+} cli_opt_usage_t;
+
+typedef enum {
+ /** Default parsing behavior. */
+ CLI_OPT_PARSE_DEFAULT = 0,
+
+ /**
+ * Parse with GNU `getopt_long` style behavior, where options can
+ * be intermixed with arguments at any position (for example,
+ * "file1 --help file2".) Like `getopt_long`, this can mutate the
+ * arguments given.
+ */
+ CLI_OPT_PARSE_GNU = (1u << 0),
+
+ /**
+ * Force GNU `getopt_long` style behavior; the `POSIXLY_CORRECT`
+ * environment variable is ignored.
+ */
+ CLI_OPT_PARSE_FORCE_GNU = (1u << 1),
+} cli_opt_flag_t;
+
+/** Specification for an available option. */
+typedef struct cli_opt_spec {
+ /** Type of option expected. */
+ cli_opt_type_t type;
+
+ /** Name of the long option. */
+ const char *name;
+
+ /** The alias is the short (one-character) option alias. */
+ const char alias;
+
+ /**
+ * If this spec is of type `CLI_OPT_TYPE_BOOL`, this is a pointer
+ * to an `int` that will be set to `1` if the option is specified.
+ *
+ * If this spec is of type `CLI_OPT_TYPE_SWITCH`, this is a pointer
+ * to an `int` that will be set to the opt's `switch_value` (below)
+ * when this option is specified.
+ *
+ * If this spec is of type `CLI_OPT_TYPE_ACCUMULATOR`, this is a
+ * pointer to an `int` that will be incremented by the opt's
+ * `switch_value` (below). If no `switch_value` is provided then
+ * the value will be incremented by 1.
+ *
+ * If this spec is of type `CLI_OPT_TYPE_VALUE`,
+ * `CLI_OPT_TYPE_VALUE_OPTIONAL`, or `CLI_OPT_TYPE_ARG`, this is
+ * a pointer to a `char *` that will be set to the value
+ * specified on the command line.
+ *
+ * If this spec is of type `CLI_OPT_TYPE_ARGS`, this is a pointer
+ * to a `char **` that will be set to the remaining values
+ * specified on the command line.
+ */
+ void *value;
+
+ /**
+ * If this spec is of type `CLI_OPT_TYPE_SWITCH`, this is the value
+ * to set in the option's `value` pointer when it is specified. If
+ * this spec is of type `CLI_OPT_TYPE_ACCUMULATOR`, this is the value
+ * to increment in the option's `value` pointer when it is
+ * specified. This is ignored for other opt types.
+ */
+ int switch_value;
+
+ /**
+ * Optional usage flags that change parsing behavior and how
+ * usage information is shown to the end-user.
+ */
+ uint32_t usage;
+
+ /**
+ * The name of the value, provided when creating usage information.
+ * This is required only for the functions that display usage
+ * information and only when a spec is of type `CLI_OPT_TYPE_VALUE,
+ * `CLI_OPT_TYPE_ARG` or `CLI_OPT_TYPE_ARGS``.
+ */
+ const char *value_name;
+
+ /**
+ * Optional short description of the option to display to the
+ * end-user. This is only used when creating usage information.
+ */
+ const char *help;
+} cli_opt_spec;
+
+/** Return value for `cli_opt_parser_next`. */
+typedef enum {
+ /** Parsing is complete; there are no more arguments. */
+ CLI_OPT_STATUS_DONE = 0,
+
+ /**
+ * This argument was parsed correctly; the `opt` structure is
+ * populated and the value pointer has been set.
+ */
+ CLI_OPT_STATUS_OK = 1,
+
+ /**
+ * The argument could not be parsed correctly, it does not match
+ * any of the specifications provided.
+ */
+ CLI_OPT_STATUS_UNKNOWN_OPTION = 2,
+
+ /**
+ * The argument matched a spec of type `CLI_OPT_VALUE`, but no value
+ * was provided.
+ */
+ CLI_OPT_STATUS_MISSING_VALUE = 3,
+
+ /** A required argument was not provided. */
+ CLI_OPT_STATUS_MISSING_ARGUMENT = 4,
+} cli_opt_status_t;
+
+/** An option provided on the command-line. */
+typedef struct cli_opt {
+ /** The status of parsing the most recent argument. */
+ cli_opt_status_t status;
+
+ /**
+ * The specification that was provided on the command-line, or
+ * `NULL` if the argument did not match an `cli_opt_spec`.
+ */
+ const cli_opt_spec *spec;
+
+ /**
+ * The argument as it was specified on the command-line, including
+ * dashes, eg, `-f` or `--foo`.
+ */
+ char *arg;
+
+ /**
+ * If the spec is of type `CLI_OPT_VALUE` or `CLI_OPT_VALUE_OPTIONAL`,
+ * this is the value provided to the argument.
+ */
+ char *value;
+
+ /**
+ * If the argument is of type `CLI_OPT_ARGS`, this is the number of
+ * arguments remaining. This value is persisted even when parsing
+ * is complete and `status` == `CLI_OPT_STATUS_DONE`.
+ */
+ size_t args_len;
+} cli_opt;
+
+/* The internal parser state. Callers should not modify this structure. */
+typedef struct cli_opt_parser {
+ const cli_opt_spec *specs;
+ char **args;
+ size_t args_len;
+ unsigned int flags;
+
+ /* Parser state */
+ size_t idx;
+ size_t arg_idx;
+ size_t in_args;
+ size_t in_short;
+ int needs_sort : 1,
+ in_literal : 1;
+} cli_opt_parser;
+
+/**
+ * Parses all the command-line arguments and updates all the options using
+ * the pointers provided. Parsing stops on any invalid argument and
+ * information about the failure will be provided in the opt argument.
+ *
+ * This is the simplest way to parse options; it handles the initialization
+ * (`parser_init`) and looping (`parser_next`).
+ *
+ * @param opt The The `cli_opt` information that failed parsing
+ * @param specs A NULL-terminated array of `cli_opt_spec`s that can be parsed
+ * @param args The arguments that will be parsed
+ * @param args_len The length of arguments to be parsed
+ * @param flags The `cli_opt_flag_t flags for parsing
+ */
+cli_opt_status_t cli_opt_parse(
+ cli_opt *opt,
+ const cli_opt_spec specs[],
+ char **args,
+ size_t args_len,
+ unsigned int flags);
+
+/**
+ * Initializes a parser that parses the given arguments according to the
+ * given specifications.
+ *
+ * @param parser The `cli_opt_parser` that will be initialized
+ * @param specs A NULL-terminated array of `cli_opt_spec`s that can be parsed
+ * @param args The arguments that will be parsed
+ * @param args_len The length of arguments to be parsed
+ * @param flags The `cli_opt_flag_t flags for parsing
+ */
+void cli_opt_parser_init(
+ cli_opt_parser *parser,
+ const cli_opt_spec specs[],
+ char **args,
+ size_t args_len,
+ unsigned int flags);
+
+/**
+ * Parses the next command-line argument and places the information about
+ * the argument into the given `opt` data.
+ *
+ * @param opt The `cli_opt` information parsed from the argument
+ * @param parser An `cli_opt_parser` that has been initialized with
+ * `cli_opt_parser_init`
+ * @return true if the caller should continue iterating, or 0 if there are
+ * no arguments left to process.
+ */
+cli_opt_status_t cli_opt_parser_next(
+ cli_opt *opt,
+ cli_opt_parser *parser);
+
+/**
+ * Prints the status after parsing the most recent argument. This is
+ * useful for printing an error message when an unknown argument was
+ * specified, or when an argument was specified without a value.
+ *
+ * @param file The file to print information to
+ * @param command The name of the command to use when printing (optional)
+ * @param opt The option that failed to parse
+ * @return 0 on success, -1 on failure
+ */
+int cli_opt_status_fprint(
+ FILE *file,
+ const char *command,
+ const cli_opt *opt);
+
+#endif /* CLI_opt_h__ */
diff --git a/src/cli/opt_usage.c b/src/cli/opt_usage.c
new file mode 100644
index 000000000..6e5d6006e
--- /dev/null
+++ b/src/cli/opt_usage.c
@@ -0,0 +1,194 @@
+/*
+ * 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.
+ */
+
+#include "cli.h"
+#include "str.h"
+
+static int print_spec_name(git_str *out, const cli_opt_spec *spec)
+{
+ if (spec->type == CLI_OPT_TYPE_VALUE && spec->alias &&
+ !(spec->usage & CLI_OPT_USAGE_VALUE_OPTIONAL) &&
+ !(spec->usage & CLI_OPT_USAGE_SHOW_LONG))
+ return git_str_printf(out, "-%c <%s>", spec->alias, spec->value_name);
+ if (spec->type == CLI_OPT_TYPE_VALUE && spec->alias &&
+ !(spec->usage & CLI_OPT_USAGE_SHOW_LONG))
+ return git_str_printf(out, "-%c [<%s>]", spec->alias, spec->value_name);
+ if (spec->type == CLI_OPT_TYPE_VALUE &&
+ !(spec->usage & CLI_OPT_USAGE_VALUE_OPTIONAL))
+ return git_str_printf(out, "--%s[=<%s>]", spec->name, spec->value_name);
+ if (spec->type == CLI_OPT_TYPE_VALUE)
+ return git_str_printf(out, "--%s=<%s>", spec->name, spec->value_name);
+ if (spec->type == CLI_OPT_TYPE_ARG)
+ return git_str_printf(out, "<%s>", spec->value_name);
+ if (spec->type == CLI_OPT_TYPE_ARGS)
+ return git_str_printf(out, "<%s>...", spec->value_name);
+ if (spec->type == CLI_OPT_TYPE_LITERAL)
+ return git_str_printf(out, "--");
+ if (spec->alias && !(spec->usage & CLI_OPT_USAGE_SHOW_LONG))
+ return git_str_printf(out, "-%c", spec->alias);
+ if (spec->name)
+ return git_str_printf(out, "--%s", spec->name);
+
+ GIT_ASSERT(0);
+}
+
+/*
+ * This is similar to adopt's function, but modified to understand
+ * that we have a command ("git") and a "subcommand" ("checkout").
+ * It also understands a terminal's line length and wrap appropriately,
+ * using a `git_str` for storage.
+ */
+int cli_opt_usage_fprint(
+ FILE *file,
+ const char *command,
+ const char *subcommand,
+ const cli_opt_spec specs[])
+{
+ git_str usage = GIT_BUF_INIT, opt = GIT_BUF_INIT;
+ const cli_opt_spec *spec;
+ size_t i, prefixlen, linelen;
+ bool choice = false, next_choice = false, optional = false;
+ int error;
+
+ /* TODO: query actual console width. */
+ int console_width = 80;
+
+ if ((error = git_str_printf(&usage, "usage: %s", command)) < 0)
+ goto done;
+
+ if (subcommand &&
+ (error = git_str_printf(&usage, " %s", subcommand)) < 0)
+ goto done;
+
+ linelen = git_str_len(&usage);
+ prefixlen = linelen + 1;
+
+ for (spec = specs; spec->type; ++spec) {
+ if (!choice)
+ optional = !(spec->usage & CLI_OPT_USAGE_REQUIRED);
+
+ next_choice = !!((spec + 1)->usage & CLI_OPT_USAGE_CHOICE);
+
+ if (spec->usage & CLI_OPT_USAGE_HIDDEN)
+ continue;
+
+ if (choice)
+ git_str_putc(&opt, '|');
+ else
+ git_str_clear(&opt);
+
+ if (optional && !choice)
+ git_str_putc(&opt, '[');
+ if (!optional && !choice && next_choice)
+ git_str_putc(&opt, '(');
+
+ if ((error = print_spec_name(&opt, spec)) < 0)
+ goto done;
+
+ if (!optional && choice && !next_choice)
+ git_str_putc(&opt, ')');
+ else if (optional && !next_choice)
+ git_str_putc(&opt, ']');
+
+ if ((choice = next_choice))
+ continue;
+
+ if (git_str_oom(&opt)) {
+ error = -1;
+ goto done;
+ }
+
+ if (linelen > prefixlen &&
+ console_width > 0 &&
+ linelen + git_str_len(&opt) + 1 > (size_t)console_width) {
+ git_str_putc(&usage, '\n');
+
+ for (i = 0; i < prefixlen; i++)
+ git_str_putc(&usage, ' ');
+
+ linelen = prefixlen;
+ } else {
+ git_str_putc(&usage, ' ');
+ linelen += git_str_len(&opt) + 1;
+ }
+
+ git_str_puts(&usage, git_str_cstr(&opt));
+
+ if (git_str_oom(&usage)) {
+ error = -1;
+ goto done;
+ }
+ }
+
+ error = fprintf(file, "%s\n", git_str_cstr(&usage));
+
+done:
+ error = (error < 0) ? -1 : 0;
+
+ git_str_dispose(&usage);
+ git_str_dispose(&opt);
+ return error;
+}
+
+int cli_opt_usage_error(
+ const char *subcommand,
+ const cli_opt_spec specs[],
+ const cli_opt *invalid_opt)
+{
+ cli_opt_status_fprint(stderr, PROGRAM_NAME, invalid_opt);
+ cli_opt_usage_fprint(stderr, PROGRAM_NAME, subcommand, specs);
+ return CLI_EXIT_USAGE;
+}
+
+int cli_opt_help_fprint(
+ FILE *file,
+ const cli_opt_spec specs[])
+{
+ git_str help = GIT_BUF_INIT;
+ const cli_opt_spec *spec;
+ int error;
+
+ /* Display required arguments first */
+ for (spec = specs; spec->type; ++spec) {
+ if (! (spec->usage & CLI_OPT_USAGE_REQUIRED) ||
+ (spec->usage & CLI_OPT_USAGE_HIDDEN))
+ continue;
+
+ git_str_printf(&help, " ");
+
+ if ((error = print_spec_name(&help, spec)) < 0)
+ goto done;
+
+ git_str_printf(&help, ": %s\n", spec->help);
+ }
+
+ /* Display the remaining arguments */
+ for (spec = specs; spec->type; ++spec) {
+ if ((spec->usage & CLI_OPT_USAGE_REQUIRED) ||
+ (spec->usage & CLI_OPT_USAGE_HIDDEN))
+ continue;
+
+ git_str_printf(&help, " ");
+
+ if ((error = print_spec_name(&help, spec)) < 0)
+ goto done;
+
+ git_str_printf(&help, ": %s\n", spec->help);
+
+ }
+
+ if (git_str_oom(&help) ||
+ p_write(fileno(file), help.ptr, help.size) < 0)
+ error = -1;
+
+done:
+ error = (error < 0) ? -1 : 0;
+
+ git_str_dispose(&help);
+ return error;
+}
+
diff --git a/src/cli/opt_usage.h b/src/cli/opt_usage.h
new file mode 100644
index 000000000..c752494e1
--- /dev/null
+++ b/src/cli/opt_usage.h
@@ -0,0 +1,35 @@
+/*
+ * 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 CLI_opt_usage_h__
+#define CLI_opt_usage_h__
+
+/**
+ * Prints usage information to the given file handle.
+ *
+ * @param file The file to print information to
+ * @param command The name of the command to use when printing
+ * @param subcommand The name of the subcommand (eg "checkout") to use when printing, or NULL to skip
+ * @param specs The specifications allowed by the command
+ * @return 0 on success, -1 on failure
+ */
+int cli_opt_usage_fprint(
+ FILE *file,
+ const char *command,
+ const char *subcommand,
+ const cli_opt_spec specs[]);
+
+int cli_opt_usage_error(
+ const char *subcommand,
+ const cli_opt_spec specs[],
+ const cli_opt *invalid_opt);
+
+int cli_opt_help_fprint(
+ FILE *file,
+ const cli_opt_spec specs[]);
+
+#endif /* CLI_opt_usage_h__ */
diff --git a/src/win32/precompiled.c b/src/cli/win32/precompiled.c
index 5f656a45d..5f656a45d 100644
--- a/src/win32/precompiled.c
+++ b/src/cli/win32/precompiled.c
diff --git a/src/cli/win32/precompiled.h b/src/cli/win32/precompiled.h
new file mode 100644
index 000000000..b0309b864
--- /dev/null
+++ b/src/cli/win32/precompiled.h
@@ -0,0 +1,3 @@
+#include <git2.h>
+
+#include "cli.h"
diff --git a/src/libgit2/CMakeLists.txt b/src/libgit2/CMakeLists.txt
new file mode 100644
index 000000000..0c7ddddba
--- /dev/null
+++ b/src/libgit2/CMakeLists.txt
@@ -0,0 +1,131 @@
+# libgit2: the shared library: this CMakeLists.txt compiles the core
+# git library functionality.
+
+add_library(libgit2 OBJECT)
+set_target_properties(libgit2 PROPERTIES C_STANDARD 90)
+set_target_properties(libgit2 PROPERTIES C_EXTENSIONS OFF)
+
+include(PkgBuildConfig)
+
+set(LIBGIT2_INCLUDES
+ "${PROJECT_BINARY_DIR}/src"
+ "${PROJECT_SOURCE_DIR}/src/libgit2"
+ "${PROJECT_SOURCE_DIR}/src/util"
+ "${PROJECT_SOURCE_DIR}/include")
+
+if(WIN32 AND EMBED_SSH_PATH)
+ file(GLOB SRC_SSH "${EMBED_SSH_PATH}/src/*.c")
+ list(SORT SRC_SSH)
+ target_sources(libgit2 PRIVATE ${SRC_SSH})
+
+ list(APPEND LIBGIT2_SYSTEM_INCLUDES "${EMBED_SSH_PATH}/include")
+ file(WRITE "${EMBED_SSH_PATH}/src/libssh2_config.h" "#define HAVE_WINCNG\n#define LIBSSH2_WINCNG\n#include \"../win32/libssh2_config.h\"")
+ set(GIT_SSH 1)
+endif()
+
+# Collect sourcefiles
+file(GLOB SRC_H
+ "${PROJECT_SOURCE_DIR}/include/git2.h"
+ "${PROJECT_SOURCE_DIR}/include/git2/*.h"
+ "${PROJECT_SOURCE_DIR}/include/git2/sys/*.h")
+list(SORT SRC_H)
+target_sources(libgit2 PRIVATE ${SRC_H})
+
+file(GLOB SRC_GIT2 *.c *.h
+ streams/*.c streams/*.h
+ transports/*.c transports/*.h
+ xdiff/*.c xdiff/*.h)
+list(SORT SRC_GIT2)
+target_sources(libgit2 PRIVATE ${SRC_GIT2})
+
+if(WIN32 AND NOT CYGWIN)
+ # Add resource information on Windows
+ set(SRC_RC "git2.rc")
+endif()
+
+if(APPLE)
+ # The old Secure Transport API has been deprecated in macOS 10.15.
+ set_source_files_properties(streams/stransport.c PROPERTIES COMPILE_FLAGS -Wno-deprecated)
+endif()
+
+# the xdiff dependency is not (yet) warning-free, disable warnings
+# as errors for the xdiff sources until we've sorted them out
+if(MSVC)
+ set_source_files_properties(xdiff/xdiffi.c PROPERTIES COMPILE_FLAGS -WX-)
+ set_source_files_properties(xdiff/xemit.c PROPERTIES COMPILE_FLAGS -WX-)
+ set_source_files_properties(xdiff/xhistogram.c PROPERTIES COMPILE_FLAGS -WX-)
+ set_source_files_properties(xdiff/xmerge.c PROPERTIES COMPILE_FLAGS -WX-)
+ set_source_files_properties(xdiff/xutils.c PROPERTIES COMPILE_FLAGS -WX-)
+ set_source_files_properties(xdiff/xpatience.c PROPERTIES COMPILE_FLAGS -WX-)
+else()
+ set_source_files_properties(xdiff/xdiffi.c PROPERTIES COMPILE_FLAGS "-Wno-sign-compare -Wno-unused-parameter")
+ set_source_files_properties(xdiff/xemit.c PROPERTIES COMPILE_FLAGS "-Wno-sign-compare -Wno-unused-parameter")
+ set_source_files_properties(xdiff/xhistogram.c PROPERTIES COMPILE_FLAGS "-Wno-sign-compare")
+ set_source_files_properties(xdiff/xutils.c PROPERTIES COMPILE_FLAGS "-Wno-sign-compare")
+ set_source_files_properties(xdiff/xpatience.c PROPERTIES COMPILE_FLAGS "-Wno-sign-compare")
+endif()
+
+ide_split_sources(libgit2)
+list(APPEND LIBGIT2_OBJECTS $<TARGET_OBJECTS:util> $<TARGET_OBJECTS:libgit2> ${LIBGIT2_DEPENDENCY_OBJECTS})
+
+target_include_directories(libgit2 PRIVATE ${LIBGIT2_INCLUDES} ${LIBGIT2_DEPENDENCY_INCLUDES} PUBLIC ${PROJECT_SOURCE_DIR}/include)
+target_include_directories(libgit2 SYSTEM PRIVATE ${LIBGIT2_SYSTEM_INCLUDES})
+
+set(LIBGIT2_INCLUDES ${LIBGIT2_INCLUDES} PARENT_SCOPE)
+set(LIBGIT2_OBJECTS ${LIBGIT2_OBJECTS} PARENT_SCOPE)
+set(LIBGIT2_DEPENDENCY_INCLUDES ${LIBGIT2_DEPENDENCY_INCLUDES} PARENT_SCOPE)
+set(LIBGIT2_DEPENDENCY_OBJECTS ${LIBGIT2_DEPENDENCY_OBJECTS} PARENT_SCOPE)
+set(LIBGIT2_SYSTEM_INCLUDES ${LIBGIT2_SYSTEM_INCLUDES} PARENT_SCOPE)
+set(LIBGIT2_SYSTEM_LIBS ${LIBGIT2_SYSTEM_LIBS} PARENT_SCOPE)
+
+#
+# Compile and link libgit2
+#
+
+add_library(libgit2package ${SRC_RC} ${LIBGIT2_OBJECTS})
+target_link_libraries(libgit2package ${LIBGIT2_SYSTEM_LIBS})
+
+set_target_properties(libgit2package PROPERTIES C_STANDARD 90)
+set_target_properties(libgit2package PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR})
+set_target_properties(libgit2package PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR})
+set_target_properties(libgit2package PROPERTIES ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR})
+
+# Workaround for Cmake bug #0011240 (see http://public.kitware.com/Bug/view.php?id=11240)
+# Win64+MSVC+static libs = linker error
+if(MSVC AND GIT_ARCH_64 AND NOT BUILD_SHARED_LIBS)
+ set_target_properties(libgit2package PROPERTIES STATIC_LIBRARY_FLAGS "/MACHINE:x64")
+endif()
+
+ide_split_sources(libgit2package)
+
+if(SONAME)
+ set_target_properties(libgit2package PROPERTIES VERSION ${libgit2_VERSION})
+ set_target_properties(libgit2package PROPERTIES SOVERSION "${libgit2_VERSION_MAJOR}.${libgit2_VERSION_MINOR}")
+ if(LIBGIT2_FILENAME)
+ target_compile_definitions(libgit2package PRIVATE LIBGIT2_FILENAME=\"${LIBGIT2_FILENAME}\")
+ set_target_properties(libgit2package PROPERTIES OUTPUT_NAME ${LIBGIT2_FILENAME})
+ elseif(DEFINED LIBGIT2_PREFIX)
+ set_target_properties(libgit2package PROPERTIES PREFIX "${LIBGIT2_PREFIX}")
+ endif()
+endif()
+
+pkg_build_config(NAME libgit2
+ VERSION ${libgit2_VERSION}
+ DESCRIPTION "The git library, take 2"
+ LIBS_SELF git2
+ PRIVATE_LIBS ${LIBGIT2_PC_LIBS}
+ REQUIRES ${LIBGIT2_PC_REQUIRES})
+
+if(MSVC_IDE)
+ # Precompiled headers
+ set_target_properties(libgit2package PROPERTIES COMPILE_FLAGS "/Yuprecompiled.h /FIprecompiled.h")
+ set_source_files_properties(win32/precompiled.c COMPILE_FLAGS "/Ycprecompiled.h")
+endif()
+
+# Install
+install(TARGETS libgit2package
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+ ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
+install(DIRECTORY ${PROJECT_SOURCE_DIR}/include/git2 DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
+install(FILES ${PROJECT_SOURCE_DIR}/include/git2.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
diff --git a/src/annotated_commit.c b/src/libgit2/annotated_commit.c
index e48947679..e48947679 100644
--- a/src/annotated_commit.c
+++ b/src/libgit2/annotated_commit.c
diff --git a/src/annotated_commit.h b/src/libgit2/annotated_commit.h
index 444a2ed10..444a2ed10 100644
--- a/src/annotated_commit.h
+++ b/src/libgit2/annotated_commit.h
diff --git a/src/apply.c b/src/libgit2/apply.c
index 18304da4d..18304da4d 100644
--- a/src/apply.c
+++ b/src/libgit2/apply.c
diff --git a/src/apply.h b/src/libgit2/apply.h
index e990a7107..e990a7107 100644
--- a/src/apply.h
+++ b/src/libgit2/apply.h
diff --git a/src/attr.c b/src/libgit2/attr.c
index 1623b1d45..1623b1d45 100644
--- a/src/attr.c
+++ b/src/libgit2/attr.c
diff --git a/src/attr.h b/src/libgit2/attr.h
index 977565205..977565205 100644
--- a/src/attr.h
+++ b/src/libgit2/attr.h
diff --git a/src/attr_file.c b/src/libgit2/attr_file.c
index 0eb881a9b..0eb881a9b 100644
--- a/src/attr_file.c
+++ b/src/libgit2/attr_file.c
diff --git a/src/attr_file.h b/src/libgit2/attr_file.h
index 08630d1a6..08630d1a6 100644
--- a/src/attr_file.h
+++ b/src/libgit2/attr_file.h
diff --git a/src/attrcache.c b/src/libgit2/attrcache.c
index b16d95c3c..b16d95c3c 100644
--- a/src/attrcache.c
+++ b/src/libgit2/attrcache.c
diff --git a/src/attrcache.h b/src/libgit2/attrcache.h
index b13e0e8f0..b13e0e8f0 100644
--- a/src/attrcache.h
+++ b/src/libgit2/attrcache.h
diff --git a/src/blame.c b/src/libgit2/blame.c
index a6ab43efd..a6ab43efd 100644
--- a/src/blame.c
+++ b/src/libgit2/blame.c
diff --git a/src/blame.h b/src/libgit2/blame.h
index 4141e2bb5..4141e2bb5 100644
--- a/src/blame.h
+++ b/src/libgit2/blame.h
diff --git a/src/blame_git.c b/src/libgit2/blame_git.c
index 2504b338a..2504b338a 100644
--- a/src/blame_git.c
+++ b/src/libgit2/blame_git.c
diff --git a/src/blame_git.h b/src/libgit2/blame_git.h
index 48b85a20d..48b85a20d 100644
--- a/src/blame_git.h
+++ b/src/libgit2/blame_git.h
diff --git a/src/blob.c b/src/libgit2/blob.c
index 19ce8b3b5..b1680d3a8 100644
--- a/src/blob.c
+++ b/src/libgit2/blob.c
@@ -101,7 +101,7 @@ static int write_file_stream(
git_oid *id, git_odb *odb, const char *path, git_object_size_t file_size)
{
int fd, error;
- char buffer[FILEIO_BUFSIZE];
+ char buffer[GIT_BUFSIZE_FILEIO];
git_odb_stream *stream = NULL;
ssize_t read_len = -1;
git_object_size_t written = 0;
diff --git a/src/blob.h b/src/libgit2/blob.h
index 9a5dda225..9a5dda225 100644
--- a/src/blob.h
+++ b/src/libgit2/blob.h
diff --git a/src/branch.c b/src/libgit2/branch.c
index 2e29af99d..2e29af99d 100644
--- a/src/branch.c
+++ b/src/libgit2/branch.c
diff --git a/src/branch.h b/src/libgit2/branch.h
index b4db42a01..b4db42a01 100644
--- a/src/branch.h
+++ b/src/libgit2/branch.h
diff --git a/src/buf.c b/src/libgit2/buf.c
index 652f5dd52..652f5dd52 100644
--- a/src/buf.c
+++ b/src/libgit2/buf.c
diff --git a/src/buf.h b/src/libgit2/buf.h
index 4bc7f2709..4bc7f2709 100644
--- a/src/buf.h
+++ b/src/libgit2/buf.h
diff --git a/src/cache.c b/src/libgit2/cache.c
index 2f68e357c..2f68e357c 100644
--- a/src/cache.c
+++ b/src/libgit2/cache.c
diff --git a/src/cache.h b/src/libgit2/cache.h
index 42c4fa80d..42c4fa80d 100644
--- a/src/cache.h
+++ b/src/libgit2/cache.h
diff --git a/src/checkout.c b/src/libgit2/checkout.c
index 6a4643196..6a4643196 100644
--- a/src/checkout.c
+++ b/src/libgit2/checkout.c
diff --git a/src/checkout.h b/src/libgit2/checkout.h
index 517fbf3b1..517fbf3b1 100644
--- a/src/checkout.h
+++ b/src/libgit2/checkout.h
diff --git a/src/cherrypick.c b/src/libgit2/cherrypick.c
index 9ec4962b9..9ec4962b9 100644
--- a/src/cherrypick.c
+++ b/src/libgit2/cherrypick.c
diff --git a/src/clone.c b/src/libgit2/clone.c
index 1843875f8..1843875f8 100644
--- a/src/clone.c
+++ b/src/libgit2/clone.c
diff --git a/src/clone.h b/src/libgit2/clone.h
index 7d73cabd5..7d73cabd5 100644
--- a/src/clone.h
+++ b/src/libgit2/clone.h
diff --git a/src/commit.c b/src/libgit2/commit.c
index b137463f3..b137463f3 100644
--- a/src/commit.c
+++ b/src/libgit2/commit.c
diff --git a/src/commit.h b/src/libgit2/commit.h
index 7a2454e61..7a2454e61 100644
--- a/src/commit.h
+++ b/src/libgit2/commit.h
diff --git a/src/commit_graph.c b/src/libgit2/commit_graph.c
index 70e866b92..70e866b92 100644
--- a/src/commit_graph.c
+++ b/src/libgit2/commit_graph.c
diff --git a/src/commit_graph.h b/src/libgit2/commit_graph.h
index 45e125b9e..45e125b9e 100644
--- a/src/commit_graph.h
+++ b/src/libgit2/commit_graph.h
diff --git a/src/commit_list.c b/src/libgit2/commit_list.c
index 4585508bc..4585508bc 100644
--- a/src/commit_list.c
+++ b/src/libgit2/commit_list.c
diff --git a/src/commit_list.h b/src/libgit2/commit_list.h
index aad39f351..aad39f351 100644
--- a/src/commit_list.h
+++ b/src/libgit2/commit_list.h
diff --git a/src/libgit2/common.h b/src/libgit2/common.h
new file mode 100644
index 000000000..bb9ec5ac1
--- /dev/null
+++ b/src/libgit2/common.h
@@ -0,0 +1,55 @@
+/*
+ * 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_common_h__
+#define INCLUDE_common_h__
+
+#include "git2_util.h"
+#include "errors.h"
+
+/*
+* Include the declarations for deprecated functions; this ensures
+* that they're decorated with the proper extern/visibility attributes.
+*/
+#include "git2/deprecated.h"
+
+#include "posix.h"
+
+/**
+ * Initialize a structure with a version.
+ */
+GIT_INLINE(void) git__init_structure(void *structure, size_t len, unsigned int version)
+{
+ memset(structure, 0, len);
+ *((int*)structure) = version;
+}
+#define GIT_INIT_STRUCTURE(S,V) git__init_structure(S, sizeof(*S), V)
+
+#define GIT_INIT_STRUCTURE_FROM_TEMPLATE(PTR,VERSION,TYPE,TPL) do { \
+ TYPE _tmpl = TPL; \
+ GIT_ERROR_CHECK_VERSION(&(VERSION), _tmpl.version, #TYPE); \
+ memcpy((PTR), &_tmpl, sizeof(_tmpl)); } while (0)
+
+/**
+ * Check a versioned structure for validity
+ */
+GIT_INLINE(int) git_error__check_version(const void *structure, unsigned int expected_max, const char *name)
+{
+ unsigned int actual;
+
+ if (!structure)
+ return 0;
+
+ actual = *(const unsigned int*)structure;
+ if (actual > 0 && actual <= expected_max)
+ return 0;
+
+ git_error_set(GIT_ERROR_INVALID, "invalid version %d on %s", actual, name);
+ return -1;
+}
+#define GIT_ERROR_CHECK_VERSION(S,V,N) if (git_error__check_version(S,V,N) < 0) return -1
+
+#endif
diff --git a/src/config.c b/src/libgit2/config.c
index 88da34c5e..88da34c5e 100644
--- a/src/config.c
+++ b/src/libgit2/config.c
diff --git a/src/config.h b/src/libgit2/config.h
index 01b84b157..01b84b157 100644
--- a/src/config.h
+++ b/src/libgit2/config.h
diff --git a/src/config_backend.h b/src/libgit2/config_backend.h
index dbb190514..dbb190514 100644
--- a/src/config_backend.h
+++ b/src/libgit2/config_backend.h
diff --git a/src/config_cache.c b/src/libgit2/config_cache.c
index 4bb91f52b..4bb91f52b 100644
--- a/src/config_cache.c
+++ b/src/libgit2/config_cache.c
diff --git a/src/config_entries.c b/src/libgit2/config_entries.c
index 66aae096d..66aae096d 100644
--- a/src/config_entries.c
+++ b/src/libgit2/config_entries.c
diff --git a/src/config_entries.h b/src/libgit2/config_entries.h
index 832379e74..832379e74 100644
--- a/src/config_entries.h
+++ b/src/libgit2/config_entries.h
diff --git a/src/config_file.c b/src/libgit2/config_file.c
index 66fcb8ae2..66fcb8ae2 100644
--- a/src/config_file.c
+++ b/src/libgit2/config_file.c
diff --git a/src/config_mem.c b/src/libgit2/config_mem.c
index 560229cf5..560229cf5 100644
--- a/src/config_mem.c
+++ b/src/libgit2/config_mem.c
diff --git a/src/config_parse.c b/src/libgit2/config_parse.c
index 06931368e..06931368e 100644
--- a/src/config_parse.c
+++ b/src/libgit2/config_parse.c
diff --git a/src/config_parse.h b/src/libgit2/config_parse.h
index b791d3245..b791d3245 100644
--- a/src/config_parse.h
+++ b/src/libgit2/config_parse.h
diff --git a/src/config_snapshot.c b/src/libgit2/config_snapshot.c
index e295d2f7f..e295d2f7f 100644
--- a/src/config_snapshot.c
+++ b/src/libgit2/config_snapshot.c
diff --git a/src/crlf.c b/src/libgit2/crlf.c
index 1e1f1e845..1e1f1e845 100644
--- a/src/crlf.c
+++ b/src/libgit2/crlf.c
diff --git a/src/delta.c b/src/libgit2/delta.c
index 2d2c5fa85..2d2c5fa85 100644
--- a/src/delta.c
+++ b/src/libgit2/delta.c
diff --git a/src/delta.h b/src/libgit2/delta.h
index f61987304..f61987304 100644
--- a/src/delta.h
+++ b/src/libgit2/delta.h
diff --git a/src/describe.c b/src/libgit2/describe.c
index 1033eac50..1033eac50 100644
--- a/src/describe.c
+++ b/src/libgit2/describe.c
diff --git a/src/diff.c b/src/libgit2/diff.c
index 9840d6050..9840d6050 100644
--- a/src/diff.c
+++ b/src/libgit2/diff.c
diff --git a/src/diff.h b/src/libgit2/diff.h
index 2cc35e65b..2cc35e65b 100644
--- a/src/diff.h
+++ b/src/libgit2/diff.h
diff --git a/src/diff_driver.c b/src/libgit2/diff_driver.c
index 5f25fdb44..5f25fdb44 100644
--- a/src/diff_driver.c
+++ b/src/libgit2/diff_driver.c
diff --git a/src/diff_driver.h b/src/libgit2/diff_driver.h
index 03711e89e..03711e89e 100644
--- a/src/diff_driver.h
+++ b/src/libgit2/diff_driver.h
diff --git a/src/diff_file.c b/src/libgit2/diff_file.c
index c7e9fbeee..c7e9fbeee 100644
--- a/src/diff_file.c
+++ b/src/libgit2/diff_file.c
diff --git a/src/diff_file.h b/src/libgit2/diff_file.h
index 8d743e821..8d743e821 100644
--- a/src/diff_file.h
+++ b/src/libgit2/diff_file.h
diff --git a/src/diff_generate.c b/src/libgit2/diff_generate.c
index cfaefba66..cfaefba66 100644
--- a/src/diff_generate.c
+++ b/src/libgit2/diff_generate.c
diff --git a/src/diff_generate.h b/src/libgit2/diff_generate.h
index b782f29c6..b782f29c6 100644
--- a/src/diff_generate.h
+++ b/src/libgit2/diff_generate.h
diff --git a/src/diff_parse.c b/src/libgit2/diff_parse.c
index 75e41a544..75e41a544 100644
--- a/src/diff_parse.c
+++ b/src/libgit2/diff_parse.c
diff --git a/src/diff_parse.h b/src/libgit2/diff_parse.h
index 876782128..876782128 100644
--- a/src/diff_parse.h
+++ b/src/libgit2/diff_parse.h
diff --git a/src/diff_print.c b/src/libgit2/diff_print.c
index 03d25b087..03d25b087 100644
--- a/src/diff_print.c
+++ b/src/libgit2/diff_print.c
diff --git a/src/diff_stats.c b/src/libgit2/diff_stats.c
index 259939844..259939844 100644
--- a/src/diff_stats.c
+++ b/src/libgit2/diff_stats.c
diff --git a/src/diff_stats.h b/src/libgit2/diff_stats.h
index c71862b4e..c71862b4e 100644
--- a/src/diff_stats.h
+++ b/src/libgit2/diff_stats.h
diff --git a/src/diff_tform.c b/src/libgit2/diff_tform.c
index 913d649b0..913d649b0 100644
--- a/src/diff_tform.c
+++ b/src/libgit2/diff_tform.c
diff --git a/src/diff_tform.h b/src/libgit2/diff_tform.h
index 7abb8b3fe..7abb8b3fe 100644
--- a/src/diff_tform.h
+++ b/src/libgit2/diff_tform.h
diff --git a/src/diff_xdiff.c b/src/libgit2/diff_xdiff.c
index 3f6eccac1..5f56c5209 100644
--- a/src/diff_xdiff.c
+++ b/src/libgit2/diff_xdiff.c
@@ -11,6 +11,7 @@
#include "diff.h"
#include "diff_driver.h"
#include "patch_generate.h"
+#include "utf8.h"
static int git_xdiff_scan_int(const char **str, int *value)
{
diff --git a/src/diff_xdiff.h b/src/libgit2/diff_xdiff.h
index 9b303e9dc..9b303e9dc 100644
--- a/src/diff_xdiff.h
+++ b/src/libgit2/diff_xdiff.h
diff --git a/src/email.c b/src/libgit2/email.c
index e19a2928c..e19a2928c 100644
--- a/src/email.c
+++ b/src/libgit2/email.c
diff --git a/src/email.h b/src/libgit2/email.h
index 083e56d5c..083e56d5c 100644
--- a/src/email.h
+++ b/src/libgit2/email.h
diff --git a/src/errors.c b/src/libgit2/errors.c
index 3614b9ce5..3614b9ce5 100644
--- a/src/errors.c
+++ b/src/libgit2/errors.c
diff --git a/src/errors.h b/src/libgit2/errors.h
index a2f60f752..772c7bad1 100644
--- a/src/errors.h
+++ b/src/libgit2/errors.h
@@ -11,9 +11,8 @@
#include "common.h"
/*
- * Set the error message for this thread, formatting as needed.
+ * `vprintf`-style formatting for the error message for this thread.
*/
-void git_error_set(int error_class, const char *fmt, ...) GIT_FORMAT_PRINTF(2, 3);
void git_error_vset(int error_class, const char *fmt, va_list ap);
/**
diff --git a/src/fetch.c b/src/libgit2/fetch.c
index 03d38452c..03d38452c 100644
--- a/src/fetch.c
+++ b/src/libgit2/fetch.c
diff --git a/src/fetch.h b/src/libgit2/fetch.h
index 10b6731f0..10b6731f0 100644
--- a/src/fetch.h
+++ b/src/libgit2/fetch.h
diff --git a/src/fetchhead.c b/src/libgit2/fetchhead.c
index 6511124ef..6511124ef 100644
--- a/src/fetchhead.c
+++ b/src/libgit2/fetchhead.c
diff --git a/src/fetchhead.h b/src/libgit2/fetchhead.h
index 9e5171010..9e5171010 100644
--- a/src/fetchhead.h
+++ b/src/libgit2/fetchhead.h
diff --git a/src/filter.c b/src/libgit2/filter.c
index 2712e8c60..20b215729 100644
--- a/src/filter.c
+++ b/src/libgit2/filter.c
@@ -1085,7 +1085,7 @@ int git_filter_list_stream_file(
const char *path,
git_writestream *target)
{
- char buf[FILTERIO_BUFSIZE];
+ char buf[GIT_BUFSIZE_FILTERIO];
git_str abspath = GIT_STR_INIT;
const char *base = repo ? git_repository_workdir(repo) : NULL;
git_vector filter_streams = GIT_VECTOR_INIT;
diff --git a/src/filter.h b/src/libgit2/filter.h
index 58cb4b424..58cb4b424 100644
--- a/src/filter.h
+++ b/src/libgit2/filter.h
diff --git a/src/win32/git2.rc b/src/libgit2/git2.rc
index d273afd70..d273afd70 100644
--- a/src/win32/git2.rc
+++ b/src/libgit2/git2.rc
diff --git a/src/graph.c b/src/libgit2/graph.c
index 35e914f74..35e914f74 100644
--- a/src/graph.c
+++ b/src/libgit2/graph.c
diff --git a/src/hashsig.c b/src/libgit2/hashsig.c
index 6b4fb8352..6b4fb8352 100644
--- a/src/hashsig.c
+++ b/src/libgit2/hashsig.c
diff --git a/src/ident.c b/src/libgit2/ident.c
index 53095864e..53095864e 100644
--- a/src/ident.c
+++ b/src/libgit2/ident.c
diff --git a/src/idxmap.c b/src/libgit2/idxmap.c
index bc23608f2..bc23608f2 100644
--- a/src/idxmap.c
+++ b/src/libgit2/idxmap.c
diff --git a/src/idxmap.h b/src/libgit2/idxmap.h
index 76170ef32..76170ef32 100644
--- a/src/idxmap.h
+++ b/src/libgit2/idxmap.h
diff --git a/src/ignore.c b/src/libgit2/ignore.c
index cee58d7f1..cee58d7f1 100644
--- a/src/ignore.c
+++ b/src/libgit2/ignore.c
diff --git a/src/ignore.h b/src/libgit2/ignore.h
index aa5ca62b7..aa5ca62b7 100644
--- a/src/ignore.h
+++ b/src/libgit2/ignore.h
diff --git a/src/index.c b/src/libgit2/index.c
index aa97c6421..aa97c6421 100644
--- a/src/index.c
+++ b/src/libgit2/index.c
diff --git a/src/index.h b/src/libgit2/index.h
index 71bb096f7..71bb096f7 100644
--- a/src/index.h
+++ b/src/libgit2/index.h
diff --git a/src/indexer.c b/src/libgit2/indexer.c
index f9a32e7ac..f9a32e7ac 100644
--- a/src/indexer.c
+++ b/src/libgit2/indexer.c
diff --git a/src/indexer.h b/src/libgit2/indexer.h
index 8ee6115a6..8ee6115a6 100644
--- a/src/indexer.h
+++ b/src/libgit2/indexer.h
diff --git a/src/iterator.c b/src/libgit2/iterator.c
index 15bb63dc8..15bb63dc8 100644
--- a/src/iterator.c
+++ b/src/libgit2/iterator.c
diff --git a/src/iterator.h b/src/libgit2/iterator.h
index 6bb8489d0..6bb8489d0 100644
--- a/src/iterator.h
+++ b/src/libgit2/iterator.h
diff --git a/src/libgit2.c b/src/libgit2/libgit2.c
index efad3bf6d..efad3bf6d 100644
--- a/src/libgit2.c
+++ b/src/libgit2/libgit2.c
diff --git a/src/libgit2.h b/src/libgit2/libgit2.h
index a898367ae..a898367ae 100644
--- a/src/libgit2.h
+++ b/src/libgit2/libgit2.h
diff --git a/src/mailmap.c b/src/libgit2/mailmap.c
index 4336fe3e5..4336fe3e5 100644
--- a/src/mailmap.c
+++ b/src/libgit2/mailmap.c
diff --git a/src/mailmap.h b/src/libgit2/mailmap.h
index 2c9736a4a..2c9736a4a 100644
--- a/src/mailmap.h
+++ b/src/libgit2/mailmap.h
diff --git a/src/merge.c b/src/libgit2/merge.c
index 641b32632..641b32632 100644
--- a/src/merge.c
+++ b/src/libgit2/merge.c
diff --git a/src/merge.h b/src/libgit2/merge.h
index 23932905e..23932905e 100644
--- a/src/merge.h
+++ b/src/libgit2/merge.h
diff --git a/src/merge_driver.c b/src/libgit2/merge_driver.c
index 19b35ac0e..19b35ac0e 100644
--- a/src/merge_driver.c
+++ b/src/libgit2/merge_driver.c
diff --git a/src/merge_driver.h b/src/libgit2/merge_driver.h
index 6b7da5287..6b7da5287 100644
--- a/src/merge_driver.h
+++ b/src/libgit2/merge_driver.h
diff --git a/src/merge_file.c b/src/libgit2/merge_file.c
index 732a047b1..732a047b1 100644
--- a/src/merge_file.c
+++ b/src/libgit2/merge_file.c
diff --git a/src/message.c b/src/libgit2/message.c
index ec0103a33..ec0103a33 100644
--- a/src/message.c
+++ b/src/libgit2/message.c
diff --git a/src/midx.c b/src/libgit2/midx.c
index eb99e7373..eb99e7373 100644
--- a/src/midx.c
+++ b/src/libgit2/midx.c
diff --git a/src/midx.h b/src/libgit2/midx.h
index 7dd851bd3..7dd851bd3 100644
--- a/src/midx.h
+++ b/src/libgit2/midx.h
diff --git a/src/mwindow.c b/src/libgit2/mwindow.c
index d06b7a80e..d06b7a80e 100644
--- a/src/mwindow.c
+++ b/src/libgit2/mwindow.c
diff --git a/src/mwindow.h b/src/libgit2/mwindow.h
index e3a03f019..e3a03f019 100644
--- a/src/mwindow.h
+++ b/src/libgit2/mwindow.h
diff --git a/src/netops.c b/src/libgit2/netops.c
index 0a27365b8..00640c600 100644
--- a/src/netops.c
+++ b/src/libgit2/netops.c
@@ -12,7 +12,6 @@
#include "posix.h"
#include "str.h"
-#include "http_parser.h"
#include "runtime.h"
int gitno_recv(gitno_buffer *buf)
diff --git a/src/netops.h b/src/libgit2/netops.h
index 56f968534..56f968534 100644
--- a/src/netops.h
+++ b/src/libgit2/netops.h
diff --git a/src/notes.c b/src/libgit2/notes.c
index d1a2b0f64..d1a2b0f64 100644
--- a/src/notes.c
+++ b/src/libgit2/notes.c
diff --git a/src/notes.h b/src/libgit2/notes.h
index 2168e4595..2168e4595 100644
--- a/src/notes.h
+++ b/src/libgit2/notes.h
diff --git a/src/object.c b/src/libgit2/object.c
index 7bc256fce..7bc256fce 100644
--- a/src/object.c
+++ b/src/libgit2/object.c
diff --git a/src/object.h b/src/libgit2/object.h
index 66be57557..66be57557 100644
--- a/src/object.h
+++ b/src/libgit2/object.h
diff --git a/src/object_api.c b/src/libgit2/object_api.c
index d45abd5ce..d45abd5ce 100644
--- a/src/object_api.c
+++ b/src/libgit2/object_api.c
diff --git a/src/odb.c b/src/libgit2/odb.c
index 14eff53c7..7b98c72ee 100644
--- a/src/odb.c
+++ b/src/libgit2/odb.c
@@ -198,7 +198,7 @@ void git_odb_object_free(git_odb_object *object)
int git_odb__hashfd(git_oid *out, git_file fd, size_t size, git_object_t type)
{
size_t hdr_len;
- char hdr[64], buffer[FILEIO_BUFSIZE];
+ char hdr[64], buffer[GIT_BUFSIZE_FILEIO];
git_hash_ctx ctx;
ssize_t read_len = 0;
int error = 0;
@@ -1067,7 +1067,7 @@ int git_odb_expand_ids(
int git_odb_read_header(size_t *len_p, git_object_t *type_p, git_odb *db, const git_oid *id)
{
int error;
- git_odb_object *object;
+ git_odb_object *object = NULL;
error = git_odb__read_header_or_object(&object, len_p, type_p, db, id);
diff --git a/src/odb.h b/src/libgit2/odb.h
index 5aa4cc84a..5aa4cc84a 100644
--- a/src/odb.h
+++ b/src/libgit2/odb.h
diff --git a/src/odb_loose.c b/src/libgit2/odb_loose.c
index 463e24fa5..463e24fa5 100644
--- a/src/odb_loose.c
+++ b/src/libgit2/odb_loose.c
diff --git a/src/odb_mempack.c b/src/libgit2/odb_mempack.c
index 6f27f45f8..6f27f45f8 100644
--- a/src/odb_mempack.c
+++ b/src/libgit2/odb_mempack.c
diff --git a/src/odb_pack.c b/src/libgit2/odb_pack.c
index 818cc6125..818cc6125 100644
--- a/src/odb_pack.c
+++ b/src/libgit2/odb_pack.c
diff --git a/src/offmap.c b/src/libgit2/offmap.c
index be9eb66d8..be9eb66d8 100644
--- a/src/offmap.c
+++ b/src/libgit2/offmap.c
diff --git a/src/offmap.h b/src/libgit2/offmap.h
index 81c459b01..81c459b01 100644
--- a/src/offmap.h
+++ b/src/libgit2/offmap.h
diff --git a/src/oid.c b/src/libgit2/oid.c
index 19061e899..19061e899 100644
--- a/src/oid.c
+++ b/src/libgit2/oid.c
diff --git a/src/oid.h b/src/libgit2/oid.h
index 5baec33e5..5baec33e5 100644
--- a/src/oid.h
+++ b/src/libgit2/oid.h
diff --git a/src/oidarray.c b/src/libgit2/oidarray.c
index 583017c4e..583017c4e 100644
--- a/src/oidarray.c
+++ b/src/libgit2/oidarray.c
diff --git a/src/oidarray.h b/src/libgit2/oidarray.h
index eed3a1091..eed3a1091 100644
--- a/src/oidarray.h
+++ b/src/libgit2/oidarray.h
diff --git a/src/oidmap.c b/src/libgit2/oidmap.c
index 0ae8bf33e..0ae8bf33e 100644
--- a/src/oidmap.c
+++ b/src/libgit2/oidmap.c
diff --git a/src/oidmap.h b/src/libgit2/oidmap.h
index b748f727c..b748f727c 100644
--- a/src/oidmap.h
+++ b/src/libgit2/oidmap.h
diff --git a/src/pack-objects.c b/src/libgit2/pack-objects.c
index 1aa6731b3..1aa6731b3 100644
--- a/src/pack-objects.c
+++ b/src/libgit2/pack-objects.c
diff --git a/src/pack-objects.h b/src/libgit2/pack-objects.h
index 2faa3ec7f..2faa3ec7f 100644
--- a/src/pack-objects.h
+++ b/src/libgit2/pack-objects.h
diff --git a/src/pack.c b/src/libgit2/pack.c
index 5c0cba7e8..5c0cba7e8 100644
--- a/src/pack.c
+++ b/src/libgit2/pack.c
diff --git a/src/pack.h b/src/libgit2/pack.h
index bf279c6b6..bf279c6b6 100644
--- a/src/pack.h
+++ b/src/libgit2/pack.h
diff --git a/src/parse.c b/src/libgit2/parse.c
index 0a10758bf..0a10758bf 100644
--- a/src/parse.c
+++ b/src/libgit2/parse.c
diff --git a/src/parse.h b/src/libgit2/parse.h
index 0ecb7c103..0ecb7c103 100644
--- a/src/parse.h
+++ b/src/libgit2/parse.h
diff --git a/src/patch.c b/src/libgit2/patch.c
index a30546f3c..a30546f3c 100644
--- a/src/patch.c
+++ b/src/libgit2/patch.c
diff --git a/src/patch.h b/src/libgit2/patch.h
index 1e1471ed6..1e1471ed6 100644
--- a/src/patch.h
+++ b/src/libgit2/patch.h
diff --git a/src/patch_generate.c b/src/libgit2/patch_generate.c
index bc598fea8..bc598fea8 100644
--- a/src/patch_generate.c
+++ b/src/libgit2/patch_generate.c
diff --git a/src/patch_generate.h b/src/libgit2/patch_generate.h
index 56e3e9df4..56e3e9df4 100644
--- a/src/patch_generate.h
+++ b/src/libgit2/patch_generate.h
diff --git a/src/patch_parse.c b/src/libgit2/patch_parse.c
index 78cd96252..78cd96252 100644
--- a/src/patch_parse.c
+++ b/src/libgit2/patch_parse.c
diff --git a/src/patch_parse.h b/src/libgit2/patch_parse.h
index 140629da8..140629da8 100644
--- a/src/patch_parse.h
+++ b/src/libgit2/patch_parse.h
diff --git a/src/path.c b/src/libgit2/path.c
index 05a3dc2cf..a19340efe 100644
--- a/src/path.c
+++ b/src/libgit2/path.c
@@ -9,6 +9,7 @@
#include "repository.h"
#include "fs_path.h"
+#include "utf8.h"
typedef struct {
git_repository *repo;
diff --git a/src/path.h b/src/libgit2/path.h
index c4a2c4250..c4a2c4250 100644
--- a/src/path.h
+++ b/src/libgit2/path.h
diff --git a/src/pathspec.c b/src/libgit2/pathspec.c
index 3e44643c6..3e44643c6 100644
--- a/src/pathspec.c
+++ b/src/libgit2/pathspec.c
diff --git a/src/pathspec.h b/src/libgit2/pathspec.h
index 0256cb927..0256cb927 100644
--- a/src/pathspec.h
+++ b/src/libgit2/pathspec.h
diff --git a/src/proxy.c b/src/libgit2/proxy.c
index ef91ad6ea..ef91ad6ea 100644
--- a/src/proxy.c
+++ b/src/libgit2/proxy.c
diff --git a/src/proxy.h b/src/libgit2/proxy.h
index 7c0ab598d..7c0ab598d 100644
--- a/src/proxy.h
+++ b/src/libgit2/proxy.h
diff --git a/src/push.c b/src/libgit2/push.c
index da8aebadd..da8aebadd 100644
--- a/src/push.c
+++ b/src/libgit2/push.c
diff --git a/src/push.h b/src/libgit2/push.h
index fc72e845e..fc72e845e 100644
--- a/src/push.h
+++ b/src/libgit2/push.h
diff --git a/src/reader.c b/src/libgit2/reader.c
index ba9775240..ba9775240 100644
--- a/src/reader.c
+++ b/src/libgit2/reader.c
diff --git a/src/reader.h b/src/libgit2/reader.h
index b58dc93f6..b58dc93f6 100644
--- a/src/reader.h
+++ b/src/libgit2/reader.h
diff --git a/src/rebase.c b/src/libgit2/rebase.c
index 6f01d3990..6f01d3990 100644
--- a/src/rebase.c
+++ b/src/libgit2/rebase.c
diff --git a/src/refdb.c b/src/libgit2/refdb.c
index ed33de92b..ed33de92b 100644
--- a/src/refdb.c
+++ b/src/libgit2/refdb.c
diff --git a/src/refdb.h b/src/libgit2/refdb.h
index 84e19b1c3..84e19b1c3 100644
--- a/src/refdb.h
+++ b/src/libgit2/refdb.h
diff --git a/src/refdb_fs.c b/src/libgit2/refdb_fs.c
index 95bda9404..95bda9404 100644
--- a/src/refdb_fs.c
+++ b/src/libgit2/refdb_fs.c
diff --git a/src/reflog.c b/src/libgit2/reflog.c
index 1e9c0d4f1..1e9c0d4f1 100644
--- a/src/reflog.c
+++ b/src/libgit2/reflog.c
diff --git a/src/reflog.h b/src/libgit2/reflog.h
index 8c3895952..8c3895952 100644
--- a/src/reflog.h
+++ b/src/libgit2/reflog.h
diff --git a/src/refs.c b/src/libgit2/refs.c
index 5c875b95b..5c875b95b 100644
--- a/src/refs.c
+++ b/src/libgit2/refs.c
diff --git a/src/refs.h b/src/libgit2/refs.h
index cb888bf8f..cb888bf8f 100644
--- a/src/refs.h
+++ b/src/libgit2/refs.h
diff --git a/src/refspec.c b/src/libgit2/refspec.c
index f0a0c2bfb..f0a0c2bfb 100644
--- a/src/refspec.c
+++ b/src/libgit2/refspec.c
diff --git a/src/refspec.h b/src/libgit2/refspec.h
index bf4f7fcfb..bf4f7fcfb 100644
--- a/src/refspec.h
+++ b/src/libgit2/refspec.h
diff --git a/src/remote.c b/src/libgit2/remote.c
index f6421b9eb..f6421b9eb 100644
--- a/src/remote.c
+++ b/src/libgit2/remote.c
diff --git a/src/remote.h b/src/libgit2/remote.h
index ea9c7d17f..ea9c7d17f 100644
--- a/src/remote.h
+++ b/src/libgit2/remote.h
diff --git a/src/repo_template.h b/src/libgit2/repo_template.h
index 099279aa7..099279aa7 100644
--- a/src/repo_template.h
+++ b/src/libgit2/repo_template.h
diff --git a/src/repository.c b/src/libgit2/repository.c
index 80b4a98eb..80b4a98eb 100644
--- a/src/repository.c
+++ b/src/libgit2/repository.c
diff --git a/src/repository.h b/src/libgit2/repository.h
index 3c3aa1e8e..3c3aa1e8e 100644
--- a/src/repository.h
+++ b/src/libgit2/repository.h
diff --git a/src/reset.c b/src/libgit2/reset.c
index e0d942e5e..e0d942e5e 100644
--- a/src/reset.c
+++ b/src/libgit2/reset.c
diff --git a/src/revert.c b/src/libgit2/revert.c
index d6ab6ae3c..d6ab6ae3c 100644
--- a/src/revert.c
+++ b/src/libgit2/revert.c
diff --git a/src/revparse.c b/src/libgit2/revparse.c
index 9bc28e9fc..9bc28e9fc 100644
--- a/src/revparse.c
+++ b/src/libgit2/revparse.c
diff --git a/src/revwalk.c b/src/libgit2/revwalk.c
index 553e0497a..553e0497a 100644
--- a/src/revwalk.c
+++ b/src/libgit2/revwalk.c
diff --git a/src/revwalk.h b/src/libgit2/revwalk.h
index 94b8a6fb1..94b8a6fb1 100644
--- a/src/revwalk.h
+++ b/src/libgit2/revwalk.h
diff --git a/src/settings.h b/src/libgit2/settings.h
index dc42ce939..dc42ce939 100644
--- a/src/settings.h
+++ b/src/libgit2/settings.h
diff --git a/src/signature.c b/src/libgit2/signature.c
index 5d6ab572c..5d6ab572c 100644
--- a/src/signature.c
+++ b/src/libgit2/signature.c
diff --git a/src/signature.h b/src/libgit2/signature.h
index 5c8270954..5c8270954 100644
--- a/src/signature.h
+++ b/src/libgit2/signature.h
diff --git a/src/stash.c b/src/libgit2/stash.c
index 5fc01ac36..5fc01ac36 100644
--- a/src/stash.c
+++ b/src/libgit2/stash.c
diff --git a/src/status.c b/src/libgit2/status.c
index df0f74507..df0f74507 100644
--- a/src/status.c
+++ b/src/libgit2/status.c
diff --git a/src/status.h b/src/libgit2/status.h
index 907479a22..907479a22 100644
--- a/src/status.h
+++ b/src/libgit2/status.h
diff --git a/src/strarray.c b/src/libgit2/strarray.c
index 2f9b77cc2..2f9b77cc2 100644
--- a/src/strarray.c
+++ b/src/libgit2/strarray.c
diff --git a/src/stream.h b/src/libgit2/stream.h
index f16b026fb..f16b026fb 100644
--- a/src/stream.h
+++ b/src/libgit2/stream.h
diff --git a/src/streams/mbedtls.c b/src/libgit2/streams/mbedtls.c
index 0cf5c8af1..0cf5c8af1 100644
--- a/src/streams/mbedtls.c
+++ b/src/libgit2/streams/mbedtls.c
diff --git a/src/streams/mbedtls.h b/src/libgit2/streams/mbedtls.h
index bcca6dd40..bcca6dd40 100644
--- a/src/streams/mbedtls.h
+++ b/src/libgit2/streams/mbedtls.h
diff --git a/src/streams/openssl.c b/src/libgit2/streams/openssl.c
index 89c96780c..89c96780c 100644
--- a/src/streams/openssl.c
+++ b/src/libgit2/streams/openssl.c
diff --git a/src/streams/openssl.h b/src/libgit2/streams/openssl.h
index 89fb60a82..89fb60a82 100644
--- a/src/streams/openssl.h
+++ b/src/libgit2/streams/openssl.h
diff --git a/src/streams/openssl_dynamic.c b/src/libgit2/streams/openssl_dynamic.c
index da16b6ed7..da16b6ed7 100644
--- a/src/streams/openssl_dynamic.c
+++ b/src/libgit2/streams/openssl_dynamic.c
diff --git a/src/streams/openssl_dynamic.h b/src/libgit2/streams/openssl_dynamic.h
index a99691910..a99691910 100644
--- a/src/streams/openssl_dynamic.h
+++ b/src/libgit2/streams/openssl_dynamic.h
diff --git a/src/streams/openssl_legacy.c b/src/libgit2/streams/openssl_legacy.c
index e61e6efbb..e61e6efbb 100644
--- a/src/streams/openssl_legacy.c
+++ b/src/libgit2/streams/openssl_legacy.c
diff --git a/src/streams/openssl_legacy.h b/src/libgit2/streams/openssl_legacy.h
index e6dae9572..e6dae9572 100644
--- a/src/streams/openssl_legacy.h
+++ b/src/libgit2/streams/openssl_legacy.h
diff --git a/src/streams/registry.c b/src/libgit2/streams/registry.c
index e60e1cd63..e60e1cd63 100644
--- a/src/streams/registry.c
+++ b/src/libgit2/streams/registry.c
diff --git a/src/streams/registry.h b/src/libgit2/streams/registry.h
index adc2b8bdf..adc2b8bdf 100644
--- a/src/streams/registry.h
+++ b/src/libgit2/streams/registry.h
diff --git a/src/streams/socket.c b/src/libgit2/streams/socket.c
index 9415fe892..9415fe892 100644
--- a/src/streams/socket.c
+++ b/src/libgit2/streams/socket.c
diff --git a/src/streams/socket.h b/src/libgit2/streams/socket.h
index 3235f3167..3235f3167 100644
--- a/src/streams/socket.h
+++ b/src/libgit2/streams/socket.h
diff --git a/src/streams/stransport.c b/src/libgit2/streams/stransport.c
index 3f31d2541..3f31d2541 100644
--- a/src/streams/stransport.c
+++ b/src/libgit2/streams/stransport.c
diff --git a/src/streams/stransport.h b/src/libgit2/streams/stransport.h
index 1026e204b..1026e204b 100644
--- a/src/streams/stransport.h
+++ b/src/libgit2/streams/stransport.h
diff --git a/src/streams/tls.c b/src/libgit2/streams/tls.c
index e063a33f9..e063a33f9 100644
--- a/src/streams/tls.c
+++ b/src/libgit2/streams/tls.c
diff --git a/src/streams/tls.h b/src/libgit2/streams/tls.h
index 465a6ea89..465a6ea89 100644
--- a/src/streams/tls.h
+++ b/src/libgit2/streams/tls.h
diff --git a/src/submodule.c b/src/libgit2/submodule.c
index 0f4f0726c..0f4f0726c 100644
--- a/src/submodule.c
+++ b/src/libgit2/submodule.c
diff --git a/src/submodule.h b/src/libgit2/submodule.h
index 7fa982486..7fa982486 100644
--- a/src/submodule.h
+++ b/src/libgit2/submodule.h
diff --git a/src/sysdir.c b/src/libgit2/sysdir.c
index 450cb509b..450cb509b 100644
--- a/src/sysdir.c
+++ b/src/libgit2/sysdir.c
diff --git a/src/sysdir.h b/src/libgit2/sysdir.h
index 568f27940..568f27940 100644
--- a/src/sysdir.h
+++ b/src/libgit2/sysdir.h
diff --git a/src/tag.c b/src/libgit2/tag.c
index 5734106fa..5734106fa 100644
--- a/src/tag.c
+++ b/src/libgit2/tag.c
diff --git a/src/tag.h b/src/libgit2/tag.h
index 76ae1508e..76ae1508e 100644
--- a/src/tag.h
+++ b/src/libgit2/tag.h
diff --git a/src/threadstate.c b/src/libgit2/threadstate.c
index 9e3ef5818..9e3ef5818 100644
--- a/src/threadstate.c
+++ b/src/libgit2/threadstate.c
diff --git a/src/threadstate.h b/src/libgit2/threadstate.h
index c10f26b59..c10f26b59 100644
--- a/src/threadstate.h
+++ b/src/libgit2/threadstate.h
diff --git a/src/trace.c b/src/libgit2/trace.c
index b0c56c4dc..b0c56c4dc 100644
--- a/src/trace.c
+++ b/src/libgit2/trace.c
diff --git a/src/trace.h b/src/libgit2/trace.h
index 239928dcb..239928dcb 100644
--- a/src/trace.h
+++ b/src/libgit2/trace.h
diff --git a/src/trailer.c b/src/libgit2/trailer.c
index 4761c9922..4761c9922 100644
--- a/src/trailer.c
+++ b/src/libgit2/trailer.c
diff --git a/src/transaction.c b/src/libgit2/transaction.c
index ccffa9984..ccffa9984 100644
--- a/src/transaction.c
+++ b/src/libgit2/transaction.c
diff --git a/src/transaction.h b/src/libgit2/transaction.h
index 780c06830..780c06830 100644
--- a/src/transaction.h
+++ b/src/libgit2/transaction.h
diff --git a/src/transport.c b/src/libgit2/transport.c
index 640ccacae..640ccacae 100644
--- a/src/transport.c
+++ b/src/libgit2/transport.c
diff --git a/src/transports/auth.c b/src/libgit2/transports/auth.c
index 90b6b124f..90b6b124f 100644
--- a/src/transports/auth.c
+++ b/src/libgit2/transports/auth.c
diff --git a/src/transports/auth.h b/src/libgit2/transports/auth.h
index 64680cc53..64680cc53 100644
--- a/src/transports/auth.h
+++ b/src/libgit2/transports/auth.h
diff --git a/src/transports/auth_negotiate.c b/src/libgit2/transports/auth_negotiate.c
index 6380504be..6380504be 100644
--- a/src/transports/auth_negotiate.c
+++ b/src/libgit2/transports/auth_negotiate.c
diff --git a/src/transports/auth_negotiate.h b/src/libgit2/transports/auth_negotiate.h
index 34aff295b..34aff295b 100644
--- a/src/transports/auth_negotiate.h
+++ b/src/libgit2/transports/auth_negotiate.h
diff --git a/src/transports/auth_ntlm.c b/src/libgit2/transports/auth_ntlm.c
index f49ce101a..f49ce101a 100644
--- a/src/transports/auth_ntlm.c
+++ b/src/libgit2/transports/auth_ntlm.c
diff --git a/src/transports/auth_ntlm.h b/src/libgit2/transports/auth_ntlm.h
index 40689498c..40689498c 100644
--- a/src/transports/auth_ntlm.h
+++ b/src/libgit2/transports/auth_ntlm.h
diff --git a/src/transports/credential.c b/src/libgit2/transports/credential.c
index 6e00b0282..6e00b0282 100644
--- a/src/transports/credential.c
+++ b/src/libgit2/transports/credential.c
diff --git a/src/transports/credential_helpers.c b/src/libgit2/transports/credential_helpers.c
index 6d34a4e97..6d34a4e97 100644
--- a/src/transports/credential_helpers.c
+++ b/src/libgit2/transports/credential_helpers.c
diff --git a/src/transports/git.c b/src/libgit2/transports/git.c
index 591e2ab03..591e2ab03 100644
--- a/src/transports/git.c
+++ b/src/libgit2/transports/git.c
diff --git a/src/transports/http.c b/src/libgit2/transports/http.c
index 7db5582ca..7db5582ca 100644
--- a/src/transports/http.c
+++ b/src/libgit2/transports/http.c
diff --git a/src/transports/http.h b/src/libgit2/transports/http.h
index 8e8e7226e..8e8e7226e 100644
--- a/src/transports/http.h
+++ b/src/libgit2/transports/http.h
diff --git a/src/transports/httpclient.c b/src/libgit2/transports/httpclient.c
index 75782da82..75782da82 100644
--- a/src/transports/httpclient.c
+++ b/src/libgit2/transports/httpclient.c
diff --git a/src/transports/httpclient.h b/src/libgit2/transports/httpclient.h
index 6d0ef9edb..6d0ef9edb 100644
--- a/src/transports/httpclient.h
+++ b/src/libgit2/transports/httpclient.h
diff --git a/src/transports/local.c b/src/libgit2/transports/local.c
index 6c754a034..6c754a034 100644
--- a/src/transports/local.c
+++ b/src/libgit2/transports/local.c
diff --git a/src/transports/smart.c b/src/libgit2/transports/smart.c
index 801fcbe53..801fcbe53 100644
--- a/src/transports/smart.c
+++ b/src/libgit2/transports/smart.c
diff --git a/src/transports/smart.h b/src/libgit2/transports/smart.h
index 9323d6c44..9323d6c44 100644
--- a/src/transports/smart.h
+++ b/src/libgit2/transports/smart.h
diff --git a/src/transports/smart_pkt.c b/src/libgit2/transports/smart_pkt.c
index b42edd0d6..b42edd0d6 100644
--- a/src/transports/smart_pkt.c
+++ b/src/libgit2/transports/smart_pkt.c
diff --git a/src/transports/smart_protocol.c b/src/libgit2/transports/smart_protocol.c
index 8cf027133..8cf027133 100644
--- a/src/transports/smart_protocol.c
+++ b/src/libgit2/transports/smart_protocol.c
diff --git a/src/transports/ssh.c b/src/libgit2/transports/ssh.c
index 89f085230..89f085230 100644
--- a/src/transports/ssh.c
+++ b/src/libgit2/transports/ssh.c
diff --git a/src/transports/ssh.h b/src/libgit2/transports/ssh.h
index d3e741f1d..d3e741f1d 100644
--- a/src/transports/ssh.h
+++ b/src/libgit2/transports/ssh.h
diff --git a/src/transports/winhttp.c b/src/libgit2/transports/winhttp.c
index 8ec5b37c5..8ec5b37c5 100644
--- a/src/transports/winhttp.c
+++ b/src/libgit2/transports/winhttp.c
diff --git a/src/tree-cache.c b/src/libgit2/tree-cache.c
index 0977c92f3..0977c92f3 100644
--- a/src/tree-cache.c
+++ b/src/libgit2/tree-cache.c
diff --git a/src/tree-cache.h b/src/libgit2/tree-cache.h
index a27e30466..a27e30466 100644
--- a/src/tree-cache.h
+++ b/src/libgit2/tree-cache.h
diff --git a/src/tree.c b/src/libgit2/tree.c
index a1545dc2d..a1545dc2d 100644
--- a/src/tree.c
+++ b/src/libgit2/tree.c
diff --git a/src/tree.h b/src/libgit2/tree.h
index 6bd9ed652..6bd9ed652 100644
--- a/src/tree.h
+++ b/src/libgit2/tree.h
diff --git a/src/userdiff.h b/src/libgit2/userdiff.h
index c9a80d712..c9a80d712 100644
--- a/src/userdiff.h
+++ b/src/libgit2/userdiff.h
diff --git a/src/worktree.c b/src/libgit2/worktree.c
index 2ac2274f1..2ac2274f1 100644
--- a/src/worktree.c
+++ b/src/libgit2/worktree.c
diff --git a/src/worktree.h b/src/libgit2/worktree.h
index 587189f81..587189f81 100644
--- a/src/worktree.h
+++ b/src/libgit2/worktree.h
diff --git a/src/xdiff/git-xdiff.h b/src/libgit2/xdiff/git-xdiff.h
index b75dba819..b75dba819 100644
--- a/src/xdiff/git-xdiff.h
+++ b/src/libgit2/xdiff/git-xdiff.h
diff --git a/src/xdiff/xdiff.h b/src/libgit2/xdiff/xdiff.h
index fb47f63fb..fb47f63fb 100644
--- a/src/xdiff/xdiff.h
+++ b/src/libgit2/xdiff/xdiff.h
diff --git a/src/xdiff/xdiffi.c b/src/libgit2/xdiff/xdiffi.c
index af31b7f4b..af31b7f4b 100644
--- a/src/xdiff/xdiffi.c
+++ b/src/libgit2/xdiff/xdiffi.c
diff --git a/src/xdiff/xdiffi.h b/src/libgit2/xdiff/xdiffi.h
index 8f1c7c8b0..8f1c7c8b0 100644
--- a/src/xdiff/xdiffi.h
+++ b/src/libgit2/xdiff/xdiffi.h
diff --git a/src/xdiff/xemit.c b/src/libgit2/xdiff/xemit.c
index 1cbf2b982..1cbf2b982 100644
--- a/src/xdiff/xemit.c
+++ b/src/libgit2/xdiff/xemit.c
diff --git a/src/xdiff/xemit.h b/src/libgit2/xdiff/xemit.h
index 1b9887e67..1b9887e67 100644
--- a/src/xdiff/xemit.h
+++ b/src/libgit2/xdiff/xemit.h
diff --git a/src/xdiff/xhistogram.c b/src/libgit2/xdiff/xhistogram.c
index 80794748b..80794748b 100644
--- a/src/xdiff/xhistogram.c
+++ b/src/libgit2/xdiff/xhistogram.c
diff --git a/src/xdiff/xinclude.h b/src/libgit2/xdiff/xinclude.h
index 75db1d8f3..75db1d8f3 100644
--- a/src/xdiff/xinclude.h
+++ b/src/libgit2/xdiff/xinclude.h
diff --git a/src/xdiff/xmacros.h b/src/libgit2/xdiff/xmacros.h
index 2809a28ca..2809a28ca 100644
--- a/src/xdiff/xmacros.h
+++ b/src/libgit2/xdiff/xmacros.h
diff --git a/src/xdiff/xmerge.c b/src/libgit2/xdiff/xmerge.c
index 433e2d741..433e2d741 100644
--- a/src/xdiff/xmerge.c
+++ b/src/libgit2/xdiff/xmerge.c
diff --git a/src/xdiff/xpatience.c b/src/libgit2/xdiff/xpatience.c
index c5d48e80a..c5d48e80a 100644
--- a/src/xdiff/xpatience.c
+++ b/src/libgit2/xdiff/xpatience.c
diff --git a/src/xdiff/xprepare.c b/src/libgit2/xdiff/xprepare.c
index 4527a4a07..4527a4a07 100644
--- a/src/xdiff/xprepare.c
+++ b/src/libgit2/xdiff/xprepare.c
diff --git a/src/xdiff/xprepare.h b/src/libgit2/xdiff/xprepare.h
index 947d9fc1b..947d9fc1b 100644
--- a/src/xdiff/xprepare.h
+++ b/src/libgit2/xdiff/xprepare.h
diff --git a/src/xdiff/xtypes.h b/src/libgit2/xdiff/xtypes.h
index 8442bd436..8442bd436 100644
--- a/src/xdiff/xtypes.h
+++ b/src/libgit2/xdiff/xtypes.h
diff --git a/src/xdiff/xutils.c b/src/libgit2/xdiff/xutils.c
index cfa6e2220..cfa6e2220 100644
--- a/src/xdiff/xutils.c
+++ b/src/libgit2/xdiff/xutils.c
diff --git a/src/xdiff/xutils.h b/src/libgit2/xdiff/xutils.h
index fba7bae03..fba7bae03 100644
--- a/src/xdiff/xutils.h
+++ b/src/libgit2/xdiff/xutils.h
diff --git a/src/util/CMakeLists.txt b/src/util/CMakeLists.txt
new file mode 100644
index 000000000..b725d5426
--- /dev/null
+++ b/src/util/CMakeLists.txt
@@ -0,0 +1,60 @@
+# util: a shared library for common utility functions for libgit2 projects
+
+add_library(util OBJECT)
+set_target_properties(util PROPERTIES C_STANDARD 90)
+set_target_properties(util PROPERTIES C_EXTENSIONS OFF)
+
+set(UTIL_INCLUDES
+ "${PROJECT_BINARY_DIR}/src"
+ "${PROJECT_SOURCE_DIR}/src/util"
+ "${PROJECT_SOURCE_DIR}/include")
+
+file(GLOB UTIL_SRC *.c *.h allocators/*.c allocators/*.h hash/sha1.h)
+list(SORT UTIL_SRC)
+
+#
+# Platform specific sources
+#
+
+if(WIN32 AND NOT CYGWIN)
+ file(GLOB UTIL_SRC_OS win32/*.c win32/*.h)
+ list(SORT UTIL_SRC_OS)
+elseif(NOT AMIGA)
+ file(GLOB UTIL_SRC_OS unix/*.c unix/*.h)
+ list(SORT UTIL_SRC_OS)
+endif()
+
+#
+# Hash backend selection
+#
+
+if(USE_SHA1 STREQUAL "CollisionDetection")
+ file(GLOB UTIL_SRC_HASH hash/sha1/collisiondetect.* hash/sha1/sha1dc/*)
+ target_compile_definitions(util PRIVATE SHA1DC_NO_STANDARD_INCLUDES=1)
+ target_compile_definitions(util PRIVATE SHA1DC_CUSTOM_INCLUDE_SHA1_C=\"git2_util.h\")
+ target_compile_definitions(util PRIVATE SHA1DC_CUSTOM_INCLUDE_UBC_CHECK_C=\"git2_util.h\")
+elseif(USE_SHA1 STREQUAL "OpenSSL")
+ file(GLOB UTIL_SRC_HASH hash/sha1/openssl.*)
+elseif(USE_SHA1 STREQUAL "CommonCrypto")
+ file(GLOB UTIL_SRC_HASH hash/sha1/common_crypto.*)
+elseif(USE_SHA1 STREQUAL "mbedTLS")
+ file(GLOB UTIL_SRC_HASH hash/sha1/mbedtls.*)
+elseif(USE_SHA1 STREQUAL "Win32")
+ file(GLOB UTIL_SRC_HASH hash/sha1/win32.*)
+elseif(USE_SHA1 STREQUAL "Generic")
+ file(GLOB UTIL_SRC_HASH hash/sha1/generic.*)
+else()
+ message(FATAL_ERROR "Asked for unknown SHA1 backend: ${USE_SHA1}")
+endif()
+
+list(SORT UTIL_SRC_HASH)
+
+#
+# Build the library
+#
+
+target_sources(util PRIVATE ${UTIL_SRC} ${UTIL_SRC_OS} ${UTIL_SRC_HASH})
+ide_split_sources(util)
+
+target_include_directories(util PRIVATE ${UTIL_INCLUDES} ${LIBGIT2_DEPENDENCY_INCLUDES} PUBLIC ${libgit2_SOURCE_DIR}/include)
+target_include_directories(util SYSTEM PRIVATE ${LIBGIT2_SYSTEM_INCLUDES})
diff --git a/src/alloc.c b/src/util/alloc.c
index 2820d84a2..2820d84a2 100644
--- a/src/alloc.c
+++ b/src/util/alloc.c
diff --git a/src/alloc.h b/src/util/alloc.h
index 04fb7e101..04fb7e101 100644
--- a/src/alloc.h
+++ b/src/util/alloc.h
diff --git a/src/allocators/failalloc.c b/src/util/allocators/failalloc.c
index 5257d1dec..5257d1dec 100644
--- a/src/allocators/failalloc.c
+++ b/src/util/allocators/failalloc.c
diff --git a/src/allocators/failalloc.h b/src/util/allocators/failalloc.h
index 6115e51e7..91264a0bb 100644
--- a/src/allocators/failalloc.h
+++ b/src/util/allocators/failalloc.h
@@ -8,7 +8,7 @@
#ifndef INCLUDE_allocators_failalloc_h__
#define INCLUDE_allocators_failalloc_h__
-#include "common.h"
+#include "git2_util.h"
extern void *git_failalloc_malloc(size_t len, const char *file, int line);
extern void *git_failalloc_calloc(size_t nelem, size_t elsize, const char *file, int line);
diff --git a/src/allocators/stdalloc.c b/src/util/allocators/stdalloc.c
index 2b36d9f3d..2b36d9f3d 100644
--- a/src/allocators/stdalloc.c
+++ b/src/util/allocators/stdalloc.c
diff --git a/src/allocators/stdalloc.h b/src/util/allocators/stdalloc.h
index fa23fe6e3..955038cb0 100644
--- a/src/allocators/stdalloc.h
+++ b/src/util/allocators/stdalloc.h
@@ -8,7 +8,7 @@
#ifndef INCLUDE_allocators_stdalloc_h__
#define INCLUDE_allocators_stdalloc_h__
-#include "common.h"
+#include "git2_util.h"
#include "alloc.h"
diff --git a/src/allocators/win32_leakcheck.c b/src/util/allocators/win32_leakcheck.c
index fe06a14af..fe06a14af 100644
--- a/src/allocators/win32_leakcheck.c
+++ b/src/util/allocators/win32_leakcheck.c
diff --git a/src/allocators/win32_leakcheck.h b/src/util/allocators/win32_leakcheck.h
index 089690f90..edcd9307f 100644
--- a/src/allocators/win32_leakcheck.h
+++ b/src/util/allocators/win32_leakcheck.h
@@ -8,7 +8,7 @@
#ifndef INCLUDE_allocators_win32_leakcheck_h
#define INCLUDE_allocators_win32_leakcheck_h
-#include "common.h"
+#include "git2_util.h"
#include "alloc.h"
diff --git a/src/array.h b/src/util/array.h
index e97688b36..cbab52ad1 100644
--- a/src/array.h
+++ b/src/util/array.h
@@ -7,7 +7,7 @@
#ifndef INCLUDE_array_h__
#define INCLUDE_array_h__
-#include "common.h"
+#include "git2_util.h"
/*
* Use this to declare a typesafe resizable array of items, a la:
diff --git a/src/assert_safe.h b/src/util/assert_safe.h
index 8c261100f..8c261100f 100644
--- a/src/assert_safe.h
+++ b/src/util/assert_safe.h
diff --git a/src/bitvec.h b/src/util/bitvec.h
index 544832d95..544832d95 100644
--- a/src/bitvec.h
+++ b/src/util/bitvec.h
diff --git a/src/cc-compat.h b/src/util/cc-compat.h
index a0971e86c..a0971e86c 100644
--- a/src/cc-compat.h
+++ b/src/util/cc-compat.h
diff --git a/src/date.c b/src/util/date.c
index 0e5ffc96b..4d757e21a 100644
--- a/src/date.c
+++ b/src/util/date.c
@@ -1,10 +1,11 @@
/*
- * GIT - The information manager from hell
+ * Copyright (C) the libgit2 contributors. All rights reserved.
*
- * Copyright (C) Linus Torvalds, 2005
+ * This file is part of libgit2, distributed under the GNU GPL v2 with
+ * a Linking Exception. For full terms see the included COPYING file.
*/
-#include "common.h"
+#include "git2_util.h"
#ifndef GIT_WIN32
#include <sys/time.h>
diff --git a/src/date.h b/src/util/date.h
index 7ebd3c30e..7ebd3c30e 100644
--- a/src/date.h
+++ b/src/util/date.h
diff --git a/src/filebuf.c b/src/util/filebuf.c
index eafcba3bd..e014d43b2 100644
--- a/src/filebuf.c
+++ b/src/util/filebuf.c
@@ -65,7 +65,7 @@ static int lock_file(git_filebuf *file, int flags, mode_t mode)
if ((flags & GIT_FILEBUF_APPEND) && git_fs_path_exists(file->path_original) == true) {
git_file source;
- char buffer[FILEIO_BUFSIZE];
+ char buffer[GIT_BUFSIZE_FILEIO];
ssize_t read_bytes;
int error = 0;
diff --git a/src/filebuf.h b/src/util/filebuf.h
index adbb19936..4a61ae4e3 100644
--- a/src/filebuf.h
+++ b/src/util/filebuf.h
@@ -7,7 +7,7 @@
#ifndef INCLUDE_filebuf_h__
#define INCLUDE_filebuf_h__
-#include "common.h"
+#include "git2_util.h"
#include "futils.h"
#include "hash.h"
diff --git a/src/fs_path.c b/src/util/fs_path.c
index 7a657778a..920c39073 100644
--- a/src/fs_path.c
+++ b/src/util/fs_path.c
@@ -7,8 +7,9 @@
#include "fs_path.h"
+#include "git2_util.h"
+#include "futils.h"
#include "posix.h"
-#include "repository.h"
#ifdef GIT_WIN32
#include "win32/posix.h"
#include "win32/w32_buffer.h"
@@ -21,6 +22,13 @@
#include <stdio.h>
#include <ctype.h>
+#define ensure_error_set(code) do { \
+ const git_error *e = git_error_last(); \
+ if (!e || !e->message) \
+ git_error_set(e ? e->klass : GIT_ERROR_CALLBACK, \
+ "filesystem callback returned %d", code); \
+ } while(0)
+
static int dos_drive_prefix_length(const char *path)
{
int i;
@@ -530,7 +538,7 @@ int git_fs_path_walk_up(
if (!scan) {
error = cb(data, "");
if (error)
- git_error_set_after_callback(error);
+ ensure_error_set(error);
return error;
}
@@ -543,7 +551,7 @@ int git_fs_path_walk_up(
iter.ptr[scan] = oldc;
if (error) {
- git_error_set_after_callback(error);
+ ensure_error_set(error);
break;
}
@@ -563,7 +571,7 @@ int git_fs_path_walk_up(
if (!error && stop == 0 && iter.ptr[0] != '/') {
error = cb(data, "");
if (error)
- git_error_set_after_callback(error);
+ ensure_error_set(error);
}
return error;
@@ -1167,7 +1175,7 @@ int git_fs_path_direach(
/* Only set our own error if the callback did not set one already */
if (error != 0) {
if (!git_error_last())
- git_error_set_after_callback(error);
+ ensure_error_set(error);
break;
}
diff --git a/src/fs_path.h b/src/util/fs_path.h
index 222c44abc..bb840c43c 100644
--- a/src/fs_path.h
+++ b/src/util/fs_path.h
@@ -7,7 +7,7 @@
#ifndef INCLUDE_fs_path_h__
#define INCLUDE_fs_path_h__
-#include "common.h"
+#include "git2_util.h"
#include "posix.h"
#include "str.h"
diff --git a/src/futils.c b/src/util/futils.c
index 42c35955e..cb872de09 100644
--- a/src/futils.c
+++ b/src/util/futils.c
@@ -167,18 +167,60 @@ int git_futils_readbuffer_fd(git_str *buf, git_file fd, size_t len)
/* p_read loops internally to read len bytes */
read_size = p_read(fd, buf->ptr, len);
- if (read_size != (ssize_t)len) {
+ if (read_size < 0) {
git_error_set(GIT_ERROR_OS, "failed to read descriptor");
git_str_dispose(buf);
return -1;
}
+ if ((size_t)read_size != len) {
+ git_error_set(GIT_ERROR_FILESYSTEM, "could not read (expected %" PRIuZ " bytes, read %" PRIuZ ")", len, (size_t)read_size);
+ git_str_dispose(buf);
+ return -1;
+ }
+
buf->ptr[read_size] = '\0';
buf->size = read_size;
return 0;
}
+int git_futils_readbuffer_fd_full(git_str *buf, git_file fd)
+{
+ static size_t blocksize = 10240;
+ size_t alloc_len = 0, total_size = 0;
+ ssize_t read_size = 0;
+
+ git_str_clear(buf);
+
+ while (true) {
+ GIT_ERROR_CHECK_ALLOC_ADD(&alloc_len, alloc_len, blocksize);
+
+ if (git_str_grow(buf, alloc_len) < 0)
+ return -1;
+
+ /* p_read loops internally to read blocksize bytes */
+ read_size = p_read(fd, buf->ptr, blocksize);
+
+ if (read_size < 0) {
+ git_error_set(GIT_ERROR_OS, "failed to read descriptor");
+ git_str_dispose(buf);
+ return -1;
+ }
+
+ total_size += read_size;
+
+ if ((size_t)read_size < blocksize) {
+ break;
+ }
+ }
+
+ buf->ptr[total_size] = '\0';
+ buf->size = total_size;
+
+ return 0;
+}
+
int git_futils_readbuffer_updated(
git_str *out,
const char *path,
@@ -856,7 +898,7 @@ int git_futils_fake_symlink(const char *target, const char *path)
static int cp_by_fd(int ifd, int ofd, bool close_fd_when_done)
{
int error = 0;
- char buffer[FILEIO_BUFSIZE];
+ char buffer[GIT_BUFSIZE_FILEIO];
ssize_t len = 0;
while (!error && (len = p_read(ifd, buffer, sizeof(buffer))) > 0)
diff --git a/src/futils.h b/src/util/futils.h
index a82ec41cc..3f207afb2 100644
--- a/src/futils.h
+++ b/src/util/futils.h
@@ -7,7 +7,7 @@
#ifndef INCLUDE_futils_h__
#define INCLUDE_futils_h__
-#include "common.h"
+#include "git2_util.h"
#include "map.h"
#include "posix.h"
@@ -27,6 +27,7 @@ extern int git_futils_readbuffer_updated(
const char *path,
unsigned char checksum[GIT_HASH_SHA1_SIZE],
int *updated);
+extern int git_futils_readbuffer_fd_full(git_str *obj, git_file fd);
extern int git_futils_readbuffer_fd(git_str *obj, git_file fd, size_t len);
/* Additional constants for `git_futils_writebuffer`'s `open_flags`. We
diff --git a/src/common.h b/src/util/git2_util.h
index 549bddb59..ad3f1c71f 100644
--- a/src/common.h
+++ b/src/util/git2_util.h
@@ -4,8 +4,8 @@
* 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_common_h__
-#define INCLUDE_common_h__
+#ifndef INCLUDE_git2_util_h__
+#define INCLUDE_git2_util_h__
#ifndef LIBGIT2_NO_FEATURES_H
# include "git2/sys/features.h"
@@ -14,13 +14,13 @@
#include "git2/common.h"
#include "cc-compat.h"
+typedef struct git_str git_str;
+
/** Declare a function as always inlined. */
#if defined(_MSC_VER)
# define GIT_INLINE(type) static __inline type
#elif defined(__GNUC__)
# define GIT_INLINE(type) static __inline__ type
-#elif defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)
-# define GIT_INLINE(type) static inline type
#else
# define GIT_INLINE(type) static type
#endif
@@ -67,12 +67,12 @@
# include <ws2tcpip.h>
# include "win32/msvc-compat.h"
# include "win32/mingw-compat.h"
-# include "win32/w32_common.h"
# include "win32/win32-compat.h"
-# include "win32/error.h"
+# include "win32/w32_common.h"
# include "win32/version.h"
+# include "win32/error.h"
# ifdef GIT_THREADS
-# include "win32/thread.h"
+# include "win32/thread.h"
# endif
#else
@@ -99,24 +99,17 @@
#include "git2/types.h"
#include "git2/errors.h"
-#include "errors.h"
#include "thread.h"
#include "integer.h"
#include "assert_safe.h"
-#include "utf8.h"
-
-/*
- * Include the declarations for deprecated functions; this ensures
- * that they're decorated with the proper extern/visibility attributes.
- */
-#include "git2/deprecated.h"
#include "posix.h"
-#define DEFAULT_BUFSIZE 65536
-#define FILEIO_BUFSIZE DEFAULT_BUFSIZE
-#define FILTERIO_BUFSIZE DEFAULT_BUFSIZE
-#define NETIO_BUFSIZE DEFAULT_BUFSIZE
+#define GIT_BUFSIZE_DEFAULT 65536
+#define GIT_BUFSIZE_FILEIO GIT_BUFSIZE_DEFAULT
+#define GIT_BUFSIZE_FILTERIO GIT_BUFSIZE_DEFAULT
+#define GIT_BUFSIZE_NETIO GIT_BUFSIZE_DEFAULT
+
/**
* Check a pointer allocation result, returning -1 if it failed.
@@ -126,7 +119,7 @@
} while(0)
/**
- * Check a string buffer allocation result, returning -1 if it failed.
+ * Check a buffer allocation result, returning -1 if it failed.
*/
#define GIT_ERROR_CHECK_ALLOC_STR(buf) do { \
if ((void *)(buf) == NULL || git_str_oom(buf)) { return -1; } \
@@ -138,40 +131,6 @@
#define GIT_ERROR_CHECK_ERROR(code) \
do { int _err = (code); if (_err) return _err; } while (0)
-/**
- * Check a versioned structure for validity
- */
-GIT_INLINE(int) git_error__check_version(const void *structure, unsigned int expected_max, const char *name)
-{
- unsigned int actual;
-
- if (!structure)
- return 0;
-
- actual = *(const unsigned int*)structure;
- if (actual > 0 && actual <= expected_max)
- return 0;
-
- git_error_set(GIT_ERROR_INVALID, "invalid version %d on %s", actual, name);
- return -1;
-}
-#define GIT_ERROR_CHECK_VERSION(S,V,N) if (git_error__check_version(S,V,N) < 0) return -1
-
-/**
- * Initialize a structure with a version.
- */
-GIT_INLINE(void) git__init_structure(void *structure, size_t len, unsigned int version)
-{
- memset(structure, 0, len);
- *((int*)structure) = version;
-}
-#define GIT_INIT_STRUCTURE(S,V) git__init_structure(S, sizeof(*S), V)
-
-#define GIT_INIT_STRUCTURE_FROM_TEMPLATE(PTR,VERSION,TYPE,TPL) do { \
- TYPE _tmpl = TPL; \
- GIT_ERROR_CHECK_VERSION(&(VERSION), _tmpl.version, #TYPE); \
- memcpy((PTR), &_tmpl, sizeof(_tmpl)); } while (0)
-
/** Check for additive overflow, setting an error if would occur. */
#define GIT_ADD_SIZET_OVERFLOW(out, one, two) \
@@ -204,11 +163,6 @@ GIT_INLINE(void) git__init_structure(void *structure, size_t len, unsigned int v
#define GIT_ERROR_CHECK_ALLOC_MULTIPLY(out, nelem, elsize) \
if (GIT_MULTIPLY_SIZET_OVERFLOW(out, nelem, elsize)) { return -1; }
-/* NOTE: other git_error functions are in the public errors.h header file */
-
-/* Forward declare git_str */
-typedef struct git_str git_str;
-
#include "util.h"
#endif
diff --git a/src/hash.c b/src/util/hash.c
index 98ceb05d2..98ceb05d2 100644
--- a/src/hash.c
+++ b/src/util/hash.c
diff --git a/src/hash.h b/src/util/hash.h
index 507c1cb25..5f1386563 100644
--- a/src/hash.h
+++ b/src/util/hash.h
@@ -8,7 +8,7 @@
#ifndef INCLUDE_hash_h__
#define INCLUDE_hash_h__
-#include "common.h"
+#include "git2_util.h"
#include "hash/sha1.h"
diff --git a/src/hash/sha1.h b/src/util/hash/sha1.h
index 4b4dae3f8..9d32bce42 100644
--- a/src/hash/sha1.h
+++ b/src/util/hash/sha1.h
@@ -8,7 +8,7 @@
#ifndef INCLUDE_hash_sha1_h__
#define INCLUDE_hash_sha1_h__
-#include "common.h"
+#include "git2_util.h"
typedef struct git_hash_sha1_ctx git_hash_sha1_ctx;
diff --git a/src/hash/sha1/collisiondetect.c b/src/util/hash/sha1/collisiondetect.c
index ec7059c4c..ec7059c4c 100644
--- a/src/hash/sha1/collisiondetect.c
+++ b/src/util/hash/sha1/collisiondetect.c
diff --git a/src/hash/sha1/collisiondetect.h b/src/util/hash/sha1/collisiondetect.h
index eb88e86c1..eb88e86c1 100644
--- a/src/hash/sha1/collisiondetect.h
+++ b/src/util/hash/sha1/collisiondetect.h
diff --git a/src/hash/sha1/common_crypto.c b/src/util/hash/sha1/common_crypto.c
index 9d608f449..9d608f449 100644
--- a/src/hash/sha1/common_crypto.c
+++ b/src/util/hash/sha1/common_crypto.c
diff --git a/src/hash/sha1/common_crypto.h b/src/util/hash/sha1/common_crypto.h
index a5fcfb33e..a5fcfb33e 100644
--- a/src/hash/sha1/common_crypto.h
+++ b/src/util/hash/sha1/common_crypto.h
diff --git a/src/hash/sha1/generic.c b/src/util/hash/sha1/generic.c
index 85b34c578..85b34c578 100644
--- a/src/hash/sha1/generic.c
+++ b/src/util/hash/sha1/generic.c
diff --git a/src/hash/sha1/generic.h b/src/util/hash/sha1/generic.h
index 53fc0823e..53fc0823e 100644
--- a/src/hash/sha1/generic.h
+++ b/src/util/hash/sha1/generic.h
diff --git a/src/hash/sha1/mbedtls.c b/src/util/hash/sha1/mbedtls.c
index 56016bec8..56016bec8 100644
--- a/src/hash/sha1/mbedtls.c
+++ b/src/util/hash/sha1/mbedtls.c
diff --git a/src/hash/sha1/mbedtls.h b/src/util/hash/sha1/mbedtls.h
index 15f7462a4..15f7462a4 100644
--- a/src/hash/sha1/mbedtls.h
+++ b/src/util/hash/sha1/mbedtls.h
diff --git a/src/hash/sha1/openssl.c b/src/util/hash/sha1/openssl.c
index 64bf99b3c..64bf99b3c 100644
--- a/src/hash/sha1/openssl.c
+++ b/src/util/hash/sha1/openssl.c
diff --git a/src/hash/sha1/openssl.h b/src/util/hash/sha1/openssl.h
index a223ca03e..a223ca03e 100644
--- a/src/hash/sha1/openssl.h
+++ b/src/util/hash/sha1/openssl.h
diff --git a/src/hash/sha1/sha1dc/sha1.c b/src/util/hash/sha1/sha1dc/sha1.c
index 929822728..929822728 100644
--- a/src/hash/sha1/sha1dc/sha1.c
+++ b/src/util/hash/sha1/sha1dc/sha1.c
diff --git a/src/hash/sha1/sha1dc/sha1.h b/src/util/hash/sha1/sha1dc/sha1.h
index 1e4e94be5..1e4e94be5 100644
--- a/src/hash/sha1/sha1dc/sha1.h
+++ b/src/util/hash/sha1/sha1dc/sha1.h
diff --git a/src/hash/sha1/sha1dc/ubc_check.c b/src/util/hash/sha1/sha1dc/ubc_check.c
index b3beff2af..b3beff2af 100644
--- a/src/hash/sha1/sha1dc/ubc_check.c
+++ b/src/util/hash/sha1/sha1dc/ubc_check.c
diff --git a/src/hash/sha1/sha1dc/ubc_check.h b/src/util/hash/sha1/sha1dc/ubc_check.h
index d7e17dc73..d7e17dc73 100644
--- a/src/hash/sha1/sha1dc/ubc_check.h
+++ b/src/util/hash/sha1/sha1dc/ubc_check.h
diff --git a/src/hash/sha1/win32.c b/src/util/hash/sha1/win32.c
index b89dfbad8..b89dfbad8 100644
--- a/src/hash/sha1/win32.c
+++ b/src/util/hash/sha1/win32.c
diff --git a/src/hash/sha1/win32.h b/src/util/hash/sha1/win32.h
index 791d20a42..791d20a42 100644
--- a/src/hash/sha1/win32.h
+++ b/src/util/hash/sha1/win32.h
diff --git a/src/integer.h b/src/util/integer.h
index 63277177b..63277177b 100644
--- a/src/integer.h
+++ b/src/util/integer.h
diff --git a/src/khash.h b/src/util/khash.h
index c9b7f131f..c9b7f131f 100644
--- a/src/khash.h
+++ b/src/util/khash.h
diff --git a/src/map.h b/src/util/map.h
index 01931d199..c101e46f6 100644
--- a/src/map.h
+++ b/src/util/map.h
@@ -7,7 +7,7 @@
#ifndef INCLUDE_map_h__
#define INCLUDE_map_h__
-#include "common.h"
+#include "git2_util.h"
/* p_mmap() prot values */
diff --git a/src/net.c b/src/util/net.c
index a76fd1d7c..b2236daf8 100644
--- a/src/net.c
+++ b/src/util/net.c
@@ -6,7 +6,6 @@
*/
#include "net.h"
-#include "netops.h"
#include <ctype.h>
diff --git a/src/net.h b/src/util/net.h
index 499315e6c..88030a952 100644
--- a/src/net.h
+++ b/src/util/net.h
@@ -7,7 +7,7 @@
#ifndef INCLUDE_net_h__
#define INCLUDE_net_h__
-#include "common.h"
+#include "git2_util.h"
typedef struct git_net_url {
char *scheme;
diff --git a/src/pool.c b/src/util/pool.c
index 16ffa398d..16ffa398d 100644
--- a/src/pool.c
+++ b/src/util/pool.c
diff --git a/src/pool.h b/src/util/pool.h
index cecb84665..0238431b0 100644
--- a/src/pool.h
+++ b/src/util/pool.h
@@ -7,7 +7,7 @@
#ifndef INCLUDE_pool_h__
#define INCLUDE_pool_h__
-#include "common.h"
+#include "git2_util.h"
#include "vector.h"
diff --git a/src/posix.c b/src/util/posix.c
index b1f85dc94..b1f85dc94 100644
--- a/src/posix.c
+++ b/src/util/posix.c
diff --git a/src/posix.h b/src/util/posix.h
index e6f603078..c8f8cd9d2 100644
--- a/src/posix.h
+++ b/src/util/posix.h
@@ -7,7 +7,7 @@
#ifndef INCLUDE_posix_h__
#define INCLUDE_posix_h__
-#include "common.h"
+#include "git2_util.h"
#include <stdlib.h>
#include <fcntl.h>
diff --git a/src/pqueue.c b/src/util/pqueue.c
index 3820e999c..3820e999c 100644
--- a/src/pqueue.c
+++ b/src/util/pqueue.c
diff --git a/src/pqueue.h b/src/util/pqueue.h
index 4db74ea03..97232b4a9 100644
--- a/src/pqueue.h
+++ b/src/util/pqueue.h
@@ -7,7 +7,7 @@
#ifndef INCLUDE_pqueue_h__
#define INCLUDE_pqueue_h__
-#include "common.h"
+#include "git2_util.h"
#include "vector.h"
diff --git a/src/rand.c b/src/util/rand.c
index 0a208134e..432494902 100644
--- a/src/rand.c
+++ b/src/util/rand.c
@@ -6,7 +6,7 @@ worldwide. This software is distributed without any warranty.
See <http://creativecommons.org/publicdomain/zero/1.0/>. */
-#include "common.h"
+#include "git2_util.h"
#include "rand.h"
#include "runtime.h"
diff --git a/src/rand.h b/src/util/rand.h
index 2e60561e5..fa0619aa2 100644
--- a/src/rand.h
+++ b/src/util/rand.h
@@ -7,7 +7,7 @@
#ifndef INCLUDE_rand_h__
#define INCLUDE_rand_h__
-#include "common.h"
+#include "git2_util.h"
/**
* Initialize the random number generation subsystem. This will
diff --git a/src/regexp.c b/src/util/regexp.c
index 2569dea0a..2569dea0a 100644
--- a/src/regexp.c
+++ b/src/util/regexp.c
diff --git a/src/regexp.h b/src/util/regexp.h
index 2592ef383..d0862b107 100644
--- a/src/regexp.h
+++ b/src/util/regexp.h
@@ -8,7 +8,7 @@
#ifndef INCLUDE_regexp_h__
#define INCLUDE_regexp_h__
-#include "common.h"
+#include "git2_util.h"
#if defined(GIT_REGEX_BUILTIN) || defined(GIT_REGEX_PCRE)
# include "pcre.h"
diff --git a/src/runtime.c b/src/util/runtime.c
index c05dee8b9..a7711ffc4 100644
--- a/src/runtime.c
+++ b/src/util/runtime.c
@@ -5,7 +5,7 @@
* a Linking Exception. For full terms see the included COPYING file.
*/
-#include "common.h"
+#include "git2_util.h"
#include "runtime.h"
static git_runtime_shutdown_fn shutdown_callback[32];
diff --git a/src/runtime.h b/src/util/runtime.h
index 24ac58ee9..6cbfd6043 100644
--- a/src/runtime.h
+++ b/src/util/runtime.h
@@ -7,7 +7,7 @@
#ifndef INCLUDE_runtime_h__
#define INCLUDE_runtime_h__
-#include "common.h"
+#include "git2_util.h"
typedef int (*git_runtime_init_fn)(void);
typedef void (*git_runtime_shutdown_fn)(void);
diff --git a/src/sortedcache.c b/src/util/sortedcache.c
index 7ff900efe..7ff900efe 100644
--- a/src/sortedcache.c
+++ b/src/util/sortedcache.c
diff --git a/src/sortedcache.h b/src/util/sortedcache.h
index ef260a093..3eee4659f 100644
--- a/src/sortedcache.h
+++ b/src/util/sortedcache.h
@@ -7,7 +7,7 @@
#ifndef INCLUDE_sorted_cache_h__
#define INCLUDE_sorted_cache_h__
-#include "common.h"
+#include "git2_util.h"
#include "util.h"
#include "futils.h"
diff --git a/src/str.c b/src/util/str.c
index 0d405bfda..0d405bfda 100644
--- a/src/str.c
+++ b/src/util/str.c
diff --git a/src/str.h b/src/util/str.h
index ef769ce2f..588e6fc22 100644
--- a/src/str.h
+++ b/src/util/str.h
@@ -7,7 +7,7 @@
#ifndef INCLUDE_str_h__
#define INCLUDE_str_h__
-#include "common.h"
+#include "git2_util.h"
struct git_str {
char *ptr;
diff --git a/src/strmap.c b/src/util/strmap.c
index c6e5b6dc7..c6e5b6dc7 100644
--- a/src/strmap.c
+++ b/src/util/strmap.c
diff --git a/src/strmap.h b/src/util/strmap.h
index 9f5e4cc8b..b64d3dcb5 100644
--- a/src/strmap.h
+++ b/src/util/strmap.h
@@ -7,7 +7,7 @@
#ifndef INCLUDE_strmap_h__
#define INCLUDE_strmap_h__
-#include "common.h"
+#include "git2_util.h"
/** A map with C strings as key. */
typedef struct kh_str_s git_strmap;
diff --git a/src/strnlen.h b/src/util/strnlen.h
index eecfe3c02..eecfe3c02 100644
--- a/src/strnlen.h
+++ b/src/util/strnlen.h
diff --git a/src/thread.c b/src/util/thread.c
index 3171771d7..bc7364f8c 100644
--- a/src/thread.c
+++ b/src/util/thread.c
@@ -5,7 +5,7 @@
* a Linking Exception. For full terms see the included COPYING file.
*/
-#include "common.h"
+#include "git2_util.h"
#if !defined(GIT_THREADS)
diff --git a/src/thread.h b/src/util/thread.h
index 4bbac9fd8..4bbac9fd8 100644
--- a/src/thread.h
+++ b/src/util/thread.h
diff --git a/src/tsort.c b/src/util/tsort.c
index 045efad23..2ef03d03a 100644
--- a/src/tsort.c
+++ b/src/util/tsort.c
@@ -5,7 +5,7 @@
* a Linking Exception. For full terms see the included COPYING file.
*/
-#include "common.h"
+#include "git2_util.h"
/**
* An array-of-pointers implementation of Python's Timsort
diff --git a/src/unix/map.c b/src/util/unix/map.c
index 23fcb786e..933077689 100644
--- a/src/unix/map.c
+++ b/src/util/unix/map.c
@@ -5,7 +5,7 @@
* a Linking Exception. For full terms see the included COPYING file.
*/
-#include "common.h"
+#include "git2_util.h"
#if !defined(GIT_WIN32) && !defined(NO_MMAP)
diff --git a/src/unix/posix.h b/src/util/unix/posix.h
index 49065e533..778477e8e 100644
--- a/src/unix/posix.h
+++ b/src/util/unix/posix.h
@@ -7,7 +7,7 @@
#ifndef INCLUDE_unix_posix_h__
#define INCLUDE_unix_posix_h__
-#include "common.h"
+#include "git2_util.h"
#include <stdio.h>
#include <dirent.h>
diff --git a/src/unix/pthread.h b/src/util/unix/pthread.h
index 55f4ae227..55f4ae227 100644
--- a/src/unix/pthread.h
+++ b/src/util/unix/pthread.h
diff --git a/src/unix/realpath.c b/src/util/unix/realpath.c
index f1ca669f7..9e31a63b9 100644
--- a/src/unix/realpath.c
+++ b/src/util/unix/realpath.c
@@ -5,7 +5,7 @@
* a Linking Exception. For full terms see the included COPYING file.
*/
-#include "common.h"
+#include "git2_util.h"
#ifndef GIT_WIN32
diff --git a/src/utf8.c b/src/util/utf8.c
index 77065cb71..c566fdf20 100644
--- a/src/utf8.c
+++ b/src/util/utf8.c
@@ -7,7 +7,7 @@
#include "utf8.h"
-#include "common.h"
+#include "git2_util.h"
/*
* git_utf8_iterate is taken from the utf8proc project,
diff --git a/src/utf8.h b/src/util/utf8.h
index dff91b294..753ab07e2 100644
--- a/src/utf8.h
+++ b/src/util/utf8.h
@@ -7,7 +7,7 @@
#ifndef INCLUDE_utf8_h__
#define INCLUDE_utf8_h__
-#include "common.h"
+#include "git2_util.h"
/*
* Iterate through an UTF-8 string, yielding one codepoint at a time.
diff --git a/src/util.c b/src/util/util.c
index e06d4ca09..aee95fddf 100644
--- a/src/util.c
+++ b/src/util/util.c
@@ -7,7 +7,7 @@
#include "util.h"
-#include "common.h"
+#include "git2_util.h"
#ifdef GIT_WIN32
# include "win32/utf-conv.h"
diff --git a/src/util.h b/src/util/util.h
index 141779ade..8d6d1d6b6 100644
--- a/src/util.h
+++ b/src/util/util.h
@@ -12,7 +12,7 @@
#endif
#include "str.h"
-#include "common.h"
+#include "git2_util.h"
#include "strnlen.h"
#include "thread.h"
diff --git a/src/varint.c b/src/util/varint.c
index 9ffc1d744..9ffc1d744 100644
--- a/src/varint.c
+++ b/src/util/varint.c
diff --git a/src/varint.h b/src/util/varint.h
index 652e22486..79b8f5548 100644
--- a/src/varint.h
+++ b/src/util/varint.h
@@ -7,7 +7,7 @@
#ifndef INCLUDE_varint_h__
#define INCLUDE_varint_h__
-#include "common.h"
+#include "git2_util.h"
#include <stdint.h>
diff --git a/src/vector.c b/src/util/vector.c
index 4a4bc8c0e..4a4bc8c0e 100644
--- a/src/vector.c
+++ b/src/util/vector.c
diff --git a/src/vector.h b/src/util/vector.h
index ae3c79a4c..e50cdfefc 100644
--- a/src/vector.h
+++ b/src/util/vector.h
@@ -7,7 +7,7 @@
#ifndef INCLUDE_vector_h__
#define INCLUDE_vector_h__
-#include "common.h"
+#include "git2_util.h"
typedef int (*git_vector_cmp)(const void *, const void *);
diff --git a/src/wildmatch.c b/src/util/wildmatch.c
index a894e4841..a894e4841 100644
--- a/src/wildmatch.c
+++ b/src/util/wildmatch.c
diff --git a/src/wildmatch.h b/src/util/wildmatch.h
index 44bb575a6..f20640500 100644
--- a/src/wildmatch.h
+++ b/src/util/wildmatch.h
@@ -8,7 +8,7 @@
#ifndef INCLUDE_wildmatch_h__
#define INCLUDE_wildmatch_h__
-#include "common.h"
+#include "git2_util.h"
#define WM_CASEFOLD 1
#define WM_PATHNAME 2
diff --git a/src/win32/dir.c b/src/util/win32/dir.c
index 44052caf0..44052caf0 100644
--- a/src/win32/dir.c
+++ b/src/util/win32/dir.c
diff --git a/src/win32/dir.h b/src/util/win32/dir.h
index acd64729e..810111534 100644
--- a/src/win32/dir.h
+++ b/src/util/win32/dir.h
@@ -7,7 +7,7 @@
#ifndef INCLUDE_win32_dir_h__
#define INCLUDE_win32_dir_h__
-#include "common.h"
+#include "git2_util.h"
#include "w32_util.h"
diff --git a/src/win32/error.c b/src/util/win32/error.c
index 3a52fb5a9..3a52fb5a9 100644
--- a/src/win32/error.c
+++ b/src/util/win32/error.c
diff --git a/src/win32/error.h b/src/util/win32/error.h
index 9e81141ce..fd53b7f99 100644
--- a/src/win32/error.h
+++ b/src/util/win32/error.h
@@ -8,7 +8,7 @@
#ifndef INCLUDE_win32_error_h__
#define INCLUDE_win32_error_h__
-#include "common.h"
+#include "git2_util.h"
extern char *git_win32_get_error_message(DWORD error_code);
diff --git a/src/win32/findfile.c b/src/util/win32/findfile.c
index 725a90167..725a90167 100644
--- a/src/win32/findfile.c
+++ b/src/util/win32/findfile.c
diff --git a/src/win32/findfile.h b/src/util/win32/findfile.h
index 61fb7dbad..7b191d1fe 100644
--- a/src/win32/findfile.h
+++ b/src/util/win32/findfile.h
@@ -8,7 +8,7 @@
#ifndef INCLUDE_win32_findfile_h__
#define INCLUDE_win32_findfile_h__
-#include "common.h"
+#include "git2_util.h"
/** Sets the mock registry root for Git for Windows for testing. */
extern int git_win32__set_registry_system_dir(const wchar_t *mock_sysdir);
diff --git a/src/win32/map.c b/src/util/win32/map.c
index 2aabc9b15..52e1363ea 100644
--- a/src/win32/map.c
+++ b/src/util/win32/map.c
@@ -5,7 +5,7 @@
* a Linking Exception. For full terms see the included COPYING file.
*/
-#include "common.h"
+#include "git2_util.h"
#include "map.h"
#include <errno.h>
diff --git a/src/win32/mingw-compat.h b/src/util/win32/mingw-compat.h
index aa2bef98d..aa2bef98d 100644
--- a/src/win32/mingw-compat.h
+++ b/src/util/win32/mingw-compat.h
diff --git a/src/win32/msvc-compat.h b/src/util/win32/msvc-compat.h
index 03f9f36dc..03f9f36dc 100644
--- a/src/win32/msvc-compat.h
+++ b/src/util/win32/msvc-compat.h
diff --git a/src/win32/path_w32.c b/src/util/win32/path_w32.c
index d9fc8292b..d9fc8292b 100644
--- a/src/win32/path_w32.c
+++ b/src/util/win32/path_w32.c
diff --git a/src/win32/path_w32.h b/src/util/win32/path_w32.h
index 837b11ebd..b241d5c8a 100644
--- a/src/win32/path_w32.h
+++ b/src/util/win32/path_w32.h
@@ -7,7 +7,7 @@
#ifndef INCLUDE_win32_path_w32_h__
#define INCLUDE_win32_path_w32_h__
-#include "common.h"
+#include "git2_util.h"
/**
* Create a Win32 path (in UCS-2 format) from a UTF-8 string. If the given
diff --git a/src/win32/posix.h b/src/util/win32/posix.h
index 578347f15..03fa2ac52 100644
--- a/src/win32/posix.h
+++ b/src/util/win32/posix.h
@@ -7,7 +7,7 @@
#ifndef INCLUDE_win32_posix_h__
#define INCLUDE_win32_posix_h__
-#include "common.h"
+#include "git2_util.h"
#include "../posix.h"
#include "win32-compat.h"
#include "path_w32.h"
diff --git a/src/win32/posix_w32.c b/src/util/win32/posix_w32.c
index 5f7cd0c26..5862e5c9a 100644
--- a/src/win32/posix_w32.c
+++ b/src/util/win32/posix_w32.c
@@ -5,7 +5,7 @@
* a Linking Exception. For full terms see the included COPYING file.
*/
-#include "common.h"
+#include "git2_util.h"
#include "../posix.h"
#include "../futils.h"
diff --git a/tests/precompiled.c b/src/util/win32/precompiled.c
index 5f656a45d..5f656a45d 100644
--- a/tests/precompiled.c
+++ b/src/util/win32/precompiled.c
diff --git a/src/win32/precompiled.h b/src/util/win32/precompiled.h
index 806b1698a..1163c3d63 100644
--- a/src/win32/precompiled.h
+++ b/src/util/win32/precompiled.h
@@ -1,4 +1,4 @@
-#include "common.h"
+#include "git2_util.h"
#include <errno.h>
#include <limits.h>
diff --git a/src/win32/reparse.h b/src/util/win32/reparse.h
index 23312319f..23312319f 100644
--- a/src/win32/reparse.h
+++ b/src/util/win32/reparse.h
diff --git a/src/win32/thread.c b/src/util/win32/thread.c
index f5cacd320..f5cacd320 100644
--- a/src/win32/thread.c
+++ b/src/util/win32/thread.c
diff --git a/src/win32/thread.h b/src/util/win32/thread.h
index 8305036b4..184762e2a 100644
--- a/src/win32/thread.h
+++ b/src/util/win32/thread.h
@@ -8,7 +8,7 @@
#ifndef INCLUDE_win32_thread_h__
#define INCLUDE_win32_thread_h__
-#include "common.h"
+#include "git2_util.h"
#if defined (_MSC_VER)
# define GIT_RESTRICT __restrict
diff --git a/src/win32/utf-conv.c b/src/util/win32/utf-conv.c
index 4bde3023a..4bde3023a 100644
--- a/src/win32/utf-conv.c
+++ b/src/util/win32/utf-conv.c
diff --git a/src/win32/utf-conv.h b/src/util/win32/utf-conv.h
index 6090a4b35..120d647ef 100644
--- a/src/win32/utf-conv.h
+++ b/src/util/win32/utf-conv.h
@@ -7,7 +7,7 @@
#ifndef INCLUDE_win32_utf_conv_h__
#define INCLUDE_win32_utf_conv_h__
-#include "common.h"
+#include "git2_util.h"
#include <wchar.h>
diff --git a/src/win32/version.h b/src/util/win32/version.h
index 79667697f..79667697f 100644
--- a/src/win32/version.h
+++ b/src/util/win32/version.h
diff --git a/src/win32/w32_buffer.c b/src/util/win32/w32_buffer.c
index 6fee8203c..6fee8203c 100644
--- a/src/win32/w32_buffer.c
+++ b/src/util/win32/w32_buffer.c
diff --git a/src/win32/w32_buffer.h b/src/util/win32/w32_buffer.h
index 4227296d8..68ea96035 100644
--- a/src/win32/w32_buffer.h
+++ b/src/util/win32/w32_buffer.h
@@ -7,7 +7,7 @@
#ifndef INCLUDE_win32_w32_buffer_h__
#define INCLUDE_win32_w32_buffer_h__
-#include "common.h"
+#include "git2_util.h"
#include "str.h"
/**
diff --git a/src/win32/w32_common.h b/src/util/win32/w32_common.h
index c20b3e85e..c20b3e85e 100644
--- a/src/win32/w32_common.h
+++ b/src/util/win32/w32_common.h
diff --git a/src/win32/w32_leakcheck.c b/src/util/win32/w32_leakcheck.c
index 0f095de12..0f095de12 100644
--- a/src/win32/w32_leakcheck.c
+++ b/src/util/win32/w32_leakcheck.c
diff --git a/src/win32/w32_leakcheck.h b/src/util/win32/w32_leakcheck.h
index cb45e3675..82d863851 100644
--- a/src/win32/w32_leakcheck.h
+++ b/src/util/win32/w32_leakcheck.h
@@ -8,7 +8,7 @@
#ifndef INCLUDE_win32_leakcheck_h__
#define INCLUDE_win32_leakcheck_h__
-#include "common.h"
+#include "git2_util.h"
/* Initialize the win32 leak checking system. */
int git_win32_leakcheck_global_init(void);
diff --git a/src/win32/w32_util.c b/src/util/win32/w32_util.c
index fe4b75bae..fe4b75bae 100644
--- a/src/win32/w32_util.c
+++ b/src/util/win32/w32_util.c
diff --git a/src/win32/w32_util.h b/src/util/win32/w32_util.h
index 1321d30e6..519663720 100644
--- a/src/win32/w32_util.h
+++ b/src/util/win32/w32_util.h
@@ -8,7 +8,7 @@
#ifndef INCLUDE_win32_w32_util_h__
#define INCLUDE_win32_w32_util_h__
-#include "common.h"
+#include "git2_util.h"
#include "utf-conv.h"
#include "posix.h"
diff --git a/src/win32/win32-compat.h b/src/util/win32/win32-compat.h
index dee40a438..dee40a438 100644
--- a/src/win32/win32-compat.h
+++ b/src/util/win32/win32-compat.h
diff --git a/src/zstream.c b/src/util/zstream.c
index cb8b125ed..cb8b125ed 100644
--- a/src/zstream.c
+++ b/src/util/zstream.c
diff --git a/src/zstream.h b/src/util/zstream.h
index 3f8b1c72f..d78b11291 100644
--- a/src/zstream.h
+++ b/src/util/zstream.h
@@ -7,7 +7,7 @@
#ifndef INCLUDE_zstream_h__
#define INCLUDE_zstream_h__
-#include "common.h"
+#include "git2_util.h"
#include <zlib.h>
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index f293c158d..df100e980 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -1,96 +1,6 @@
-set(Python_ADDITIONAL_VERSIONS 3 2.7)
-find_package(PythonInterp)
+# The main libgit2 tests tree: this CMakeLists.txt includes the
+# subprojects that make up core libgit2 support.
-if(NOT PYTHONINTERP_FOUND)
- message(FATAL_ERROR "Could not find a python interpreter, which is needed to build the tests. "
- "Make sure python is available, or pass -DBUILD_TESTS=OFF to skip building the tests")
-ENDIF()
-
-set(CLAR_FIXTURES "${CMAKE_CURRENT_SOURCE_DIR}/resources/")
-set(CLAR_PATH "${CMAKE_CURRENT_SOURCE_DIR}")
-add_definitions(-DCLAR_FIXTURE_PATH=\"${CLAR_FIXTURES}\")
-add_definitions(-DCLAR_TMPDIR=\"libgit2_tests\")
-add_definitions(-DCLAR_WIN32_LONGPATHS)
-add_definitions(-D_FILE_OFFSET_BITS=64)
-
-# Ensure that we do not use deprecated functions internally
-add_definitions(-DGIT_DEPRECATE_HARD)
-
-set(TEST_INCLUDES "${CLAR_PATH}" "${CMAKE_CURRENT_BINARY_DIR}")
-file(GLOB_RECURSE SRC_TEST ${CLAR_PATH}/*/*.c ${CLAR_PATH}/*/*.h)
-set(SRC_CLAR "main.c" "clar_libgit2.c" "clar_libgit2_trace.c" "clar_libgit2_timer.c" "clar.c")
-
-if(MSVC_IDE)
- list(APPEND SRC_CLAR "precompiled.c")
-endif()
-
-add_custom_command(
- OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/clar.suite ${CMAKE_CURRENT_BINARY_DIR}/clar_suite.h
- COMMAND ${PYTHON_EXECUTABLE} generate.py -o "${CMAKE_CURRENT_BINARY_DIR}" -f -xonline -xstress -xperf .
- DEPENDS ${SRC_TEST}
- WORKING_DIRECTORY ${CLAR_PATH}
-)
-
-set_source_files_properties(
- ${CLAR_PATH}/clar.c
- PROPERTIES OBJECT_DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/clar.suite)
-
-add_executable(libgit2_tests ${SRC_CLAR} ${SRC_TEST} ${LIBGIT2_OBJECTS})
-
-set_target_properties(libgit2_tests PROPERTIES C_STANDARD 90)
-set_target_properties(libgit2_tests PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR})
-
-target_include_directories(libgit2_tests PRIVATE ${TEST_INCLUDES} ${LIBGIT2_INCLUDES} ${LIBGIT2_DEPENDENCY_INCLUDES})
-target_include_directories(libgit2_tests SYSTEM PRIVATE ${LIBGIT2_SYSTEM_INCLUDES})
-target_link_libraries(libgit2_tests ${LIBGIT2_SYSTEM_LIBS})
-
-ide_split_sources(libgit2_tests)
-
-#
-# Old versions of gcc require us to declare our test functions; don't do
-# this on newer compilers to avoid unnecessary recompilation.
-#
-if(CMAKE_COMPILER_IS_GNUCC AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 6.0)
- target_compile_options(libgit2_tests PRIVATE -include "clar_suite.h")
-endif()
-
-if(MSVC_IDE)
- # Precompiled headers
- set_target_properties(libgit2_tests PROPERTIES COMPILE_FLAGS "/Yuprecompiled.h /FIprecompiled.h")
- set_source_files_properties("precompiled.c" COMPILE_FLAGS "/Ycprecompiled.h")
-endif()
-
-function(ADD_CLAR_TEST name)
- if(NOT USE_LEAK_CHECKER STREQUAL "OFF")
- add_test(${name} "${PROJECT_SOURCE_DIR}/script/${USE_LEAK_CHECKER}.sh" "${PROJECT_BINARY_DIR}/libgit2_tests" ${ARGN})
- else()
- add_test(${name} "${PROJECT_BINARY_DIR}/libgit2_tests" ${ARGN})
- endif()
-endfunction(ADD_CLAR_TEST)
-
-add_clar_test(offline -v -xonline)
-add_clar_test(invasive -v -score::ftruncate -sfilter::stream::bigfile -sodb::largefiles -siterator::workdir::filesystem_gunk -srepo::init -srepo::init::at_filesystem_root)
-add_clar_test(online -v -sonline -xonline::customcert)
-add_clar_test(online_customcert -v -sonline::customcert)
-add_clar_test(gitdaemon -v -sonline::push)
-add_clar_test(ssh -v -sonline::push -sonline::clone::ssh_cert -sonline::clone::ssh_with_paths -sonline::clone::path_whitespace_ssh)
-add_clar_test(proxy -v -sonline::clone::proxy)
-add_clar_test(auth_clone -v -sonline::clone::cred)
-add_clar_test(auth_clone_and_push -v -sonline::clone::push -sonline::push)
-
-#
-# Header file validation project: ensure that we do not publish any sloppy
-# definitions in our headers and that a consumer can include <git2.dll>
-# even when they have aggressive C90 warnings enabled.
-#
-
-add_executable(headertest headertest.c)
-set_target_properties(headertest PROPERTIES C_STANDARD 90)
-set_target_properties(headertest PROPERTIES C_EXTENSIONS OFF)
-target_include_directories(headertest PRIVATE ${LIBGIT2_INCLUDES})
-
-if (MSVC)
- target_compile_options(headertest PUBLIC /W4 /WX)
-else()
- target_compile_options(headertest PUBLIC -Wall -Wextra -pedantic -Werror)
-endif()
+add_subdirectory(headertest)
+add_subdirectory(libgit2)
+add_subdirectory(util)
diff --git a/tests/README.md b/tests/README.md
index 4369a8f33..5920b1547 100644
--- a/tests/README.md
+++ b/tests/README.md
@@ -1,33 +1,56 @@
-Writing Clar tests for libgit2
-==============================
-
-For information on the Clar testing framework and a detailed introduction
-please visit:
-
-https://github.com/vmg/clar
-
-
-* Write your modules and tests. Use good, meaningful names.
-
-* Make sure you actually build the tests by setting:
-
- cmake -DBUILD_TESTS=ON build/
-
-* Test:
-
- ./build/libgit2_tests
-
-* Make sure everything is fine.
-
-* Send your pull request. That's it.
-
-
-Memory leak checks
-------------------
+# libgit2 tests
+
+These are the unit and integration tests for the libgit2 projects.
+
+* `clar`
+ This is [clar](https://github.com/clar-test/clar) the common test framework.
+* `headertest`
+ This is a simple project that ensures that our public headers are
+ compatible with extremely strict compilation options.
+* `libgit2`
+ These tests exercise the core git functionality in libgit2 itself.
+* `resources`
+ These are the resources for the tests, including files and git
+ repositories.
+* `util`
+ These are tests of the common utility library.
+
+## Writing tests for libgit2
+
+libgit2 uses the [clar test framework](http://github.com/clar-test/clar), a
+C testing framework.
+
+The best resources for learning clar are [clar itself](https://github.com/clar-test/clar)
+and the existing tests within libgit2. In general:
+
+* If you place a `.c` file into a test directory, it is eligible to contain
+test cases.
+* The function name for your test is important; test function names begin
+ with `test_`, followed by the folder path (underscore separated), two
+ underscores as a delimiter, then the test name. For example, a file
+ `merge/analysis.c` may contain a test `uptodate`:
+
+ ```
+ void test_merge_analysis__uptodate(void)
+ {
+ ...
+ }
+ ```
+
+* You can run an individual test by passing `-s` to the test runner. Tests
+ are referred to by their function names; for example, the function
+ `test_merge_analysis__uptodate` is referred to as `merge::analysis::uptodate`.
+ To run only that function you can use the `-s` option on the test runner:
+
+ ```
+ libgit2_tests -smerge::analysis::uptodate
+ ```
+
+## Memory leak checking
These are automatically run as part of CI, but if you want to check locally:
-#### Linux
+### Linux
Uses [`valgrind`](http://www.valgrind.org/):
@@ -38,7 +61,7 @@ $ valgrind --leak-check=full --show-reachable=yes --num-callers=50 --suppression
./libgit2_tests
```
-#### macOS
+### macOS
Uses [`leaks`](https://developer.apple.com/library/archive/documentation/Performance/Conceptual/ManagingMemory/Articles/FindingLeaks.html), which requires XCode installed:
@@ -46,3 +69,13 @@ Uses [`leaks`](https://developer.apple.com/library/archive/documentation/Perform
$ MallocStackLogging=1 MallocScribble=1 MallocLogFile=/dev/null CLAR_AT_EXIT="leaks -quiet \$PPID" \
./libgit2_tests
```
+
+### Windows
+
+Build with the `WIN32_LEAKCHECK` option:
+
+```console
+$ cmake -DBUILD_TESTS=ON -DWIN32_LEAKCHECK=ON ..
+$ cmake --build .
+$ ./libgit2_tests
+```
diff --git a/tests/clar.c b/tests/clar/clar.c
index ca508d073..ca508d073 100644
--- a/tests/clar.c
+++ b/tests/clar/clar.c
diff --git a/tests/clar.h b/tests/clar/clar.h
index 3f659c2f6..3f659c2f6 100644
--- a/tests/clar.h
+++ b/tests/clar/clar.h
diff --git a/tests/clar/fixtures.h b/tests/clar/clar/fixtures.h
index 77033d365..77033d365 100644
--- a/tests/clar/fixtures.h
+++ b/tests/clar/clar/fixtures.h
diff --git a/tests/clar/fs.h b/tests/clar/clar/fs.h
index 44ede4572..44ede4572 100644
--- a/tests/clar/fs.h
+++ b/tests/clar/clar/fs.h
diff --git a/tests/clar/print.h b/tests/clar/clar/print.h
index dbfd27655..dbfd27655 100644
--- a/tests/clar/print.h
+++ b/tests/clar/clar/print.h
diff --git a/tests/clar/sandbox.h b/tests/clar/clar/sandbox.h
index 0ba147962..0ba147962 100644
--- a/tests/clar/sandbox.h
+++ b/tests/clar/clar/sandbox.h
diff --git a/tests/clar/summary.h b/tests/clar/clar/summary.h
index 6279f5057..6279f5057 100644
--- a/tests/clar/summary.h
+++ b/tests/clar/clar/summary.h
diff --git a/tests/clar_libgit2.c b/tests/clar/clar_libgit2.c
index 55a09d111..55a09d111 100644
--- a/tests/clar_libgit2.c
+++ b/tests/clar/clar_libgit2.c
diff --git a/tests/clar_libgit2.h b/tests/clar/clar_libgit2.h
index e3b7bd9f8..e3b7bd9f8 100644
--- a/tests/clar_libgit2.h
+++ b/tests/clar/clar_libgit2.h
diff --git a/tests/clar_libgit2_timer.c b/tests/clar/clar_libgit2_timer.c
index 2330f9351..2330f9351 100644
--- a/tests/clar_libgit2_timer.c
+++ b/tests/clar/clar_libgit2_timer.c
diff --git a/tests/clar_libgit2_timer.h b/tests/clar/clar_libgit2_timer.h
index 7571a52e9..7571a52e9 100644
--- a/tests/clar_libgit2_timer.h
+++ b/tests/clar/clar_libgit2_timer.h
diff --git a/tests/clar_libgit2_trace.c b/tests/clar/clar_libgit2_trace.c
index ebb0f41dd..ebb0f41dd 100644
--- a/tests/clar_libgit2_trace.c
+++ b/tests/clar/clar_libgit2_trace.c
diff --git a/tests/clar_libgit2_trace.h b/tests/clar/clar_libgit2_trace.h
index 09d1e050f..09d1e050f 100644
--- a/tests/clar_libgit2_trace.h
+++ b/tests/clar/clar_libgit2_trace.h
diff --git a/tests/generate.py b/tests/clar/generate.py
index d2cdb684a..d2cdb684a 100644
--- a/tests/generate.py
+++ b/tests/clar/generate.py
diff --git a/tests/main.c b/tests/clar/main.c
index 56751c288..56751c288 100644
--- a/tests/main.c
+++ b/tests/clar/main.c
diff --git a/tests/headertest/CMakeLists.txt b/tests/headertest/CMakeLists.txt
new file mode 100644
index 000000000..c70ce1ae1
--- /dev/null
+++ b/tests/headertest/CMakeLists.txt
@@ -0,0 +1,14 @@
+# Header file validation project: ensure that we do not publish any sloppy
+# definitions in our headers and that a consumer can include <git2.dll>
+# even when they have aggressive C90 warnings enabled.
+
+add_executable(headertest headertest.c)
+set_target_properties(headertest PROPERTIES C_STANDARD 90)
+set_target_properties(headertest PROPERTIES C_EXTENSIONS OFF)
+target_include_directories(headertest PRIVATE ${LIBGIT2_INCLUDES})
+
+if (MSVC)
+ target_compile_options(headertest PUBLIC /W4 /WX)
+else()
+ target_compile_options(headertest PUBLIC -Wall -Wextra -pedantic -Werror)
+endif()
diff --git a/tests/headertest.c b/tests/headertest/headertest.c
index 2af8a14ec..2af8a14ec 100644
--- a/tests/headertest.c
+++ b/tests/headertest/headertest.c
diff --git a/tests/libgit2/CMakeLists.txt b/tests/libgit2/CMakeLists.txt
new file mode 100644
index 000000000..27f421ad6
--- /dev/null
+++ b/tests/libgit2/CMakeLists.txt
@@ -0,0 +1,75 @@
+# tests: the unit and integration tests for libgit2
+
+set(Python_ADDITIONAL_VERSIONS 3 2.7)
+find_package(PythonInterp)
+
+if(NOT PYTHONINTERP_FOUND)
+ message(FATAL_ERROR "Could not find a python interpreter, which is needed to build the tests. "
+ "Make sure python is available, or pass -DBUILD_TESTS=OFF to skip building the tests")
+ENDIF()
+
+set(CLAR_PATH "${PROJECT_SOURCE_DIR}/tests/clar")
+set(CLAR_FIXTURES "${PROJECT_SOURCE_DIR}/tests/resources/")
+set(TEST_PATH "${CMAKE_CURRENT_SOURCE_DIR}")
+add_definitions(-DCLAR_FIXTURE_PATH=\"${CLAR_FIXTURES}\")
+add_definitions(-DCLAR_TMPDIR=\"libgit2_tests\")
+add_definitions(-DCLAR_WIN32_LONGPATHS)
+add_definitions(-D_FILE_OFFSET_BITS=64)
+
+# Ensure that we do not use deprecated functions internally
+add_definitions(-DGIT_DEPRECATE_HARD)
+
+set(TEST_INCLUDES "${CLAR_PATH}" "${TEST_PATH}" "${CMAKE_CURRENT_BINARY_DIR}")
+file(GLOB_RECURSE SRC_TEST ${TEST_PATH}/*/*.c ${TEST_PATH}/*/*.h)
+file(GLOB_RECURSE SRC_CLAR ${CLAR_PATH}/*.c ${CLAR_PATH}/*.h)
+
+if(MSVC_IDE)
+ list(APPEND SRC_TEST "precompiled.c")
+endif()
+
+add_custom_command(
+ OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/clar.suite ${CMAKE_CURRENT_BINARY_DIR}/clar_suite.h
+ COMMAND ${PYTHON_EXECUTABLE} ${CLAR_PATH}/generate.py -o "${CMAKE_CURRENT_BINARY_DIR}" -f -xonline -xstress -xperf .
+ DEPENDS ${SRC_TEST}
+ WORKING_DIRECTORY ${TEST_PATH}
+)
+
+set_source_files_properties(
+ ${CLAR_PATH}/clar.c
+ PROPERTIES OBJECT_DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/clar.suite)
+
+add_executable(libgit2_tests ${SRC_CLAR} ${SRC_TEST} ${LIBGIT2_OBJECTS})
+
+set_target_properties(libgit2_tests PROPERTIES C_STANDARD 90)
+set_target_properties(libgit2_tests PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR})
+
+target_include_directories(libgit2_tests PRIVATE ${TEST_INCLUDES} ${LIBGIT2_INCLUDES} ${LIBGIT2_DEPENDENCY_INCLUDES})
+target_include_directories(libgit2_tests SYSTEM PRIVATE ${LIBGIT2_SYSTEM_INCLUDES})
+target_link_libraries(libgit2_tests ${LIBGIT2_SYSTEM_LIBS})
+
+ide_split_sources(libgit2_tests)
+
+#
+# Old versions of gcc require us to declare our test functions; don't do
+# this on newer compilers to avoid unnecessary recompilation.
+#
+if(CMAKE_COMPILER_IS_GNUCC AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 6.0)
+ target_compile_options(libgit2_tests PRIVATE -include "clar_suite.h")
+endif()
+
+if(MSVC_IDE)
+ # Precompiled headers
+ set_target_properties(libgit2_tests PROPERTIES COMPILE_FLAGS "/Yuprecompiled.h /FIprecompiled.h")
+ set_source_files_properties("precompiled.c" COMPILE_FLAGS "/Ycprecompiled.h")
+endif()
+
+include(AddClarTest)
+add_clar_test(libgit2_tests offline -v -xonline)
+add_clar_test(libgit2_tests invasive -v -score::ftruncate -sfilter::stream::bigfile -sodb::largefiles -siterator::workdir::filesystem_gunk -srepo::init -srepo::init::at_filesystem_root)
+add_clar_test(libgit2_tests online -v -sonline -xonline::customcert)
+add_clar_test(libgit2_tests online_customcert -v -sonline::customcert)
+add_clar_test(libgit2_tests gitdaemon -v -sonline::push)
+add_clar_test(libgit2_tests ssh -v -sonline::push -sonline::clone::ssh_cert -sonline::clone::ssh_with_paths -sonline::clone::path_whitespace_ssh)
+add_clar_test(libgit2_tests proxy -v -sonline::clone::proxy)
+add_clar_test(libgit2_tests auth_clone -v -sonline::clone::cred)
+add_clar_test(libgit2_tests auth_clone_and_push -v -sonline::clone::push -sonline::push)
diff --git a/tests/apply/apply_helpers.c b/tests/libgit2/apply/apply_helpers.c
index 91cc51a71..91cc51a71 100644
--- a/tests/apply/apply_helpers.c
+++ b/tests/libgit2/apply/apply_helpers.c
diff --git a/tests/apply/apply_helpers.h b/tests/libgit2/apply/apply_helpers.h
index 82094773e..82094773e 100644
--- a/tests/apply/apply_helpers.h
+++ b/tests/libgit2/apply/apply_helpers.h
diff --git a/tests/apply/both.c b/tests/libgit2/apply/both.c
index 108963270..108963270 100644
--- a/tests/apply/both.c
+++ b/tests/libgit2/apply/both.c
diff --git a/tests/apply/callbacks.c b/tests/libgit2/apply/callbacks.c
index 1b759dc9b..1b759dc9b 100644
--- a/tests/apply/callbacks.c
+++ b/tests/libgit2/apply/callbacks.c
diff --git a/tests/apply/check.c b/tests/libgit2/apply/check.c
index 9e42365ed..9e42365ed 100644
--- a/tests/apply/check.c
+++ b/tests/libgit2/apply/check.c
diff --git a/tests/apply/fromdiff.c b/tests/libgit2/apply/fromdiff.c
index 9da6ac923..9da6ac923 100644
--- a/tests/apply/fromdiff.c
+++ b/tests/libgit2/apply/fromdiff.c
diff --git a/tests/apply/fromfile.c b/tests/libgit2/apply/fromfile.c
index 8cde62392..8cde62392 100644
--- a/tests/apply/fromfile.c
+++ b/tests/libgit2/apply/fromfile.c
diff --git a/tests/apply/index.c b/tests/libgit2/apply/index.c
index 9c9094cce..9c9094cce 100644
--- a/tests/apply/index.c
+++ b/tests/libgit2/apply/index.c
diff --git a/tests/apply/partial.c b/tests/libgit2/apply/partial.c
index fd4908d4b..fd4908d4b 100644
--- a/tests/apply/partial.c
+++ b/tests/libgit2/apply/partial.c
diff --git a/tests/apply/tree.c b/tests/libgit2/apply/tree.c
index 5154f134f..5154f134f 100644
--- a/tests/apply/tree.c
+++ b/tests/libgit2/apply/tree.c
diff --git a/tests/apply/workdir.c b/tests/libgit2/apply/workdir.c
index d0d9c1aba..d0d9c1aba 100644
--- a/tests/apply/workdir.c
+++ b/tests/libgit2/apply/workdir.c
diff --git a/tests/attr/attr_expect.h b/tests/libgit2/attr/attr_expect.h
index faf7a1181..faf7a1181 100644
--- a/tests/attr/attr_expect.h
+++ b/tests/libgit2/attr/attr_expect.h
diff --git a/tests/attr/file.c b/tests/libgit2/attr/file.c
index 1ac48c0fe..1ac48c0fe 100644
--- a/tests/attr/file.c
+++ b/tests/libgit2/attr/file.c
diff --git a/tests/attr/flags.c b/tests/libgit2/attr/flags.c
index 6470ec732..6470ec732 100644
--- a/tests/attr/flags.c
+++ b/tests/libgit2/attr/flags.c
diff --git a/tests/attr/lookup.c b/tests/libgit2/attr/lookup.c
index f19f38fbb..f19f38fbb 100644
--- a/tests/attr/lookup.c
+++ b/tests/libgit2/attr/lookup.c
diff --git a/tests/attr/macro.c b/tests/libgit2/attr/macro.c
index 1fbfd137f..1fbfd137f 100644
--- a/tests/attr/macro.c
+++ b/tests/libgit2/attr/macro.c
diff --git a/tests/attr/repo.c b/tests/libgit2/attr/repo.c
index abd238154..abd238154 100644
--- a/tests/attr/repo.c
+++ b/tests/libgit2/attr/repo.c
diff --git a/tests/blame/blame_helpers.c b/tests/libgit2/blame/blame_helpers.c
index 6b3ce677d..6b3ce677d 100644
--- a/tests/blame/blame_helpers.c
+++ b/tests/libgit2/blame/blame_helpers.c
diff --git a/tests/blame/blame_helpers.h b/tests/libgit2/blame/blame_helpers.h
index 5b34b4aef..5b34b4aef 100644
--- a/tests/blame/blame_helpers.h
+++ b/tests/libgit2/blame/blame_helpers.h
diff --git a/tests/blame/buffer.c b/tests/libgit2/blame/buffer.c
index 06d5042dd..06d5042dd 100644
--- a/tests/blame/buffer.c
+++ b/tests/libgit2/blame/buffer.c
diff --git a/tests/blame/getters.c b/tests/libgit2/blame/getters.c
index 66eaeecf9..66eaeecf9 100644
--- a/tests/blame/getters.c
+++ b/tests/libgit2/blame/getters.c
diff --git a/tests/blame/harder.c b/tests/libgit2/blame/harder.c
index e77741720..e77741720 100644
--- a/tests/blame/harder.c
+++ b/tests/libgit2/blame/harder.c
diff --git a/tests/blame/simple.c b/tests/libgit2/blame/simple.c
index 6b13cccd4..6b13cccd4 100644
--- a/tests/blame/simple.c
+++ b/tests/libgit2/blame/simple.c
diff --git a/tests/checkout/binaryunicode.c b/tests/libgit2/checkout/binaryunicode.c
index edb5cfaf5..edb5cfaf5 100644
--- a/tests/checkout/binaryunicode.c
+++ b/tests/libgit2/checkout/binaryunicode.c
diff --git a/tests/checkout/checkout_helpers.c b/tests/libgit2/checkout/checkout_helpers.c
index 1e9c21bdc..1e9c21bdc 100644
--- a/tests/checkout/checkout_helpers.c
+++ b/tests/libgit2/checkout/checkout_helpers.c
diff --git a/tests/checkout/checkout_helpers.h b/tests/libgit2/checkout/checkout_helpers.h
index 879b48b06..879b48b06 100644
--- a/tests/checkout/checkout_helpers.h
+++ b/tests/libgit2/checkout/checkout_helpers.h
diff --git a/tests/checkout/conflict.c b/tests/libgit2/checkout/conflict.c
index 4a9e4b9fa..4a9e4b9fa 100644
--- a/tests/checkout/conflict.c
+++ b/tests/libgit2/checkout/conflict.c
diff --git a/tests/checkout/crlf.c b/tests/libgit2/checkout/crlf.c
index 21f8a852a..21f8a852a 100644
--- a/tests/checkout/crlf.c
+++ b/tests/libgit2/checkout/crlf.c
diff --git a/tests/checkout/head.c b/tests/libgit2/checkout/head.c
index 3b0bf4729..3b0bf4729 100644
--- a/tests/checkout/head.c
+++ b/tests/libgit2/checkout/head.c
diff --git a/tests/checkout/icase.c b/tests/libgit2/checkout/icase.c
index d77c7abd5..d77c7abd5 100644
--- a/tests/checkout/icase.c
+++ b/tests/libgit2/checkout/icase.c
diff --git a/tests/checkout/index.c b/tests/libgit2/checkout/index.c
index 6a80d22c5..6a80d22c5 100644
--- a/tests/checkout/index.c
+++ b/tests/libgit2/checkout/index.c
diff --git a/tests/checkout/nasty.c b/tests/libgit2/checkout/nasty.c
index 732f1d5e8..732f1d5e8 100644
--- a/tests/checkout/nasty.c
+++ b/tests/libgit2/checkout/nasty.c
diff --git a/tests/checkout/tree.c b/tests/libgit2/checkout/tree.c
index d4b57f5d1..d4b57f5d1 100644
--- a/tests/checkout/tree.c
+++ b/tests/libgit2/checkout/tree.c
diff --git a/tests/checkout/typechange.c b/tests/libgit2/checkout/typechange.c
index b888843f0..b888843f0 100644
--- a/tests/checkout/typechange.c
+++ b/tests/libgit2/checkout/typechange.c
diff --git a/tests/cherrypick/bare.c b/tests/libgit2/cherrypick/bare.c
index f90ce0226..f90ce0226 100644
--- a/tests/cherrypick/bare.c
+++ b/tests/libgit2/cherrypick/bare.c
diff --git a/tests/cherrypick/workdir.c b/tests/libgit2/cherrypick/workdir.c
index 8fd1ecbdf..8fd1ecbdf 100644
--- a/tests/cherrypick/workdir.c
+++ b/tests/libgit2/cherrypick/workdir.c
diff --git a/tests/clone/empty.c b/tests/libgit2/clone/empty.c
index 94847bc73..94847bc73 100644
--- a/tests/clone/empty.c
+++ b/tests/libgit2/clone/empty.c
diff --git a/tests/clone/local.c b/tests/libgit2/clone/local.c
index e0bd74df7..e0bd74df7 100644
--- a/tests/clone/local.c
+++ b/tests/libgit2/clone/local.c
diff --git a/tests/clone/nonetwork.c b/tests/libgit2/clone/nonetwork.c
index eab633635..eab633635 100644
--- a/tests/clone/nonetwork.c
+++ b/tests/libgit2/clone/nonetwork.c
diff --git a/tests/clone/transport.c b/tests/libgit2/clone/transport.c
index fa4f65357..fa4f65357 100644
--- a/tests/clone/transport.c
+++ b/tests/libgit2/clone/transport.c
diff --git a/tests/commit/commit.c b/tests/libgit2/commit/commit.c
index fd574f7f2..fd574f7f2 100644
--- a/tests/commit/commit.c
+++ b/tests/libgit2/commit/commit.c
diff --git a/tests/commit/parent.c b/tests/libgit2/commit/parent.c
index 18ce0bba6..18ce0bba6 100644
--- a/tests/commit/parent.c
+++ b/tests/libgit2/commit/parent.c
diff --git a/tests/commit/parse.c b/tests/libgit2/commit/parse.c
index 04366d7d2..04366d7d2 100644
--- a/tests/commit/parse.c
+++ b/tests/libgit2/commit/parse.c
diff --git a/tests/commit/signature.c b/tests/libgit2/commit/signature.c
index a91551415..a91551415 100644
--- a/tests/commit/signature.c
+++ b/tests/libgit2/commit/signature.c
diff --git a/tests/commit/write.c b/tests/libgit2/commit/write.c
index 5a9c9d5a5..5a9c9d5a5 100644
--- a/tests/commit/write.c
+++ b/tests/libgit2/commit/write.c
diff --git a/tests/config/add.c b/tests/libgit2/config/add.c
index 405f1e2c9..405f1e2c9 100644
--- a/tests/config/add.c
+++ b/tests/libgit2/config/add.c
diff --git a/tests/config/backend.c b/tests/libgit2/config/backend.c
index 96feecc4a..96feecc4a 100644
--- a/tests/config/backend.c
+++ b/tests/libgit2/config/backend.c
diff --git a/tests/config/conditionals.c b/tests/libgit2/config/conditionals.c
index 564719dcb..564719dcb 100644
--- a/tests/config/conditionals.c
+++ b/tests/libgit2/config/conditionals.c
diff --git a/tests/config/config_helpers.c b/tests/libgit2/config/config_helpers.c
index ecdab5bf6..ecdab5bf6 100644
--- a/tests/config/config_helpers.c
+++ b/tests/libgit2/config/config_helpers.c
diff --git a/tests/config/config_helpers.h b/tests/libgit2/config/config_helpers.h
index 440645730..440645730 100644
--- a/tests/config/config_helpers.h
+++ b/tests/libgit2/config/config_helpers.h
diff --git a/tests/config/configlevel.c b/tests/libgit2/config/configlevel.c
index 8422d32c9..8422d32c9 100644
--- a/tests/config/configlevel.c
+++ b/tests/libgit2/config/configlevel.c
diff --git a/tests/config/global.c b/tests/libgit2/config/global.c
index 5aba4eec6..5aba4eec6 100644
--- a/tests/config/global.c
+++ b/tests/libgit2/config/global.c
diff --git a/tests/config/include.c b/tests/libgit2/config/include.c
index 9328f3cf6..9328f3cf6 100644
--- a/tests/config/include.c
+++ b/tests/libgit2/config/include.c
diff --git a/tests/config/memory.c b/tests/libgit2/config/memory.c
index ae661899d..ae661899d 100644
--- a/tests/config/memory.c
+++ b/tests/libgit2/config/memory.c
diff --git a/tests/config/multivar.c b/tests/libgit2/config/multivar.c
index 244e37559..244e37559 100644
--- a/tests/config/multivar.c
+++ b/tests/libgit2/config/multivar.c
diff --git a/tests/config/new.c b/tests/libgit2/config/new.c
index baca05332..baca05332 100644
--- a/tests/config/new.c
+++ b/tests/libgit2/config/new.c
diff --git a/tests/config/read.c b/tests/libgit2/config/read.c
index a2e668c20..a2e668c20 100644
--- a/tests/config/read.c
+++ b/tests/libgit2/config/read.c
diff --git a/tests/config/readonly.c b/tests/libgit2/config/readonly.c
index a8901e394..a8901e394 100644
--- a/tests/config/readonly.c
+++ b/tests/libgit2/config/readonly.c
diff --git a/tests/config/rename.c b/tests/libgit2/config/rename.c
index be620c307..be620c307 100644
--- a/tests/config/rename.c
+++ b/tests/libgit2/config/rename.c
diff --git a/tests/config/snapshot.c b/tests/libgit2/config/snapshot.c
index 5cc08a721..5cc08a721 100644
--- a/tests/config/snapshot.c
+++ b/tests/libgit2/config/snapshot.c
diff --git a/tests/config/stress.c b/tests/libgit2/config/stress.c
index 69e6810fa..69e6810fa 100644
--- a/tests/config/stress.c
+++ b/tests/libgit2/config/stress.c
diff --git a/tests/config/validkeyname.c b/tests/libgit2/config/validkeyname.c
index 4b36509af..4b36509af 100644
--- a/tests/config/validkeyname.c
+++ b/tests/libgit2/config/validkeyname.c
diff --git a/tests/config/write.c b/tests/libgit2/config/write.c
index 9d8c3fe94..9d8c3fe94 100644
--- a/tests/config/write.c
+++ b/tests/libgit2/config/write.c
diff --git a/tests/core/buf.c b/tests/libgit2/core/buf.c
index 3959fa883..3959fa883 100644
--- a/tests/core/buf.c
+++ b/tests/libgit2/core/buf.c
diff --git a/tests/core/env.c b/tests/libgit2/core/env.c
index 8ba9b9124..8ba9b9124 100644
--- a/tests/core/env.c
+++ b/tests/libgit2/core/env.c
diff --git a/tests/core/features.c b/tests/libgit2/core/features.c
index 7b28cc0cb..7b28cc0cb 100644
--- a/tests/core/features.c
+++ b/tests/libgit2/core/features.c
diff --git a/tests/libgit2/core/hashsig.c b/tests/libgit2/core/hashsig.c
new file mode 100644
index 000000000..6cadb1c1a
--- /dev/null
+++ b/tests/libgit2/core/hashsig.c
@@ -0,0 +1,182 @@
+#include "clar_libgit2.h"
+#include "git2/sys/hashsig.h"
+#include "futils.h"
+
+#define SIMILARITY_TEST_DATA_1 \
+ "000\n001\n002\n003\n004\n005\n006\n007\n008\n009\n" \
+ "010\n011\n012\n013\n014\n015\n016\n017\n018\n019\n" \
+ "020\n021\n022\n023\n024\n025\n026\n027\n028\n029\n" \
+ "030\n031\n032\n033\n034\n035\n036\n037\n038\n039\n" \
+ "040\n041\n042\n043\n044\n045\n046\n047\n048\n049\n"
+
+void test_core_hashsig__similarity_metric(void)
+{
+ git_hashsig *a, *b;
+ git_str buf = GIT_STR_INIT;
+ int sim;
+
+ /* in the first case, we compare data to itself and expect 100% match */
+
+ cl_git_pass(git_str_sets(&buf, SIMILARITY_TEST_DATA_1));
+ cl_git_pass(git_hashsig_create(&a, buf.ptr, buf.size, GIT_HASHSIG_NORMAL));
+ cl_git_pass(git_hashsig_create(&b, buf.ptr, buf.size, GIT_HASHSIG_NORMAL));
+
+ cl_assert_equal_i(100, git_hashsig_compare(a, b));
+
+ git_hashsig_free(a);
+ git_hashsig_free(b);
+
+ /* if we change just a single byte, how much does that change magnify? */
+
+ cl_git_pass(git_str_sets(&buf, SIMILARITY_TEST_DATA_1));
+ cl_git_pass(git_hashsig_create(&a, buf.ptr, buf.size, GIT_HASHSIG_NORMAL));
+ cl_git_pass(git_str_sets(&buf,
+ "000\n001\n002\n003\n004\n005\n006\n007\n008\n009\n" \
+ "010\n011\n012\n013\n014\n015\n016\n017\n018\n019\n" \
+ "x020x\n021\n022\n023\n024\n025\n026\n027\n028\n029\n" \
+ "030\n031\n032\n033\n034\n035\n036\n037\n038\n039\n" \
+ "040\n041\n042\n043\n044\n045\n046\n047\n048\n049\n"
+ ));
+ cl_git_pass(git_hashsig_create(&b, buf.ptr, buf.size, GIT_HASHSIG_NORMAL));
+
+ sim = git_hashsig_compare(a, b);
+
+ cl_assert_in_range(95, sim, 100); /* expect >95% similarity */
+
+ git_hashsig_free(a);
+ git_hashsig_free(b);
+
+ /* let's try comparing data to a superset of itself */
+
+ cl_git_pass(git_str_sets(&buf, SIMILARITY_TEST_DATA_1));
+ cl_git_pass(git_hashsig_create(&a, buf.ptr, buf.size, GIT_HASHSIG_NORMAL));
+ cl_git_pass(git_str_sets(&buf, SIMILARITY_TEST_DATA_1
+ "050\n051\n052\n053\n054\n055\n056\n057\n058\n059\n"));
+ cl_git_pass(git_hashsig_create(&b, buf.ptr, buf.size, GIT_HASHSIG_NORMAL));
+
+ sim = git_hashsig_compare(a, b);
+ /* 20% lines added ~= 10% lines changed */
+
+ cl_assert_in_range(85, sim, 95); /* expect similarity around 90% */
+
+ git_hashsig_free(a);
+ git_hashsig_free(b);
+
+ /* what if we keep about half the original data and add half new */
+
+ cl_git_pass(git_str_sets(&buf, SIMILARITY_TEST_DATA_1));
+ cl_git_pass(git_hashsig_create(&a, buf.ptr, buf.size, GIT_HASHSIG_NORMAL));
+ cl_git_pass(git_str_sets(&buf,
+ "000\n001\n002\n003\n004\n005\n006\n007\n008\n009\n" \
+ "010\n011\n012\n013\n014\n015\n016\n017\n018\n019\n" \
+ "020x\n021\n022\n023\n024\n" \
+ "x25\nx26\nx27\nx28\nx29\n" \
+ "x30\nx31\nx32\nx33\nx34\nx35\nx36\nx37\nx38\nx39\n" \
+ "x40\nx41\nx42\nx43\nx44\nx45\nx46\nx47\nx48\nx49\n"
+ ));
+ cl_git_pass(git_hashsig_create(&b, buf.ptr, buf.size, GIT_HASHSIG_NORMAL));
+
+ sim = git_hashsig_compare(a, b);
+ /* 50% lines changed */
+
+ cl_assert_in_range(40, sim, 60); /* expect in the 40-60% similarity range */
+
+ git_hashsig_free(a);
+ git_hashsig_free(b);
+
+ /* lastly, let's check that we can hash file content as well */
+
+ cl_git_pass(git_str_sets(&buf, SIMILARITY_TEST_DATA_1));
+ cl_git_pass(git_hashsig_create(&a, buf.ptr, buf.size, GIT_HASHSIG_NORMAL));
+
+ cl_git_pass(git_futils_mkdir("scratch", 0755, GIT_MKDIR_PATH));
+ cl_git_mkfile("scratch/testdata", SIMILARITY_TEST_DATA_1);
+ cl_git_pass(git_hashsig_create_fromfile(
+ &b, "scratch/testdata", GIT_HASHSIG_NORMAL));
+
+ cl_assert_equal_i(100, git_hashsig_compare(a, b));
+
+ git_hashsig_free(a);
+ git_hashsig_free(b);
+
+ git_str_dispose(&buf);
+ git_futils_rmdir_r("scratch", NULL, GIT_RMDIR_REMOVE_FILES);
+}
+
+void test_core_hashsig__similarity_metric_whitespace(void)
+{
+ git_hashsig *a, *b;
+ git_str buf = GIT_STR_INIT;
+ int sim, i, j;
+ git_hashsig_option_t opt;
+ const char *tabbed =
+ " for (s = 0; s < sizeof(sep) / sizeof(char); ++s) {\n"
+ " separator = sep[s];\n"
+ " expect = expect_values[s];\n"
+ "\n"
+ " for (j = 0; j < sizeof(b) / sizeof(char*); ++j) {\n"
+ " for (i = 0; i < sizeof(a) / sizeof(char*); ++i) {\n"
+ " git_str_join(&buf, separator, a[i], b[j]);\n"
+ " cl_assert_equal_s(*expect, buf.ptr);\n"
+ " expect++;\n"
+ " }\n"
+ " }\n"
+ " }\n";
+ const char *spaced =
+ " for (s = 0; s < sizeof(sep) / sizeof(char); ++s) {\n"
+ " separator = sep[s];\n"
+ " expect = expect_values[s];\n"
+ "\n"
+ " for (j = 0; j < sizeof(b) / sizeof(char*); ++j) {\n"
+ " for (i = 0; i < sizeof(a) / sizeof(char*); ++i) {\n"
+ " git_str_join(&buf, separator, a[i], b[j]);\n"
+ " cl_assert_equal_s(*expect, buf.ptr);\n"
+ " expect++;\n"
+ " }\n"
+ " }\n"
+ " }\n";
+ const char *crlf_spaced2 =
+ " for (s = 0; s < sizeof(sep) / sizeof(char); ++s) {\r\n"
+ " separator = sep[s];\r\n"
+ " expect = expect_values[s];\r\n"
+ "\r\n"
+ " for (j = 0; j < sizeof(b) / sizeof(char*); ++j) {\r\n"
+ " for (i = 0; i < sizeof(a) / sizeof(char*); ++i) {\r\n"
+ " git_str_join(&buf, separator, a[i], b[j]);\r\n"
+ " cl_assert_equal_s(*expect, buf.ptr);\r\n"
+ " expect++;\r\n"
+ " }\r\n"
+ " }\r\n"
+ " }\r\n";
+ const char *text[3] = { tabbed, spaced, crlf_spaced2 };
+
+ /* let's try variations of our own code with whitespace changes */
+
+ for (opt = GIT_HASHSIG_NORMAL; opt <= GIT_HASHSIG_SMART_WHITESPACE; ++opt) {
+ for (i = 0; i < 3; ++i) {
+ for (j = 0; j < 3; ++j) {
+ cl_git_pass(git_str_sets(&buf, text[i]));
+ cl_git_pass(git_hashsig_create(&a, buf.ptr, buf.size, opt));
+
+ cl_git_pass(git_str_sets(&buf, text[j]));
+ cl_git_pass(git_hashsig_create(&b, buf.ptr, buf.size, opt));
+
+ sim = git_hashsig_compare(a, b);
+
+ if (opt == GIT_HASHSIG_NORMAL) {
+ if (i == j)
+ cl_assert_equal_i(100, sim);
+ else
+ cl_assert_in_range(0, sim, 30); /* pretty different */
+ } else {
+ cl_assert_equal_i(100, sim);
+ }
+
+ git_hashsig_free(a);
+ git_hashsig_free(b);
+ }
+ }
+ }
+
+ git_str_dispose(&buf);
+}
diff --git a/tests/core/oid.c b/tests/libgit2/core/oid.c
index 894feadf6..894feadf6 100644
--- a/tests/core/oid.c
+++ b/tests/libgit2/core/oid.c
diff --git a/tests/core/oidmap.c b/tests/libgit2/core/oidmap.c
index 7f98287a6..7f98287a6 100644
--- a/tests/core/oidmap.c
+++ b/tests/libgit2/core/oidmap.c
diff --git a/tests/core/opts.c b/tests/libgit2/core/opts.c
index e8f65d510..e8f65d510 100644
--- a/tests/core/opts.c
+++ b/tests/libgit2/core/opts.c
diff --git a/tests/libgit2/core/pool.c b/tests/libgit2/core/pool.c
new file mode 100644
index 000000000..5746e35b8
--- /dev/null
+++ b/tests/libgit2/core/pool.c
@@ -0,0 +1,33 @@
+#include "clar_libgit2.h"
+#include "pool.h"
+#include "git2/oid.h"
+
+static char to_hex[] = "0123456789abcdef";
+
+void test_core_pool__oid(void)
+{
+ git_pool p;
+ char oid_hex[GIT_OID_HEXSZ];
+ git_oid *oid;
+ int i, j;
+
+ memset(oid_hex, '0', sizeof(oid_hex));
+
+ git_pool_init(&p, sizeof(git_oid));
+ p.page_size = 4000;
+
+ for (i = 1000; i < 10000; i++) {
+ oid = git_pool_malloc(&p, 1);
+ cl_assert(oid != NULL);
+
+ for (j = 0; j < 8; j++)
+ oid_hex[j] = to_hex[(i >> (4 * j)) & 0x0f];
+ cl_git_pass(git_oid_fromstr(oid, oid_hex));
+ }
+
+#ifndef GIT_DEBUG_POOL
+ /* with fixed page size, allocation must end up with these values */
+ cl_assert_equal_i(sizeof(void *) == 8 ? 55 : 45, git_pool__open_pages(&p));
+#endif
+ git_pool_clear(&p);
+}
diff --git a/tests/core/structinit.c b/tests/libgit2/core/structinit.c
index 160e2f612..160e2f612 100644
--- a/tests/core/structinit.c
+++ b/tests/libgit2/core/structinit.c
diff --git a/tests/core/useragent.c b/tests/libgit2/core/useragent.c
index a4ece902f..a4ece902f 100644
--- a/tests/core/useragent.c
+++ b/tests/libgit2/core/useragent.c
diff --git a/tests/date/date.c b/tests/libgit2/date/date.c
index 82b5c6728..82b5c6728 100644
--- a/tests/date/date.c
+++ b/tests/libgit2/date/date.c
diff --git a/tests/date/rfc2822.c b/tests/libgit2/date/rfc2822.c
index b0bbcfce5..b0bbcfce5 100644
--- a/tests/date/rfc2822.c
+++ b/tests/libgit2/date/rfc2822.c
diff --git a/tests/delta/apply.c b/tests/libgit2/delta/apply.c
index 5bb95a283..5bb95a283 100644
--- a/tests/delta/apply.c
+++ b/tests/libgit2/delta/apply.c
diff --git a/tests/describe/describe.c b/tests/libgit2/describe/describe.c
index ba67ca46b..ba67ca46b 100644
--- a/tests/describe/describe.c
+++ b/tests/libgit2/describe/describe.c
diff --git a/tests/describe/describe_helpers.c b/tests/libgit2/describe/describe_helpers.c
index 3df3b7c59..3df3b7c59 100644
--- a/tests/describe/describe_helpers.c
+++ b/tests/libgit2/describe/describe_helpers.c
diff --git a/tests/describe/describe_helpers.h b/tests/libgit2/describe/describe_helpers.h
index 43e8c5e19..43e8c5e19 100644
--- a/tests/describe/describe_helpers.h
+++ b/tests/libgit2/describe/describe_helpers.h
diff --git a/tests/describe/t6120.c b/tests/libgit2/describe/t6120.c
index 5ec176b87..5ec176b87 100644
--- a/tests/describe/t6120.c
+++ b/tests/libgit2/describe/t6120.c
diff --git a/tests/diff/binary.c b/tests/libgit2/diff/binary.c
index 4e71f39c6..4e71f39c6 100644
--- a/tests/diff/binary.c
+++ b/tests/libgit2/diff/binary.c
diff --git a/tests/diff/blob.c b/tests/libgit2/diff/blob.c
index d2f42207d..d2f42207d 100644
--- a/tests/diff/blob.c
+++ b/tests/libgit2/diff/blob.c
diff --git a/tests/diff/diff_helpers.c b/tests/libgit2/diff/diff_helpers.c
index e9900339f..e9900339f 100644
--- a/tests/diff/diff_helpers.c
+++ b/tests/libgit2/diff/diff_helpers.c
diff --git a/tests/diff/diff_helpers.h b/tests/libgit2/diff/diff_helpers.h
index af855ce68..af855ce68 100644
--- a/tests/diff/diff_helpers.h
+++ b/tests/libgit2/diff/diff_helpers.h
diff --git a/tests/diff/diffiter.c b/tests/libgit2/diff/diffiter.c
index 991c73bf4..991c73bf4 100644
--- a/tests/diff/diffiter.c
+++ b/tests/libgit2/diff/diffiter.c
diff --git a/tests/diff/drivers.c b/tests/libgit2/diff/drivers.c
index 304a54b56..304a54b56 100644
--- a/tests/diff/drivers.c
+++ b/tests/libgit2/diff/drivers.c
diff --git a/tests/diff/externalmodifications.c b/tests/libgit2/diff/externalmodifications.c
index df62c3316..df62c3316 100644
--- a/tests/diff/externalmodifications.c
+++ b/tests/libgit2/diff/externalmodifications.c
diff --git a/tests/diff/format_email.c b/tests/libgit2/diff/format_email.c
index 612804c42..612804c42 100644
--- a/tests/diff/format_email.c
+++ b/tests/libgit2/diff/format_email.c
diff --git a/tests/diff/index.c b/tests/libgit2/diff/index.c
index b616a372b..b616a372b 100644
--- a/tests/diff/index.c
+++ b/tests/libgit2/diff/index.c
diff --git a/tests/diff/notify.c b/tests/libgit2/diff/notify.c
index 653512795..653512795 100644
--- a/tests/diff/notify.c
+++ b/tests/libgit2/diff/notify.c
diff --git a/tests/diff/parse.c b/tests/libgit2/diff/parse.c
index d3a0c8de6..d3a0c8de6 100644
--- a/tests/diff/parse.c
+++ b/tests/libgit2/diff/parse.c
diff --git a/tests/diff/patch.c b/tests/libgit2/diff/patch.c
index 8945afc26..8945afc26 100644
--- a/tests/diff/patch.c
+++ b/tests/libgit2/diff/patch.c
diff --git a/tests/diff/patchid.c b/tests/libgit2/diff/patchid.c
index 621a720f7..621a720f7 100644
--- a/tests/diff/patchid.c
+++ b/tests/libgit2/diff/patchid.c
diff --git a/tests/diff/pathspec.c b/tests/libgit2/diff/pathspec.c
index 5761d2d2b..5761d2d2b 100644
--- a/tests/diff/pathspec.c
+++ b/tests/libgit2/diff/pathspec.c
diff --git a/tests/diff/racediffiter.c b/tests/libgit2/diff/racediffiter.c
index d364d6b21..d364d6b21 100644
--- a/tests/diff/racediffiter.c
+++ b/tests/libgit2/diff/racediffiter.c
diff --git a/tests/diff/rename.c b/tests/libgit2/diff/rename.c
index 30e9ea432..30e9ea432 100644
--- a/tests/diff/rename.c
+++ b/tests/libgit2/diff/rename.c
diff --git a/tests/diff/stats.c b/tests/libgit2/diff/stats.c
index f69dba9b3..f69dba9b3 100644
--- a/tests/diff/stats.c
+++ b/tests/libgit2/diff/stats.c
diff --git a/tests/diff/submodules.c b/tests/libgit2/diff/submodules.c
index 0436ca5c8..0436ca5c8 100644
--- a/tests/diff/submodules.c
+++ b/tests/libgit2/diff/submodules.c
diff --git a/tests/diff/tree.c b/tests/libgit2/diff/tree.c
index e03ee7b22..e03ee7b22 100644
--- a/tests/diff/tree.c
+++ b/tests/libgit2/diff/tree.c
diff --git a/tests/libgit2/diff/userdiff.c b/tests/libgit2/diff/userdiff.c
new file mode 100644
index 000000000..230494009
--- /dev/null
+++ b/tests/libgit2/diff/userdiff.c
@@ -0,0 +1,25 @@
+#include "clar_libgit2.h"
+
+#include "userdiff.h"
+
+static git_regexp regex;
+
+void test_diff_userdiff__cleanup(void)
+{
+ git_regexp_dispose(&regex);
+}
+
+void test_diff_userdiff__compile_userdiff_regexps(void)
+{
+ size_t idx;
+
+ for (idx = 0; idx < ARRAY_SIZE(builtin_defs); ++idx) {
+ git_diff_driver_definition ddef = builtin_defs[idx];
+
+ cl_git_pass(git_regexp_compile(&regex, ddef.fns, ddef.flags));
+ git_regexp_dispose(&regex);
+
+ cl_git_pass(git_regexp_compile(&regex, ddef.words, 0));
+ git_regexp_dispose(&regex);
+ }
+}
diff --git a/tests/diff/workdir.c b/tests/libgit2/diff/workdir.c
index cdf53faa1..cdf53faa1 100644
--- a/tests/diff/workdir.c
+++ b/tests/libgit2/diff/workdir.c
diff --git a/tests/email/create.c b/tests/libgit2/email/create.c
index 27a665582..27a665582 100644
--- a/tests/email/create.c
+++ b/tests/libgit2/email/create.c
diff --git a/tests/email/create.c.bak b/tests/libgit2/email/create.c.bak
index 3bb95a6f6..3bb95a6f6 100644
--- a/tests/email/create.c.bak
+++ b/tests/libgit2/email/create.c.bak
diff --git a/tests/fetch/local.c b/tests/libgit2/fetch/local.c
index 20bd7adf4..20bd7adf4 100644
--- a/tests/fetch/local.c
+++ b/tests/libgit2/fetch/local.c
diff --git a/tests/fetchhead/fetchhead_data.h b/tests/libgit2/fetchhead/fetchhead_data.h
index 77c322001..77c322001 100644
--- a/tests/fetchhead/fetchhead_data.h
+++ b/tests/libgit2/fetchhead/fetchhead_data.h
diff --git a/tests/fetchhead/nonetwork.c b/tests/libgit2/fetchhead/nonetwork.c
index aadcc7880..aadcc7880 100644
--- a/tests/fetchhead/nonetwork.c
+++ b/tests/libgit2/fetchhead/nonetwork.c
diff --git a/tests/filter/bare.c b/tests/libgit2/filter/bare.c
index 8402638ce..8402638ce 100644
--- a/tests/filter/bare.c
+++ b/tests/libgit2/filter/bare.c
diff --git a/tests/filter/blob.c b/tests/libgit2/filter/blob.c
index 1cc33d42f..1cc33d42f 100644
--- a/tests/filter/blob.c
+++ b/tests/libgit2/filter/blob.c
diff --git a/tests/filter/crlf.c b/tests/libgit2/filter/crlf.c
index 925ea58d2..925ea58d2 100644
--- a/tests/filter/crlf.c
+++ b/tests/libgit2/filter/crlf.c
diff --git a/tests/filter/crlf.h b/tests/libgit2/filter/crlf.h
index 786edfc96..786edfc96 100644
--- a/tests/filter/crlf.h
+++ b/tests/libgit2/filter/crlf.h
diff --git a/tests/filter/custom.c b/tests/libgit2/filter/custom.c
index 57cef33ce..57cef33ce 100644
--- a/tests/filter/custom.c
+++ b/tests/libgit2/filter/custom.c
diff --git a/tests/filter/custom_helpers.c b/tests/libgit2/filter/custom_helpers.c
index 95a9f978e..95a9f978e 100644
--- a/tests/filter/custom_helpers.c
+++ b/tests/libgit2/filter/custom_helpers.c
diff --git a/tests/filter/custom_helpers.h b/tests/libgit2/filter/custom_helpers.h
index 0936c581b..0936c581b 100644
--- a/tests/filter/custom_helpers.h
+++ b/tests/libgit2/filter/custom_helpers.h
diff --git a/tests/filter/file.c b/tests/libgit2/filter/file.c
index 14b33bab9..14b33bab9 100644
--- a/tests/filter/file.c
+++ b/tests/libgit2/filter/file.c
diff --git a/tests/filter/ident.c b/tests/libgit2/filter/ident.c
index ed2e4677f..ed2e4677f 100644
--- a/tests/filter/ident.c
+++ b/tests/libgit2/filter/ident.c
diff --git a/tests/filter/query.c b/tests/libgit2/filter/query.c
index 429c10443..429c10443 100644
--- a/tests/filter/query.c
+++ b/tests/libgit2/filter/query.c
diff --git a/tests/filter/stream.c b/tests/libgit2/filter/stream.c
index 0f85f9c47..0f85f9c47 100644
--- a/tests/filter/stream.c
+++ b/tests/libgit2/filter/stream.c
diff --git a/tests/filter/systemattrs.c b/tests/libgit2/filter/systemattrs.c
index b687b4b44..b687b4b44 100644
--- a/tests/filter/systemattrs.c
+++ b/tests/libgit2/filter/systemattrs.c
diff --git a/tests/filter/wildcard.c b/tests/libgit2/filter/wildcard.c
index ee61a8dba..ee61a8dba 100644
--- a/tests/filter/wildcard.c
+++ b/tests/libgit2/filter/wildcard.c
diff --git a/tests/graph/ahead_behind.c b/tests/libgit2/graph/ahead_behind.c
index 77d7768af..77d7768af 100644
--- a/tests/graph/ahead_behind.c
+++ b/tests/libgit2/graph/ahead_behind.c
diff --git a/tests/graph/commitgraph.c b/tests/libgit2/graph/commitgraph.c
index 7607c35a3..7607c35a3 100644
--- a/tests/graph/commitgraph.c
+++ b/tests/libgit2/graph/commitgraph.c
diff --git a/tests/graph/descendant_of.c b/tests/libgit2/graph/descendant_of.c
index 8e9952a09..8e9952a09 100644
--- a/tests/graph/descendant_of.c
+++ b/tests/libgit2/graph/descendant_of.c
diff --git a/tests/graph/reachable_from_any.c b/tests/libgit2/graph/reachable_from_any.c
index 9693d7d67..9693d7d67 100644
--- a/tests/graph/reachable_from_any.c
+++ b/tests/libgit2/graph/reachable_from_any.c
diff --git a/tests/ignore/path.c b/tests/libgit2/ignore/path.c
index a574d1d79..a574d1d79 100644
--- a/tests/ignore/path.c
+++ b/tests/libgit2/ignore/path.c
diff --git a/tests/ignore/status.c b/tests/libgit2/ignore/status.c
index deb717590..deb717590 100644
--- a/tests/ignore/status.c
+++ b/tests/libgit2/ignore/status.c
diff --git a/tests/index/add.c b/tests/libgit2/index/add.c
index f101ea266..f101ea266 100644
--- a/tests/index/add.c
+++ b/tests/libgit2/index/add.c
diff --git a/tests/index/addall.c b/tests/libgit2/index/addall.c
index 6f95f6386..6f95f6386 100644
--- a/tests/index/addall.c
+++ b/tests/libgit2/index/addall.c
diff --git a/tests/index/bypath.c b/tests/libgit2/index/bypath.c
index b32a0a789..b32a0a789 100644
--- a/tests/index/bypath.c
+++ b/tests/libgit2/index/bypath.c
diff --git a/tests/index/cache.c b/tests/libgit2/index/cache.c
index 56885aff7..56885aff7 100644
--- a/tests/index/cache.c
+++ b/tests/libgit2/index/cache.c
diff --git a/tests/index/collision.c b/tests/libgit2/index/collision.c
index 18d2664f0..18d2664f0 100644
--- a/tests/index/collision.c
+++ b/tests/libgit2/index/collision.c
diff --git a/tests/index/conflicts.c b/tests/libgit2/index/conflicts.c
index 41d0e219c..41d0e219c 100644
--- a/tests/index/conflicts.c
+++ b/tests/libgit2/index/conflicts.c
diff --git a/tests/index/conflicts.h b/tests/libgit2/index/conflicts.h
index 3e26e6d5b..3e26e6d5b 100644
--- a/tests/index/conflicts.h
+++ b/tests/libgit2/index/conflicts.h
diff --git a/tests/index/crlf.c b/tests/libgit2/index/crlf.c
index 7520c23a3..7520c23a3 100644
--- a/tests/index/crlf.c
+++ b/tests/libgit2/index/crlf.c
diff --git a/tests/index/filemodes.c b/tests/libgit2/index/filemodes.c
index 1ab8a9a7f..1ab8a9a7f 100644
--- a/tests/index/filemodes.c
+++ b/tests/libgit2/index/filemodes.c
diff --git a/tests/index/inmemory.c b/tests/libgit2/index/inmemory.c
index 38e91e0fd..38e91e0fd 100644
--- a/tests/index/inmemory.c
+++ b/tests/libgit2/index/inmemory.c
diff --git a/tests/index/names.c b/tests/libgit2/index/names.c
index 369318b03..369318b03 100644
--- a/tests/index/names.c
+++ b/tests/libgit2/index/names.c
diff --git a/tests/index/nsec.c b/tests/libgit2/index/nsec.c
index 3efd855a7..3efd855a7 100644
--- a/tests/index/nsec.c
+++ b/tests/libgit2/index/nsec.c
diff --git a/tests/index/racy.c b/tests/libgit2/index/racy.c
index 07b3b73d4..07b3b73d4 100644
--- a/tests/index/racy.c
+++ b/tests/libgit2/index/racy.c
diff --git a/tests/index/read_index.c b/tests/libgit2/index/read_index.c
index 836c12b0e..836c12b0e 100644
--- a/tests/index/read_index.c
+++ b/tests/libgit2/index/read_index.c
diff --git a/tests/index/read_tree.c b/tests/libgit2/index/read_tree.c
index 0e1882818..0e1882818 100644
--- a/tests/index/read_tree.c
+++ b/tests/libgit2/index/read_tree.c
diff --git a/tests/index/rename.c b/tests/libgit2/index/rename.c
index 86eaf0053..86eaf0053 100644
--- a/tests/index/rename.c
+++ b/tests/libgit2/index/rename.c
diff --git a/tests/index/reuc.c b/tests/libgit2/index/reuc.c
index 1f95c4136..1f95c4136 100644
--- a/tests/index/reuc.c
+++ b/tests/libgit2/index/reuc.c
diff --git a/tests/index/splitindex.c b/tests/libgit2/index/splitindex.c
index d32ed1022..d32ed1022 100644
--- a/tests/index/splitindex.c
+++ b/tests/libgit2/index/splitindex.c
diff --git a/tests/index/stage.c b/tests/libgit2/index/stage.c
index cdfe3a811..cdfe3a811 100644
--- a/tests/index/stage.c
+++ b/tests/libgit2/index/stage.c
diff --git a/tests/index/tests.c b/tests/libgit2/index/tests.c
index 205d12e5b..205d12e5b 100644
--- a/tests/index/tests.c
+++ b/tests/libgit2/index/tests.c
diff --git a/tests/index/version.c b/tests/libgit2/index/version.c
index b6c0b7918..b6c0b7918 100644
--- a/tests/index/version.c
+++ b/tests/libgit2/index/version.c
diff --git a/tests/iterator/index.c b/tests/libgit2/iterator/index.c
index 7218b4f75..7218b4f75 100644
--- a/tests/iterator/index.c
+++ b/tests/libgit2/iterator/index.c
diff --git a/tests/iterator/iterator_helpers.c b/tests/libgit2/iterator/iterator_helpers.c
index b210dbb0c..b210dbb0c 100644
--- a/tests/iterator/iterator_helpers.c
+++ b/tests/libgit2/iterator/iterator_helpers.c
diff --git a/tests/iterator/iterator_helpers.h b/tests/libgit2/iterator/iterator_helpers.h
index 1884b41a1..1884b41a1 100644
--- a/tests/iterator/iterator_helpers.h
+++ b/tests/libgit2/iterator/iterator_helpers.h
diff --git a/tests/iterator/tree.c b/tests/libgit2/iterator/tree.c
index 4145c8dea..4145c8dea 100644
--- a/tests/iterator/tree.c
+++ b/tests/libgit2/iterator/tree.c
diff --git a/tests/iterator/workdir.c b/tests/libgit2/iterator/workdir.c
index 86b847cab..86b847cab 100644
--- a/tests/iterator/workdir.c
+++ b/tests/libgit2/iterator/workdir.c
diff --git a/tests/mailmap/basic.c b/tests/libgit2/mailmap/basic.c
index 1f8ca56c2..1f8ca56c2 100644
--- a/tests/mailmap/basic.c
+++ b/tests/libgit2/mailmap/basic.c
diff --git a/tests/mailmap/blame.c b/tests/libgit2/mailmap/blame.c
index e6bc1a41f..e6bc1a41f 100644
--- a/tests/mailmap/blame.c
+++ b/tests/libgit2/mailmap/blame.c
diff --git a/tests/mailmap/mailmap_testdata.h b/tests/libgit2/mailmap/mailmap_testdata.h
index a06606b4b..a06606b4b 100644
--- a/tests/mailmap/mailmap_testdata.h
+++ b/tests/libgit2/mailmap/mailmap_testdata.h
diff --git a/tests/mailmap/parsing.c b/tests/libgit2/mailmap/parsing.c
index 5ea470f34..5ea470f34 100644
--- a/tests/mailmap/parsing.c
+++ b/tests/libgit2/mailmap/parsing.c
diff --git a/tests/merge/analysis.c b/tests/libgit2/merge/analysis.c
index 8c61303e3..8c61303e3 100644
--- a/tests/merge/analysis.c
+++ b/tests/libgit2/merge/analysis.c
diff --git a/tests/merge/annotated_commit.c b/tests/libgit2/merge/annotated_commit.c
index cfdf849e5..cfdf849e5 100644
--- a/tests/merge/annotated_commit.c
+++ b/tests/libgit2/merge/annotated_commit.c
diff --git a/tests/merge/conflict_data.h b/tests/libgit2/merge/conflict_data.h
index 0b1e7ee03..0b1e7ee03 100644
--- a/tests/merge/conflict_data.h
+++ b/tests/libgit2/merge/conflict_data.h
diff --git a/tests/merge/driver.c b/tests/libgit2/merge/driver.c
index b7d320cbb..b7d320cbb 100644
--- a/tests/merge/driver.c
+++ b/tests/libgit2/merge/driver.c
diff --git a/tests/merge/files.c b/tests/libgit2/merge/files.c
index 6296f3b7b..6296f3b7b 100644
--- a/tests/merge/files.c
+++ b/tests/libgit2/merge/files.c
diff --git a/tests/merge/merge_helpers.c b/tests/libgit2/merge/merge_helpers.c
index ce3cd229b..ce3cd229b 100644
--- a/tests/merge/merge_helpers.c
+++ b/tests/libgit2/merge/merge_helpers.c
diff --git a/tests/merge/merge_helpers.h b/tests/libgit2/merge/merge_helpers.h
index 339812ba5..339812ba5 100644
--- a/tests/merge/merge_helpers.h
+++ b/tests/libgit2/merge/merge_helpers.h
diff --git a/tests/merge/trees/automerge.c b/tests/libgit2/merge/trees/automerge.c
index 3bf6c5208..3bf6c5208 100644
--- a/tests/merge/trees/automerge.c
+++ b/tests/libgit2/merge/trees/automerge.c
diff --git a/tests/merge/trees/commits.c b/tests/libgit2/merge/trees/commits.c
index 79fba8ac5..79fba8ac5 100644
--- a/tests/merge/trees/commits.c
+++ b/tests/libgit2/merge/trees/commits.c
diff --git a/tests/merge/trees/modeconflict.c b/tests/libgit2/merge/trees/modeconflict.c
index a0521c4e8..a0521c4e8 100644
--- a/tests/merge/trees/modeconflict.c
+++ b/tests/libgit2/merge/trees/modeconflict.c
diff --git a/tests/merge/trees/recursive.c b/tests/libgit2/merge/trees/recursive.c
index 71f5af150..71f5af150 100644
--- a/tests/merge/trees/recursive.c
+++ b/tests/libgit2/merge/trees/recursive.c
diff --git a/tests/merge/trees/renames.c b/tests/libgit2/merge/trees/renames.c
index 26f6d3306..26f6d3306 100644
--- a/tests/merge/trees/renames.c
+++ b/tests/libgit2/merge/trees/renames.c
diff --git a/tests/merge/trees/treediff.c b/tests/libgit2/merge/trees/treediff.c
index cd2cf7827..cd2cf7827 100644
--- a/tests/merge/trees/treediff.c
+++ b/tests/libgit2/merge/trees/treediff.c
diff --git a/tests/merge/trees/trivial.c b/tests/libgit2/merge/trees/trivial.c
index dce392c86..dce392c86 100644
--- a/tests/merge/trees/trivial.c
+++ b/tests/libgit2/merge/trees/trivial.c
diff --git a/tests/merge/trees/whitespace.c b/tests/libgit2/merge/trees/whitespace.c
index 9917df506..9917df506 100644
--- a/tests/merge/trees/whitespace.c
+++ b/tests/libgit2/merge/trees/whitespace.c
diff --git a/tests/merge/workdir/dirty.c b/tests/libgit2/merge/workdir/dirty.c
index b9c2ad033..b9c2ad033 100644
--- a/tests/merge/workdir/dirty.c
+++ b/tests/libgit2/merge/workdir/dirty.c
diff --git a/tests/merge/workdir/recursive.c b/tests/libgit2/merge/workdir/recursive.c
index 7669e1b1a..7669e1b1a 100644
--- a/tests/merge/workdir/recursive.c
+++ b/tests/libgit2/merge/workdir/recursive.c
diff --git a/tests/merge/workdir/renames.c b/tests/libgit2/merge/workdir/renames.c
index 1b5128cf1..1b5128cf1 100644
--- a/tests/merge/workdir/renames.c
+++ b/tests/libgit2/merge/workdir/renames.c
diff --git a/tests/merge/workdir/setup.c b/tests/libgit2/merge/workdir/setup.c
index 3db2d074f..3db2d074f 100644
--- a/tests/merge/workdir/setup.c
+++ b/tests/libgit2/merge/workdir/setup.c
diff --git a/tests/merge/workdir/simple.c b/tests/libgit2/merge/workdir/simple.c
index b9d3fc24c..b9d3fc24c 100644
--- a/tests/merge/workdir/simple.c
+++ b/tests/libgit2/merge/workdir/simple.c
diff --git a/tests/merge/workdir/submodules.c b/tests/libgit2/merge/workdir/submodules.c
index 5117be789..5117be789 100644
--- a/tests/merge/workdir/submodules.c
+++ b/tests/libgit2/merge/workdir/submodules.c
diff --git a/tests/merge/workdir/trivial.c b/tests/libgit2/merge/workdir/trivial.c
index fe8374851..fe8374851 100644
--- a/tests/merge/workdir/trivial.c
+++ b/tests/libgit2/merge/workdir/trivial.c
diff --git a/tests/message/trailer.c b/tests/libgit2/message/trailer.c
index 919e10a49..919e10a49 100644
--- a/tests/message/trailer.c
+++ b/tests/libgit2/message/trailer.c
diff --git a/tests/network/cred.c b/tests/libgit2/network/cred.c
index 5e4db7599..5e4db7599 100644
--- a/tests/network/cred.c
+++ b/tests/libgit2/network/cred.c
diff --git a/tests/network/fetchlocal.c b/tests/libgit2/network/fetchlocal.c
index dc37c38ab..dc37c38ab 100644
--- a/tests/network/fetchlocal.c
+++ b/tests/libgit2/network/fetchlocal.c
diff --git a/tests/network/matchhost.c b/tests/libgit2/network/matchhost.c
index 3100dc21d..3100dc21d 100644
--- a/tests/network/matchhost.c
+++ b/tests/libgit2/network/matchhost.c
diff --git a/tests/network/refspecs.c b/tests/libgit2/network/refspecs.c
index d9e0d9e8d..d9e0d9e8d 100644
--- a/tests/network/refspecs.c
+++ b/tests/libgit2/network/refspecs.c
diff --git a/tests/network/remote/defaultbranch.c b/tests/libgit2/network/remote/defaultbranch.c
index a7c0d81f6..a7c0d81f6 100644
--- a/tests/network/remote/defaultbranch.c
+++ b/tests/libgit2/network/remote/defaultbranch.c
diff --git a/tests/network/remote/delete.c b/tests/libgit2/network/remote/delete.c
index f23a638aa..f23a638aa 100644
--- a/tests/network/remote/delete.c
+++ b/tests/libgit2/network/remote/delete.c
diff --git a/tests/network/remote/isvalidname.c b/tests/libgit2/network/remote/isvalidname.c
index a3080f67c..a3080f67c 100644
--- a/tests/network/remote/isvalidname.c
+++ b/tests/libgit2/network/remote/isvalidname.c
diff --git a/tests/network/remote/local.c b/tests/libgit2/network/remote/local.c
index 2007f3776..2007f3776 100644
--- a/tests/network/remote/local.c
+++ b/tests/libgit2/network/remote/local.c
diff --git a/tests/network/remote/push.c b/tests/libgit2/network/remote/push.c
index 3905debdf..3905debdf 100644
--- a/tests/network/remote/push.c
+++ b/tests/libgit2/network/remote/push.c
diff --git a/tests/network/remote/remotes.c b/tests/libgit2/network/remote/remotes.c
index 79c4f39fa..79c4f39fa 100644
--- a/tests/network/remote/remotes.c
+++ b/tests/libgit2/network/remote/remotes.c
diff --git a/tests/network/remote/rename.c b/tests/libgit2/network/remote/rename.c
index 1fd2affba..1fd2affba 100644
--- a/tests/network/remote/rename.c
+++ b/tests/libgit2/network/remote/rename.c
diff --git a/tests/network/url/joinpath.c b/tests/libgit2/network/url/joinpath.c
index bf4557138..bf4557138 100644
--- a/tests/network/url/joinpath.c
+++ b/tests/libgit2/network/url/joinpath.c
diff --git a/tests/network/url/parse.c b/tests/libgit2/network/url/parse.c
index 8149ba52c..8149ba52c 100644
--- a/tests/network/url/parse.c
+++ b/tests/libgit2/network/url/parse.c
diff --git a/tests/network/url/pattern.c b/tests/libgit2/network/url/pattern.c
index 5e4495f70..5e4495f70 100644
--- a/tests/network/url/pattern.c
+++ b/tests/libgit2/network/url/pattern.c
diff --git a/tests/network/url/redirect.c b/tests/libgit2/network/url/redirect.c
index a94db7daf..a94db7daf 100644
--- a/tests/network/url/redirect.c
+++ b/tests/libgit2/network/url/redirect.c
diff --git a/tests/network/url/scp.c b/tests/libgit2/network/url/scp.c
index 8cdc832ae..8cdc832ae 100644
--- a/tests/network/url/scp.c
+++ b/tests/libgit2/network/url/scp.c
diff --git a/tests/network/url/valid.c b/tests/libgit2/network/url/valid.c
index 2b2cb7ba4..2b2cb7ba4 100644
--- a/tests/network/url/valid.c
+++ b/tests/libgit2/network/url/valid.c
diff --git a/tests/notes/notes.c b/tests/libgit2/notes/notes.c
index a36cddb8a..a36cddb8a 100644
--- a/tests/notes/notes.c
+++ b/tests/libgit2/notes/notes.c
diff --git a/tests/notes/notesref.c b/tests/libgit2/notes/notesref.c
index 6ba324c76..6ba324c76 100644
--- a/tests/notes/notesref.c
+++ b/tests/libgit2/notes/notesref.c
diff --git a/tests/object/blob/filter.c b/tests/libgit2/object/blob/filter.c
index 00b553e71..00b553e71 100644
--- a/tests/object/blob/filter.c
+++ b/tests/libgit2/object/blob/filter.c
diff --git a/tests/object/blob/fromstream.c b/tests/libgit2/object/blob/fromstream.c
index 60ff3991b..60ff3991b 100644
--- a/tests/object/blob/fromstream.c
+++ b/tests/libgit2/object/blob/fromstream.c
diff --git a/tests/object/blob/write.c b/tests/libgit2/object/blob/write.c
index 422258d63..422258d63 100644
--- a/tests/object/blob/write.c
+++ b/tests/libgit2/object/blob/write.c
diff --git a/tests/object/cache.c b/tests/libgit2/object/cache.c
index 08bf03648..08bf03648 100644
--- a/tests/object/cache.c
+++ b/tests/libgit2/object/cache.c
diff --git a/tests/object/commit/commitstagedfile.c b/tests/libgit2/object/commit/commitstagedfile.c
index 7322a4e86..7322a4e86 100644
--- a/tests/object/commit/commitstagedfile.c
+++ b/tests/libgit2/object/commit/commitstagedfile.c
diff --git a/tests/object/commit/parse.c b/tests/libgit2/object/commit/parse.c
index 4ff1ad62a..4ff1ad62a 100644
--- a/tests/object/commit/parse.c
+++ b/tests/libgit2/object/commit/parse.c
diff --git a/tests/object/lookup.c b/tests/libgit2/object/lookup.c
index a7b1ceeb4..a7b1ceeb4 100644
--- a/tests/object/lookup.c
+++ b/tests/libgit2/object/lookup.c
diff --git a/tests/object/lookupbypath.c b/tests/libgit2/object/lookupbypath.c
index f2257f556..f2257f556 100644
--- a/tests/object/lookupbypath.c
+++ b/tests/libgit2/object/lookupbypath.c
diff --git a/tests/object/message.c b/tests/libgit2/object/message.c
index d87c8ef70..d87c8ef70 100644
--- a/tests/object/message.c
+++ b/tests/libgit2/object/message.c
diff --git a/tests/object/peel.c b/tests/libgit2/object/peel.c
index 8be6e42d4..8be6e42d4 100644
--- a/tests/object/peel.c
+++ b/tests/libgit2/object/peel.c
diff --git a/tests/object/raw/chars.c b/tests/libgit2/object/raw/chars.c
index cde0bdbf6..cde0bdbf6 100644
--- a/tests/object/raw/chars.c
+++ b/tests/libgit2/object/raw/chars.c
diff --git a/tests/object/raw/compare.c b/tests/libgit2/object/raw/compare.c
index 56c016b72..56c016b72 100644
--- a/tests/object/raw/compare.c
+++ b/tests/libgit2/object/raw/compare.c
diff --git a/tests/object/raw/convert.c b/tests/libgit2/object/raw/convert.c
index 40a01ae09..40a01ae09 100644
--- a/tests/object/raw/convert.c
+++ b/tests/libgit2/object/raw/convert.c
diff --git a/tests/object/raw/data.h b/tests/libgit2/object/raw/data.h
index 57431e70e..57431e70e 100644
--- a/tests/object/raw/data.h
+++ b/tests/libgit2/object/raw/data.h
diff --git a/tests/object/raw/fromstr.c b/tests/libgit2/object/raw/fromstr.c
index 8c11c105f..8c11c105f 100644
--- a/tests/object/raw/fromstr.c
+++ b/tests/libgit2/object/raw/fromstr.c
diff --git a/tests/object/raw/hash.c b/tests/libgit2/object/raw/hash.c
index 5a3e81855..5a3e81855 100644
--- a/tests/object/raw/hash.c
+++ b/tests/libgit2/object/raw/hash.c
diff --git a/tests/object/raw/short.c b/tests/libgit2/object/raw/short.c
index e8d2cf5a5..e8d2cf5a5 100644
--- a/tests/object/raw/short.c
+++ b/tests/libgit2/object/raw/short.c
diff --git a/tests/object/raw/size.c b/tests/libgit2/object/raw/size.c
index 930c6de23..930c6de23 100644
--- a/tests/object/raw/size.c
+++ b/tests/libgit2/object/raw/size.c
diff --git a/tests/object/raw/type2string.c b/tests/libgit2/object/raw/type2string.c
index ebd81f552..ebd81f552 100644
--- a/tests/object/raw/type2string.c
+++ b/tests/libgit2/object/raw/type2string.c
diff --git a/tests/object/raw/write.c b/tests/libgit2/object/raw/write.c
index 40e05f357..40e05f357 100644
--- a/tests/object/raw/write.c
+++ b/tests/libgit2/object/raw/write.c
diff --git a/tests/object/shortid.c b/tests/libgit2/object/shortid.c
index 9b673efeb..9b673efeb 100644
--- a/tests/object/shortid.c
+++ b/tests/libgit2/object/shortid.c
diff --git a/tests/object/tag/list.c b/tests/libgit2/object/tag/list.c
index d15f09205..d15f09205 100644
--- a/tests/object/tag/list.c
+++ b/tests/libgit2/object/tag/list.c
diff --git a/tests/object/tag/parse.c b/tests/libgit2/object/tag/parse.c
index 2c0635ae4..2c0635ae4 100644
--- a/tests/object/tag/parse.c
+++ b/tests/libgit2/object/tag/parse.c
diff --git a/tests/object/tag/peel.c b/tests/libgit2/object/tag/peel.c
index 7456a8e17..7456a8e17 100644
--- a/tests/object/tag/peel.c
+++ b/tests/libgit2/object/tag/peel.c
diff --git a/tests/object/tag/read.c b/tests/libgit2/object/tag/read.c
index 90ba58029..90ba58029 100644
--- a/tests/object/tag/read.c
+++ b/tests/libgit2/object/tag/read.c
diff --git a/tests/object/tag/write.c b/tests/libgit2/object/tag/write.c
index 3c1a98956..3c1a98956 100644
--- a/tests/object/tag/write.c
+++ b/tests/libgit2/object/tag/write.c
diff --git a/tests/object/tree/attributes.c b/tests/libgit2/object/tree/attributes.c
index 8654dfa31..8654dfa31 100644
--- a/tests/object/tree/attributes.c
+++ b/tests/libgit2/object/tree/attributes.c
diff --git a/tests/object/tree/duplicateentries.c b/tests/libgit2/object/tree/duplicateentries.c
index c11ae0d3d..c11ae0d3d 100644
--- a/tests/object/tree/duplicateentries.c
+++ b/tests/libgit2/object/tree/duplicateentries.c
diff --git a/tests/object/tree/frompath.c b/tests/libgit2/object/tree/frompath.c
index 86ca47e94..86ca47e94 100644
--- a/tests/object/tree/frompath.c
+++ b/tests/libgit2/object/tree/frompath.c
diff --git a/tests/object/tree/parse.c b/tests/libgit2/object/tree/parse.c
index 9d76a74f0..9d76a74f0 100644
--- a/tests/object/tree/parse.c
+++ b/tests/libgit2/object/tree/parse.c
diff --git a/tests/object/tree/read.c b/tests/libgit2/object/tree/read.c
index 95a2e70fb..95a2e70fb 100644
--- a/tests/object/tree/read.c
+++ b/tests/libgit2/object/tree/read.c
diff --git a/tests/object/tree/update.c b/tests/libgit2/object/tree/update.c
index 41b50f3e9..41b50f3e9 100644
--- a/tests/object/tree/update.c
+++ b/tests/libgit2/object/tree/update.c
diff --git a/tests/object/tree/walk.c b/tests/libgit2/object/tree/walk.c
index d1fdaa3a0..d1fdaa3a0 100644
--- a/tests/object/tree/walk.c
+++ b/tests/libgit2/object/tree/walk.c
diff --git a/tests/object/tree/write.c b/tests/libgit2/object/tree/write.c
index a4ceb35b6..a4ceb35b6 100644
--- a/tests/object/tree/write.c
+++ b/tests/libgit2/object/tree/write.c
diff --git a/tests/object/validate.c b/tests/libgit2/object/validate.c
index 87193deb6..87193deb6 100644
--- a/tests/object/validate.c
+++ b/tests/libgit2/object/validate.c
diff --git a/tests/odb/alternates.c b/tests/libgit2/odb/alternates.c
index 6c00fda2f..6c00fda2f 100644
--- a/tests/odb/alternates.c
+++ b/tests/libgit2/odb/alternates.c
diff --git a/tests/odb/backend/backend_helpers.c b/tests/libgit2/odb/backend/backend_helpers.c
index 542799242..542799242 100644
--- a/tests/odb/backend/backend_helpers.c
+++ b/tests/libgit2/odb/backend/backend_helpers.c
diff --git a/tests/odb/backend/backend_helpers.h b/tests/libgit2/odb/backend/backend_helpers.h
index 32d7a8bf0..32d7a8bf0 100644
--- a/tests/odb/backend/backend_helpers.h
+++ b/tests/libgit2/odb/backend/backend_helpers.h
diff --git a/tests/odb/backend/mempack.c b/tests/libgit2/odb/backend/mempack.c
index 2eeed51aa..2eeed51aa 100644
--- a/tests/odb/backend/mempack.c
+++ b/tests/libgit2/odb/backend/mempack.c
diff --git a/tests/odb/backend/multiple.c b/tests/libgit2/odb/backend/multiple.c
index 5f1eacd52..5f1eacd52 100644
--- a/tests/odb/backend/multiple.c
+++ b/tests/libgit2/odb/backend/multiple.c
diff --git a/tests/odb/backend/nobackend.c b/tests/libgit2/odb/backend/nobackend.c
index 7484d423b..7484d423b 100644
--- a/tests/odb/backend/nobackend.c
+++ b/tests/libgit2/odb/backend/nobackend.c
diff --git a/tests/odb/backend/nonrefreshing.c b/tests/libgit2/odb/backend/nonrefreshing.c
index 2db10efbc..2db10efbc 100644
--- a/tests/odb/backend/nonrefreshing.c
+++ b/tests/libgit2/odb/backend/nonrefreshing.c
diff --git a/tests/odb/backend/refreshing.c b/tests/libgit2/odb/backend/refreshing.c
index 9e49298a8..9e49298a8 100644
--- a/tests/odb/backend/refreshing.c
+++ b/tests/libgit2/odb/backend/refreshing.c
diff --git a/tests/odb/backend/simple.c b/tests/libgit2/odb/backend/simple.c
index 6c9293ac0..6c9293ac0 100644
--- a/tests/odb/backend/simple.c
+++ b/tests/libgit2/odb/backend/simple.c
diff --git a/tests/odb/emptyobjects.c b/tests/libgit2/odb/emptyobjects.c
index e3ec62d3f..e3ec62d3f 100644
--- a/tests/odb/emptyobjects.c
+++ b/tests/libgit2/odb/emptyobjects.c
diff --git a/tests/odb/foreach.c b/tests/libgit2/odb/foreach.c
index c2a448363..c2a448363 100644
--- a/tests/odb/foreach.c
+++ b/tests/libgit2/odb/foreach.c
diff --git a/tests/odb/freshen.c b/tests/libgit2/odb/freshen.c
index 2396e3774..2396e3774 100644
--- a/tests/odb/freshen.c
+++ b/tests/libgit2/odb/freshen.c
diff --git a/tests/odb/largefiles.c b/tests/libgit2/odb/largefiles.c
index acc786ee4..acc786ee4 100644
--- a/tests/odb/largefiles.c
+++ b/tests/libgit2/odb/largefiles.c
diff --git a/tests/odb/loose.c b/tests/libgit2/odb/loose.c
index fe013a78c..fe013a78c 100644
--- a/tests/odb/loose.c
+++ b/tests/libgit2/odb/loose.c
diff --git a/tests/odb/loose_data.h b/tests/libgit2/odb/loose_data.h
index c10c9bc7f..c10c9bc7f 100644
--- a/tests/odb/loose_data.h
+++ b/tests/libgit2/odb/loose_data.h
diff --git a/tests/odb/mixed.c b/tests/libgit2/odb/mixed.c
index 87e945c83..87e945c83 100644
--- a/tests/odb/mixed.c
+++ b/tests/libgit2/odb/mixed.c
diff --git a/tests/odb/pack_data.h b/tests/libgit2/odb/pack_data.h
index e6371beb1..e6371beb1 100644
--- a/tests/odb/pack_data.h
+++ b/tests/libgit2/odb/pack_data.h
diff --git a/tests/odb/pack_data_one.h b/tests/libgit2/odb/pack_data_one.h
index 13570ba78..13570ba78 100644
--- a/tests/odb/pack_data_one.h
+++ b/tests/libgit2/odb/pack_data_one.h
diff --git a/tests/odb/packed.c b/tests/libgit2/odb/packed.c
index 3d502ed6d..3d502ed6d 100644
--- a/tests/odb/packed.c
+++ b/tests/libgit2/odb/packed.c
diff --git a/tests/odb/packed_one.c b/tests/libgit2/odb/packed_one.c
index 17cd4f760..17cd4f760 100644
--- a/tests/odb/packed_one.c
+++ b/tests/libgit2/odb/packed_one.c
diff --git a/tests/odb/sorting.c b/tests/libgit2/odb/sorting.c
index e027230fa..e027230fa 100644
--- a/tests/odb/sorting.c
+++ b/tests/libgit2/odb/sorting.c
diff --git a/tests/odb/streamwrite.c b/tests/libgit2/odb/streamwrite.c
index c174f6974..c174f6974 100644
--- a/tests/odb/streamwrite.c
+++ b/tests/libgit2/odb/streamwrite.c
diff --git a/tests/online/badssl.c b/tests/libgit2/online/badssl.c
index 6735e9cdb..6735e9cdb 100644
--- a/tests/online/badssl.c
+++ b/tests/libgit2/online/badssl.c
diff --git a/tests/online/clone.c b/tests/libgit2/online/clone.c
index 9f2580bb3..9f2580bb3 100644
--- a/tests/online/clone.c
+++ b/tests/libgit2/online/clone.c
diff --git a/tests/online/customcert.c b/tests/libgit2/online/customcert.c
index 7932a9e68..7932a9e68 100644
--- a/tests/online/customcert.c
+++ b/tests/libgit2/online/customcert.c
diff --git a/tests/online/fetch.c b/tests/libgit2/online/fetch.c
index 7334f7e8b..7334f7e8b 100644
--- a/tests/online/fetch.c
+++ b/tests/libgit2/online/fetch.c
diff --git a/tests/online/fetchhead.c b/tests/libgit2/online/fetchhead.c
index 1b66c528e..1b66c528e 100644
--- a/tests/online/fetchhead.c
+++ b/tests/libgit2/online/fetchhead.c
diff --git a/tests/online/push.c b/tests/libgit2/online/push.c
index 51adc3930..51adc3930 100644
--- a/tests/online/push.c
+++ b/tests/libgit2/online/push.c
diff --git a/tests/online/push_util.c b/tests/libgit2/online/push_util.c
index cd1831d4c..cd1831d4c 100644
--- a/tests/online/push_util.c
+++ b/tests/libgit2/online/push_util.c
diff --git a/tests/online/push_util.h b/tests/libgit2/online/push_util.h
index 5f669feaf..5f669feaf 100644
--- a/tests/online/push_util.h
+++ b/tests/libgit2/online/push_util.h
diff --git a/tests/online/remotes.c b/tests/libgit2/online/remotes.c
index 887874d92..887874d92 100644
--- a/tests/online/remotes.c
+++ b/tests/libgit2/online/remotes.c
diff --git a/tests/pack/filelimit.c b/tests/libgit2/pack/filelimit.c
index fa08485fb..fa08485fb 100644
--- a/tests/pack/filelimit.c
+++ b/tests/libgit2/pack/filelimit.c
diff --git a/tests/pack/indexer.c b/tests/libgit2/pack/indexer.c
index ec48ffd98..ec48ffd98 100644
--- a/tests/pack/indexer.c
+++ b/tests/libgit2/pack/indexer.c
diff --git a/tests/pack/midx.c b/tests/libgit2/pack/midx.c
index 9dd949363..9dd949363 100644
--- a/tests/pack/midx.c
+++ b/tests/libgit2/pack/midx.c
diff --git a/tests/pack/packbuilder.c b/tests/libgit2/pack/packbuilder.c
index f23579817..f23579817 100644
--- a/tests/pack/packbuilder.c
+++ b/tests/libgit2/pack/packbuilder.c
diff --git a/tests/pack/sharing.c b/tests/libgit2/pack/sharing.c
index eaf7686b7..eaf7686b7 100644
--- a/tests/pack/sharing.c
+++ b/tests/libgit2/pack/sharing.c
diff --git a/tests/pack/threadsafety.c b/tests/libgit2/pack/threadsafety.c
index fd6a61fbd..fd6a61fbd 100644
--- a/tests/pack/threadsafety.c
+++ b/tests/libgit2/pack/threadsafety.c
diff --git a/tests/patch/parse.c b/tests/libgit2/patch/parse.c
index a3c4c6730..a3c4c6730 100644
--- a/tests/patch/parse.c
+++ b/tests/libgit2/patch/parse.c
diff --git a/tests/patch/patch_common.h b/tests/libgit2/patch/patch_common.h
index 1e03889fc..1e03889fc 100644
--- a/tests/patch/patch_common.h
+++ b/tests/libgit2/patch/patch_common.h
diff --git a/tests/patch/print.c b/tests/libgit2/patch/print.c
index 33cf27ddb..33cf27ddb 100644
--- a/tests/patch/print.c
+++ b/tests/libgit2/patch/print.c
diff --git a/tests/libgit2/path/validate.c b/tests/libgit2/path/validate.c
new file mode 100644
index 000000000..df9219453
--- /dev/null
+++ b/tests/libgit2/path/validate.c
@@ -0,0 +1,63 @@
+#include "clar_libgit2.h"
+#include "path.h"
+
+void test_path_validate__cleanup(void)
+{
+ cl_git_sandbox_cleanup();
+}
+
+void test_path_validate__length(void)
+{
+ cl_must_pass(git_path_validate_length(NULL, "/foo/bar"));
+ cl_must_pass(git_path_validate_length(NULL, "C:\\Foo\\Bar"));
+ cl_must_pass(git_path_validate_length(NULL, "\\\\?\\C:\\Foo\\Bar"));
+ cl_must_pass(git_path_validate_length(NULL, "\\\\?\\C:\\Foo\\Bar"));
+ cl_must_pass(git_path_validate_length(NULL, "\\\\?\\UNC\\server\\C$\\folder"));
+
+#ifdef GIT_WIN32
+ /*
+ * In the absence of a repo configuration, 259 character paths
+ * succeed. >= 260 character paths fail.
+ */
+ cl_must_pass(git_path_validate_length(NULL, "C:\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\ok.txt"));
+ cl_must_pass(git_path_validate_length(NULL, "C:\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\260.txt"));
+ cl_must_fail(git_path_validate_length(NULL, "C:\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\longer_than_260.txt"));
+
+ /* count characters, not bytes */
+ cl_must_pass(git_path_validate_length(NULL, "C:\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\\xc2\xa2\xc2\xa2\xc2\xa2\xc2\xa2\xc2\xa2\xc2\xa2\xc2\xa2\xc2\xa2\xc2\xa2\\260.txt"));
+ cl_must_fail(git_path_validate_length(NULL, "C:\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\\xc2\xa2\xc2\xa2\xc2\xa2\xc2\xa2\xc2\xa2\xc2\xa2\xc2\xa2\xc2\xa2\xc2\xa2\\long.txt"));
+#else
+ cl_must_pass(git_path_validate_length(NULL, "/c/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/ok.txt"));
+ cl_must_pass(git_path_validate_length(NULL, "/c/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/260.txt"));
+ cl_must_pass(git_path_validate_length(NULL, "/c/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/longer_than_260.txt"));
+ cl_must_pass(git_path_validate_length(NULL, "C:\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\\xc2\xa2\xc2\xa2\xc2\xa2\xc2\xa2\xc2\xa2\xc2\xa2\xc2\xa2\xc2\xa2\xc2\xa2\\260.txt"));
+ cl_must_pass(git_path_validate_length(NULL, "C:\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\\xc2\xa2\xc2\xa2\xc2\xa2\xc2\xa2\xc2\xa2\xc2\xa2\xc2\xa2\xc2\xa2\xc2\xa2\\long.txt"));
+#endif
+}
+
+void test_path_validate__length_with_core_longpath(void)
+{
+#ifdef GIT_WIN32
+ git_repository *repo;
+ git_config *config;
+
+ repo = cl_git_sandbox_init("empty_bare.git");
+
+ cl_git_pass(git_repository_open(&repo, "empty_bare.git"));
+ cl_git_pass(git_repository_config(&config, repo));
+
+ /* fail by default */
+ cl_must_fail(git_path_validate_length(repo, "/c/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/longer_than_260.txt"));
+
+ /* set core.longpaths explicitly on */
+ cl_git_pass(git_config_set_bool(config, "core.longpaths", 1));
+ cl_must_pass(git_path_validate_length(repo, "/c/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/longer_than_260.txt"));
+
+ /* set core.longpaths explicitly off */
+ cl_git_pass(git_config_set_bool(config, "core.longpaths", 0));
+ cl_must_fail(git_path_validate_length(repo, "/c/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/longer_than_260.txt"));
+
+ git_config_free(config);
+ git_repository_free(repo);
+#endif
+}
diff --git a/tests/perf/helper__perf__do_merge.c b/tests/libgit2/perf/helper__perf__do_merge.c
index c77b46a1f..c77b46a1f 100644
--- a/tests/perf/helper__perf__do_merge.c
+++ b/tests/libgit2/perf/helper__perf__do_merge.c
diff --git a/tests/perf/helper__perf__do_merge.h b/tests/libgit2/perf/helper__perf__do_merge.h
index 4a4723da5..4a4723da5 100644
--- a/tests/perf/helper__perf__do_merge.h
+++ b/tests/libgit2/perf/helper__perf__do_merge.h
diff --git a/tests/perf/helper__perf__timer.c b/tests/libgit2/perf/helper__perf__timer.c
index 8a7ed09e8..8a7ed09e8 100644
--- a/tests/perf/helper__perf__timer.c
+++ b/tests/libgit2/perf/helper__perf__timer.c
diff --git a/tests/perf/helper__perf__timer.h b/tests/libgit2/perf/helper__perf__timer.h
index 5aff4b136..5aff4b136 100644
--- a/tests/perf/helper__perf__timer.h
+++ b/tests/libgit2/perf/helper__perf__timer.h
diff --git a/tests/perf/merge.c b/tests/libgit2/perf/merge.c
index 721902d63..721902d63 100644
--- a/tests/perf/merge.c
+++ b/tests/libgit2/perf/merge.c
diff --git a/tests/libgit2/precompiled.c b/tests/libgit2/precompiled.c
new file mode 100644
index 000000000..5f656a45d
--- /dev/null
+++ b/tests/libgit2/precompiled.c
@@ -0,0 +1 @@
+#include "precompiled.h"
diff --git a/tests/precompiled.h b/tests/libgit2/precompiled.h
index ea53a60e9..ea53a60e9 100644
--- a/tests/precompiled.h
+++ b/tests/libgit2/precompiled.h
diff --git a/tests/rebase/abort.c b/tests/libgit2/rebase/abort.c
index a83c529ce..a83c529ce 100644
--- a/tests/rebase/abort.c
+++ b/tests/libgit2/rebase/abort.c
diff --git a/tests/rebase/inmemory.c b/tests/libgit2/rebase/inmemory.c
index 040a81b1b..040a81b1b 100644
--- a/tests/rebase/inmemory.c
+++ b/tests/libgit2/rebase/inmemory.c
diff --git a/tests/rebase/iterator.c b/tests/libgit2/rebase/iterator.c
index a120f28ac..a120f28ac 100644
--- a/tests/rebase/iterator.c
+++ b/tests/libgit2/rebase/iterator.c
diff --git a/tests/rebase/merge.c b/tests/libgit2/rebase/merge.c
index 5f730f750..5f730f750 100644
--- a/tests/rebase/merge.c
+++ b/tests/libgit2/rebase/merge.c
diff --git a/tests/rebase/setup.c b/tests/libgit2/rebase/setup.c
index 34d5edbf6..34d5edbf6 100644
--- a/tests/rebase/setup.c
+++ b/tests/libgit2/rebase/setup.c
diff --git a/tests/rebase/sign.c b/tests/libgit2/rebase/sign.c
index 4064cf79b..4064cf79b 100644
--- a/tests/rebase/sign.c
+++ b/tests/libgit2/rebase/sign.c
diff --git a/tests/rebase/submodule.c b/tests/libgit2/rebase/submodule.c
index 0b3c2d5b5..0b3c2d5b5 100644
--- a/tests/rebase/submodule.c
+++ b/tests/libgit2/rebase/submodule.c
diff --git a/tests/refs/basic.c b/tests/libgit2/refs/basic.c
index 32742f9cc..32742f9cc 100644
--- a/tests/refs/basic.c
+++ b/tests/libgit2/refs/basic.c
diff --git a/tests/refs/branches/checkedout.c b/tests/libgit2/refs/branches/checkedout.c
index d6dab2c0e..d6dab2c0e 100644
--- a/tests/refs/branches/checkedout.c
+++ b/tests/libgit2/refs/branches/checkedout.c
diff --git a/tests/refs/branches/create.c b/tests/libgit2/refs/branches/create.c
index 2fb11668b..2fb11668b 100644
--- a/tests/refs/branches/create.c
+++ b/tests/libgit2/refs/branches/create.c
diff --git a/tests/refs/branches/delete.c b/tests/libgit2/refs/branches/delete.c
index 27995f9e2..27995f9e2 100644
--- a/tests/refs/branches/delete.c
+++ b/tests/libgit2/refs/branches/delete.c
diff --git a/tests/refs/branches/ishead.c b/tests/libgit2/refs/branches/ishead.c
index 1df70b789..1df70b789 100644
--- a/tests/refs/branches/ishead.c
+++ b/tests/libgit2/refs/branches/ishead.c
diff --git a/tests/refs/branches/iterator.c b/tests/libgit2/refs/branches/iterator.c
index e086681e5..e086681e5 100644
--- a/tests/refs/branches/iterator.c
+++ b/tests/libgit2/refs/branches/iterator.c
diff --git a/tests/refs/branches/lookup.c b/tests/libgit2/refs/branches/lookup.c
index ef0c1f97d..ef0c1f97d 100644
--- a/tests/refs/branches/lookup.c
+++ b/tests/libgit2/refs/branches/lookup.c
diff --git a/tests/refs/branches/move.c b/tests/libgit2/refs/branches/move.c
index 46a5082d2..46a5082d2 100644
--- a/tests/refs/branches/move.c
+++ b/tests/libgit2/refs/branches/move.c
diff --git a/tests/refs/branches/name.c b/tests/libgit2/refs/branches/name.c
index efa68e32b..efa68e32b 100644
--- a/tests/refs/branches/name.c
+++ b/tests/libgit2/refs/branches/name.c
diff --git a/tests/refs/branches/remote.c b/tests/libgit2/refs/branches/remote.c
index e2bd3485a..e2bd3485a 100644
--- a/tests/refs/branches/remote.c
+++ b/tests/libgit2/refs/branches/remote.c
diff --git a/tests/refs/branches/upstream.c b/tests/libgit2/refs/branches/upstream.c
index 919705e07..919705e07 100644
--- a/tests/refs/branches/upstream.c
+++ b/tests/libgit2/refs/branches/upstream.c
diff --git a/tests/refs/branches/upstreamname.c b/tests/libgit2/refs/branches/upstreamname.c
index 5bae154d2..5bae154d2 100644
--- a/tests/refs/branches/upstreamname.c
+++ b/tests/libgit2/refs/branches/upstreamname.c
diff --git a/tests/refs/crashes.c b/tests/libgit2/refs/crashes.c
index 4f508aed2..4f508aed2 100644
--- a/tests/refs/crashes.c
+++ b/tests/libgit2/refs/crashes.c
diff --git a/tests/refs/create.c b/tests/libgit2/refs/create.c
index 01eb62a52..01eb62a52 100644
--- a/tests/refs/create.c
+++ b/tests/libgit2/refs/create.c
diff --git a/tests/refs/delete.c b/tests/libgit2/refs/delete.c
index 42cc534b5..42cc534b5 100644
--- a/tests/refs/delete.c
+++ b/tests/libgit2/refs/delete.c
diff --git a/tests/refs/dup.c b/tests/libgit2/refs/dup.c
index 8a89cd95c..8a89cd95c 100644
--- a/tests/refs/dup.c
+++ b/tests/libgit2/refs/dup.c
diff --git a/tests/refs/foreachglob.c b/tests/libgit2/refs/foreachglob.c
index b208a95a2..b208a95a2 100644
--- a/tests/refs/foreachglob.c
+++ b/tests/libgit2/refs/foreachglob.c
diff --git a/tests/refs/isvalidname.c b/tests/libgit2/refs/isvalidname.c
index 063f0f798..063f0f798 100644
--- a/tests/refs/isvalidname.c
+++ b/tests/libgit2/refs/isvalidname.c
diff --git a/tests/refs/iterator.c b/tests/libgit2/refs/iterator.c
index a4f9e62ec..a4f9e62ec 100644
--- a/tests/refs/iterator.c
+++ b/tests/libgit2/refs/iterator.c
diff --git a/tests/refs/list.c b/tests/libgit2/refs/list.c
index 8085ff84b..8085ff84b 100644
--- a/tests/refs/list.c
+++ b/tests/libgit2/refs/list.c
diff --git a/tests/refs/listall.c b/tests/libgit2/refs/listall.c
index 9da8d1ac3..9da8d1ac3 100644
--- a/tests/refs/listall.c
+++ b/tests/libgit2/refs/listall.c
diff --git a/tests/refs/lookup.c b/tests/libgit2/refs/lookup.c
index 01e956de2..01e956de2 100644
--- a/tests/refs/lookup.c
+++ b/tests/libgit2/refs/lookup.c
diff --git a/tests/refs/namespaces.c b/tests/libgit2/refs/namespaces.c
index 19456b5a4..19456b5a4 100644
--- a/tests/refs/namespaces.c
+++ b/tests/libgit2/refs/namespaces.c
diff --git a/tests/refs/normalize.c b/tests/libgit2/refs/normalize.c
index ff815002c..ff815002c 100644
--- a/tests/refs/normalize.c
+++ b/tests/libgit2/refs/normalize.c
diff --git a/tests/refs/overwrite.c b/tests/libgit2/refs/overwrite.c
index 1826b1257..1826b1257 100644
--- a/tests/refs/overwrite.c
+++ b/tests/libgit2/refs/overwrite.c
diff --git a/tests/refs/pack.c b/tests/libgit2/refs/pack.c
index 1c1cd51cb..1c1cd51cb 100644
--- a/tests/refs/pack.c
+++ b/tests/libgit2/refs/pack.c
diff --git a/tests/refs/peel.c b/tests/libgit2/refs/peel.c
index 38f3465a0..38f3465a0 100644
--- a/tests/refs/peel.c
+++ b/tests/libgit2/refs/peel.c
diff --git a/tests/refs/races.c b/tests/libgit2/refs/races.c
index 476789358..476789358 100644
--- a/tests/refs/races.c
+++ b/tests/libgit2/refs/races.c
diff --git a/tests/refs/read.c b/tests/libgit2/refs/read.c
index a622c770b..a622c770b 100644
--- a/tests/refs/read.c
+++ b/tests/libgit2/refs/read.c
diff --git a/tests/refs/ref_helpers.c b/tests/libgit2/refs/ref_helpers.c
index 70d5d36d5..70d5d36d5 100644
--- a/tests/refs/ref_helpers.c
+++ b/tests/libgit2/refs/ref_helpers.c
diff --git a/tests/refs/ref_helpers.h b/tests/libgit2/refs/ref_helpers.h
index 0ef55bfce..0ef55bfce 100644
--- a/tests/refs/ref_helpers.h
+++ b/tests/libgit2/refs/ref_helpers.h
diff --git a/tests/refs/reflog/drop.c b/tests/libgit2/refs/reflog/drop.c
index 916bd9933..916bd9933 100644
--- a/tests/refs/reflog/drop.c
+++ b/tests/libgit2/refs/reflog/drop.c
diff --git a/tests/refs/reflog/messages.c b/tests/libgit2/refs/reflog/messages.c
index ed183d2f2..ed183d2f2 100644
--- a/tests/refs/reflog/messages.c
+++ b/tests/libgit2/refs/reflog/messages.c
diff --git a/tests/refs/reflog/reflog.c b/tests/libgit2/refs/reflog/reflog.c
index 32ce7ffb7..32ce7ffb7 100644
--- a/tests/refs/reflog/reflog.c
+++ b/tests/libgit2/refs/reflog/reflog.c
diff --git a/tests/refs/reflog/reflog_helpers.c b/tests/libgit2/refs/reflog/reflog_helpers.c
index 2ea41ee06..2ea41ee06 100644
--- a/tests/refs/reflog/reflog_helpers.c
+++ b/tests/libgit2/refs/reflog/reflog_helpers.c
diff --git a/tests/refs/reflog/reflog_helpers.h b/tests/libgit2/refs/reflog/reflog_helpers.h
index 4cd92cadc..4cd92cadc 100644
--- a/tests/refs/reflog/reflog_helpers.h
+++ b/tests/libgit2/refs/reflog/reflog_helpers.h
diff --git a/tests/refs/rename.c b/tests/libgit2/refs/rename.c
index f71e65782..f71e65782 100644
--- a/tests/refs/rename.c
+++ b/tests/libgit2/refs/rename.c
diff --git a/tests/refs/revparse.c b/tests/libgit2/refs/revparse.c
index 0bd2ae5bc..0bd2ae5bc 100644
--- a/tests/refs/revparse.c
+++ b/tests/libgit2/refs/revparse.c
diff --git a/tests/refs/setter.c b/tests/libgit2/refs/setter.c
index b34c71eb5..b34c71eb5 100644
--- a/tests/refs/setter.c
+++ b/tests/libgit2/refs/setter.c
diff --git a/tests/refs/shorthand.c b/tests/libgit2/refs/shorthand.c
index e008adc74..e008adc74 100644
--- a/tests/refs/shorthand.c
+++ b/tests/libgit2/refs/shorthand.c
diff --git a/tests/refs/tags/name.c b/tests/libgit2/refs/tags/name.c
index 1dd1760b9..1dd1760b9 100644
--- a/tests/refs/tags/name.c
+++ b/tests/libgit2/refs/tags/name.c
diff --git a/tests/refs/transactions.c b/tests/libgit2/refs/transactions.c
index 50c102ad0..50c102ad0 100644
--- a/tests/refs/transactions.c
+++ b/tests/libgit2/refs/transactions.c
diff --git a/tests/refs/unicode.c b/tests/libgit2/refs/unicode.c
index a279d5006..a279d5006 100644
--- a/tests/refs/unicode.c
+++ b/tests/libgit2/refs/unicode.c
diff --git a/tests/refs/update.c b/tests/libgit2/refs/update.c
index 1c5127d9e..1c5127d9e 100644
--- a/tests/refs/update.c
+++ b/tests/libgit2/refs/update.c
diff --git a/tests/remote/create.c b/tests/libgit2/remote/create.c
index f92be9dfc..f92be9dfc 100644
--- a/tests/remote/create.c
+++ b/tests/libgit2/remote/create.c
diff --git a/tests/remote/fetch.c b/tests/libgit2/remote/fetch.c
index 370046267..85e99206f 100644
--- a/tests/remote/fetch.c
+++ b/tests/libgit2/remote/fetch.c
@@ -1,4 +1,4 @@
-#include "../clar_libgit2.h"
+#include "clar_libgit2.h"
#include "remote.h"
#include "repository.h"
@@ -82,9 +82,9 @@ static void do_time_travelling_fetch(git_oid *commit1id, git_oid *commit2id,
cl_git_pass(git_treebuilder_write(&empty_tree_id, tb));
cl_git_pass(git_tree_lookup(&empty_tree, repo1, &empty_tree_id));
cl_git_pass(git_signature_default(&sig, repo1));
- cl_git_pass(git_commit_create(commit1id, repo1, REPO1_REFNAME, sig,
+ cl_git_pass(git_commit_create(commit1id, repo1, REPO1_REFNAME, sig,
sig, NULL, "one", empty_tree, 0, NULL));
- cl_git_pass(git_commit_create_v(commit2id, repo1, REPO1_REFNAME, sig,
+ cl_git_pass(git_commit_create_v(commit2id, repo1, REPO1_REFNAME, sig,
sig, NULL, "two", empty_tree, 1, commit1id));
git_tree_free(empty_tree);
@@ -118,7 +118,7 @@ static void do_time_travelling_fetch(git_oid *commit1id, git_oid *commit2id,
git_reference *ref;
git_reference *ref2;
cl_git_pass(git_reference_lookup(&ref, repo1, REPO1_REFNAME));
- cl_git_pass(git_reference_set_target(&ref2, ref, commit1id,
+ cl_git_pass(git_reference_set_target(&ref2, ref, commit1id,
"rollback"));
git_reference_free(ref);
git_reference_free(ref2);
diff --git a/tests/remote/httpproxy.c b/tests/libgit2/remote/httpproxy.c
index f62a2545b..f62a2545b 100644
--- a/tests/remote/httpproxy.c
+++ b/tests/libgit2/remote/httpproxy.c
diff --git a/tests/remote/insteadof.c b/tests/libgit2/remote/insteadof.c
index c39df4be7..c39df4be7 100644
--- a/tests/remote/insteadof.c
+++ b/tests/libgit2/remote/insteadof.c
diff --git a/tests/remote/list.c b/tests/libgit2/remote/list.c
index 4a6be3d1b..4a6be3d1b 100644
--- a/tests/remote/list.c
+++ b/tests/libgit2/remote/list.c
diff --git a/tests/repo/config.c b/tests/libgit2/repo/config.c
index ee7e43dff..ee7e43dff 100644
--- a/tests/repo/config.c
+++ b/tests/libgit2/repo/config.c
diff --git a/tests/repo/discover.c b/tests/libgit2/repo/discover.c
index 523fdf8e3..523fdf8e3 100644
--- a/tests/repo/discover.c
+++ b/tests/libgit2/repo/discover.c
diff --git a/tests/repo/env.c b/tests/libgit2/repo/env.c
index e3e522480..e3e522480 100644
--- a/tests/repo/env.c
+++ b/tests/libgit2/repo/env.c
diff --git a/tests/repo/extensions.c b/tests/libgit2/repo/extensions.c
index e7772acd5..e7772acd5 100644
--- a/tests/repo/extensions.c
+++ b/tests/libgit2/repo/extensions.c
diff --git a/tests/repo/getters.c b/tests/libgit2/repo/getters.c
index d401bb832..d401bb832 100644
--- a/tests/repo/getters.c
+++ b/tests/libgit2/repo/getters.c
diff --git a/tests/repo/hashfile.c b/tests/libgit2/repo/hashfile.c
index e23bb77f9..e23bb77f9 100644
--- a/tests/repo/hashfile.c
+++ b/tests/libgit2/repo/hashfile.c
diff --git a/tests/repo/head.c b/tests/libgit2/repo/head.c
index 822990555..822990555 100644
--- a/tests/repo/head.c
+++ b/tests/libgit2/repo/head.c
diff --git a/tests/repo/headtree.c b/tests/libgit2/repo/headtree.c
index e899ac399..e899ac399 100644
--- a/tests/repo/headtree.c
+++ b/tests/libgit2/repo/headtree.c
diff --git a/tests/repo/init.c b/tests/libgit2/repo/init.c
index 7cf6742ca..7cf6742ca 100644
--- a/tests/repo/init.c
+++ b/tests/libgit2/repo/init.c
diff --git a/tests/repo/message.c b/tests/libgit2/repo/message.c
index 6241f48f9..6241f48f9 100644
--- a/tests/repo/message.c
+++ b/tests/libgit2/repo/message.c
diff --git a/tests/repo/new.c b/tests/libgit2/repo/new.c
index d77e903f6..d77e903f6 100644
--- a/tests/repo/new.c
+++ b/tests/libgit2/repo/new.c
diff --git a/tests/repo/open.c b/tests/libgit2/repo/open.c
index f7ed2c373..f7ed2c373 100644
--- a/tests/repo/open.c
+++ b/tests/libgit2/repo/open.c
diff --git a/tests/repo/pathspec.c b/tests/libgit2/repo/pathspec.c
index 5b86662bc..5b86662bc 100644
--- a/tests/repo/pathspec.c
+++ b/tests/libgit2/repo/pathspec.c
diff --git a/tests/repo/repo_helpers.c b/tests/libgit2/repo/repo_helpers.c
index 1efde70a5..1efde70a5 100644
--- a/tests/repo/repo_helpers.c
+++ b/tests/libgit2/repo/repo_helpers.c
diff --git a/tests/repo/repo_helpers.h b/tests/libgit2/repo/repo_helpers.h
index a93bf36ae..a93bf36ae 100644
--- a/tests/repo/repo_helpers.h
+++ b/tests/libgit2/repo/repo_helpers.h
diff --git a/tests/repo/reservedname.c b/tests/libgit2/repo/reservedname.c
index 245d8625a..245d8625a 100644
--- a/tests/repo/reservedname.c
+++ b/tests/libgit2/repo/reservedname.c
diff --git a/tests/repo/setters.c b/tests/libgit2/repo/setters.c
index 9a965dec6..9a965dec6 100644
--- a/tests/repo/setters.c
+++ b/tests/libgit2/repo/setters.c
diff --git a/tests/repo/shallow.c b/tests/libgit2/repo/shallow.c
index adb7a9e44..adb7a9e44 100644
--- a/tests/repo/shallow.c
+++ b/tests/libgit2/repo/shallow.c
diff --git a/tests/repo/state.c b/tests/libgit2/repo/state.c
index 92b272dce..92b272dce 100644
--- a/tests/repo/state.c
+++ b/tests/libgit2/repo/state.c
diff --git a/tests/repo/template.c b/tests/libgit2/repo/template.c
index e8fe266cf..e8fe266cf 100644
--- a/tests/repo/template.c
+++ b/tests/libgit2/repo/template.c
diff --git a/tests/reset/default.c b/tests/libgit2/reset/default.c
index c76f14813..c76f14813 100644
--- a/tests/reset/default.c
+++ b/tests/libgit2/reset/default.c
diff --git a/tests/reset/hard.c b/tests/libgit2/reset/hard.c
index 9d177c021..9d177c021 100644
--- a/tests/reset/hard.c
+++ b/tests/libgit2/reset/hard.c
diff --git a/tests/reset/mixed.c b/tests/libgit2/reset/mixed.c
index 4a78d4c37..4a78d4c37 100644
--- a/tests/reset/mixed.c
+++ b/tests/libgit2/reset/mixed.c
diff --git a/tests/reset/reset_helpers.c b/tests/libgit2/reset/reset_helpers.c
index e6acec9ef..e6acec9ef 100644
--- a/tests/reset/reset_helpers.c
+++ b/tests/libgit2/reset/reset_helpers.c
diff --git a/tests/reset/reset_helpers.h b/tests/libgit2/reset/reset_helpers.h
index e7e048514..e7e048514 100644
--- a/tests/reset/reset_helpers.h
+++ b/tests/libgit2/reset/reset_helpers.h
diff --git a/tests/reset/soft.c b/tests/libgit2/reset/soft.c
index aca0834f2..aca0834f2 100644
--- a/tests/reset/soft.c
+++ b/tests/libgit2/reset/soft.c
diff --git a/tests/revert/bare.c b/tests/libgit2/revert/bare.c
index 9261cfe86..9261cfe86 100644
--- a/tests/revert/bare.c
+++ b/tests/libgit2/revert/bare.c
diff --git a/tests/revert/rename.c b/tests/libgit2/revert/rename.c
index 0d713c60f..0d713c60f 100644
--- a/tests/revert/rename.c
+++ b/tests/libgit2/revert/rename.c
diff --git a/tests/revert/workdir.c b/tests/libgit2/revert/workdir.c
index 3f54280ca..3f54280ca 100644
--- a/tests/revert/workdir.c
+++ b/tests/libgit2/revert/workdir.c
diff --git a/tests/revwalk/basic.c b/tests/libgit2/revwalk/basic.c
index 2c8d885e2..2c8d885e2 100644
--- a/tests/revwalk/basic.c
+++ b/tests/libgit2/revwalk/basic.c
diff --git a/tests/revwalk/hidecb.c b/tests/libgit2/revwalk/hidecb.c
index 54315bc77..54315bc77 100644
--- a/tests/revwalk/hidecb.c
+++ b/tests/libgit2/revwalk/hidecb.c
diff --git a/tests/revwalk/mergebase.c b/tests/libgit2/revwalk/mergebase.c
index 0378c869b..0378c869b 100644
--- a/tests/revwalk/mergebase.c
+++ b/tests/libgit2/revwalk/mergebase.c
diff --git a/tests/revwalk/signatureparsing.c b/tests/libgit2/revwalk/signatureparsing.c
index b312bad09..b312bad09 100644
--- a/tests/revwalk/signatureparsing.c
+++ b/tests/libgit2/revwalk/signatureparsing.c
diff --git a/tests/revwalk/simplify.c b/tests/libgit2/revwalk/simplify.c
index 6dd068a42..6dd068a42 100644
--- a/tests/revwalk/simplify.c
+++ b/tests/libgit2/revwalk/simplify.c
diff --git a/tests/stash/apply.c b/tests/libgit2/stash/apply.c
index 5125ae639..5125ae639 100644
--- a/tests/stash/apply.c
+++ b/tests/libgit2/stash/apply.c
diff --git a/tests/stash/drop.c b/tests/libgit2/stash/drop.c
index a57147172..a57147172 100644
--- a/tests/stash/drop.c
+++ b/tests/libgit2/stash/drop.c
diff --git a/tests/stash/foreach.c b/tests/libgit2/stash/foreach.c
index fa3a9c906..fa3a9c906 100644
--- a/tests/stash/foreach.c
+++ b/tests/libgit2/stash/foreach.c
diff --git a/tests/stash/save.c b/tests/libgit2/stash/save.c
index f574211d7..f574211d7 100644
--- a/tests/stash/save.c
+++ b/tests/libgit2/stash/save.c
diff --git a/tests/stash/stash_helpers.c b/tests/libgit2/stash/stash_helpers.c
index cd0cfbd0f..cd0cfbd0f 100644
--- a/tests/stash/stash_helpers.c
+++ b/tests/libgit2/stash/stash_helpers.c
diff --git a/tests/stash/stash_helpers.h b/tests/libgit2/stash/stash_helpers.h
index 66d758fe2..66d758fe2 100644
--- a/tests/stash/stash_helpers.h
+++ b/tests/libgit2/stash/stash_helpers.h
diff --git a/tests/stash/submodules.c b/tests/libgit2/stash/submodules.c
index 8cadca0f2..8cadca0f2 100644
--- a/tests/stash/submodules.c
+++ b/tests/libgit2/stash/submodules.c
diff --git a/tests/status/renames.c b/tests/libgit2/status/renames.c
index d5cf87d07..d5cf87d07 100644
--- a/tests/status/renames.c
+++ b/tests/libgit2/status/renames.c
diff --git a/tests/status/single.c b/tests/libgit2/status/single.c
index e7f92097c..e7f92097c 100644
--- a/tests/status/single.c
+++ b/tests/libgit2/status/single.c
diff --git a/tests/status/status_data.h b/tests/libgit2/status/status_data.h
index 09b9827f2..09b9827f2 100644
--- a/tests/status/status_data.h
+++ b/tests/libgit2/status/status_data.h
diff --git a/tests/status/status_helpers.c b/tests/libgit2/status/status_helpers.c
index 5d13caa9a..5d13caa9a 100644
--- a/tests/status/status_helpers.c
+++ b/tests/libgit2/status/status_helpers.c
diff --git a/tests/status/status_helpers.h b/tests/libgit2/status/status_helpers.h
index 464266af3..464266af3 100644
--- a/tests/status/status_helpers.h
+++ b/tests/libgit2/status/status_helpers.h
diff --git a/tests/status/submodules.c b/tests/libgit2/status/submodules.c
index d223657b4..d223657b4 100644
--- a/tests/status/submodules.c
+++ b/tests/libgit2/status/submodules.c
diff --git a/tests/status/worktree.c b/tests/libgit2/status/worktree.c
index 00c6ec2d5..00c6ec2d5 100644
--- a/tests/status/worktree.c
+++ b/tests/libgit2/status/worktree.c
diff --git a/tests/status/worktree_init.c b/tests/libgit2/status/worktree_init.c
index 40f1b2a31..40f1b2a31 100644
--- a/tests/status/worktree_init.c
+++ b/tests/libgit2/status/worktree_init.c
diff --git a/tests/stream/deprecated.c b/tests/libgit2/stream/deprecated.c
index fecd1be03..fecd1be03 100644
--- a/tests/stream/deprecated.c
+++ b/tests/libgit2/stream/deprecated.c
diff --git a/tests/stream/registration.c b/tests/libgit2/stream/registration.c
index bf3c20502..bf3c20502 100644
--- a/tests/stream/registration.c
+++ b/tests/libgit2/stream/registration.c
diff --git a/tests/stress/diff.c b/tests/libgit2/stress/diff.c
index aecf08bbe..aecf08bbe 100644
--- a/tests/stress/diff.c
+++ b/tests/libgit2/stress/diff.c
diff --git a/tests/submodule/add.c b/tests/libgit2/submodule/add.c
index ae5507d7f..ae5507d7f 100644
--- a/tests/submodule/add.c
+++ b/tests/libgit2/submodule/add.c
diff --git a/tests/submodule/escape.c b/tests/libgit2/submodule/escape.c
index bcd52b510..bcd52b510 100644
--- a/tests/submodule/escape.c
+++ b/tests/libgit2/submodule/escape.c
diff --git a/tests/submodule/init.c b/tests/libgit2/submodule/init.c
index a8e1291c4..a8e1291c4 100644
--- a/tests/submodule/init.c
+++ b/tests/libgit2/submodule/init.c
diff --git a/tests/submodule/inject_option.c b/tests/libgit2/submodule/inject_option.c
index e28ff8489..e28ff8489 100644
--- a/tests/submodule/inject_option.c
+++ b/tests/libgit2/submodule/inject_option.c
diff --git a/tests/submodule/lookup.c b/tests/libgit2/submodule/lookup.c
index acfdc838c..acfdc838c 100644
--- a/tests/submodule/lookup.c
+++ b/tests/libgit2/submodule/lookup.c
diff --git a/tests/submodule/modify.c b/tests/libgit2/submodule/modify.c
index 7e7f0ca15..7e7f0ca15 100644
--- a/tests/submodule/modify.c
+++ b/tests/libgit2/submodule/modify.c
diff --git a/tests/submodule/nosubs.c b/tests/libgit2/submodule/nosubs.c
index e82230e87..e82230e87 100644
--- a/tests/submodule/nosubs.c
+++ b/tests/libgit2/submodule/nosubs.c
diff --git a/tests/submodule/open.c b/tests/libgit2/submodule/open.c
index e6883d208..e6883d208 100644
--- a/tests/submodule/open.c
+++ b/tests/libgit2/submodule/open.c
diff --git a/tests/submodule/repository_init.c b/tests/libgit2/submodule/repository_init.c
index 39b55c403..39b55c403 100644
--- a/tests/submodule/repository_init.c
+++ b/tests/libgit2/submodule/repository_init.c
diff --git a/tests/submodule/status.c b/tests/libgit2/submodule/status.c
index 1d41337b7..1d41337b7 100644
--- a/tests/submodule/status.c
+++ b/tests/libgit2/submodule/status.c
diff --git a/tests/submodule/submodule_helpers.c b/tests/libgit2/submodule/submodule_helpers.c
index b8fc9f60d..b8fc9f60d 100644
--- a/tests/submodule/submodule_helpers.c
+++ b/tests/libgit2/submodule/submodule_helpers.c
diff --git a/tests/submodule/submodule_helpers.h b/tests/libgit2/submodule/submodule_helpers.h
index 3c3f062ae..3c3f062ae 100644
--- a/tests/submodule/submodule_helpers.h
+++ b/tests/libgit2/submodule/submodule_helpers.h
diff --git a/tests/submodule/update.c b/tests/libgit2/submodule/update.c
index 4aa959852..4aa959852 100644
--- a/tests/submodule/update.c
+++ b/tests/libgit2/submodule/update.c
diff --git a/tests/threads/atomic.c b/tests/libgit2/threads/atomic.c
index 4d04a777a..4d04a777a 100644
--- a/tests/threads/atomic.c
+++ b/tests/libgit2/threads/atomic.c
diff --git a/tests/threads/basic.c b/tests/libgit2/threads/basic.c
index 2d7ddc26b..2d7ddc26b 100644
--- a/tests/threads/basic.c
+++ b/tests/libgit2/threads/basic.c
diff --git a/tests/threads/diff.c b/tests/libgit2/threads/diff.c
index 04c8cb97f..04c8cb97f 100644
--- a/tests/threads/diff.c
+++ b/tests/libgit2/threads/diff.c
diff --git a/tests/threads/iterator.c b/tests/libgit2/threads/iterator.c
index 33d1bda81..33d1bda81 100644
--- a/tests/threads/iterator.c
+++ b/tests/libgit2/threads/iterator.c
diff --git a/tests/threads/refdb.c b/tests/libgit2/threads/refdb.c
index a4630df6a..a4630df6a 100644
--- a/tests/threads/refdb.c
+++ b/tests/libgit2/threads/refdb.c
diff --git a/tests/threads/thread_helpers.c b/tests/libgit2/threads/thread_helpers.c
index 54bf6097d..54bf6097d 100644
--- a/tests/threads/thread_helpers.c
+++ b/tests/libgit2/threads/thread_helpers.c
diff --git a/tests/threads/thread_helpers.h b/tests/libgit2/threads/thread_helpers.h
index 0f23a4ce0..0f23a4ce0 100644
--- a/tests/threads/thread_helpers.h
+++ b/tests/libgit2/threads/thread_helpers.h
diff --git a/tests/threads/tlsdata.c b/tests/libgit2/threads/tlsdata.c
index 7c69b4444..7c69b4444 100644
--- a/tests/threads/tlsdata.c
+++ b/tests/libgit2/threads/tlsdata.c
diff --git a/tests/trace/trace.c b/tests/libgit2/trace/trace.c
index 097208bff..097208bff 100644
--- a/tests/trace/trace.c
+++ b/tests/libgit2/trace/trace.c
diff --git a/tests/trace/windows/stacktrace.c b/tests/libgit2/trace/windows/stacktrace.c
index 0a77ef99d..0a77ef99d 100644
--- a/tests/trace/windows/stacktrace.c
+++ b/tests/libgit2/trace/windows/stacktrace.c
diff --git a/tests/transport/register.c b/tests/libgit2/transport/register.c
index 88ba247de..88ba247de 100644
--- a/tests/transport/register.c
+++ b/tests/libgit2/transport/register.c
diff --git a/tests/transports/smart/packet.c b/tests/libgit2/transports/smart/packet.c
index 5b623a378..5b623a378 100644
--- a/tests/transports/smart/packet.c
+++ b/tests/libgit2/transports/smart/packet.c
diff --git a/tests/valgrind-supp-mac.txt b/tests/libgit2/valgrind-supp-mac.txt
index 3298abee6..3298abee6 100644
--- a/tests/valgrind-supp-mac.txt
+++ b/tests/libgit2/valgrind-supp-mac.txt
diff --git a/tests/win32/forbidden.c b/tests/libgit2/win32/forbidden.c
index 5c007987b..5c007987b 100644
--- a/tests/win32/forbidden.c
+++ b/tests/libgit2/win32/forbidden.c
diff --git a/tests/win32/longpath.c b/tests/libgit2/win32/longpath.c
index 4be86db5a..4be86db5a 100644
--- a/tests/win32/longpath.c
+++ b/tests/libgit2/win32/longpath.c
diff --git a/tests/win32/systemdir.c b/tests/libgit2/win32/systemdir.c
index 52c1784a1..52c1784a1 100644
--- a/tests/win32/systemdir.c
+++ b/tests/libgit2/win32/systemdir.c
diff --git a/tests/worktree/bare.c b/tests/libgit2/worktree/bare.c
index 7234dfffd..7234dfffd 100644
--- a/tests/worktree/bare.c
+++ b/tests/libgit2/worktree/bare.c
diff --git a/tests/worktree/config.c b/tests/libgit2/worktree/config.c
index 81dcfe1fa..81dcfe1fa 100644
--- a/tests/worktree/config.c
+++ b/tests/libgit2/worktree/config.c
diff --git a/tests/worktree/merge.c b/tests/libgit2/worktree/merge.c
index 5b7e2a837..5b7e2a837 100644
--- a/tests/worktree/merge.c
+++ b/tests/libgit2/worktree/merge.c
diff --git a/tests/worktree/open.c b/tests/libgit2/worktree/open.c
index 0c3fdc173..0c3fdc173 100644
--- a/tests/worktree/open.c
+++ b/tests/libgit2/worktree/open.c
diff --git a/tests/worktree/reflog.c b/tests/libgit2/worktree/reflog.c
index a68e72dcf..a68e72dcf 100644
--- a/tests/worktree/reflog.c
+++ b/tests/libgit2/worktree/reflog.c
diff --git a/tests/worktree/refs.c b/tests/libgit2/worktree/refs.c
index 557726aaf..557726aaf 100644
--- a/tests/worktree/refs.c
+++ b/tests/libgit2/worktree/refs.c
diff --git a/tests/worktree/repository.c b/tests/libgit2/worktree/repository.c
index c4eeadd35..c4eeadd35 100644
--- a/tests/worktree/repository.c
+++ b/tests/libgit2/worktree/repository.c
diff --git a/tests/worktree/submodule.c b/tests/libgit2/worktree/submodule.c
index 6b0c07452..6b0c07452 100644
--- a/tests/worktree/submodule.c
+++ b/tests/libgit2/worktree/submodule.c
diff --git a/tests/worktree/worktree.c b/tests/libgit2/worktree/worktree.c
index 66273d1cb..66273d1cb 100644
--- a/tests/worktree/worktree.c
+++ b/tests/libgit2/worktree/worktree.c
diff --git a/tests/worktree/worktree_helpers.c b/tests/libgit2/worktree/worktree_helpers.c
index 6d4cdbaeb..6d4cdbaeb 100644
--- a/tests/worktree/worktree_helpers.c
+++ b/tests/libgit2/worktree/worktree_helpers.c
diff --git a/tests/worktree/worktree_helpers.h b/tests/libgit2/worktree/worktree_helpers.h
index 35ea9ed4c..35ea9ed4c 100644
--- a/tests/worktree/worktree_helpers.h
+++ b/tests/libgit2/worktree/worktree_helpers.h
diff --git a/tests/path/dotgit.c b/tests/path/dotgit.c
deleted file mode 100644
index 855145f42..000000000
--- a/tests/path/dotgit.c
+++ /dev/null
@@ -1,206 +0,0 @@
-#include "clar_libgit2.h"
-
-#include "path.h"
-
-static char *gitmodules_altnames[] = {
- ".gitmodules",
-
- /*
- * Equivalent to the ".git\u200cmodules" string from git but hard-coded
- * as a UTF-8 sequence
- */
- ".git\xe2\x80\x8cmodules",
-
- ".Gitmodules",
- ".gitmoduleS",
-
- ".gitmodules ",
- ".gitmodules.",
- ".gitmodules ",
- ".gitmodules. ",
- ".gitmodules .",
- ".gitmodules..",
- ".gitmodules ",
- ".gitmodules. ",
- ".gitmodules . ",
- ".gitmodules .",
-
- ".Gitmodules ",
- ".Gitmodules.",
- ".Gitmodules ",
- ".Gitmodules. ",
- ".Gitmodules .",
- ".Gitmodules..",
- ".Gitmodules ",
- ".Gitmodules. ",
- ".Gitmodules . ",
- ".Gitmodules .",
-
- "GITMOD~1",
- "gitmod~1",
- "GITMOD~2",
- "gitmod~3",
- "GITMOD~4",
-
- "GITMOD~1 ",
- "gitmod~2.",
- "GITMOD~3 ",
- "gitmod~4. ",
- "GITMOD~1 .",
- "gitmod~2 ",
- "GITMOD~3. ",
- "gitmod~4 . ",
-
- "GI7EBA~1",
- "gi7eba~9",
-
- "GI7EB~10",
- "GI7EB~11",
- "GI7EB~99",
- "GI7EB~10",
- "GI7E~100",
- "GI7E~101",
- "GI7E~999",
- "~1000000",
- "~9999999",
-};
-
-static char *gitmodules_not_altnames[] = {
- ".gitmodules x",
- ".gitmodules .x",
-
- " .gitmodules",
-
- "..gitmodules",
-
- "gitmodules",
-
- ".gitmodule",
-
- ".gitmodules x ",
- ".gitmodules .x",
-
- "GI7EBA~",
- "GI7EBA~0",
- "GI7EBA~~1",
- "GI7EBA~X",
- "Gx7EBA~1",
- "GI7EBX~1",
-
- "GI7EB~1",
- "GI7EB~01",
- "GI7EB~1",
-};
-
-void test_path_dotgit__dotgit_modules(void)
-{
- size_t i;
-
- cl_assert_equal_i(1, git_path_is_gitfile(".gitmodules", strlen(".gitmodules"), GIT_PATH_GITFILE_GITMODULES, GIT_PATH_FS_GENERIC));
- cl_assert_equal_i(1, git_path_is_gitfile(".git\xe2\x80\x8cmodules", strlen(".git\xe2\x80\x8cmodules"), GIT_PATH_GITFILE_GITMODULES, GIT_PATH_FS_GENERIC));
-
- for (i = 0; i < ARRAY_SIZE(gitmodules_altnames); i++) {
- const char *name = gitmodules_altnames[i];
- if (!git_path_is_gitfile(name, strlen(name), GIT_PATH_GITFILE_GITMODULES, GIT_PATH_FS_GENERIC))
- cl_fail(name);
- }
-
- for (i = 0; i < ARRAY_SIZE(gitmodules_not_altnames); i++) {
- const char *name = gitmodules_not_altnames[i];
- if (git_path_is_gitfile(name, strlen(name), GIT_PATH_GITFILE_GITMODULES, GIT_PATH_FS_GENERIC))
- cl_fail(name);
- }
-}
-
-void test_path_dotgit__dotgit_modules_symlink(void)
-{
- cl_assert_equal_b(true, git_path_is_valid(NULL, ".gitmodules", 0, GIT_PATH_REJECT_DOT_GIT_HFS|GIT_PATH_REJECT_DOT_GIT_NTFS));
- cl_assert_equal_b(false, git_path_is_valid(NULL, ".gitmodules", S_IFLNK, GIT_PATH_REJECT_DOT_GIT_HFS));
- cl_assert_equal_b(false, git_path_is_valid(NULL, ".gitmodules", S_IFLNK, GIT_PATH_REJECT_DOT_GIT_NTFS));
- cl_assert_equal_b(false, git_path_is_valid(NULL, ".gitmodules . .::$DATA", S_IFLNK, GIT_PATH_REJECT_DOT_GIT_NTFS));
-}
-
-void test_path_dotgit__git_fs_path_is_file(void)
-{
- cl_git_fail(git_path_is_gitfile("blob", 4, -1, GIT_PATH_FS_HFS));
- cl_git_pass(git_path_is_gitfile("blob", 4, GIT_PATH_GITFILE_GITIGNORE, GIT_PATH_FS_HFS));
- cl_git_pass(git_path_is_gitfile("blob", 4, GIT_PATH_GITFILE_GITMODULES, GIT_PATH_FS_HFS));
- cl_git_pass(git_path_is_gitfile("blob", 4, GIT_PATH_GITFILE_GITATTRIBUTES, GIT_PATH_FS_HFS));
- cl_git_fail(git_path_is_gitfile("blob", 4, 3, GIT_PATH_FS_HFS));
-}
-
-void test_path_dotgit__isvalid_dot_git(void)
-{
- cl_assert_equal_b(true, git_path_is_valid(NULL, ".git", 0, 0));
- cl_assert_equal_b(true, git_path_is_valid(NULL, ".git/foo", 0, 0));
- cl_assert_equal_b(true, git_path_is_valid(NULL, "foo/.git", 0, 0));
- cl_assert_equal_b(true, git_path_is_valid(NULL, "foo/.git/bar", 0, 0));
- cl_assert_equal_b(true, git_path_is_valid(NULL, "foo/.GIT/bar", 0, 0));
- cl_assert_equal_b(true, git_path_is_valid(NULL, "foo/bar/.Git", 0, 0));
-
- cl_assert_equal_b(false, git_path_is_valid(NULL, ".git", 0, GIT_PATH_REJECT_DOT_GIT_LITERAL));
- cl_assert_equal_b(false, git_path_is_valid(NULL, ".git/foo", 0, GIT_PATH_REJECT_DOT_GIT_LITERAL));
- cl_assert_equal_b(false, git_path_is_valid(NULL, "foo/.git", 0, GIT_PATH_REJECT_DOT_GIT_LITERAL));
- cl_assert_equal_b(false, git_path_is_valid(NULL, "foo/.git/bar", 0, GIT_PATH_REJECT_DOT_GIT_LITERAL));
- cl_assert_equal_b(false, git_path_is_valid(NULL, "foo/.GIT/bar", 0, GIT_PATH_REJECT_DOT_GIT_LITERAL));
- cl_assert_equal_b(false, git_path_is_valid(NULL, "foo/bar/.Git", 0, GIT_PATH_REJECT_DOT_GIT_LITERAL));
-
- cl_assert_equal_b(true, git_path_is_valid(NULL, "!git", 0, 0));
- cl_assert_equal_b(true, git_path_is_valid(NULL, "foo/!git", 0, 0));
- cl_assert_equal_b(true, git_path_is_valid(NULL, "!git/bar", 0, 0));
- cl_assert_equal_b(true, git_path_is_valid(NULL, ".tig", 0, 0));
- cl_assert_equal_b(true, git_path_is_valid(NULL, "foo/.tig", 0, 0));
- cl_assert_equal_b(true, git_path_is_valid(NULL, ".tig/bar", 0, 0));
-}
-
-void test_path_dotgit__isvalid_dotgit_ntfs(void)
-{
- cl_assert_equal_b(true, git_path_is_valid(NULL, ".git", 0, 0));
- cl_assert_equal_b(true, git_path_is_valid(NULL, ".git ", 0, 0));
- cl_assert_equal_b(true, git_path_is_valid(NULL, ".git.", 0, 0));
- cl_assert_equal_b(true, git_path_is_valid(NULL, ".git.. .", 0, 0));
-
- cl_assert_equal_b(true, git_path_is_valid(NULL, "git~1", 0, 0));
- cl_assert_equal_b(true, git_path_is_valid(NULL, "git~1 ", 0, 0));
- cl_assert_equal_b(true, git_path_is_valid(NULL, "git~1.", 0, 0));
- cl_assert_equal_b(true, git_path_is_valid(NULL, "git~1.. .", 0, 0));
-
- cl_assert_equal_b(false, git_path_is_valid(NULL, ".git", 0, GIT_PATH_REJECT_DOT_GIT_NTFS));
- cl_assert_equal_b(false, git_path_is_valid(NULL, ".git ", 0, GIT_PATH_REJECT_DOT_GIT_NTFS));
- cl_assert_equal_b(false, git_path_is_valid(NULL, ".git.", 0, GIT_PATH_REJECT_DOT_GIT_NTFS));
- cl_assert_equal_b(false, git_path_is_valid(NULL, ".git.. .", 0, GIT_PATH_REJECT_DOT_GIT_NTFS));
-
- cl_assert_equal_b(false, git_path_is_valid(NULL, "git~1", 0, GIT_PATH_REJECT_DOT_GIT_NTFS));
- cl_assert_equal_b(false, git_path_is_valid(NULL, "git~1 ", 0, GIT_PATH_REJECT_DOT_GIT_NTFS));
- cl_assert_equal_b(false, git_path_is_valid(NULL, "git~1.", 0, GIT_PATH_REJECT_DOT_GIT_NTFS));
- cl_assert_equal_b(false, git_path_is_valid(NULL, "git~1.. .", 0, GIT_PATH_REJECT_DOT_GIT_NTFS));
-}
-
-void test_path_dotgit__isvalid_dotgit_with_hfs_ignorables(void)
-{
- cl_assert_equal_b(false, git_path_is_valid(NULL, ".git", 0, GIT_PATH_REJECT_DOT_GIT_HFS));
- cl_assert_equal_b(false, git_path_is_valid(NULL, ".git\xe2\x80\x8c", 0, GIT_PATH_REJECT_DOT_GIT_HFS));
- cl_assert_equal_b(false, git_path_is_valid(NULL, ".gi\xe2\x80\x8dT", 0, GIT_PATH_REJECT_DOT_GIT_HFS));
- cl_assert_equal_b(false, git_path_is_valid(NULL, ".g\xe2\x80\x8eIt", 0, GIT_PATH_REJECT_DOT_GIT_HFS));
- cl_assert_equal_b(false, git_path_is_valid(NULL, ".\xe2\x80\x8fgIt", 0, GIT_PATH_REJECT_DOT_GIT_HFS));
- cl_assert_equal_b(false, git_path_is_valid(NULL, "\xe2\x80\xaa.gIt", 0, GIT_PATH_REJECT_DOT_GIT_HFS));
-
- cl_assert_equal_b(false, git_path_is_valid(NULL, "\xe2\x80\xab.\xe2\x80\xacG\xe2\x80\xadI\xe2\x80\xaet", 0, GIT_PATH_REJECT_DOT_GIT_HFS));
- cl_assert_equal_b(false, git_path_is_valid(NULL, "\xe2\x81\xab.\xe2\x80\xaaG\xe2\x81\xabI\xe2\x80\xact", 0, GIT_PATH_REJECT_DOT_GIT_HFS));
- cl_assert_equal_b(false, git_path_is_valid(NULL, "\xe2\x81\xad.\xe2\x80\xaeG\xef\xbb\xbfIT", 0, GIT_PATH_REJECT_DOT_GIT_HFS));
-
- cl_assert_equal_b(true, git_path_is_valid(NULL, ".", 0, GIT_PATH_REJECT_DOT_GIT_HFS));
- cl_assert_equal_b(true, git_path_is_valid(NULL, ".g", 0, GIT_PATH_REJECT_DOT_GIT_HFS));
- cl_assert_equal_b(true, git_path_is_valid(NULL, ".gi", 0, GIT_PATH_REJECT_DOT_GIT_HFS));
- cl_assert_equal_b(true, git_path_is_valid(NULL, " .git", 0, GIT_PATH_REJECT_DOT_GIT_HFS));
- cl_assert_equal_b(true, git_path_is_valid(NULL, "..git\xe2\x80\x8c", 0, GIT_PATH_REJECT_DOT_GIT_HFS));
- cl_assert_equal_b(true, git_path_is_valid(NULL, ".gi\xe2\x80\x8dT.", 0, GIT_PATH_REJECT_DOT_GIT_HFS));
- cl_assert_equal_b(true, git_path_is_valid(NULL, ".g\xe2\x80It", 0, GIT_PATH_REJECT_DOT_GIT_HFS));
- cl_assert_equal_b(true, git_path_is_valid(NULL, ".\xe2gIt", 0, GIT_PATH_REJECT_DOT_GIT_HFS));
- cl_assert_equal_b(true, git_path_is_valid(NULL, "\xe2\x80\xaa.gi", 0, GIT_PATH_REJECT_DOT_GIT_HFS));
- cl_assert_equal_b(true, git_path_is_valid(NULL, ".gi\x80\x8dT", 0, GIT_PATH_REJECT_DOT_GIT_HFS));
- cl_assert_equal_b(true, git_path_is_valid(NULL, ".gi\x8dT", 0, GIT_PATH_REJECT_DOT_GIT_HFS));
- cl_assert_equal_b(true, git_path_is_valid(NULL, ".g\xe2i\x80T\x8e", 0, GIT_PATH_REJECT_DOT_GIT_HFS));
- cl_assert_equal_b(true, git_path_is_valid(NULL, ".git\xe2\x80\xbf", 0, GIT_PATH_REJECT_DOT_GIT_HFS));
- cl_assert_equal_b(true, git_path_is_valid(NULL, ".git\xe2\xab\x81", 0, GIT_PATH_REJECT_DOT_GIT_HFS));
-}
diff --git a/tests/util/CMakeLists.txt b/tests/util/CMakeLists.txt
new file mode 100644
index 000000000..232590ffd
--- /dev/null
+++ b/tests/util/CMakeLists.txt
@@ -0,0 +1,68 @@
+# util: the unit tests for libgit2's utility library
+
+set(Python_ADDITIONAL_VERSIONS 3 2.7)
+find_package(PythonInterp)
+
+if(NOT PYTHONINTERP_FOUND)
+ message(FATAL_ERROR "Could not find a python interpeter, which is needed to build the tests. "
+ "Make sure python is available, or pass -DBUILD_TESTS=OFF to skip building the tests")
+ENDIF()
+
+set(CLAR_PATH "${libgit2_SOURCE_DIR}/tests/clar")
+set(CLAR_FIXTURES "${libgit2_SOURCE_DIR}/tests/resources/")
+set(TEST_PATH "${CMAKE_CURRENT_SOURCE_DIR}")
+add_definitions(-DCLAR_FIXTURE_PATH=\"${CLAR_FIXTURES}\")
+add_definitions(-DCLAR_TMPDIR=\"libgit2_tests\")
+add_definitions(-DCLAR_WIN32_LONGPATHS)
+add_definitions(-D_FILE_OFFSET_BITS=64)
+
+# Ensure that we do not use deprecated functions internally
+add_definitions(-DGIT_DEPRECATE_HARD)
+
+set(TEST_INCLUDES "${CLAR_PATH}" "${TEST_PATH}" "${CMAKE_CURRENT_BINARY_DIR}")
+file(GLOB_RECURSE SRC_TEST ${TEST_PATH}/*.c ${TEST_PATH}/*.h ${TEST_PATH}/*/*.c ${TEST_PATH}/*/*.h)
+file(GLOB_RECURSE SRC_CLAR ${CLAR_PATH}/*.c ${CLAR_PATH}/*.h)
+
+if(MSVC_IDE)
+ list(APPEND SRC_TEST "precompiled.c")
+endif()
+
+add_custom_command(
+ OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/clar.suite ${CMAKE_CURRENT_BINARY_DIR}/clar_suite.h
+ COMMAND ${PYTHON_EXECUTABLE} ${CLAR_PATH}/generate.py -o "${CMAKE_CURRENT_BINARY_DIR}" -f .
+ DEPENDS ${SRC_TEST}
+ WORKING_DIRECTORY ${TEST_PATH})
+
+set_source_files_properties(
+ ${CLAR_PATH}/clar.c
+ PROPERTIES OBJECT_DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/clar.suite)
+
+add_executable(util_tests ${SRC_CLAR} ${SRC_TEST} ${LIBGIT2_OBJECTS})
+
+set_target_properties(util_tests PROPERTIES C_STANDARD 90)
+set_target_properties(util_tests PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${libgit2_BINARY_DIR})
+
+target_include_directories(util_tests PRIVATE ${TEST_INCLUDES} ${LIBGIT2_INCLUDES} ${LIBGIT2_DEPENDENCY_INCLUDES})
+target_include_directories(util_tests SYSTEM PRIVATE ${LIBGIT2_SYSTEM_INCLUDES})
+target_link_libraries(util_tests ${LIBGIT2_SYSTEM_LIBS})
+
+ide_split_sources(util_tests)
+
+#
+# Old versions of gcc require us to declare our test functions; don't do
+# this on newer compilers to avoid unnecessary recompilation.
+#
+if(CMAKE_COMPILER_IS_GNUCC AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 6.0)
+ target_compile_options(util_tests PRIVATE -include "clar_suite.h")
+endif()
+
+if(MSVC_IDE)
+ # Precompiled headers
+ set_target_properties(util_tests PROPERTIES COMPILE_FLAGS "/Yuprecompiled.h /FIprecompiled.h")
+ set_source_files_properties("precompiled.c" COMPILE_FLAGS "/Ycprecompiled.h")
+endif()
+
+enable_testing()
+
+include(AddClarTest)
+add_clar_test(util_tests util -v)
diff --git a/tests/core/array.c b/tests/util/array.c
index 8e626a506..39fbc811d 100644
--- a/tests/core/array.c
+++ b/tests/util/array.c
@@ -15,7 +15,7 @@ static int int_lookup(const void *k, const void *a)
git_array_search(&p, integers, int_lookup, &key)); \
cl_assert_equal_i((n), p);
-void test_core_array__bsearch2(void)
+void test_array__bsearch2(void)
{
git_array_t(int) integers = GIT_ARRAY_INIT;
int *i, key;
diff --git a/tests/core/assert.c b/tests/util/assert.c
index ef75624b9..26c429787 100644
--- a/tests/core/assert.c
+++ b/tests/util/assert.c
@@ -36,7 +36,7 @@ static const char *bad_returns_string(void)
return hello_world;
}
-void test_core_assert__argument(void)
+void test_assert__argument(void)
{
cl_git_fail(dummy_fn(NULL));
cl_assert(git_error_last());
@@ -51,7 +51,7 @@ void test_core_assert__argument(void)
cl_git_pass(dummy_fn("foo"));
}
-void test_core_assert__argument_with_non_int_return_type(void)
+void test_assert__argument_with_non_int_return_type(void)
{
const char *foo = "foo";
@@ -66,7 +66,7 @@ void test_core_assert__argument_with_non_int_return_type(void)
cl_assert_equal_p(foo, fn_returns_string(foo));
}
-void test_core_assert__argument_with_void_return_type(void)
+void test_assert__argument_with_void_return_type(void)
{
const char *foo = "foo";
@@ -80,7 +80,7 @@ void test_core_assert__argument_with_void_return_type(void)
cl_assert_equal_p(NULL, git_error_last());
}
-void test_core_assert__internal(void)
+void test_assert__internal(void)
{
cl_git_fail(bad_math());
cl_assert(git_error_last());
diff --git a/tests/core/bitvec.c b/tests/util/bitvec.c
index 48d7b99f0..f7845895b 100644
--- a/tests/core/bitvec.c
+++ b/tests/util/bitvec.c
@@ -35,7 +35,7 @@ static void check_some_bits(git_bitvec *bv, size_t length)
cl_assert_equal_b(i % 3 == 0 || i % 7 == 0, git_bitvec_get(bv, i));
}
-void test_core_bitvec__0(void)
+void test_bitvec__0(void)
{
git_bitvec bv;
diff --git a/tests/core/copy.c b/tests/util/copy.c
index 6d22b503d..9b9f6bafc 100644
--- a/tests/core/copy.c
+++ b/tests/util/copy.c
@@ -2,7 +2,7 @@
#include "futils.h"
#include "posix.h"
-void test_core_copy__file(void)
+void test_copy__file(void)
{
struct stat st;
const char *content = "This is some stuff to copy\n";
@@ -19,7 +19,7 @@ void test_core_copy__file(void)
cl_git_pass(p_unlink("copy_me"));
}
-void test_core_copy__file_in_dir(void)
+void test_copy__file_in_dir(void)
{
struct stat st;
const char *content = "This is some other stuff to copy\n";
@@ -56,7 +56,7 @@ static void assert_hard_link(const char *path)
}
#endif
-void test_core_copy__tree(void)
+void test_copy__tree(void)
{
struct stat st;
const char *content = "File content\n";
diff --git a/tests/util/crlf.h b/tests/util/crlf.h
new file mode 100644
index 000000000..786edfc96
--- /dev/null
+++ b/tests/util/crlf.h
@@ -0,0 +1,30 @@
+#ifndef INCLUDE_filter_crlf_h__
+#define INCLUDE_filter_crlf_h__
+
+/*
+ * file content for files in the resources/crlf repository
+ */
+
+#define UTF8_BOM "\xEF\xBB\xBF"
+
+#define ALL_CRLF_TEXT_RAW "crlf\r\ncrlf\r\ncrlf\r\ncrlf\r\n"
+#define ALL_LF_TEXT_RAW "lf\nlf\nlf\nlf\nlf\n"
+#define MORE_CRLF_TEXT_RAW "crlf\r\ncrlf\r\nlf\ncrlf\r\ncrlf\r\n"
+#define MORE_LF_TEXT_RAW "lf\nlf\ncrlf\r\nlf\nlf\n"
+
+#define ALL_CRLF_TEXT_AS_CRLF ALL_CRLF_TEXT_RAW
+#define ALL_LF_TEXT_AS_CRLF "lf\r\nlf\r\nlf\r\nlf\r\nlf\r\n"
+#define MORE_CRLF_TEXT_AS_CRLF "crlf\r\ncrlf\r\nlf\r\ncrlf\r\ncrlf\r\n"
+#define MORE_LF_TEXT_AS_CRLF "lf\r\nlf\r\ncrlf\r\nlf\r\nlf\r\n"
+
+#define ALL_CRLF_TEXT_AS_LF "crlf\ncrlf\ncrlf\ncrlf\n"
+#define ALL_LF_TEXT_AS_LF ALL_LF_TEXT_RAW
+#define MORE_CRLF_TEXT_AS_LF "crlf\ncrlf\nlf\ncrlf\ncrlf\n"
+#define MORE_LF_TEXT_AS_LF "lf\nlf\ncrlf\nlf\nlf\n"
+
+#define FEW_UTF8_CRLF_RAW "\xe2\x9a\xbdThe rest is ASCII01.\r\nThe rest is ASCII02.\r\nThe rest is ASCII03.\r\nThe rest is ASCII04.\r\nThe rest is ASCII05.\r\nThe rest is ASCII06.\r\nThe rest is ASCII07.\r\nThe rest is ASCII08.\r\nThe rest is ASCII09.\r\nThe rest is ASCII10.\r\nThe rest is ASCII11.\r\nThe rest is ASCII12.\r\nThe rest is ASCII13.\r\nThe rest is ASCII14.\r\nThe rest is ASCII15.\r\nThe rest is ASCII16.\r\nThe rest is ASCII17.\r\nThe rest is ASCII18.\r\nThe rest is ASCII19.\r\nThe rest is ASCII20.\r\nThe rest is ASCII21.\r\nThe rest is ASCII22.\r\n"
+#define FEW_UTF8_LF_RAW "\xe2\x9a\xbdThe rest is ASCII01.\nThe rest is ASCII02.\nThe rest is ASCII03.\nThe rest is ASCII04.\nThe rest is ASCII05.\nThe rest is ASCII06.\nThe rest is ASCII07.\nThe rest is ASCII08.\nThe rest is ASCII09.\nThe rest is ASCII10.\nThe rest is ASCII11.\nThe rest is ASCII12.\nThe rest is ASCII13.\nThe rest is ASCII14.\nThe rest is ASCII15.\nThe rest is ASCII16.\nThe rest is ASCII17.\nThe rest is ASCII18.\nThe rest is ASCII19.\nThe rest is ASCII20.\nThe rest is ASCII21.\nThe rest is ASCII22.\n"
+#define MANY_UTF8_CRLF_RAW "Lets sing!\r\n\xe2\x99\xab\xe2\x99\xaa\xe2\x99\xac\xe2\x99\xa9\r\nEat food\r\n\xf0\x9f\x8d\x85\xf0\x9f\x8d\x95\r\n"
+#define MANY_UTF8_LF_RAW "Lets sing!\n\xe2\x99\xab\xe2\x99\xaa\xe2\x99\xac\xe2\x99\xa9\nEat food\n\xf0\x9f\x8d\x85\xf0\x9f\x8d\x95\n"
+
+#endif
diff --git a/tests/core/dirent.c b/tests/util/dirent.c
index 2419ec7ab..5840c67e0 100644
--- a/tests/core/dirent.c
+++ b/tests/util/dirent.c
@@ -108,7 +108,7 @@ static walk_data dot = {
};
/* make sure that the '.' folder is not traversed */
-void test_core_dirent__dont_traverse_dot(void)
+void test_dirent__dont_traverse_dot(void)
{
cl_set_cleanup(&dirent_cleanup__cb, &dot);
setup(&dot);
@@ -132,7 +132,7 @@ static walk_data sub = {
};
/* traverse a subfolder */
-void test_core_dirent__traverse_subfolder(void)
+void test_dirent__traverse_subfolder(void)
{
cl_set_cleanup(&dirent_cleanup__cb, &sub);
setup(&sub);
@@ -150,7 +150,7 @@ static walk_data sub_slash = {
};
/* traverse a slash-terminated subfolder */
-void test_core_dirent__traverse_slash_terminated_folder(void)
+void test_dirent__traverse_slash_terminated_folder(void)
{
cl_set_cleanup(&dirent_cleanup__cb, &sub_slash);
setup(&sub_slash);
@@ -171,7 +171,7 @@ static walk_data empty = {
};
/* make sure that empty folders are not traversed */
-void test_core_dirent__dont_traverse_empty_folders(void)
+void test_dirent__dont_traverse_empty_folders(void)
{
cl_set_cleanup(&dirent_cleanup__cb, &empty);
setup(&empty);
@@ -199,7 +199,7 @@ static walk_data odd = {
};
/* make sure that strange looking filenames ('..c') are traversed */
-void test_core_dirent__traverse_weird_filenames(void)
+void test_dirent__traverse_weird_filenames(void)
{
cl_set_cleanup(&dirent_cleanup__cb, &odd);
setup(&odd);
@@ -210,7 +210,7 @@ void test_core_dirent__traverse_weird_filenames(void)
}
/* test filename length limits */
-void test_core_dirent__length_limits(void)
+void test_dirent__length_limits(void)
{
char *big_filename = (char *)git__malloc(FILENAME_MAX + 1);
memset(big_filename, 'a', FILENAME_MAX + 1);
@@ -221,7 +221,7 @@ void test_core_dirent__length_limits(void)
git__free(big_filename);
}
-void test_core_dirent__empty_dir(void)
+void test_dirent__empty_dir(void)
{
cl_must_pass(p_mkdir("empty_dir", 0777));
cl_assert(git_fs_path_is_empty_dir("empty_dir"));
@@ -256,7 +256,7 @@ static void handle_next(git_fs_path_diriter *diriter, walk_data *walk)
}
/* test directory iterator */
-void test_core_dirent__diriter_with_fullname(void)
+void test_dirent__diriter_with_fullname(void)
{
git_fs_path_diriter diriter = GIT_FS_PATH_DIRITER_INIT;
int error;
@@ -276,7 +276,7 @@ void test_core_dirent__diriter_with_fullname(void)
check_counts(&sub);
}
-void test_core_dirent__diriter_at_directory_root(void)
+void test_dirent__diriter_at_directory_root(void)
{
git_fs_path_diriter diriter = GIT_FS_PATH_DIRITER_INIT;
const char *sandbox_path, *path;
diff --git a/tests/core/encoding.c b/tests/util/encoding.c
index 6cec24679..a25a33443 100644
--- a/tests/core/encoding.c
+++ b/tests/util/encoding.c
@@ -1,7 +1,7 @@
#include "clar_libgit2.h"
#include "varint.h"
-void test_core_encoding__decode(void)
+void test_encoding__decode(void)
{
const unsigned char *buf = (unsigned char *)"AB";
size_t size;
@@ -23,7 +23,7 @@ void test_core_encoding__decode(void)
}
-void test_core_encoding__encode(void)
+void test_encoding__encode(void)
{
unsigned char buf[100];
cl_assert(git_encode_varint(buf, 100, 65) == 1);
diff --git a/tests/core/errors.c b/tests/util/errors.c
index 386ecdc5f..78654a753 100644
--- a/tests/core/errors.c
+++ b/tests/util/errors.c
@@ -1,6 +1,6 @@
#include "clar_libgit2.h"
-void test_core_errors__public_api(void)
+void test_errors__public_api(void)
{
char *str_in_error;
@@ -30,7 +30,7 @@ void test_core_errors__public_api(void)
#include "util.h"
#include "posix.h"
-void test_core_errors__new_school(void)
+void test_errors__new_school(void)
{
char *str_in_error;
@@ -86,7 +86,7 @@ void test_core_errors__new_school(void)
git_error_clear();
}
-void test_core_errors__restore(void)
+void test_errors__restore(void)
{
git_error_state err_state = {0};
@@ -110,7 +110,7 @@ void test_core_errors__restore(void)
cl_assert_equal_s("Foo: bar", git_error_last()->message);
}
-void test_core_errors__free_state(void)
+void test_errors__free_state(void)
{
git_error_state err_state = {0};
@@ -131,7 +131,7 @@ void test_core_errors__free_state(void)
cl_assert(git_error_last() == NULL);
}
-void test_core_errors__restore_oom(void)
+void test_errors__restore_oom(void)
{
git_error_state err_state = {0};
const git_error *oom_error = NULL;
@@ -163,7 +163,7 @@ static int test_arraysize_multiply(size_t nelem, size_t size)
return 0;
}
-void test_core_errors__integer_overflow_alloc_multiply(void)
+void test_errors__integer_overflow_alloc_multiply(void)
{
cl_git_pass(test_arraysize_multiply(10, 10));
cl_git_pass(test_arraysize_multiply(1000, 1000));
@@ -185,7 +185,7 @@ static int test_arraysize_add(size_t one, size_t two)
return 0;
}
-void test_core_errors__integer_overflow_alloc_add(void)
+void test_errors__integer_overflow_alloc_add(void)
{
cl_git_pass(test_arraysize_add(10, 10));
cl_git_pass(test_arraysize_add(1000, 1000));
@@ -198,7 +198,7 @@ void test_core_errors__integer_overflow_alloc_add(void)
cl_assert_equal_s("Out of memory", git_error_last()->message);
}
-void test_core_errors__integer_overflow_sets_oom(void)
+void test_errors__integer_overflow_sets_oom(void)
{
size_t out;
diff --git a/tests/core/filebuf.c b/tests/util/filebuf.c
index 6f40c2456..29b821144 100644
--- a/tests/core/filebuf.c
+++ b/tests/util/filebuf.c
@@ -2,7 +2,7 @@
#include "filebuf.h"
/* make sure git_filebuf_open doesn't delete an existing lock */
-void test_core_filebuf__0(void)
+void test_filebuf__0(void)
{
git_filebuf file = GIT_FILEBUF_INIT;
int fd;
@@ -21,7 +21,7 @@ void test_core_filebuf__0(void)
/* make sure GIT_FILEBUF_APPEND works as expected */
-void test_core_filebuf__1(void)
+void test_filebuf__1(void)
{
git_filebuf file = GIT_FILEBUF_INIT;
char test[] = "test";
@@ -39,7 +39,7 @@ void test_core_filebuf__1(void)
/* make sure git_filebuf_write writes large buffer correctly */
-void test_core_filebuf__2(void)
+void test_filebuf__2(void)
{
git_filebuf file = GIT_FILEBUF_INIT;
char test[] = "test";
@@ -57,7 +57,7 @@ void test_core_filebuf__2(void)
}
/* make sure git_filebuf_cleanup clears the buffer */
-void test_core_filebuf__4(void)
+void test_filebuf__4(void)
{
git_filebuf file = GIT_FILEBUF_INIT;
char test[] = "test";
@@ -73,7 +73,7 @@ void test_core_filebuf__4(void)
/* make sure git_filebuf_commit clears the buffer */
-void test_core_filebuf__5(void)
+void test_filebuf__5(void)
{
git_filebuf file = GIT_FILEBUF_INIT;
char test[] = "test";
@@ -93,7 +93,7 @@ void test_core_filebuf__5(void)
/* make sure git_filebuf_commit takes umask into account */
-void test_core_filebuf__umask(void)
+void test_filebuf__umask(void)
{
git_filebuf file = GIT_FILEBUF_INIT;
char test[] = "test";
@@ -124,7 +124,7 @@ void test_core_filebuf__umask(void)
cl_must_pass(p_unlink(test));
}
-void test_core_filebuf__rename_error(void)
+void test_filebuf__rename_error(void)
{
git_filebuf file = GIT_FILEBUF_INIT;
char *dir = "subdir", *test = "subdir/test", *test_lock = "subdir/test.lock";
@@ -152,7 +152,7 @@ void test_core_filebuf__rename_error(void)
cl_assert_equal_i(false, git_fs_path_exists(test_lock));
}
-void test_core_filebuf__symlink_follow(void)
+void test_filebuf__symlink_follow(void)
{
git_filebuf file = GIT_FILEBUF_INIT;
const char *dir = "linkdir", *source = "linkdir/link";
@@ -186,7 +186,7 @@ void test_core_filebuf__symlink_follow(void)
cl_git_pass(git_futils_rmdir_r(dir, NULL, GIT_RMDIR_REMOVE_FILES));
}
-void test_core_filebuf__symlink_follow_absolute_paths(void)
+void test_filebuf__symlink_follow_absolute_paths(void)
{
git_filebuf file = GIT_FILEBUF_INIT;
git_str source = GIT_STR_INIT, target = GIT_STR_INIT;
@@ -214,7 +214,7 @@ void test_core_filebuf__symlink_follow_absolute_paths(void)
cl_git_pass(git_futils_rmdir_r("linkdir", NULL, GIT_RMDIR_REMOVE_FILES));
}
-void test_core_filebuf__symlink_depth(void)
+void test_filebuf__symlink_depth(void)
{
git_filebuf file = GIT_FILEBUF_INIT;
const char *dir = "linkdir", *source = "linkdir/link";
@@ -231,7 +231,7 @@ void test_core_filebuf__symlink_depth(void)
cl_git_pass(git_futils_rmdir_r(dir, NULL, GIT_RMDIR_REMOVE_FILES));
}
-void test_core_filebuf__hidden_file(void)
+void test_filebuf__hidden_file(void)
{
#ifndef GIT_WIN32
cl_skip();
@@ -257,7 +257,7 @@ void test_core_filebuf__hidden_file(void)
#endif
}
-void test_core_filebuf__detects_directory(void)
+void test_filebuf__detects_directory(void)
{
git_filebuf file = GIT_FILEBUF_INIT;
diff --git a/tests/core/ftruncate.c b/tests/util/ftruncate.c
index 0c731cb1e..e60e5d96d 100644
--- a/tests/core/ftruncate.c
+++ b/tests/util/ftruncate.c
@@ -8,7 +8,7 @@
static const char *filename = "core_ftruncate.txt";
static int fd = -1;
-void test_core_ftruncate__initialize(void)
+void test_ftruncate__initialize(void)
{
if (!cl_is_env_set("GITTEST_INVASIVE_FS_SIZE"))
cl_skip();
@@ -16,7 +16,7 @@ void test_core_ftruncate__initialize(void)
cl_must_pass((fd = p_open(filename, O_CREAT | O_RDWR, 0644)));
}
-void test_core_ftruncate__cleanup(void)
+void test_ftruncate__cleanup(void)
{
if (fd < 0)
return;
@@ -37,12 +37,12 @@ static void _extend(off64_t i64len)
cl_assert(st.st_size == i64len);
}
-void test_core_ftruncate__2gb(void)
+void test_ftruncate__2gb(void)
{
_extend(0x80000001);
}
-void test_core_ftruncate__4gb(void)
+void test_ftruncate__4gb(void)
{
_extend(0x100000001);
}
diff --git a/tests/core/futils.c b/tests/util/futils.c
index 3501765f6..993b14d9b 100644
--- a/tests/core/futils.c
+++ b/tests/util/futils.c
@@ -2,17 +2,17 @@
#include "futils.h"
/* Fixture setup and teardown */
-void test_core_futils__initialize(void)
+void test_futils__initialize(void)
{
cl_must_pass(p_mkdir("futils", 0777));
}
-void test_core_futils__cleanup(void)
+void test_futils__cleanup(void)
{
cl_fixture_cleanup("futils");
}
-void test_core_futils__writebuffer(void)
+void test_futils__writebuffer(void)
{
git_str out = GIT_STR_INIT,
append = GIT_STR_INIT;
@@ -37,7 +37,7 @@ void test_core_futils__writebuffer(void)
git_str_dispose(&append);
}
-void test_core_futils__write_hidden_file(void)
+void test_futils__write_hidden_file(void)
{
#ifndef GIT_WIN32
cl_skip();
@@ -66,7 +66,7 @@ void test_core_futils__write_hidden_file(void)
#endif
}
-void test_core_futils__recursive_rmdir_keeps_symlink_targets(void)
+void test_futils__recursive_rmdir_keeps_symlink_targets(void)
{
if (!git_fs_path_supports_symlinks(clar_sandbox_path()))
cl_skip();
@@ -88,7 +88,7 @@ void test_core_futils__recursive_rmdir_keeps_symlink_targets(void)
cl_must_pass(p_unlink("file-target"));
}
-void test_core_futils__mktmp_umask(void)
+void test_futils__mktmp_umask(void)
{
#ifdef GIT_WIN32
cl_skip();
diff --git a/tests/core/gitstr.c b/tests/util/gitstr.c
index 0a624e28c..aea35565b 100644
--- a/tests/core/gitstr.c
+++ b/tests/util/gitstr.c
@@ -1,5 +1,4 @@
#include "clar_libgit2.h"
-#include "git2/sys/hashsig.h"
#include "futils.h"
#define TESTSTR "Have you seen that? Have you seeeen that??"
@@ -12,7 +11,7 @@ const char *test_4096 = TESTSTR_4096;
const char *test_8192 = TESTSTR_8192;
/* test basic data concatenation */
-void test_core_gitstr__0(void)
+void test_gitstr__0(void)
{
git_str buf = GIT_STR_INIT;
@@ -30,7 +29,7 @@ void test_core_gitstr__0(void)
}
/* test git_str_printf */
-void test_core_gitstr__1(void)
+void test_gitstr__1(void)
{
git_str buf = GIT_STR_INIT;
@@ -46,7 +45,7 @@ void test_core_gitstr__1(void)
}
/* more thorough test of concatenation options */
-void test_core_gitstr__2(void)
+void test_gitstr__2(void)
{
git_str buf = GIT_STR_INIT;
int i;
@@ -158,7 +157,7 @@ void test_core_gitstr__2(void)
}
/* let's do some tests with larger buffers to push our limits */
-void test_core_gitstr__3(void)
+void test_gitstr__3(void)
{
git_str buf = GIT_STR_INIT;
@@ -181,7 +180,7 @@ void test_core_gitstr__3(void)
}
/* let's try some producer/consumer tests */
-void test_core_gitstr__4(void)
+void test_gitstr__4(void)
{
git_str buf = GIT_STR_INIT;
int i;
@@ -277,7 +276,7 @@ check_buf_append_abc(
}
/* more variations on append tests */
-void test_core_gitstr__5(void)
+void test_gitstr__5(void)
{
check_buf_append("", "", "", 0, 0);
check_buf_append("a", "", "a", 1, 0);
@@ -320,7 +319,7 @@ void test_core_gitstr__5(void)
}
/* test swap */
-void test_core_gitstr__6(void)
+void test_gitstr__6(void)
{
git_str a = GIT_STR_INIT;
git_str b = GIT_STR_INIT;
@@ -344,7 +343,7 @@ void test_core_gitstr__6(void)
/* test detach/attach data */
-void test_core_gitstr__7(void)
+void test_gitstr__7(void)
{
const char *fun = "This is fun";
git_str a = GIT_STR_INIT;
@@ -455,7 +454,7 @@ check_joinbuf_n_4(
}
/* test join */
-void test_core_gitstr__8(void)
+void test_gitstr__8(void)
{
git_str a = GIT_STR_INIT;
@@ -536,7 +535,7 @@ void test_core_gitstr__8(void)
check_joinbuf_n_4(";abcd;", ";efgh;", ";ijkl;", ";mnop;", ";abcd;efgh;ijkl;mnop;");
}
-void test_core_gitstr__9(void)
+void test_gitstr__9(void)
{
git_str buf = GIT_STR_INIT;
@@ -579,7 +578,7 @@ void test_core_gitstr__9(void)
git_str_dispose(&buf);
}
-void test_core_gitstr__10(void)
+void test_gitstr__10(void)
{
git_str a = GIT_STR_INIT;
@@ -596,7 +595,7 @@ void test_core_gitstr__10(void)
git_str_dispose(&a);
}
-void test_core_gitstr__join3(void)
+void test_gitstr__join3(void)
{
git_str a = GIT_STR_INIT;
@@ -628,7 +627,7 @@ void test_core_gitstr__join3(void)
git_str_dispose(&a);
}
-void test_core_gitstr__11(void)
+void test_gitstr__11(void)
{
git_str a = GIT_STR_INIT;
char *t1[] = { "nothing", "in", "common" };
@@ -663,7 +662,7 @@ void test_core_gitstr__11(void)
git_str_dispose(&a);
}
-void test_core_gitstr__rfind_variants(void)
+void test_gitstr__rfind_variants(void)
{
git_str a = GIT_STR_INIT;
ssize_t len;
@@ -687,7 +686,7 @@ void test_core_gitstr__rfind_variants(void)
git_str_dispose(&a);
}
-void test_core_gitstr__puts_escaped(void)
+void test_gitstr__puts_escaped(void)
{
git_str a = GIT_STR_INIT;
@@ -721,7 +720,7 @@ static void assert_unescape(char *expected, char *to_unescape) {
git_str_dispose(&buf);
}
-void test_core_gitstr__unescape(void)
+void test_gitstr__unescape(void)
{
assert_unescape("Escaped\\", "Es\\ca\\ped\\");
assert_unescape("Es\\caped\\", "Es\\\\ca\\ped\\\\");
@@ -730,7 +729,7 @@ void test_core_gitstr__unescape(void)
assert_unescape("", "");
}
-void test_core_gitstr__encode_base64(void)
+void test_gitstr__encode_base64(void)
{
git_str buf = GIT_STR_INIT;
@@ -755,7 +754,7 @@ void test_core_gitstr__encode_base64(void)
git_str_dispose(&buf);
}
-void test_core_gitstr__decode_base64(void)
+void test_gitstr__decode_base64(void)
{
git_str buf = GIT_STR_INIT;
@@ -776,7 +775,7 @@ void test_core_gitstr__decode_base64(void)
git_str_dispose(&buf);
}
-void test_core_gitstr__encode_base85(void)
+void test_gitstr__encode_base85(void)
{
git_str buf = GIT_STR_INIT;
@@ -796,7 +795,7 @@ void test_core_gitstr__encode_base85(void)
git_str_dispose(&buf);
}
-void test_core_gitstr__decode_base85(void)
+void test_gitstr__decode_base85(void)
{
git_str buf = GIT_STR_INIT;
@@ -818,7 +817,7 @@ void test_core_gitstr__decode_base85(void)
git_str_dispose(&buf);
}
-void test_core_gitstr__decode_base85_fails_gracefully(void)
+void test_gitstr__decode_base85_fails_gracefully(void)
{
git_str buf = GIT_STR_INIT;
@@ -834,7 +833,7 @@ void test_core_gitstr__decode_base85_fails_gracefully(void)
git_str_dispose(&buf);
}
-void test_core_gitstr__classify_with_utf8(void)
+void test_gitstr__classify_with_utf8(void)
{
char *data0 = "Simple text\n";
size_t data0len = 12;
@@ -863,193 +862,13 @@ void test_core_gitstr__classify_with_utf8(void)
cl_assert(!git_str_contains_nul(&b));
}
-#define SIMILARITY_TEST_DATA_1 \
- "000\n001\n002\n003\n004\n005\n006\n007\n008\n009\n" \
- "010\n011\n012\n013\n014\n015\n016\n017\n018\n019\n" \
- "020\n021\n022\n023\n024\n025\n026\n027\n028\n029\n" \
- "030\n031\n032\n033\n034\n035\n036\n037\n038\n039\n" \
- "040\n041\n042\n043\n044\n045\n046\n047\n048\n049\n"
-
-void test_core_gitstr__similarity_metric(void)
-{
- git_hashsig *a, *b;
- git_str buf = GIT_STR_INIT;
- int sim;
-
- /* in the first case, we compare data to itself and expect 100% match */
-
- cl_git_pass(git_str_sets(&buf, SIMILARITY_TEST_DATA_1));
- cl_git_pass(git_hashsig_create(&a, buf.ptr, buf.size, GIT_HASHSIG_NORMAL));
- cl_git_pass(git_hashsig_create(&b, buf.ptr, buf.size, GIT_HASHSIG_NORMAL));
-
- cl_assert_equal_i(100, git_hashsig_compare(a, b));
-
- git_hashsig_free(a);
- git_hashsig_free(b);
-
- /* if we change just a single byte, how much does that change magnify? */
-
- cl_git_pass(git_str_sets(&buf, SIMILARITY_TEST_DATA_1));
- cl_git_pass(git_hashsig_create(&a, buf.ptr, buf.size, GIT_HASHSIG_NORMAL));
- cl_git_pass(git_str_sets(&buf,
- "000\n001\n002\n003\n004\n005\n006\n007\n008\n009\n" \
- "010\n011\n012\n013\n014\n015\n016\n017\n018\n019\n" \
- "x020x\n021\n022\n023\n024\n025\n026\n027\n028\n029\n" \
- "030\n031\n032\n033\n034\n035\n036\n037\n038\n039\n" \
- "040\n041\n042\n043\n044\n045\n046\n047\n048\n049\n"
- ));
- cl_git_pass(git_hashsig_create(&b, buf.ptr, buf.size, GIT_HASHSIG_NORMAL));
-
- sim = git_hashsig_compare(a, b);
-
- cl_assert_in_range(95, sim, 100); /* expect >95% similarity */
-
- git_hashsig_free(a);
- git_hashsig_free(b);
-
- /* let's try comparing data to a superset of itself */
-
- cl_git_pass(git_str_sets(&buf, SIMILARITY_TEST_DATA_1));
- cl_git_pass(git_hashsig_create(&a, buf.ptr, buf.size, GIT_HASHSIG_NORMAL));
- cl_git_pass(git_str_sets(&buf, SIMILARITY_TEST_DATA_1
- "050\n051\n052\n053\n054\n055\n056\n057\n058\n059\n"));
- cl_git_pass(git_hashsig_create(&b, buf.ptr, buf.size, GIT_HASHSIG_NORMAL));
-
- sim = git_hashsig_compare(a, b);
- /* 20% lines added ~= 10% lines changed */
-
- cl_assert_in_range(85, sim, 95); /* expect similarity around 90% */
-
- git_hashsig_free(a);
- git_hashsig_free(b);
-
- /* what if we keep about half the original data and add half new */
-
- cl_git_pass(git_str_sets(&buf, SIMILARITY_TEST_DATA_1));
- cl_git_pass(git_hashsig_create(&a, buf.ptr, buf.size, GIT_HASHSIG_NORMAL));
- cl_git_pass(git_str_sets(&buf,
- "000\n001\n002\n003\n004\n005\n006\n007\n008\n009\n" \
- "010\n011\n012\n013\n014\n015\n016\n017\n018\n019\n" \
- "020x\n021\n022\n023\n024\n" \
- "x25\nx26\nx27\nx28\nx29\n" \
- "x30\nx31\nx32\nx33\nx34\nx35\nx36\nx37\nx38\nx39\n" \
- "x40\nx41\nx42\nx43\nx44\nx45\nx46\nx47\nx48\nx49\n"
- ));
- cl_git_pass(git_hashsig_create(&b, buf.ptr, buf.size, GIT_HASHSIG_NORMAL));
-
- sim = git_hashsig_compare(a, b);
- /* 50% lines changed */
-
- cl_assert_in_range(40, sim, 60); /* expect in the 40-60% similarity range */
-
- git_hashsig_free(a);
- git_hashsig_free(b);
-
- /* lastly, let's check that we can hash file content as well */
-
- cl_git_pass(git_str_sets(&buf, SIMILARITY_TEST_DATA_1));
- cl_git_pass(git_hashsig_create(&a, buf.ptr, buf.size, GIT_HASHSIG_NORMAL));
-
- cl_git_pass(git_futils_mkdir("scratch", 0755, GIT_MKDIR_PATH));
- cl_git_mkfile("scratch/testdata", SIMILARITY_TEST_DATA_1);
- cl_git_pass(git_hashsig_create_fromfile(
- &b, "scratch/testdata", GIT_HASHSIG_NORMAL));
-
- cl_assert_equal_i(100, git_hashsig_compare(a, b));
-
- git_hashsig_free(a);
- git_hashsig_free(b);
-
- git_str_dispose(&buf);
- git_futils_rmdir_r("scratch", NULL, GIT_RMDIR_REMOVE_FILES);
-}
-
-
-void test_core_gitstr__similarity_metric_whitespace(void)
-{
- git_hashsig *a, *b;
- git_str buf = GIT_STR_INIT;
- int sim, i, j;
- git_hashsig_option_t opt;
- const char *tabbed =
- " for (s = 0; s < sizeof(sep) / sizeof(char); ++s) {\n"
- " separator = sep[s];\n"
- " expect = expect_values[s];\n"
- "\n"
- " for (j = 0; j < sizeof(b) / sizeof(char*); ++j) {\n"
- " for (i = 0; i < sizeof(a) / sizeof(char*); ++i) {\n"
- " git_str_join(&buf, separator, a[i], b[j]);\n"
- " cl_assert_equal_s(*expect, buf.ptr);\n"
- " expect++;\n"
- " }\n"
- " }\n"
- " }\n";
- const char *spaced =
- " for (s = 0; s < sizeof(sep) / sizeof(char); ++s) {\n"
- " separator = sep[s];\n"
- " expect = expect_values[s];\n"
- "\n"
- " for (j = 0; j < sizeof(b) / sizeof(char*); ++j) {\n"
- " for (i = 0; i < sizeof(a) / sizeof(char*); ++i) {\n"
- " git_str_join(&buf, separator, a[i], b[j]);\n"
- " cl_assert_equal_s(*expect, buf.ptr);\n"
- " expect++;\n"
- " }\n"
- " }\n"
- " }\n";
- const char *crlf_spaced2 =
- " for (s = 0; s < sizeof(sep) / sizeof(char); ++s) {\r\n"
- " separator = sep[s];\r\n"
- " expect = expect_values[s];\r\n"
- "\r\n"
- " for (j = 0; j < sizeof(b) / sizeof(char*); ++j) {\r\n"
- " for (i = 0; i < sizeof(a) / sizeof(char*); ++i) {\r\n"
- " git_str_join(&buf, separator, a[i], b[j]);\r\n"
- " cl_assert_equal_s(*expect, buf.ptr);\r\n"
- " expect++;\r\n"
- " }\r\n"
- " }\r\n"
- " }\r\n";
- const char *text[3] = { tabbed, spaced, crlf_spaced2 };
-
- /* let's try variations of our own code with whitespace changes */
-
- for (opt = GIT_HASHSIG_NORMAL; opt <= GIT_HASHSIG_SMART_WHITESPACE; ++opt) {
- for (i = 0; i < 3; ++i) {
- for (j = 0; j < 3; ++j) {
- cl_git_pass(git_str_sets(&buf, text[i]));
- cl_git_pass(git_hashsig_create(&a, buf.ptr, buf.size, opt));
-
- cl_git_pass(git_str_sets(&buf, text[j]));
- cl_git_pass(git_hashsig_create(&b, buf.ptr, buf.size, opt));
-
- sim = git_hashsig_compare(a, b);
-
- if (opt == GIT_HASHSIG_NORMAL) {
- if (i == j)
- cl_assert_equal_i(100, sim);
- else
- cl_assert_in_range(0, sim, 30); /* pretty different */
- } else {
- cl_assert_equal_i(100, sim);
- }
-
- git_hashsig_free(a);
- git_hashsig_free(b);
- }
- }
- }
-
- git_str_dispose(&buf);
-}
-
-#include "../filter/crlf.h"
+#include "crlf.h"
#define check_buf(expected,buf) do { \
cl_assert_equal_s(expected, buf.ptr); \
cl_assert_equal_sz(strlen(expected), buf.size); } while (0)
-void test_core_gitstr__lf_and_crlf_conversions(void)
+void test_gitstr__lf_and_crlf_conversions(void)
{
git_str src = GIT_STR_INIT, tgt = GIT_STR_INIT;
@@ -1175,7 +994,7 @@ void test_core_gitstr__lf_and_crlf_conversions(void)
git_str_dispose(&tgt);
}
-void test_core_gitstr__dont_grow_borrowed(void)
+void test_gitstr__dont_grow_borrowed(void)
{
const char *somestring = "blah blah";
git_str buf = GIT_STR_INIT;
@@ -1188,7 +1007,7 @@ void test_core_gitstr__dont_grow_borrowed(void)
cl_git_fail_with(GIT_EINVALID, git_str_grow(&buf, 1024));
}
-void test_core_gitstr__dont_hit_infinite_loop_when_resizing(void)
+void test_gitstr__dont_hit_infinite_loop_when_resizing(void)
{
git_str buf = GIT_STR_INIT;
@@ -1204,7 +1023,7 @@ void test_core_gitstr__dont_hit_infinite_loop_when_resizing(void)
git_str_dispose(&buf);
}
-void test_core_gitstr__avoid_printing_into_oom_buffer(void)
+void test_gitstr__avoid_printing_into_oom_buffer(void)
{
git_str buf = GIT_STR_INIT;
diff --git a/tests/core/hex.c b/tests/util/hex.c
index 930af1670..c5fea0a42 100644
--- a/tests/core/hex.c
+++ b/tests/util/hex.c
@@ -1,7 +1,7 @@
#include "clar_libgit2.h"
#include "util.h"
-void test_core_hex__fromhex(void)
+void test_hex__fromhex(void)
{
/* Passing cases */
cl_assert(git__fromhex('0') == 0x0);
diff --git a/tests/core/iconv.c b/tests/util/iconv.c
index af1b4eabf..e14aebb99 100644
--- a/tests/core/iconv.c
+++ b/tests/util/iconv.c
@@ -7,21 +7,21 @@ static char *nfc = "\xC3\x85\x73\x74\x72\xC3\xB6\x6D";
static char *nfd = "\x41\xCC\x8A\x73\x74\x72\x6F\xCC\x88\x6D";
#endif
-void test_core_iconv__initialize(void)
+void test_iconv__initialize(void)
{
#ifdef GIT_USE_ICONV
cl_git_pass(git_fs_path_iconv_init_precompose(&ic));
#endif
}
-void test_core_iconv__cleanup(void)
+void test_iconv__cleanup(void)
{
#ifdef GIT_USE_ICONV
git_fs_path_iconv_clear(&ic);
#endif
}
-void test_core_iconv__unchanged(void)
+void test_iconv__unchanged(void)
{
#ifdef GIT_USE_ICONV
const char *data = "Ascii data", *original = data;
@@ -35,7 +35,7 @@ void test_core_iconv__unchanged(void)
#endif
}
-void test_core_iconv__decomposed_to_precomposed(void)
+void test_iconv__decomposed_to_precomposed(void)
{
#ifdef GIT_USE_ICONV
const char *data = nfd;
@@ -61,7 +61,7 @@ void test_core_iconv__decomposed_to_precomposed(void)
#endif
}
-void test_core_iconv__precomposed_is_unmodified(void)
+void test_iconv__precomposed_is_unmodified(void)
{
#ifdef GIT_USE_ICONV
const char *data = nfc;
diff --git a/tests/core/init.c b/tests/util/init.c
index eba77ef52..78b3dd039 100644
--- a/tests/core/init.c
+++ b/tests/util/init.c
@@ -1,6 +1,6 @@
#include "clar_libgit2.h"
-void test_core_init__returns_count(void)
+void test_init__returns_count(void)
{
/* libgit2_tests initializes us first, so we have an existing
* initialization.
@@ -12,7 +12,7 @@ void test_core_init__returns_count(void)
cl_assert_equal_i(1, git_libgit2_shutdown());
}
-void test_core_init__reinit_succeeds(void)
+void test_init__reinit_succeeds(void)
{
cl_assert_equal_i(0, git_libgit2_shutdown());
cl_assert_equal_i(1, git_libgit2_init());
@@ -33,7 +33,7 @@ static void *reinit(void *unused)
}
#endif
-void test_core_init__concurrent_init_succeeds(void)
+void test_init__concurrent_init_succeeds(void)
{
#ifdef GIT_THREADS
git_thread threads[10];
diff --git a/tests/core/integer.c b/tests/util/integer.c
index 18364ba62..2226ab41e 100644
--- a/tests/core/integer.c
+++ b/tests/util/integer.c
@@ -1,6 +1,6 @@
#include "clar_libgit2.h"
-void test_core_integer__multiply_int64_no_overflow(void)
+void test_integer__multiply_int64_no_overflow(void)
{
#if !defined(git__multiply_int64_overflow)
int64_t result = 0;
@@ -169,7 +169,7 @@ void test_core_integer__multiply_int64_no_overflow(void)
#endif
}
-void test_core_integer__multiply_int64_overflow(void)
+void test_integer__multiply_int64_overflow(void)
{
#if !defined(git__multiply_int64_overflow)
int64_t result = 0;
@@ -239,7 +239,7 @@ void test_core_integer__multiply_int64_overflow(void)
#endif
}
-void test_core_integer__multiply_int64_edge_cases(void)
+void test_integer__multiply_int64_edge_cases(void)
{
#if !defined(git__multiply_int64_overflow)
int64_t result = 0;
diff --git a/tests/core/link.c b/tests/util/link.c
index a1e2706b2..46cafada7 100644
--- a/tests/core/link.c
+++ b/tests/util/link.c
@@ -5,7 +5,7 @@
# include "win32/reparse.h"
#endif
-void test_core_link__cleanup(void)
+void test_link__cleanup(void)
{
#ifdef GIT_WIN32
RemoveDirectory("lstat_junction");
@@ -195,7 +195,7 @@ static void do_custom_reparse(const char *path)
#endif
-void test_core_link__stat_regular_file(void)
+void test_link__stat_regular_file(void)
{
struct stat st;
@@ -206,7 +206,7 @@ void test_core_link__stat_regular_file(void)
cl_assert_equal_i(24, st.st_size);
}
-void test_core_link__lstat_regular_file(void)
+void test_link__lstat_regular_file(void)
{
struct stat st;
@@ -217,7 +217,7 @@ void test_core_link__lstat_regular_file(void)
cl_assert_equal_i(24, st.st_size);
}
-void test_core_link__stat_symlink(void)
+void test_link__stat_symlink(void)
{
struct stat st;
@@ -236,7 +236,7 @@ void test_core_link__stat_symlink(void)
cl_assert_equal_i(39, st.st_size);
}
-void test_core_link__stat_symlink_directory(void)
+void test_link__stat_symlink_directory(void)
{
struct stat st;
@@ -253,7 +253,7 @@ void test_core_link__stat_symlink_directory(void)
cl_assert(S_ISDIR(st.st_mode));
}
-void test_core_link__stat_symlink_chain(void)
+void test_link__stat_symlink_chain(void)
{
struct stat st;
@@ -270,7 +270,7 @@ void test_core_link__stat_symlink_chain(void)
cl_assert_equal_i(39, st.st_size);
}
-void test_core_link__stat_dangling_symlink(void)
+void test_link__stat_dangling_symlink(void)
{
struct stat st;
@@ -283,7 +283,7 @@ void test_core_link__stat_dangling_symlink(void)
cl_must_fail(p_stat("stat_dangling", &st));
}
-void test_core_link__stat_dangling_symlink_directory(void)
+void test_link__stat_dangling_symlink_directory(void)
{
struct stat st;
@@ -296,7 +296,7 @@ void test_core_link__stat_dangling_symlink_directory(void)
cl_must_fail(p_stat("stat_dangling", &st));
}
-void test_core_link__lstat_symlink(void)
+void test_link__lstat_symlink(void)
{
git_str target_path = GIT_STR_INIT;
struct stat st;
@@ -323,7 +323,7 @@ void test_core_link__lstat_symlink(void)
git_str_dispose(&target_path);
}
-void test_core_link__lstat_symlink_directory(void)
+void test_link__lstat_symlink_directory(void)
{
git_str target_path = GIT_STR_INIT;
struct stat st;
@@ -346,7 +346,7 @@ void test_core_link__lstat_symlink_directory(void)
git_str_dispose(&target_path);
}
-void test_core_link__lstat_dangling_symlink(void)
+void test_link__lstat_dangling_symlink(void)
{
struct stat st;
@@ -362,7 +362,7 @@ void test_core_link__lstat_dangling_symlink(void)
cl_assert_equal_i(strlen("lstat_nonexistent"), st.st_size);
}
-void test_core_link__lstat_dangling_symlink_directory(void)
+void test_link__lstat_dangling_symlink_directory(void)
{
struct stat st;
@@ -378,7 +378,7 @@ void test_core_link__lstat_dangling_symlink_directory(void)
cl_assert_equal_i(strlen("lstat_nonexistent"), st.st_size);
}
-void test_core_link__stat_junction(void)
+void test_link__stat_junction(void)
{
#ifdef GIT_WIN32
git_str target_path = GIT_STR_INIT;
@@ -399,7 +399,7 @@ void test_core_link__stat_junction(void)
#endif
}
-void test_core_link__stat_dangling_junction(void)
+void test_link__stat_dangling_junction(void)
{
#ifdef GIT_WIN32
git_str target_path = GIT_STR_INIT;
@@ -419,7 +419,7 @@ void test_core_link__stat_dangling_junction(void)
#endif
}
-void test_core_link__lstat_junction(void)
+void test_link__lstat_junction(void)
{
#ifdef GIT_WIN32
git_str target_path = GIT_STR_INIT;
@@ -440,7 +440,7 @@ void test_core_link__lstat_junction(void)
#endif
}
-void test_core_link__lstat_dangling_junction(void)
+void test_link__lstat_dangling_junction(void)
{
#ifdef GIT_WIN32
git_str target_path = GIT_STR_INIT;
@@ -463,7 +463,7 @@ void test_core_link__lstat_dangling_junction(void)
#endif
}
-void test_core_link__stat_hardlink(void)
+void test_link__stat_hardlink(void)
{
struct stat st;
@@ -482,7 +482,7 @@ void test_core_link__stat_hardlink(void)
cl_assert_equal_i(26, st.st_size);
}
-void test_core_link__lstat_hardlink(void)
+void test_link__lstat_hardlink(void)
{
struct stat st;
@@ -501,7 +501,7 @@ void test_core_link__lstat_hardlink(void)
cl_assert_equal_i(26, st.st_size);
}
-void test_core_link__stat_reparse_point(void)
+void test_link__stat_reparse_point(void)
{
#ifdef GIT_WIN32
struct stat st;
@@ -519,7 +519,7 @@ void test_core_link__stat_reparse_point(void)
#endif
}
-void test_core_link__lstat_reparse_point(void)
+void test_link__lstat_reparse_point(void)
{
#ifdef GIT_WIN32
struct stat st;
@@ -533,7 +533,7 @@ void test_core_link__lstat_reparse_point(void)
#endif
}
-void test_core_link__readlink_nonexistent_file(void)
+void test_link__readlink_nonexistent_file(void)
{
char buf[2048];
@@ -541,7 +541,7 @@ void test_core_link__readlink_nonexistent_file(void)
cl_assert_equal_i(ENOENT, errno);
}
-void test_core_link__readlink_normal_file(void)
+void test_link__readlink_normal_file(void)
{
char buf[2048];
@@ -550,7 +550,7 @@ void test_core_link__readlink_normal_file(void)
cl_assert_equal_i(EINVAL, errno);
}
-void test_core_link__readlink_symlink(void)
+void test_link__readlink_symlink(void)
{
git_str target_path = GIT_STR_INIT;
int len;
@@ -574,7 +574,7 @@ void test_core_link__readlink_symlink(void)
git_str_dispose(&target_path);
}
-void test_core_link__readlink_dangling(void)
+void test_link__readlink_dangling(void)
{
git_str target_path = GIT_STR_INIT;
int len;
@@ -597,7 +597,7 @@ void test_core_link__readlink_dangling(void)
git_str_dispose(&target_path);
}
-void test_core_link__readlink_multiple(void)
+void test_link__readlink_multiple(void)
{
git_str target_path = GIT_STR_INIT,
path3 = GIT_STR_INIT, path2 = GIT_STR_INIT, path1 = GIT_STR_INIT;
diff --git a/tests/core/memmem.c b/tests/util/memmem.c
index fd9986d01..1c713e8bd 100644
--- a/tests/core/memmem.c
+++ b/tests/util/memmem.c
@@ -14,7 +14,7 @@ static void assert_absent(const char *haystack, const char *needle)
NULL);
}
-void test_core_memmem__found(void)
+void test_memmem__found(void)
{
assert_found("a", "a", 0);
assert_found("ab", "a", 0);
@@ -26,7 +26,7 @@ void test_core_memmem__found(void)
assert_found("abababc", "abc", 4);
}
-void test_core_memmem__absent(void)
+void test_memmem__absent(void)
{
assert_absent("a", "b");
assert_absent("a", "aa");
@@ -36,7 +36,7 @@ void test_core_memmem__absent(void)
assert_absent("abcabcabc", "bcac");
}
-void test_core_memmem__edgecases(void)
+void test_memmem__edgecases(void)
{
assert_absent(NULL, NULL);
assert_absent("a", NULL);
diff --git a/tests/core/mkdir.c b/tests/util/mkdir.c
index 58a4cfcdb..8658eec0d 100644
--- a/tests/core/mkdir.c
+++ b/tests/util/mkdir.c
@@ -12,7 +12,7 @@ static void cleanup_basic_dirs(void *ref)
git_futils_rmdir_r("d4", NULL, GIT_RMDIR_EMPTY_HIERARCHY);
}
-void test_core_mkdir__absolute(void)
+void test_mkdir__absolute(void)
{
git_str path = GIT_STR_INIT;
@@ -51,7 +51,7 @@ void test_core_mkdir__absolute(void)
git_str_dispose(&path);
}
-void test_core_mkdir__basic(void)
+void test_mkdir__basic(void)
{
cl_set_cleanup(cleanup_basic_dirs, NULL);
@@ -97,7 +97,7 @@ static void cleanup_basedir(void *ref)
git_futils_rmdir_r("base", NULL, GIT_RMDIR_EMPTY_HIERARCHY);
}
-void test_core_mkdir__with_base(void)
+void test_mkdir__with_base(void)
{
#define BASEDIR "base/dir/here"
@@ -166,7 +166,7 @@ static void check_mode_at_line(
"%07o", (int)expected, (int)(actual & 0777));
}
-void test_core_mkdir__chmods(void)
+void test_mkdir__chmods(void)
{
struct stat st;
mode_t *old = git__malloc(sizeof(mode_t));
@@ -226,7 +226,7 @@ void test_core_mkdir__chmods(void)
check_mode(0777, st.st_mode);
}
-void test_core_mkdir__keeps_parent_symlinks(void)
+void test_mkdir__keeps_parent_symlinks(void)
{
#ifndef GIT_WIN32
git_str path = GIT_STR_INIT;
@@ -260,7 +260,7 @@ void test_core_mkdir__keeps_parent_symlinks(void)
#endif
}
-void test_core_mkdir__mkdir_path_inside_unwriteable_parent(void)
+void test_mkdir__mkdir_path_inside_unwriteable_parent(void)
{
struct stat st;
mode_t *old;
diff --git a/tests/core/path.c b/tests/util/path.c
index a0ae77f1c..404c17a2b 100644
--- a/tests/core/path.c
+++ b/tests/util/path.c
@@ -4,12 +4,12 @@
static char *path_save;
-void test_core_path__initialize(void)
+void test_path__initialize(void)
{
path_save = cl_getenv("PATH");
}
-void test_core_path__cleanup(void)
+void test_path__cleanup(void)
{
cl_setenv("PATH", path_save);
git__free(path_save);
@@ -90,7 +90,7 @@ static void check_setenv(const char* name, const char* value)
}
/* get the dirname of a path */
-void test_core_path__00_dirname(void)
+void test_path__00_dirname(void)
{
check_dirname(NULL, ".");
check_dirname("", ".");
@@ -123,7 +123,7 @@ void test_core_path__00_dirname(void)
}
/* get the base name of a path */
-void test_core_path__01_basename(void)
+void test_path__01_basename(void)
{
check_basename(NULL, ".");
check_basename("", ".");
@@ -140,7 +140,7 @@ void test_core_path__01_basename(void)
}
/* properly join path components */
-void test_core_path__05_joins(void)
+void test_path__05_joins(void)
{
check_joinpath("", "", "");
check_joinpath("", "a", "a");
@@ -175,7 +175,7 @@ void test_core_path__05_joins(void)
}
/* properly join path components for more than one path */
-void test_core_path__06_long_joins(void)
+void test_path__06_long_joins(void)
{
check_joinpath_n("", "", "", "", "");
check_joinpath_n("", "a", "", "", "a/");
@@ -230,7 +230,7 @@ check_string_to_dir(
}
/* convert paths to dirs */
-void test_core_path__07_path_to_dir(void)
+void test_path__07_path_to_dir(void)
{
check_path_to_dir("", "");
check_path_to_dir(".", "./");
@@ -258,7 +258,7 @@ void test_core_path__07_path_to_dir(void)
}
/* join path to itself */
-void test_core_path__08_self_join(void)
+void test_path__08_self_join(void)
{
git_str path = GIT_STR_INIT;
size_t asize = 0;
@@ -302,7 +302,7 @@ static void check_percent_decoding(const char *expected_result, const char *inpu
git_str_dispose(&buf);
}
-void test_core_path__09_percent_decode(void)
+void test_path__09_percent_decode(void)
{
check_percent_decoding("abcd", "abcd");
check_percent_decoding("a2%", "a2%");
@@ -337,7 +337,7 @@ static void check_fromurl(const char *expected_result, const char *input, int sh
#define ABS_PATH_MARKER "/"
#endif
-void test_core_path__10_fromurl(void)
+void test_path__10_fromurl(void)
{
/* Failing cases */
check_fromurl(NULL, "a", 1);
@@ -380,7 +380,7 @@ static int check_one_walkup_step(void *ref, const char *path)
return 0;
}
-void test_core_path__11_walkup(void)
+void test_path__11_walkup(void)
{
git_str p = GIT_STR_INIT;
@@ -442,7 +442,7 @@ void test_core_path__11_walkup(void)
git_str_dispose(&p);
}
-void test_core_path__11a_walkup_cancel(void)
+void test_path__11a_walkup_cancel(void)
{
git_str p = GIT_STR_INIT;
int cancel[] = { 3, 2, 1, 0 };
@@ -478,7 +478,7 @@ void test_core_path__11a_walkup_cancel(void)
git_str_dispose(&p);
}
-void test_core_path__12_offset_to_path_root(void)
+void test_path__12_offset_to_path_root(void)
{
cl_assert(git_fs_path_root("non/rooted/path") == -1);
cl_assert(git_fs_path_root("/rooted/path") == 0);
@@ -495,7 +495,7 @@ void test_core_path__12_offset_to_path_root(void)
#define NON_EXISTING_FILEPATH "i_hope_i_do_not_exist"
-void test_core_path__13_cannot_prettify_a_non_existing_file(void)
+void test_path__13_cannot_prettify_a_non_existing_file(void)
{
git_str p = GIT_STR_INIT;
@@ -506,7 +506,7 @@ void test_core_path__13_cannot_prettify_a_non_existing_file(void)
git_str_dispose(&p);
}
-void test_core_path__14_apply_relative(void)
+void test_path__14_apply_relative(void)
{
git_str p = GIT_STR_INIT;
@@ -575,7 +575,7 @@ static void assert_resolve_relative(
cl_assert_equal_s(expected, buf->ptr);
}
-void test_core_path__15_resolve_relative(void)
+void test_path__15_resolve_relative(void)
{
git_str buf = GIT_STR_INIT;
@@ -663,7 +663,7 @@ void test_core_path__15_resolve_relative(void)
#define assert_common_dirlen(i, p, q) \
cl_assert_equal_i((i), git_fs_path_common_dirlen((p), (q)));
-void test_core_path__16_resolve_relative(void)
+void test_path__16_resolve_relative(void)
{
assert_common_dirlen(0, "", "");
assert_common_dirlen(0, "", "bar.txt");
@@ -694,7 +694,7 @@ static void fix_path(git_str *s)
#endif
}
-void test_core_path__find_exe_in_path(void)
+void test_path__find_exe_in_path(void)
{
char *orig_path;
git_str sandbox_path = GIT_STR_INIT;
diff --git a/tests/path/core.c b/tests/util/path/core.c
index db5359af8..f30f6c01b 100644
--- a/tests/path/core.c
+++ b/tests/util/path/core.c
@@ -1,11 +1,5 @@
#include "clar_libgit2.h"
#include "fs_path.h"
-#include "path.h"
-
-void test_path_core__cleanup(void)
-{
- cl_git_sandbox_cleanup();
-}
static void test_make_relative(
const char *expected_path,
@@ -280,62 +274,6 @@ void test_path_core__isvalid_nt_chars(void)
cl_assert_equal_b(false, git_fs_path_is_valid("asdf*bar", GIT_FS_PATH_REJECT_NT_CHARS));
}
-void test_path_core__validate_workdir(void)
-{
- cl_must_pass(git_path_validate_length(NULL, "/foo/bar"));
- cl_must_pass(git_path_validate_length(NULL, "C:\\Foo\\Bar"));
- cl_must_pass(git_path_validate_length(NULL, "\\\\?\\C:\\Foo\\Bar"));
- cl_must_pass(git_path_validate_length(NULL, "\\\\?\\C:\\Foo\\Bar"));
- cl_must_pass(git_path_validate_length(NULL, "\\\\?\\UNC\\server\\C$\\folder"));
-
-#ifdef GIT_WIN32
- /*
- * In the absence of a repo configuration, 259 character paths
- * succeed. >= 260 character paths fail.
- */
- cl_must_pass(git_path_validate_length(NULL, "C:\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\ok.txt"));
- cl_must_pass(git_path_validate_length(NULL, "C:\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\260.txt"));
- cl_must_fail(git_path_validate_length(NULL, "C:\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\longer_than_260.txt"));
-
- /* count characters, not bytes */
- cl_must_pass(git_path_validate_length(NULL, "C:\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\\xc2\xa2\xc2\xa2\xc2\xa2\xc2\xa2\xc2\xa2\xc2\xa2\xc2\xa2\xc2\xa2\xc2\xa2\\260.txt"));
- cl_must_fail(git_path_validate_length(NULL, "C:\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\\xc2\xa2\xc2\xa2\xc2\xa2\xc2\xa2\xc2\xa2\xc2\xa2\xc2\xa2\xc2\xa2\xc2\xa2\\long.txt"));
-#else
- cl_must_pass(git_path_validate_length(NULL, "/c/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/ok.txt"));
- cl_must_pass(git_path_validate_length(NULL, "/c/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/260.txt"));
- cl_must_pass(git_path_validate_length(NULL, "/c/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/longer_than_260.txt"));
- cl_must_pass(git_path_validate_length(NULL, "C:\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\\xc2\xa2\xc2\xa2\xc2\xa2\xc2\xa2\xc2\xa2\xc2\xa2\xc2\xa2\xc2\xa2\xc2\xa2\\260.txt"));
- cl_must_pass(git_path_validate_length(NULL, "C:\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\\xc2\xa2\xc2\xa2\xc2\xa2\xc2\xa2\xc2\xa2\xc2\xa2\xc2\xa2\xc2\xa2\xc2\xa2\\long.txt"));
-#endif
-}
-
-void test_path_core__validate_workdir_with_core_longpath(void)
-{
-#ifdef GIT_WIN32
- git_repository *repo;
- git_config *config;
-
- repo = cl_git_sandbox_init("empty_bare.git");
-
- cl_git_pass(git_repository_open(&repo, "empty_bare.git"));
- cl_git_pass(git_repository_config(&config, repo));
-
- /* fail by default */
- cl_must_fail(git_path_validate_length(repo, "/c/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/longer_than_260.txt"));
-
- /* set core.longpaths explicitly on */
- cl_git_pass(git_config_set_bool(config, "core.longpaths", 1));
- cl_must_pass(git_path_validate_length(repo, "/c/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/longer_than_260.txt"));
-
- /* set core.longpaths explicitly off */
- cl_git_pass(git_config_set_bool(config, "core.longpaths", 0));
- cl_must_fail(git_path_validate_length(repo, "/c/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/longer_than_260.txt"));
-
- git_config_free(config);
- git_repository_free(repo);
-#endif
-}
-
static void test_join_unrooted(
const char *expected_result,
ssize_t expected_rootlen,
diff --git a/tests/path/win32.c b/tests/util/path/win32.c
index 1aaf6867a..1aaf6867a 100644
--- a/tests/path/win32.c
+++ b/tests/util/path/win32.c
diff --git a/tests/core/pool.c b/tests/util/pool.c
index b07da0abd..464aad733 100644
--- a/tests/core/pool.c
+++ b/tests/util/pool.c
@@ -2,7 +2,7 @@
#include "pool.h"
#include "git2/oid.h"
-void test_core_pool__0(void)
+void test_pool__0(void)
{
int i;
git_pool p;
@@ -20,7 +20,7 @@ void test_core_pool__0(void)
git_pool_clear(&p);
}
-void test_core_pool__1(void)
+void test_pool__1(void)
{
int i;
git_pool p;
@@ -50,37 +50,7 @@ void test_core_pool__1(void)
git_pool_clear(&p);
}
-static char to_hex[] = "0123456789abcdef";
-
-void test_core_pool__2(void)
-{
- git_pool p;
- char oid_hex[GIT_OID_HEXSZ];
- git_oid *oid;
- int i, j;
-
- memset(oid_hex, '0', sizeof(oid_hex));
-
- git_pool_init(&p, sizeof(git_oid));
- p.page_size = 4000;
-
- for (i = 1000; i < 10000; i++) {
- oid = git_pool_malloc(&p, 1);
- cl_assert(oid != NULL);
-
- for (j = 0; j < 8; j++)
- oid_hex[j] = to_hex[(i >> (4 * j)) & 0x0f];
- cl_git_pass(git_oid_fromstr(oid, oid_hex));
- }
-
-#ifndef GIT_DEBUG_POOL
- /* with fixed page size, allocation must end up with these values */
- cl_assert_equal_i(sizeof(void *) == 8 ? 55 : 45, git_pool__open_pages(&p));
-#endif
- git_pool_clear(&p);
-}
-
-void test_core_pool__strndup_limit(void)
+void test_pool__strndup_limit(void)
{
git_pool p;
diff --git a/tests/core/posix.c b/tests/util/posix.c
index cba312913..155f03a95 100644
--- a/tests/core/posix.c
+++ b/tests/util/posix.c
@@ -13,7 +13,7 @@
#include "futils.h"
#include "posix.h"
-void test_core_posix__initialize(void)
+void test_posix__initialize(void)
{
#ifdef GIT_WIN32
/* on win32, the WSA context needs to be initialized
@@ -35,7 +35,7 @@ static bool supports_ipv6(void)
#endif
}
-void test_core_posix__inet_pton(void)
+void test_posix__inet_pton(void)
{
struct in_addr addr;
struct in6_addr addr6;
@@ -96,7 +96,7 @@ void test_core_posix__inet_pton(void)
cl_assert_equal_i(EAFNOSUPPORT, errno);
}
-void test_core_posix__utimes(void)
+void test_posix__utimes(void)
{
struct p_timeval times[2];
struct stat st;
@@ -145,7 +145,7 @@ void test_core_posix__utimes(void)
cl_must_pass(p_unlink("foo"));
}
-void test_core_posix__unlink_removes_symlink(void)
+void test_posix__unlink_removes_symlink(void)
{
if (!git_fs_path_supports_symlinks(clar_sandbox_path()))
clar__skip();
@@ -166,7 +166,7 @@ void test_core_posix__unlink_removes_symlink(void)
cl_must_pass(p_rmdir("dir"));
}
-void test_core_posix__symlink_resolves_to_correct_type(void)
+void test_posix__symlink_resolves_to_correct_type(void)
{
git_str contents = GIT_STR_INIT;
@@ -190,7 +190,7 @@ void test_core_posix__symlink_resolves_to_correct_type(void)
git_str_dispose(&contents);
}
-void test_core_posix__relative_symlink(void)
+void test_posix__relative_symlink(void)
{
git_str contents = GIT_STR_INIT;
@@ -210,7 +210,7 @@ void test_core_posix__relative_symlink(void)
git_str_dispose(&contents);
}
-void test_core_posix__symlink_to_file_across_dirs(void)
+void test_posix__symlink_to_file_across_dirs(void)
{
git_str contents = GIT_STR_INIT;
diff --git a/tests/core/pqueue.c b/tests/util/pqueue.c
index 2b90f4172..38931ecfd 100644
--- a/tests/core/pqueue.c
+++ b/tests/util/pqueue.c
@@ -7,7 +7,7 @@ static int cmp_ints(const void *v1, const void *v2)
return (i1 < i2) ? -1 : (i1 > i2) ? 1 : 0;
}
-void test_core_pqueue__items_are_put_in_order(void)
+void test_pqueue__items_are_put_in_order(void)
{
git_pqueue pq;
int i, vals[20];
@@ -36,7 +36,7 @@ void test_core_pqueue__items_are_put_in_order(void)
git_pqueue_free(&pq);
}
-void test_core_pqueue__interleave_inserts_and_pops(void)
+void test_pqueue__interleave_inserts_and_pops(void)
{
git_pqueue pq;
int chunk, v, i, vals[200];
@@ -70,7 +70,7 @@ void test_core_pqueue__interleave_inserts_and_pops(void)
git_pqueue_free(&pq);
}
-void test_core_pqueue__max_heap_size(void)
+void test_pqueue__max_heap_size(void)
{
git_pqueue pq;
int i, vals[100];
@@ -95,7 +95,7 @@ void test_core_pqueue__max_heap_size(void)
git_pqueue_free(&pq);
}
-void test_core_pqueue__max_heap_size_without_comparison(void)
+void test_pqueue__max_heap_size_without_comparison(void)
{
git_pqueue pq;
int i, vals[100] = { 0 };
@@ -123,7 +123,7 @@ static int cmp_ints_like_commit_time(const void *a, const void *b)
return *((const int *)a) < *((const int *)b);
}
-void test_core_pqueue__interleaved_pushes_and_pops(void)
+void test_pqueue__interleaved_pushes_and_pops(void)
{
git_pqueue pq;
int i, j, *val;
diff --git a/tests/util/precompiled.c b/tests/util/precompiled.c
new file mode 100644
index 000000000..5f656a45d
--- /dev/null
+++ b/tests/util/precompiled.c
@@ -0,0 +1 @@
+#include "precompiled.h"
diff --git a/tests/util/precompiled.h b/tests/util/precompiled.h
new file mode 100644
index 000000000..6fa21423b
--- /dev/null
+++ b/tests/util/precompiled.h
@@ -0,0 +1,3 @@
+#include "common.h"
+#include "clar.h"
+#include "clar_libgit2.h"
diff --git a/tests/core/qsort.c b/tests/util/qsort.c
index efb79e6e9..d8fa20a0a 100644
--- a/tests/core/qsort.c
+++ b/tests/util/qsort.c
@@ -38,37 +38,37 @@ static int cmp_str(const void *_a, const void *_b, void *payload)
return strcmp((const char *) _a, (const char *) _b);
}
-void test_core_qsort__array_with_single_entry(void)
+void test_qsort__array_with_single_entry(void)
{
int a[] = { 10 };
assert_sorted(a, cmp_int);
}
-void test_core_qsort__array_with_equal_entries(void)
+void test_qsort__array_with_equal_entries(void)
{
int a[] = { 4, 4, 4, 4 };
assert_sorted(a, cmp_int);
}
-void test_core_qsort__sorted_array(void)
+void test_qsort__sorted_array(void)
{
int a[] = { 1, 10 };
assert_sorted(a, cmp_int);
}
-void test_core_qsort__unsorted_array(void)
+void test_qsort__unsorted_array(void)
{
int a[] = { 123, 9, 412938, 10, 234, 89 };
assert_sorted(a, cmp_int);
}
-void test_core_qsort__sorting_strings(void)
+void test_qsort__sorting_strings(void)
{
char *a[] = { "foo", "bar", "baz" };
assert_sorted(a, cmp_str);
}
-void test_core_qsort__sorting_big_entries(void)
+void test_qsort__sorting_big_entries(void)
{
struct big_entries a[5];
diff --git a/tests/core/regexp.c b/tests/util/regexp.c
index 8db5641e5..a76955d59 100644
--- a/tests/core/regexp.c
+++ b/tests/util/regexp.c
@@ -3,7 +3,6 @@
#include <locale.h>
#include "regexp.h"
-#include "userdiff.h"
#if LC_ALL > 0
static const char *old_locales[LC_ALL];
@@ -11,14 +10,14 @@ static const char *old_locales[LC_ALL];
static git_regexp regex;
-void test_core_regexp__initialize(void)
+void test_regexp__initialize(void)
{
#if LC_ALL > 0
memset(&old_locales, 0, sizeof(old_locales));
#endif
}
-void test_core_regexp__cleanup(void)
+void test_regexp__cleanup(void)
{
git_regexp_dispose(&regex);
}
@@ -39,13 +38,13 @@ static void try_set_locale(int category)
}
-void test_core_regexp__compile_ignores_global_locale_ctype(void)
+void test_regexp__compile_ignores_global_locale_ctype(void)
{
try_set_locale(LC_CTYPE);
cl_git_pass(git_regexp_compile(&regex, "[\xc0-\xff][\x80-\xbf]", 0));
}
-void test_core_regexp__compile_ignores_global_locale_collate(void)
+void test_regexp__compile_ignores_global_locale_collate(void)
{
#ifdef GIT_WIN32
cl_skip();
@@ -55,7 +54,7 @@ void test_core_regexp__compile_ignores_global_locale_collate(void)
cl_git_pass(git_regexp_compile(&regex, "[\xc0-\xff][\x80-\xbf]", 0));
}
-void test_core_regexp__regex_matches_digits_with_locale(void)
+void test_regexp__regex_matches_digits_with_locale(void)
{
char c, str[2];
@@ -75,7 +74,7 @@ void test_core_regexp__regex_matches_digits_with_locale(void)
}
}
-void test_core_regexp__regex_matches_alphabet_with_locale(void)
+void test_regexp__regex_matches_alphabet_with_locale(void)
{
char c, str[2];
@@ -99,40 +98,25 @@ void test_core_regexp__regex_matches_alphabet_with_locale(void)
}
}
-void test_core_regexp__compile_userdiff_regexps(void)
-{
- size_t idx;
-
- for (idx = 0; idx < ARRAY_SIZE(builtin_defs); ++idx) {
- git_diff_driver_definition ddef = builtin_defs[idx];
-
- cl_git_pass(git_regexp_compile(&regex, ddef.fns, ddef.flags));
- git_regexp_dispose(&regex);
-
- cl_git_pass(git_regexp_compile(&regex, ddef.words, 0));
- git_regexp_dispose(&regex);
- }
-}
-
-void test_core_regexp__simple_search_matches(void)
+void test_regexp__simple_search_matches(void)
{
cl_git_pass(git_regexp_compile(&regex, "a", 0));
cl_git_pass(git_regexp_search(&regex, "a", 0, NULL));
}
-void test_core_regexp__case_insensitive_search_matches(void)
+void test_regexp__case_insensitive_search_matches(void)
{
cl_git_pass(git_regexp_compile(&regex, "a", GIT_REGEXP_ICASE));
cl_git_pass(git_regexp_search(&regex, "A", 0, NULL));
}
-void test_core_regexp__nonmatching_search_returns_error(void)
+void test_regexp__nonmatching_search_returns_error(void)
{
cl_git_pass(git_regexp_compile(&regex, "a", 0));
cl_git_fail(git_regexp_search(&regex, "b", 0, NULL));
}
-void test_core_regexp__search_finds_complete_match(void)
+void test_regexp__search_finds_complete_match(void)
{
git_regmatch matches[1];
@@ -142,7 +126,7 @@ void test_core_regexp__search_finds_complete_match(void)
cl_assert_equal_i(matches[0].end, 3);
}
-void test_core_regexp__search_finds_correct_offsets(void)
+void test_regexp__search_finds_correct_offsets(void)
{
git_regmatch matches[3];
@@ -156,7 +140,7 @@ void test_core_regexp__search_finds_correct_offsets(void)
cl_assert_equal_i(matches[2].end, 2);
}
-void test_core_regexp__search_finds_empty_group(void)
+void test_regexp__search_finds_empty_group(void)
{
git_regmatch matches[3];
@@ -170,7 +154,7 @@ void test_core_regexp__search_finds_empty_group(void)
cl_assert_equal_i(matches[2].end, 1);
}
-void test_core_regexp__search_fills_matches_with_first_matching_groups(void)
+void test_regexp__search_fills_matches_with_first_matching_groups(void)
{
git_regmatch matches[2];
@@ -182,7 +166,7 @@ void test_core_regexp__search_fills_matches_with_first_matching_groups(void)
cl_assert_equal_i(matches[1].end, 1);
}
-void test_core_regexp__search_skips_nonmatching_group(void)
+void test_regexp__search_skips_nonmatching_group(void)
{
git_regmatch matches[4];
@@ -198,7 +182,7 @@ void test_core_regexp__search_skips_nonmatching_group(void)
cl_assert_equal_i(matches[3].end, 2);
}
-void test_core_regexp__search_initializes_trailing_nonmatching_groups(void)
+void test_regexp__search_initializes_trailing_nonmatching_groups(void)
{
git_regmatch matches[3];
diff --git a/tests/core/rmdir.c b/tests/util/rmdir.c
index f6c66b3a4..71ec05f9b 100644
--- a/tests/core/rmdir.c
+++ b/tests/util/rmdir.c
@@ -3,7 +3,7 @@
static const char *empty_tmp_dir = "test_gitfo_rmdir_recurs_test";
-void test_core_rmdir__initialize(void)
+void test_rmdir__initialize(void)
{
git_str path = GIT_STR_INIT;
@@ -27,14 +27,14 @@ void test_core_rmdir__initialize(void)
git_str_dispose(&path);
}
-void test_core_rmdir__cleanup(void)
+void test_rmdir__cleanup(void)
{
if (git_fs_path_exists(empty_tmp_dir))
cl_git_pass(git_futils_rmdir_r(empty_tmp_dir, NULL, GIT_RMDIR_REMOVE_FILES));
}
/* make sure empty dir can be deleted recursively */
-void test_core_rmdir__delete_recursive(void)
+void test_rmdir__delete_recursive(void)
{
git_str path = GIT_STR_INIT;
cl_git_pass(git_str_joinpath(&path, empty_tmp_dir, "/one"));
@@ -48,7 +48,7 @@ void test_core_rmdir__delete_recursive(void)
}
/* make sure non-empty dir cannot be deleted recursively */
-void test_core_rmdir__fail_to_delete_non_empty_dir(void)
+void test_rmdir__fail_to_delete_non_empty_dir(void)
{
git_str file = GIT_STR_INIT;
@@ -66,13 +66,13 @@ void test_core_rmdir__fail_to_delete_non_empty_dir(void)
git_str_dispose(&file);
}
-void test_core_rmdir__keep_base(void)
+void test_rmdir__keep_base(void)
{
cl_git_pass(git_futils_rmdir_r(empty_tmp_dir, NULL, GIT_RMDIR_SKIP_ROOT));
cl_assert(git_fs_path_exists(empty_tmp_dir));
}
-void test_core_rmdir__can_skip_non_empty_dir(void)
+void test_rmdir__can_skip_non_empty_dir(void)
{
git_str file = GIT_STR_INIT;
@@ -89,7 +89,7 @@ void test_core_rmdir__can_skip_non_empty_dir(void)
git_str_dispose(&file);
}
-void test_core_rmdir__can_remove_empty_parents(void)
+void test_rmdir__can_remove_empty_parents(void)
{
git_str file = GIT_STR_INIT;
diff --git a/tests/core/sha1.c b/tests/util/sha1.c
index 9ccdaab3c..68982758e 100644
--- a/tests/core/sha1.c
+++ b/tests/util/sha1.c
@@ -3,12 +3,12 @@
#define FIXTURE_DIR "sha1"
-void test_core_sha1__initialize(void)
+void test_sha1__initialize(void)
{
cl_fixture_sandbox(FIXTURE_DIR);
}
-void test_core_sha1__cleanup(void)
+void test_sha1__cleanup(void)
{
cl_fixture_cleanup(FIXTURE_DIR);
}
@@ -37,7 +37,7 @@ static int sha1_file(unsigned char *out, const char *filename)
return ret;
}
-void test_core_sha1__sum(void)
+void test_sha1__sum(void)
{
unsigned char expected[GIT_HASH_SHA1_SIZE] = {
0x4e, 0x72, 0x67, 0x9e, 0x3e, 0xa4, 0xd0, 0x4e, 0x0c, 0x64,
@@ -50,7 +50,7 @@ void test_core_sha1__sum(void)
}
/* test that sha1 collision detection works when enabled */
-void test_core_sha1__detect_collision_attack(void)
+void test_sha1__detect_collision_attack(void)
{
unsigned char actual[GIT_HASH_SHA1_SIZE];
unsigned char expected[GIT_HASH_SHA1_SIZE] = {
diff --git a/tests/core/sortedcache.c b/tests/util/sortedcache.c
index cb4e34efa..72da7aeb1 100644
--- a/tests/core/sortedcache.c
+++ b/tests/util/sortedcache.c
@@ -6,7 +6,7 @@ static int name_only_cmp(const void *a, const void *b)
return strcmp(a, b);
}
-void test_core_sortedcache__name_only(void)
+void test_sortedcache__name_only(void)
{
git_sortedcache *sc;
void *item;
@@ -84,7 +84,7 @@ static void sortedcache_test_struct_free(void *payload, void *item_)
item->smaller_value = 0;
}
-void test_core_sortedcache__in_memory(void)
+void test_sortedcache__in_memory(void)
{
git_sortedcache *sc;
sortedcache_test_struct *item;
@@ -269,7 +269,7 @@ static void sortedcache_test_reload(git_sortedcache *sc)
git_str_dispose(&buf);
}
-void test_core_sortedcache__on_disk(void)
+void test_sortedcache__on_disk(void)
{
git_sortedcache *sc;
sortedcache_test_struct *item;
diff --git a/tests/core/stat.c b/tests/util/stat.c
index 210072fe3..84c23fb21 100644
--- a/tests/core/stat.c
+++ b/tests/util/stat.c
@@ -2,14 +2,14 @@
#include "futils.h"
#include "posix.h"
-void test_core_stat__initialize(void)
+void test_stat__initialize(void)
{
cl_git_pass(git_futils_mkdir("root/d1/d2", 0755, GIT_MKDIR_PATH));
cl_git_mkfile("root/file", "whatever\n");
cl_git_mkfile("root/d1/file", "whatever\n");
}
-void test_core_stat__cleanup(void)
+void test_stat__cleanup(void)
{
git_futils_rmdir_r("root", NULL, GIT_RMDIR_REMOVE_FILES);
}
@@ -17,7 +17,7 @@ void test_core_stat__cleanup(void)
#define cl_assert_error(val) \
do { err = errno; cl_assert_equal_i((val), err); } while (0)
-void test_core_stat__0(void)
+void test_stat__0(void)
{
struct stat st;
int err;
@@ -94,7 +94,7 @@ void test_core_stat__0(void)
cl_assert_error(ENOTDIR);
}
-void test_core_stat__root(void)
+void test_stat__root(void)
{
const char *sandbox = clar_sandbox_path();
git_str root = GIT_STR_INIT;
diff --git a/tests/str/basic.c b/tests/util/str/basic.c
index 5d2556805..5d2556805 100644
--- a/tests/str/basic.c
+++ b/tests/util/str/basic.c
diff --git a/tests/str/oom.c b/tests/util/str/oom.c
index 3d59ead01..dd3796674 100644
--- a/tests/str/oom.c
+++ b/tests/util/str/oom.c
@@ -25,12 +25,12 @@ void test_str_oom__initialize(void)
oom_alloc.gmalloc = oom_malloc;
oom_alloc.grealloc = oom_realloc;
- cl_git_pass(git_libgit2_opts(GIT_OPT_SET_ALLOCATOR, &oom_alloc));
+ cl_git_pass(git_allocator_setup(&oom_alloc));
}
void test_str_oom__cleanup(void)
{
- cl_git_pass(git_libgit2_opts(GIT_OPT_SET_ALLOCATOR, NULL));
+ cl_git_pass(git_allocator_setup(NULL));
}
void test_str_oom__grow(void)
diff --git a/tests/str/percent.c b/tests/util/str/percent.c
index 339389075..339389075 100644
--- a/tests/str/percent.c
+++ b/tests/util/str/percent.c
diff --git a/tests/str/quote.c b/tests/util/str/quote.c
index 2c6546247..2c6546247 100644
--- a/tests/str/quote.c
+++ b/tests/util/str/quote.c
diff --git a/tests/str/splice.c b/tests/util/str/splice.c
index 14e844e2f..14e844e2f 100644
--- a/tests/str/splice.c
+++ b/tests/util/str/splice.c
diff --git a/tests/core/string.c b/tests/util/string.c
index 928dfbcc1..de04dea69 100644
--- a/tests/core/string.c
+++ b/tests/util/string.c
@@ -1,7 +1,7 @@
#include "clar_libgit2.h"
/* compare prefixes */
-void test_core_string__0(void)
+void test_string__0(void)
{
cl_assert(git__prefixcmp("", "") == 0);
cl_assert(git__prefixcmp("a", "") == 0);
@@ -14,7 +14,7 @@ void test_core_string__0(void)
}
/* compare suffixes */
-void test_core_string__1(void)
+void test_string__1(void)
{
cl_assert(git__suffixcmp("", "") == 0);
cl_assert(git__suffixcmp("a", "") == 0);
@@ -27,7 +27,7 @@ void test_core_string__1(void)
}
/* compare icase sorting with case equality */
-void test_core_string__2(void)
+void test_string__2(void)
{
cl_assert(git__strcasesort_cmp("", "") == 0);
cl_assert(git__strcasesort_cmp("foo", "foo") == 0);
@@ -41,7 +41,7 @@ void test_core_string__2(void)
}
/* compare prefixes with len */
-void test_core_string__prefixncmp(void)
+void test_string__prefixncmp(void)
{
cl_assert(git__prefixncmp("", 0, "") == 0);
cl_assert(git__prefixncmp("a", 1, "") == 0);
@@ -58,7 +58,7 @@ void test_core_string__prefixncmp(void)
}
/* compare prefixes with len */
-void test_core_string__prefixncmp_icase(void)
+void test_string__prefixncmp_icase(void)
{
cl_assert(git__prefixncmp_icase("", 0, "") == 0);
cl_assert(git__prefixncmp_icase("a", 1, "") == 0);
@@ -82,7 +82,7 @@ void test_core_string__prefixncmp_icase(void)
cl_assert(git__prefixncmp_icase("ab", 1, "aa") < 0);
}
-void test_core_string__strcmp(void)
+void test_string__strcmp(void)
{
cl_assert(git__strcmp("", "") == 0);
cl_assert(git__strcmp("foo", "foo") == 0);
@@ -103,7 +103,7 @@ void test_core_string__strcmp(void)
cl_assert(git__strcmp("\303\215", "\303\255") < 0);
}
-void test_core_string__strcasecmp(void)
+void test_string__strcasecmp(void)
{
cl_assert(git__strcasecmp("", "") == 0);
cl_assert(git__strcasecmp("foo", "foo") == 0);
@@ -124,7 +124,7 @@ void test_core_string__strcasecmp(void)
cl_assert(git__strcasecmp("\303\215", "\303\255") < 0);
}
-void test_core_string__strlcmp(void)
+void test_string__strlcmp(void)
{
const char foo[3] = { 'f', 'o', 'o' };
diff --git a/tests/core/strmap.c b/tests/util/strmap.c
index ba118ae1e..c4f5c8647 100644
--- a/tests/core/strmap.c
+++ b/tests/util/strmap.c
@@ -3,18 +3,18 @@
static git_strmap *g_table;
-void test_core_strmap__initialize(void)
+void test_strmap__initialize(void)
{
cl_git_pass(git_strmap_new(&g_table));
cl_assert(g_table != NULL);
}
-void test_core_strmap__cleanup(void)
+void test_strmap__cleanup(void)
{
git_strmap_free(g_table);
}
-void test_core_strmap__0(void)
+void test_strmap__0(void)
{
cl_assert(git_strmap_size(g_table) == 0);
}
@@ -40,7 +40,7 @@ static void insert_strings(git_strmap *table, size_t count)
cl_assert_equal_i(git_strmap_size(table), count);
}
-void test_core_strmap__inserted_strings_can_be_retrieved(void)
+void test_strmap__inserted_strings_can_be_retrieved(void)
{
char *str;
int i;
@@ -57,7 +57,7 @@ void test_core_strmap__inserted_strings_can_be_retrieved(void)
cl_assert(i == 20);
}
-void test_core_strmap__deleted_entry_cannot_be_retrieved(void)
+void test_strmap__deleted_entry_cannot_be_retrieved(void)
{
char *str;
int i;
@@ -77,7 +77,7 @@ void test_core_strmap__deleted_entry_cannot_be_retrieved(void)
cl_assert_equal_i(i, 19);
}
-void test_core_strmap__inserting_many_keys_succeeds(void)
+void test_strmap__inserting_many_keys_succeeds(void)
{
char *str;
int i;
@@ -89,7 +89,7 @@ void test_core_strmap__inserting_many_keys_succeeds(void)
cl_assert_equal_i(i, 10000);
}
-void test_core_strmap__get_succeeds_with_existing_entries(void)
+void test_strmap__get_succeeds_with_existing_entries(void)
{
const char *keys[] = { "foo", "bar", "gobble" };
char *values[] = { "oof", "rab", "elbbog" };
@@ -103,7 +103,7 @@ void test_core_strmap__get_succeeds_with_existing_entries(void)
cl_assert_equal_s(git_strmap_get(g_table, "gobble"), "elbbog");
}
-void test_core_strmap__get_returns_null_on_nonexisting_key(void)
+void test_strmap__get_returns_null_on_nonexisting_key(void)
{
const char *keys[] = { "foo", "bar", "gobble" };
char *values[] = { "oof", "rab", "elbbog" };
@@ -115,13 +115,13 @@ void test_core_strmap__get_returns_null_on_nonexisting_key(void)
cl_assert_equal_p(git_strmap_get(g_table, "other"), NULL);
}
-void test_core_strmap__set_persists_key(void)
+void test_strmap__set_persists_key(void)
{
cl_git_pass(git_strmap_set(g_table, "foo", "oof"));
cl_assert_equal_s(git_strmap_get(g_table, "foo"), "oof");
}
-void test_core_strmap__set_persists_multpile_keys(void)
+void test_strmap__set_persists_multpile_keys(void)
{
cl_git_pass(git_strmap_set(g_table, "foo", "oof"));
cl_git_pass(git_strmap_set(g_table, "bar", "rab"));
@@ -129,7 +129,7 @@ void test_core_strmap__set_persists_multpile_keys(void)
cl_assert_equal_s(git_strmap_get(g_table, "bar"), "rab");
}
-void test_core_strmap__set_updates_existing_key(void)
+void test_strmap__set_updates_existing_key(void)
{
cl_git_pass(git_strmap_set(g_table, "foo", "oof"));
cl_git_pass(git_strmap_set(g_table, "bar", "rab"));
@@ -142,7 +142,7 @@ void test_core_strmap__set_updates_existing_key(void)
cl_assert_equal_s(git_strmap_get(g_table, "foo"), "other");
}
-void test_core_strmap__iteration(void)
+void test_strmap__iteration(void)
{
struct {
char *key;
@@ -182,7 +182,7 @@ void test_core_strmap__iteration(void)
cl_assert_equal_i(n, ARRAY_SIZE(entries));
}
-void test_core_strmap__iterating_empty_map_stops_immediately(void)
+void test_strmap__iterating_empty_map_stops_immediately(void)
{
size_t i = 0;
diff --git a/tests/core/strtol.c b/tests/util/strtol.c
index 851b91b0a..54c63ca08 100644
--- a/tests/core/strtol.c
+++ b/tests/util/strtol.c
@@ -26,7 +26,7 @@ static void assert_l64_fails(const char *string, int base)
cl_git_fail(git__strntol64(&i, string, strlen(string), NULL, base));
}
-void test_core_strtol__int32(void)
+void test_strtol__int32(void)
{
assert_l32_parses("123", 123, 10);
assert_l32_parses(" +123 ", 123, 10);
@@ -43,7 +43,7 @@ void test_core_strtol__int32(void)
assert_l32_fails(" -2147483657 ", 10);
}
-void test_core_strtol__int64(void)
+void test_strtol__int64(void)
{
assert_l64_parses("123", 123, 10);
assert_l64_parses(" +123 ", 123, 10);
@@ -66,7 +66,7 @@ void test_core_strtol__int64(void)
assert_l64_fails("-0x8000000000000001", 16);
}
-void test_core_strtol__base_autodetection(void)
+void test_strtol__base_autodetection(void)
{
assert_l64_parses("0", 0, 0);
assert_l64_parses("00", 0, 0);
@@ -78,7 +78,7 @@ void test_core_strtol__base_autodetection(void)
assert_l64_parses("0x18", 24, 0);
}
-void test_core_strtol__buffer_length_with_autodetection_truncates(void)
+void test_strtol__buffer_length_with_autodetection_truncates(void)
{
int64_t i64;
@@ -88,7 +88,7 @@ void test_core_strtol__buffer_length_with_autodetection_truncates(void)
cl_assert_equal_i(i64, 1);
}
-void test_core_strtol__buffer_length_truncates(void)
+void test_strtol__buffer_length_truncates(void)
{
int32_t i32;
int64_t i64;
@@ -100,7 +100,7 @@ void test_core_strtol__buffer_length_truncates(void)
cl_assert_equal_i(i64, 1);
}
-void test_core_strtol__buffer_length_with_leading_ws_truncates(void)
+void test_strtol__buffer_length_with_leading_ws_truncates(void)
{
int64_t i64;
@@ -110,7 +110,7 @@ void test_core_strtol__buffer_length_with_leading_ws_truncates(void)
cl_assert_equal_i(i64, 1);
}
-void test_core_strtol__buffer_length_with_leading_sign_truncates(void)
+void test_strtol__buffer_length_with_leading_sign_truncates(void)
{
int64_t i64;
@@ -120,7 +120,7 @@ void test_core_strtol__buffer_length_with_leading_sign_truncates(void)
cl_assert_equal_i(i64, -1);
}
-void test_core_strtol__error_message_cuts_off(void)
+void test_strtol__error_message_cuts_off(void)
{
assert_l32_fails("2147483657foobar", 10);
cl_assert(strstr(git_error_last()->message, "2147483657") != NULL);
diff --git a/tests/core/utf8.c b/tests/util/utf8.c
index e1987b8d6..3987603bb 100644
--- a/tests/core/utf8.c
+++ b/tests/util/utf8.c
@@ -1,7 +1,7 @@
#include "clar_libgit2.h"
#include "utf8.h"
-void test_core_utf8__char_length(void)
+void test_utf8__char_length(void)
{
cl_assert_equal_i(0, git_utf8_char_length("", 0));
cl_assert_equal_i(1, git_utf8_char_length("$", 1));
diff --git a/tests/core/vector.c b/tests/util/vector.c
index 08cd2c19b..04afaa496 100644
--- a/tests/core/vector.c
+++ b/tests/util/vector.c
@@ -4,7 +4,7 @@
#include "vector.h"
/* initial size of 1 would cause writing past array bounds */
-void test_core_vector__0(void)
+void test_vector__0(void)
{
git_vector x;
int i;
@@ -17,7 +17,7 @@ void test_core_vector__0(void)
/* don't read past array bounds on remove() */
-void test_core_vector__1(void)
+void test_vector__1(void)
{
git_vector x;
/* make initial capacity exact for our insertions. */
@@ -37,7 +37,7 @@ static int test_cmp(const void *a, const void *b)
}
/* remove duplicates */
-void test_core_vector__2(void)
+void test_vector__2(void)
{
git_vector x;
int *ptrs[2];
@@ -72,7 +72,7 @@ static int compare_them(const void *a, const void *b)
}
/* insert_sorted */
-void test_core_vector__3(void)
+void test_vector__3(void)
{
git_vector x;
intptr_t i;
@@ -95,7 +95,7 @@ void test_core_vector__3(void)
}
/* insert_sorted with duplicates */
-void test_core_vector__4(void)
+void test_vector__4(void)
{
git_vector x;
intptr_t i;
@@ -158,7 +158,7 @@ static my_struct *alloc_struct(int value)
}
/* insert_sorted with duplicates and special handling */
-void test_core_vector__5(void)
+void test_vector__5(void)
{
git_vector x;
int i;
@@ -199,7 +199,7 @@ static int remove_ones(const git_vector *v, size_t idx, void *p)
}
/* Test removal based on callback */
-void test_core_vector__remove_matching(void)
+void test_vector__remove_matching(void)
{
git_vector x;
size_t i;
@@ -287,7 +287,7 @@ static void assert_vector(git_vector *x, void *expected[], size_t len)
cl_assert(expected[i] == x->contents[i]);
}
-void test_core_vector__grow_and_shrink(void)
+void test_vector__grow_and_shrink(void)
{
git_vector x = GIT_VECTOR_INIT;
void *expected1[] = {
@@ -379,7 +379,7 @@ void test_core_vector__grow_and_shrink(void)
git_vector_free(&x);
}
-void test_core_vector__reverse(void)
+void test_vector__reverse(void)
{
git_vector v = GIT_VECTOR_INIT;
size_t i;
@@ -410,7 +410,7 @@ void test_core_vector__reverse(void)
git_vector_free(&v);
}
-void test_core_vector__dup_empty_vector(void)
+void test_vector__dup_empty_vector(void)
{
git_vector v = GIT_VECTOR_INIT;
git_vector dup = GIT_VECTOR_INIT;
diff --git a/tests/core/wildmatch.c b/tests/util/wildmatch.c
index 7c56ee7b8..a5af61ab4 100644
--- a/tests/core/wildmatch.c
+++ b/tests/util/wildmatch.c
@@ -26,7 +26,7 @@ static void assert_matches_(const char *string, const char *pattern,
* tests for git-ls-files.
*/
-void test_core_wildmatch__basic_wildmatch(void)
+void test_wildmatch__basic_wildmatch(void)
{
assert_matches("foo", "foo", 1, 1, 1, 1);
assert_matches("foo", "bar", 0, 0, 0, 0);
@@ -58,7 +58,7 @@ void test_core_wildmatch__basic_wildmatch(void)
assert_matches("]", "]", 1, 1, 1, 1);
}
-void test_core_wildmatch__slash_matching_features(void)
+void test_wildmatch__slash_matching_features(void)
{
assert_matches("foo/baz/bar", "foo*bar", 0, 0, 1, 1);
assert_matches("foo/baz/bar", "foo**bar", 0, 0, 1, 1);
@@ -90,7 +90,7 @@ void test_core_wildmatch__slash_matching_features(void)
assert_matches("deep/foo/bar/baz/x", "**/bar/*/*", 1, 1, 1, 1);
}
-void test_core_wildmatch__various_additional(void)
+void test_wildmatch__various_additional(void)
{
assert_matches("acrt", "a[c-c]st", 0, 0, 0, 0);
assert_matches("acrt", "a[c-c]rt", 1, 1, 1, 1);
@@ -115,7 +115,7 @@ void test_core_wildmatch__various_additional(void)
assert_matches("foo/bar/baz/to", "**/t[o]", 1, 1, 1, 1);
}
-void test_core_wildmatch__character_classes(void)
+void test_wildmatch__character_classes(void)
{
assert_matches("a1B", "[[:alpha:]][[:digit:]][[:upper:]]", 1, 1, 1, 1);
assert_matches("a", "[[:digit:][:upper:][:space:]]", 0, 1, 0, 1);
@@ -136,7 +136,7 @@ void test_core_wildmatch__character_classes(void)
assert_matches("q", "[a-c[:digit:]x-z]", 0, 0, 0, 0);
}
-void test_core_wildmatch__additional_with_malformed(void)
+void test_wildmatch__additional_with_malformed(void)
{
assert_matches("]", "[\\\\-^]", 1, 1, 1, 1);
assert_matches("[", "[\\\\-^]", 0, 0, 0, 0);
@@ -190,7 +190,7 @@ void test_core_wildmatch__additional_with_malformed(void)
assert_matches("-", "[[-\\]]", 0, 0, 0, 0);
}
-void test_core_wildmatch__recursion(void)
+void test_wildmatch__recursion(void)
{
assert_matches("-adobe-courier-bold-o-normal--12-120-75-75-m-70-iso8859-1", "-*-*-*-*-*-*-12-*-*-*-m-*-*-*", 1, 1, 1, 1);
assert_matches("-adobe-courier-bold-o-normal--12-120-75-75-X-70-iso8859-1", "-*-*-*-*-*-*-12-*-*-*-m-*-*-*", 0, 0, 0, 0);
@@ -210,7 +210,7 @@ void test_core_wildmatch__recursion(void)
assert_matches("ab/cXd/efXg/hi", "**/*X*/**/*i", 1, 1, 1, 1);
}
-void test_core_wildmatch__pathmatch(void)
+void test_wildmatch__pathmatch(void)
{
assert_matches("foo", "fo", 0, 0, 0, 0);
assert_matches("foo/bar", "foo/bar", 1, 1, 1, 1);
@@ -229,7 +229,7 @@ void test_core_wildmatch__pathmatch(void)
assert_matches("ab/cXd/efXg/hi", "*Xg*i", 0, 0, 1, 1);
}
-void test_core_wildmatch__case_sensitivity(void)
+void test_wildmatch__case_sensitivity(void)
{
assert_matches("a", "[A-Z]", 0, 1, 0, 1);
assert_matches("A", "[A-Z]", 1, 1, 1, 1);
diff --git a/tests/core/zstream.c b/tests/util/zstream.c
index c22e81008..5c89895c7 100644
--- a/tests/core/zstream.c
+++ b/tests/util/zstream.c
@@ -41,7 +41,7 @@ static void assert_zlib_equal_(
#define assert_zlib_equal(E,EL,C,CL) \
assert_zlib_equal_(E, EL, C, CL, #EL " != " #CL, __FILE__, __func__, (int)__LINE__)
-void test_core_zstream__basic(void)
+void test_zstream__basic(void)
{
git_zstream z = GIT_ZSTREAM_INIT;
char out[128];
@@ -57,7 +57,7 @@ void test_core_zstream__basic(void)
assert_zlib_equal(data, strlen(data) + 1, out, outlen);
}
-void test_core_zstream__fails_on_trailing_garbage(void)
+void test_zstream__fails_on_trailing_garbage(void)
{
git_str deflated = GIT_STR_INIT, inflated = GIT_STR_INIT;
char i = 0;
@@ -76,7 +76,7 @@ void test_core_zstream__fails_on_trailing_garbage(void)
git_str_dispose(&inflated);
}
-void test_core_zstream__buffer(void)
+void test_zstream__buffer(void)
{
git_str out = GIT_STR_INIT;
cl_git_pass(git_zstream_deflatebuf(&out, data, strlen(data) + 1));
@@ -140,7 +140,7 @@ static void compress_and_decompress_input_various_ways(git_str *input)
git__free(fixed);
}
-void test_core_zstream__big_data(void)
+void test_zstream__big_data(void)
{
git_str in = GIT_STR_INIT;
size_t scan, target;