rugged 0.26.7 → 0.27.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -2
- data/ext/rugged/rugged_blame.c +6 -3
- data/ext/rugged/rugged_branch_collection.c +3 -6
- data/ext/rugged/rugged_commit.c +56 -0
- data/ext/rugged/rugged_config.c +44 -9
- data/ext/rugged/rugged_diff.c +3 -14
- data/ext/rugged/rugged_diff_hunk.c +1 -3
- data/ext/rugged/rugged_index.c +1 -5
- data/ext/rugged/rugged_note.c +1 -4
- data/ext/rugged/rugged_patch.c +1 -4
- data/ext/rugged/rugged_reference_collection.c +1 -7
- data/ext/rugged/rugged_remote.c +5 -8
- data/ext/rugged/rugged_remote_collection.c +1 -6
- data/ext/rugged/rugged_repo.c +16 -48
- data/ext/rugged/rugged_revwalk.c +7 -16
- data/ext/rugged/rugged_settings.c +28 -0
- data/ext/rugged/rugged_submodule_collection.c +3 -4
- data/ext/rugged/rugged_tag_collection.c +1 -5
- data/ext/rugged/rugged_tree.c +2 -3
- data/lib/rugged/repository.rb +43 -0
- data/lib/rugged/version.rb +1 -1
- data/vendor/libgit2/AUTHORS +1 -0
- data/vendor/libgit2/CMakeLists.txt +61 -510
- data/vendor/libgit2/cmake/Modules/EnableWarnings.cmake +14 -0
- data/vendor/libgit2/cmake/Modules/FindCoreFoundation.cmake +25 -8
- data/vendor/libgit2/cmake/Modules/FindSecurity.cmake +27 -8
- data/vendor/libgit2/cmake/Modules/FindStatNsec.cmake +20 -0
- data/vendor/libgit2/cmake/Modules/IdeSplitSources.cmake +22 -0
- data/vendor/libgit2/deps/http-parser/CMakeLists.txt +3 -0
- data/vendor/libgit2/deps/regex/CMakeLists.txt +2 -0
- data/vendor/libgit2/deps/winhttp/CMakeLists.txt +26 -0
- data/vendor/libgit2/deps/zlib/CMakeLists.txt +4 -0
- data/vendor/libgit2/include/git2/config.h +29 -2
- data/vendor/libgit2/include/git2/describe.h +1 -1
- data/vendor/libgit2/include/git2/diff.h +59 -8
- data/vendor/libgit2/include/git2/graph.h +3 -0
- data/vendor/libgit2/include/git2/merge.h +6 -0
- data/vendor/libgit2/include/git2/message.h +43 -3
- data/vendor/libgit2/include/git2/notes.h +89 -0
- data/vendor/libgit2/include/git2/odb.h +8 -1
- data/vendor/libgit2/include/git2/patch.h +2 -2
- data/vendor/libgit2/include/git2/pathspec.h +35 -18
- data/vendor/libgit2/include/git2/refs.h +3 -0
- data/vendor/libgit2/include/git2/remote.h +34 -4
- data/vendor/libgit2/include/git2/repository.h +6 -6
- data/vendor/libgit2/include/git2/reset.h +4 -4
- data/vendor/libgit2/include/git2/status.h +4 -0
- data/vendor/libgit2/include/git2/sys/config.h +4 -1
- data/vendor/libgit2/include/git2/sys/odb_backend.h +2 -1
- data/vendor/libgit2/include/git2/tree.h +4 -3
- data/vendor/libgit2/include/git2/types.h +1 -0
- data/vendor/libgit2/include/git2/version.h +4 -4
- data/vendor/libgit2/include/git2/worktree.h +1 -1
- data/vendor/libgit2/src/CMakeLists.txt +463 -0
- data/vendor/libgit2/src/annotated_commit.c +1 -1
- data/vendor/libgit2/src/annotated_commit.h +2 -0
- data/vendor/libgit2/src/apply.c +2 -1
- data/vendor/libgit2/src/apply.h +2 -0
- data/vendor/libgit2/src/attr.c +24 -4
- data/vendor/libgit2/src/attr.h +2 -0
- data/vendor/libgit2/src/attr_file.c +9 -2
- data/vendor/libgit2/src/attr_file.h +2 -0
- data/vendor/libgit2/src/attrcache.c +9 -1
- data/vendor/libgit2/src/attrcache.h +2 -0
- data/vendor/libgit2/src/blame.c +1 -0
- data/vendor/libgit2/src/blame.h +2 -1
- data/vendor/libgit2/src/blame_git.c +1 -0
- data/vendor/libgit2/src/blame_git.h +2 -0
- data/vendor/libgit2/src/blob.c +2 -2
- data/vendor/libgit2/src/blob.h +2 -0
- data/vendor/libgit2/src/branch.c +8 -1
- data/vendor/libgit2/src/branch.h +2 -0
- data/vendor/libgit2/src/buf_text.c +7 -7
- data/vendor/libgit2/src/buf_text.h +3 -3
- data/vendor/libgit2/src/buffer.c +31 -1
- data/vendor/libgit2/src/buffer.h +3 -0
- data/vendor/libgit2/src/cache.c +2 -2
- data/vendor/libgit2/src/cache.h +2 -0
- data/vendor/libgit2/src/cc-compat.h +3 -3
- data/vendor/libgit2/src/checkout.c +30 -19
- data/vendor/libgit2/src/checkout.h +2 -0
- data/vendor/libgit2/src/cherrypick.c +1 -0
- data/vendor/libgit2/src/clone.c +2 -1
- data/vendor/libgit2/src/clone.h +4 -0
- data/vendor/libgit2/src/commit.c +2 -1
- data/vendor/libgit2/src/commit.h +2 -0
- data/vendor/libgit2/src/commit_list.c +1 -1
- data/vendor/libgit2/src/commit_list.h +2 -0
- data/vendor/libgit2/src/common.h +11 -5
- data/vendor/libgit2/src/config.c +12 -10
- data/vendor/libgit2/src/config.h +2 -0
- data/vendor/libgit2/src/config_cache.c +1 -0
- data/vendor/libgit2/src/config_file.c +287 -786
- data/vendor/libgit2/src/config_file.h +4 -3
- data/vendor/libgit2/src/config_parse.c +525 -0
- data/vendor/libgit2/src/config_parse.h +64 -0
- data/vendor/libgit2/src/crlf.c +2 -1
- data/vendor/libgit2/src/delta.c +28 -30
- data/vendor/libgit2/src/delta.h +1 -0
- data/vendor/libgit2/src/describe.c +3 -1
- data/vendor/libgit2/src/diff.c +148 -2
- data/vendor/libgit2/src/diff.h +3 -1
- data/vendor/libgit2/src/diff_driver.c +12 -9
- data/vendor/libgit2/src/diff_driver.h +4 -1
- data/vendor/libgit2/src/diff_file.c +7 -4
- data/vendor/libgit2/src/diff_file.h +1 -0
- data/vendor/libgit2/src/diff_generate.c +6 -3
- data/vendor/libgit2/src/diff_generate.h +6 -1
- data/vendor/libgit2/src/diff_parse.c +5 -4
- data/vendor/libgit2/src/diff_parse.h +2 -0
- data/vendor/libgit2/src/diff_print.c +2 -0
- data/vendor/libgit2/src/diff_stats.c +2 -0
- data/vendor/libgit2/src/diff_tform.c +2 -1
- data/vendor/libgit2/src/diff_tform.h +4 -1
- data/vendor/libgit2/src/diff_xdiff.c +5 -2
- data/vendor/libgit2/src/diff_xdiff.h +2 -0
- data/vendor/libgit2/src/errors.c +2 -0
- data/vendor/libgit2/src/features.h.in +36 -0
- data/vendor/libgit2/src/fetch.c +2 -2
- data/vendor/libgit2/src/fetch.h +4 -0
- data/vendor/libgit2/src/fetchhead.c +3 -3
- data/vendor/libgit2/src/fetchhead.h +3 -0
- data/vendor/libgit2/src/filebuf.c +2 -1
- data/vendor/libgit2/src/filebuf.h +2 -0
- data/vendor/libgit2/src/fileops.c +12 -1
- data/vendor/libgit2/src/fileops.h +7 -1
- data/vendor/libgit2/src/filter.c +2 -1
- data/vendor/libgit2/src/filter.h +1 -0
- data/vendor/libgit2/src/fnmatch.c +2 -2
- data/vendor/libgit2/src/fnmatch.h +3 -4
- data/vendor/libgit2/src/global.c +4 -3
- data/vendor/libgit2/src/global.h +1 -5
- data/vendor/libgit2/src/graph.c +2 -0
- data/vendor/libgit2/src/hash.c +0 -1
- data/vendor/libgit2/src/hash.h +3 -1
- data/vendor/libgit2/src/hash/hash_collisiondetect.h +3 -3
- data/vendor/libgit2/src/hash/hash_common_crypto.h +18 -5
- data/vendor/libgit2/src/hash/hash_generic.c +2 -2
- data/vendor/libgit2/src/hash/hash_generic.h +5 -3
- data/vendor/libgit2/src/hash/hash_openssl.h +3 -3
- data/vendor/libgit2/src/hash/hash_win32.c +57 -14
- data/vendor/libgit2/src/hash/hash_win32.h +4 -3
- data/vendor/libgit2/src/hashsig.c +3 -0
- data/vendor/libgit2/src/ident.c +2 -0
- data/vendor/libgit2/src/idxmap.h +2 -1
- data/vendor/libgit2/src/ignore.c +14 -2
- data/vendor/libgit2/src/ignore.h +2 -0
- data/vendor/libgit2/src/index.c +20 -40
- data/vendor/libgit2/src/index.h +2 -0
- data/vendor/libgit2/src/indexer.c +13 -5
- data/vendor/libgit2/src/indexer.h +5 -1
- data/vendor/libgit2/src/integer.h +1 -1
- data/vendor/libgit2/src/iterator.c +44 -3
- data/vendor/libgit2/src/iterator.h +3 -0
- data/vendor/libgit2/src/map.h +1 -1
- data/vendor/libgit2/src/merge.c +155 -33
- data/vendor/libgit2/src/merge.h +2 -0
- data/vendor/libgit2/src/merge_driver.c +2 -2
- data/vendor/libgit2/src/merge_driver.h +2 -0
- data/vendor/libgit2/src/merge_file.c +3 -0
- data/vendor/libgit2/src/message.h +3 -1
- data/vendor/libgit2/src/mwindow.c +1 -1
- data/vendor/libgit2/src/mwindow.h +2 -0
- data/vendor/libgit2/src/netops.c +75 -62
- data/vendor/libgit2/src/netops.h +2 -1
- data/vendor/libgit2/src/notes.c +164 -48
- data/vendor/libgit2/src/notes.h +1 -1
- data/vendor/libgit2/src/object.c +14 -3
- data/vendor/libgit2/src/object.h +4 -0
- data/vendor/libgit2/src/object_api.c +3 -2
- data/vendor/libgit2/src/odb.c +104 -38
- data/vendor/libgit2/src/odb.h +3 -1
- data/vendor/libgit2/src/odb_loose.c +414 -267
- data/vendor/libgit2/src/odb_mempack.c +1 -0
- data/vendor/libgit2/src/odb_pack.c +2 -1
- data/vendor/libgit2/src/offmap.h +1 -0
- data/vendor/libgit2/src/oid.c +2 -1
- data/vendor/libgit2/src/oid.h +3 -8
- data/vendor/libgit2/src/oidarray.c +2 -1
- data/vendor/libgit2/src/oidarray.h +1 -0
- data/vendor/libgit2/src/oidmap.h +1 -0
- data/vendor/libgit2/src/pack-objects.c +5 -1
- data/vendor/libgit2/src/pack-objects.h +1 -1
- data/vendor/libgit2/src/pack.c +2 -6
- data/vendor/libgit2/src/pack.h +2 -1
- data/vendor/libgit2/src/parse.c +121 -0
- data/vendor/libgit2/src/parse.h +61 -0
- data/vendor/libgit2/src/patch.c +9 -2
- data/vendor/libgit2/src/patch.h +2 -0
- data/vendor/libgit2/src/patch_generate.c +6 -5
- data/vendor/libgit2/src/patch_generate.h +1 -0
- data/vendor/libgit2/src/patch_parse.c +265 -276
- data/vendor/libgit2/src/patch_parse.h +6 -11
- data/vendor/libgit2/src/path.c +24 -181
- data/vendor/libgit2/src/path.h +14 -73
- data/vendor/libgit2/src/pathspec.c +2 -1
- data/vendor/libgit2/src/pathspec.h +2 -1
- data/vendor/libgit2/src/pool.c +8 -0
- data/vendor/libgit2/src/pool.h +1 -0
- data/vendor/libgit2/src/posix.c +2 -1
- data/vendor/libgit2/src/posix.h +1 -0
- data/vendor/libgit2/src/pqueue.c +1 -0
- data/vendor/libgit2/src/pqueue.h +2 -0
- data/vendor/libgit2/src/proxy.c +2 -1
- data/vendor/libgit2/src/proxy.h +3 -1
- data/vendor/libgit2/src/push.c +4 -171
- data/vendor/libgit2/src/push.h +2 -0
- data/vendor/libgit2/src/rebase.c +1 -0
- data/vendor/libgit2/src/refdb.c +2 -3
- data/vendor/libgit2/src/refdb.h +2 -0
- data/vendor/libgit2/src/refdb_fs.c +5 -3
- data/vendor/libgit2/src/refdb_fs.h +4 -0
- data/vendor/libgit2/src/reflog.c +1 -0
- data/vendor/libgit2/src/reflog.h +2 -1
- data/vendor/libgit2/src/refs.c +1 -0
- data/vendor/libgit2/src/refs.h +2 -1
- data/vendor/libgit2/src/refspec.c +2 -2
- data/vendor/libgit2/src/refspec.h +2 -0
- data/vendor/libgit2/src/remote.c +56 -10
- data/vendor/libgit2/src/remote.h +2 -0
- data/vendor/libgit2/src/repository.c +16 -14
- data/vendor/libgit2/src/repository.h +2 -0
- data/vendor/libgit2/src/reset.c +6 -5
- data/vendor/libgit2/src/revert.c +1 -0
- data/vendor/libgit2/src/revparse.c +3 -5
- data/vendor/libgit2/src/revwalk.c +2 -2
- data/vendor/libgit2/src/revwalk.h +2 -0
- data/vendor/libgit2/src/settings.c +6 -8
- data/vendor/libgit2/src/sha1_lookup.c +2 -216
- data/vendor/libgit2/src/sha1_lookup.h +2 -6
- data/vendor/libgit2/src/signature.c +8 -3
- data/vendor/libgit2/src/signature.h +2 -0
- data/vendor/libgit2/src/sortedcache.c +7 -0
- data/vendor/libgit2/src/sortedcache.h +2 -0
- data/vendor/libgit2/src/stash.c +1 -0
- data/vendor/libgit2/src/status.c +14 -9
- data/vendor/libgit2/src/status.h +2 -0
- data/vendor/libgit2/src/{curl_stream.c → streams/curl.c} +2 -0
- data/vendor/libgit2/src/{curl_stream.h → streams/curl.h} +4 -2
- data/vendor/libgit2/src/{openssl_stream.c → streams/openssl.c} +47 -18
- data/vendor/libgit2/src/{openssl_stream.h → streams/openssl.h} +6 -2
- data/vendor/libgit2/src/{socket_stream.c → streams/socket.c} +2 -2
- data/vendor/libgit2/src/{socket_stream.h → streams/socket.h} +4 -2
- data/vendor/libgit2/src/{stransport_stream.c → streams/stransport.c} +4 -2
- data/vendor/libgit2/src/{stransport_stream.h → streams/stransport.h} +4 -2
- data/vendor/libgit2/src/{tls_stream.c → streams/tls.c} +4 -3
- data/vendor/libgit2/src/{tls_stream.h → streams/tls.h} +4 -2
- data/vendor/libgit2/src/submodule.c +28 -80
- data/vendor/libgit2/src/submodule.h +2 -13
- data/vendor/libgit2/src/sysdir.c +75 -8
- data/vendor/libgit2/src/sysdir.h +2 -1
- data/vendor/libgit2/src/tag.c +2 -2
- data/vendor/libgit2/src/tag.h +2 -0
- data/vendor/libgit2/src/thread-utils.c +1 -0
- data/vendor/libgit2/src/thread-utils.h +1 -1
- data/vendor/libgit2/src/trace.c +2 -2
- data/vendor/libgit2/src/trace.h +2 -0
- data/vendor/libgit2/src/trailer.c +416 -0
- data/vendor/libgit2/src/transaction.c +2 -1
- data/vendor/libgit2/src/transport.c +2 -0
- data/vendor/libgit2/src/transports/auth.c +2 -1
- data/vendor/libgit2/src/transports/auth.h +4 -3
- data/vendor/libgit2/src/transports/auth_negotiate.c +2 -1
- data/vendor/libgit2/src/transports/auth_negotiate.h +3 -3
- data/vendor/libgit2/src/transports/cred.c +2 -0
- data/vendor/libgit2/src/transports/cred.h +4 -2
- data/vendor/libgit2/src/transports/cred_helpers.c +1 -0
- data/vendor/libgit2/src/transports/git.c +3 -1
- data/vendor/libgit2/src/transports/http.c +10 -14
- data/vendor/libgit2/src/transports/http.h +23 -0
- data/vendor/libgit2/src/transports/local.c +23 -5
- data/vendor/libgit2/src/transports/smart.c +3 -1
- data/vendor/libgit2/src/transports/smart.h +23 -16
- data/vendor/libgit2/src/transports/smart_pkt.c +114 -130
- data/vendor/libgit2/src/transports/smart_protocol.c +26 -22
- data/vendor/libgit2/src/transports/ssh.c +12 -7
- data/vendor/libgit2/src/transports/ssh.h +4 -2
- data/vendor/libgit2/src/transports/winhttp.c +19 -21
- data/vendor/libgit2/src/tree-cache.c +1 -0
- data/vendor/libgit2/src/tree-cache.h +1 -0
- data/vendor/libgit2/src/tree.c +20 -14
- data/vendor/libgit2/src/tree.h +2 -0
- data/vendor/libgit2/src/tsort.c +0 -1
- data/vendor/libgit2/src/unix/map.c +4 -1
- data/vendor/libgit2/src/unix/posix.h +8 -4
- data/vendor/libgit2/src/unix/pthread.h +1 -1
- data/vendor/libgit2/src/unix/realpath.c +4 -1
- data/vendor/libgit2/src/util.c +6 -5
- data/vendor/libgit2/src/util.h +39 -111
- data/vendor/libgit2/src/varint.c +0 -1
- data/vendor/libgit2/src/varint.h +2 -0
- data/vendor/libgit2/src/vector.c +1 -1
- data/vendor/libgit2/src/win32/dir.c +3 -0
- data/vendor/libgit2/src/win32/dir.h +4 -3
- data/vendor/libgit2/src/win32/error.c +1 -1
- data/vendor/libgit2/src/win32/error.h +4 -2
- data/vendor/libgit2/src/win32/findfile.c +2 -1
- data/vendor/libgit2/src/win32/findfile.h +4 -2
- data/vendor/libgit2/src/win32/map.c +2 -0
- data/vendor/libgit2/src/win32/mingw-compat.h +3 -3
- data/vendor/libgit2/src/win32/msvc-compat.h +3 -3
- data/vendor/libgit2/src/win32/path_w32.c +7 -12
- data/vendor/libgit2/src/win32/path_w32.h +3 -2
- data/vendor/libgit2/src/win32/posix.h +2 -2
- data/vendor/libgit2/src/win32/posix_w32.c +11 -5
- data/vendor/libgit2/src/win32/precompiled.h +2 -1
- data/vendor/libgit2/src/win32/reparse.h +2 -2
- data/vendor/libgit2/src/win32/thread.c +1 -0
- data/vendor/libgit2/src/win32/thread.h +2 -2
- data/vendor/libgit2/src/win32/utf-conv.c +0 -1
- data/vendor/libgit2/src/win32/utf-conv.h +4 -3
- data/vendor/libgit2/src/win32/w32_buffer.c +1 -1
- data/vendor/libgit2/src/win32/w32_buffer.h +4 -2
- data/vendor/libgit2/src/win32/w32_crtdbg_stacktrace.c +2 -1
- data/vendor/libgit2/src/win32/w32_crtdbg_stacktrace.h +85 -2
- data/vendor/libgit2/src/win32/w32_stack.c +2 -1
- data/vendor/libgit2/src/win32/w32_stack.h +5 -3
- data/vendor/libgit2/src/win32/w32_util.h +4 -2
- data/vendor/libgit2/src/win32/win32-compat.h +3 -3
- data/vendor/libgit2/src/worktree.c +4 -5
- data/vendor/libgit2/src/worktree.h +2 -0
- data/vendor/libgit2/src/xdiff/xdiff.h +22 -13
- data/vendor/libgit2/src/xdiff/xdiffi.c +523 -81
- data/vendor/libgit2/src/xdiff/xdiffi.h +2 -2
- data/vendor/libgit2/src/xdiff/xemit.c +63 -39
- data/vendor/libgit2/src/xdiff/xemit.h +2 -2
- data/vendor/libgit2/src/xdiff/xhistogram.c +0 -1
- data/vendor/libgit2/src/xdiff/xinclude.h +3 -2
- data/vendor/libgit2/src/xdiff/xmacros.h +2 -2
- data/vendor/libgit2/src/xdiff/xmerge.c +80 -20
- data/vendor/libgit2/src/xdiff/xpatience.c +41 -9
- data/vendor/libgit2/src/xdiff/xprepare.c +2 -2
- data/vendor/libgit2/src/xdiff/xprepare.h +2 -2
- data/vendor/libgit2/src/xdiff/xtypes.h +2 -2
- data/vendor/libgit2/src/xdiff/xutils.c +47 -27
- data/vendor/libgit2/src/xdiff/xutils.h +2 -5
- data/vendor/libgit2/src/zstream.c +65 -45
- data/vendor/libgit2/src/zstream.h +9 -2
- metadata +27 -13
- data/vendor/libgit2/include/git2/sys/remote.h +0 -16
data/vendor/libgit2/src/sysdir.h
CHANGED
@@ -8,6 +8,7 @@
|
|
8
8
|
#define INCLUDE_sysdir_h__
|
9
9
|
|
10
10
|
#include "common.h"
|
11
|
+
|
11
12
|
#include "posix.h"
|
12
13
|
#include "buffer.h"
|
13
14
|
|
@@ -115,4 +116,4 @@ extern int git_sysdir_get_str(char *out, size_t outlen, git_sysdir_t which);
|
|
115
116
|
*/
|
116
117
|
extern int git_sysdir_set(git_sysdir_t which, const char *paths);
|
117
118
|
|
118
|
-
#endif
|
119
|
+
#endif
|
data/vendor/libgit2/src/tag.c
CHANGED
data/vendor/libgit2/src/tag.h
CHANGED
data/vendor/libgit2/src/trace.c
CHANGED
data/vendor/libgit2/src/trace.h
CHANGED
@@ -0,0 +1,416 @@
|
|
1
|
+
/*
|
2
|
+
* Copyright (C) the libgit2 contributors. All rights reserved.
|
3
|
+
*
|
4
|
+
* This file is part of libgit2, distributed under the GNU GPL v2 with
|
5
|
+
* a Linking Exception. For full terms see the included COPYING file.
|
6
|
+
*/
|
7
|
+
#include "array.h"
|
8
|
+
#include "common.h"
|
9
|
+
#include "git2/message.h"
|
10
|
+
|
11
|
+
#include <stddef.h>
|
12
|
+
#include <string.h>
|
13
|
+
#include <ctype.h>
|
14
|
+
|
15
|
+
#define COMMENT_LINE_CHAR '#'
|
16
|
+
#define TRAILER_SEPARATORS ":"
|
17
|
+
|
18
|
+
static const char *const git_generated_prefixes[] = {
|
19
|
+
"Signed-off-by: ",
|
20
|
+
"(cherry picked from commit ",
|
21
|
+
NULL
|
22
|
+
};
|
23
|
+
|
24
|
+
static int is_blank_line(const char *str)
|
25
|
+
{
|
26
|
+
const char *s = str;
|
27
|
+
while (*s && *s != '\n' && isspace(*s))
|
28
|
+
s++;
|
29
|
+
return !*s || *s == '\n';
|
30
|
+
}
|
31
|
+
|
32
|
+
static const char *next_line(const char *str)
|
33
|
+
{
|
34
|
+
const char *nl = strchr(str, '\n');
|
35
|
+
|
36
|
+
if (nl) {
|
37
|
+
return nl + 1;
|
38
|
+
} else {
|
39
|
+
// return pointer to the NUL terminator:
|
40
|
+
return str + strlen(str);
|
41
|
+
}
|
42
|
+
}
|
43
|
+
|
44
|
+
/*
|
45
|
+
* Return the position of the start of the last line. If len is 0, return -1.
|
46
|
+
*/
|
47
|
+
static int last_line(const char *buf, size_t len)
|
48
|
+
{
|
49
|
+
int i;
|
50
|
+
if (len == 0)
|
51
|
+
return -1;
|
52
|
+
if (len == 1)
|
53
|
+
return 0;
|
54
|
+
/*
|
55
|
+
* Skip the last character (in addition to the null terminator),
|
56
|
+
* because if the last character is a newline, it is considered as part
|
57
|
+
* of the last line anyway.
|
58
|
+
*/
|
59
|
+
i = len - 2;
|
60
|
+
|
61
|
+
for (; i >= 0; i--) {
|
62
|
+
if (buf[i] == '\n')
|
63
|
+
return i + 1;
|
64
|
+
}
|
65
|
+
return 0;
|
66
|
+
}
|
67
|
+
|
68
|
+
/*
|
69
|
+
* If the given line is of the form
|
70
|
+
* "<token><optional whitespace><separator>..." or "<separator>...", return the
|
71
|
+
* location of the separator. Otherwise, return -1. The optional whitespace
|
72
|
+
* is allowed there primarily to allow things like "Bug #43" where <token> is
|
73
|
+
* "Bug" and <separator> is "#".
|
74
|
+
*
|
75
|
+
* The separator-starts-line case (in which this function returns 0) is
|
76
|
+
* distinguished from the non-well-formed-line case (in which this function
|
77
|
+
* returns -1) because some callers of this function need such a distinction.
|
78
|
+
*/
|
79
|
+
static int find_separator(const char *line, const char *separators)
|
80
|
+
{
|
81
|
+
int whitespace_found = 0;
|
82
|
+
const char *c;
|
83
|
+
for (c = line; *c; c++) {
|
84
|
+
if (strchr(separators, *c))
|
85
|
+
return c - line;
|
86
|
+
if (!whitespace_found && (isalnum(*c) || *c == '-'))
|
87
|
+
continue;
|
88
|
+
if (c != line && (*c == ' ' || *c == '\t')) {
|
89
|
+
whitespace_found = 1;
|
90
|
+
continue;
|
91
|
+
}
|
92
|
+
break;
|
93
|
+
}
|
94
|
+
return -1;
|
95
|
+
}
|
96
|
+
|
97
|
+
/*
|
98
|
+
* Inspect the given string and determine the true "end" of the log message, in
|
99
|
+
* order to find where to put a new Signed-off-by: line. Ignored are
|
100
|
+
* trailing comment lines and blank lines. To support "git commit -s
|
101
|
+
* --amend" on an existing commit, we also ignore "Conflicts:". To
|
102
|
+
* support "git commit -v", we truncate at cut lines.
|
103
|
+
*
|
104
|
+
* Returns the number of bytes from the tail to ignore, to be fed as
|
105
|
+
* the second parameter to append_signoff().
|
106
|
+
*/
|
107
|
+
static int ignore_non_trailer(const char *buf, size_t len)
|
108
|
+
{
|
109
|
+
int boc = 0;
|
110
|
+
size_t bol = 0;
|
111
|
+
int in_old_conflicts_block = 0;
|
112
|
+
size_t cutoff = len;
|
113
|
+
|
114
|
+
while (bol < cutoff) {
|
115
|
+
const char *next_line = memchr(buf + bol, '\n', len - bol);
|
116
|
+
|
117
|
+
if (!next_line)
|
118
|
+
next_line = buf + len;
|
119
|
+
else
|
120
|
+
next_line++;
|
121
|
+
|
122
|
+
if (buf[bol] == COMMENT_LINE_CHAR || buf[bol] == '\n') {
|
123
|
+
/* is this the first of the run of comments? */
|
124
|
+
if (!boc)
|
125
|
+
boc = bol;
|
126
|
+
/* otherwise, it is just continuing */
|
127
|
+
} else if (git__prefixcmp(buf + bol, "Conflicts:\n") == 0) {
|
128
|
+
in_old_conflicts_block = 1;
|
129
|
+
if (!boc)
|
130
|
+
boc = bol;
|
131
|
+
} else if (in_old_conflicts_block && buf[bol] == '\t') {
|
132
|
+
; /* a pathname in the conflicts block */
|
133
|
+
} else if (boc) {
|
134
|
+
/* the previous was not trailing comment */
|
135
|
+
boc = 0;
|
136
|
+
in_old_conflicts_block = 0;
|
137
|
+
}
|
138
|
+
bol = next_line - buf;
|
139
|
+
}
|
140
|
+
return boc ? len - boc : len - cutoff;
|
141
|
+
}
|
142
|
+
|
143
|
+
/*
|
144
|
+
* Return the position of the start of the patch or the length of str if there
|
145
|
+
* is no patch in the message.
|
146
|
+
*/
|
147
|
+
static int find_patch_start(const char *str)
|
148
|
+
{
|
149
|
+
const char *s;
|
150
|
+
|
151
|
+
for (s = str; *s; s = next_line(s)) {
|
152
|
+
if (git__prefixcmp(s, "---") == 0)
|
153
|
+
return s - str;
|
154
|
+
}
|
155
|
+
|
156
|
+
return s - str;
|
157
|
+
}
|
158
|
+
|
159
|
+
/*
|
160
|
+
* Return the position of the first trailer line or len if there are no
|
161
|
+
* trailers.
|
162
|
+
*/
|
163
|
+
static int find_trailer_start(const char *buf, size_t len)
|
164
|
+
{
|
165
|
+
const char *s;
|
166
|
+
int end_of_title, l, only_spaces = 1;
|
167
|
+
int recognized_prefix = 0, trailer_lines = 0, non_trailer_lines = 0;
|
168
|
+
/*
|
169
|
+
* Number of possible continuation lines encountered. This will be
|
170
|
+
* reset to 0 if we encounter a trailer (since those lines are to be
|
171
|
+
* considered continuations of that trailer), and added to
|
172
|
+
* non_trailer_lines if we encounter a non-trailer (since those lines
|
173
|
+
* are to be considered non-trailers).
|
174
|
+
*/
|
175
|
+
int possible_continuation_lines = 0;
|
176
|
+
|
177
|
+
/* The first paragraph is the title and cannot be trailers */
|
178
|
+
for (s = buf; s < buf + len; s = next_line(s)) {
|
179
|
+
if (s[0] == COMMENT_LINE_CHAR)
|
180
|
+
continue;
|
181
|
+
if (is_blank_line(s))
|
182
|
+
break;
|
183
|
+
}
|
184
|
+
end_of_title = s - buf;
|
185
|
+
|
186
|
+
/*
|
187
|
+
* Get the start of the trailers by looking starting from the end for a
|
188
|
+
* blank line before a set of non-blank lines that (i) are all
|
189
|
+
* trailers, or (ii) contains at least one Git-generated trailer and
|
190
|
+
* consists of at least 25% trailers.
|
191
|
+
*/
|
192
|
+
for (l = last_line(buf, len);
|
193
|
+
l >= end_of_title;
|
194
|
+
l = last_line(buf, l)) {
|
195
|
+
const char *bol = buf + l;
|
196
|
+
const char *const *p;
|
197
|
+
int separator_pos;
|
198
|
+
|
199
|
+
if (bol[0] == COMMENT_LINE_CHAR) {
|
200
|
+
non_trailer_lines += possible_continuation_lines;
|
201
|
+
possible_continuation_lines = 0;
|
202
|
+
continue;
|
203
|
+
}
|
204
|
+
if (is_blank_line(bol)) {
|
205
|
+
if (only_spaces)
|
206
|
+
continue;
|
207
|
+
non_trailer_lines += possible_continuation_lines;
|
208
|
+
if (recognized_prefix &&
|
209
|
+
trailer_lines * 3 >= non_trailer_lines)
|
210
|
+
return next_line(bol) - buf;
|
211
|
+
else if (trailer_lines && !non_trailer_lines)
|
212
|
+
return next_line(bol) - buf;
|
213
|
+
return len;
|
214
|
+
}
|
215
|
+
only_spaces = 0;
|
216
|
+
|
217
|
+
for (p = git_generated_prefixes; *p; p++) {
|
218
|
+
if (git__prefixcmp(bol, *p) == 0) {
|
219
|
+
trailer_lines++;
|
220
|
+
possible_continuation_lines = 0;
|
221
|
+
recognized_prefix = 1;
|
222
|
+
goto continue_outer_loop;
|
223
|
+
}
|
224
|
+
}
|
225
|
+
|
226
|
+
separator_pos = find_separator(bol, TRAILER_SEPARATORS);
|
227
|
+
if (separator_pos >= 1 && !isspace(bol[0])) {
|
228
|
+
trailer_lines++;
|
229
|
+
possible_continuation_lines = 0;
|
230
|
+
if (recognized_prefix)
|
231
|
+
continue;
|
232
|
+
} else if (isspace(bol[0]))
|
233
|
+
possible_continuation_lines++;
|
234
|
+
else {
|
235
|
+
non_trailer_lines++;
|
236
|
+
non_trailer_lines += possible_continuation_lines;
|
237
|
+
possible_continuation_lines = 0;
|
238
|
+
}
|
239
|
+
continue_outer_loop:
|
240
|
+
;
|
241
|
+
}
|
242
|
+
|
243
|
+
return len;
|
244
|
+
}
|
245
|
+
|
246
|
+
/* Return the position of the end of the trailers. */
|
247
|
+
static int find_trailer_end(const char *buf, size_t len)
|
248
|
+
{
|
249
|
+
return len - ignore_non_trailer(buf, len);
|
250
|
+
}
|
251
|
+
|
252
|
+
static char *extract_trailer_block(const char *message, size_t* len)
|
253
|
+
{
|
254
|
+
size_t patch_start = find_patch_start(message);
|
255
|
+
size_t trailer_end = find_trailer_end(message, patch_start);
|
256
|
+
size_t trailer_start = find_trailer_start(message, trailer_end);
|
257
|
+
|
258
|
+
size_t trailer_len = trailer_end - trailer_start;
|
259
|
+
|
260
|
+
char *buffer = git__malloc(trailer_len + 1);
|
261
|
+
memcpy(buffer, message + trailer_start, trailer_len);
|
262
|
+
buffer[trailer_len] = 0;
|
263
|
+
|
264
|
+
*len = trailer_len;
|
265
|
+
|
266
|
+
return buffer;
|
267
|
+
}
|
268
|
+
|
269
|
+
enum trailer_state {
|
270
|
+
S_START = 0,
|
271
|
+
S_KEY = 1,
|
272
|
+
S_KEY_WS = 2,
|
273
|
+
S_SEP_WS = 3,
|
274
|
+
S_VALUE = 4,
|
275
|
+
S_VALUE_NL = 5,
|
276
|
+
S_VALUE_END = 6,
|
277
|
+
S_IGNORE = 7,
|
278
|
+
};
|
279
|
+
|
280
|
+
#define NEXT(st) { state = (st); ptr++; continue; }
|
281
|
+
#define GOTO(st) { state = (st); continue; }
|
282
|
+
|
283
|
+
typedef git_array_t(git_message_trailer) git_array_trailer_t;
|
284
|
+
|
285
|
+
int git_message_trailers(git_message_trailer_array *trailer_arr, const char *message)
|
286
|
+
{
|
287
|
+
enum trailer_state state = S_START;
|
288
|
+
int rc = 0;
|
289
|
+
char *ptr;
|
290
|
+
char *key = NULL;
|
291
|
+
char *value = NULL;
|
292
|
+
git_array_trailer_t arr = GIT_ARRAY_INIT;
|
293
|
+
|
294
|
+
size_t trailer_len;
|
295
|
+
char *trailer = extract_trailer_block(message, &trailer_len);
|
296
|
+
|
297
|
+
for (ptr = trailer;;) {
|
298
|
+
switch (state) {
|
299
|
+
case S_START: {
|
300
|
+
if (*ptr == 0) {
|
301
|
+
goto ret;
|
302
|
+
}
|
303
|
+
|
304
|
+
key = ptr;
|
305
|
+
GOTO(S_KEY);
|
306
|
+
}
|
307
|
+
case S_KEY: {
|
308
|
+
if (*ptr == 0) {
|
309
|
+
goto ret;
|
310
|
+
}
|
311
|
+
|
312
|
+
if (isalnum(*ptr) || *ptr == '-') {
|
313
|
+
// legal key character
|
314
|
+
NEXT(S_KEY);
|
315
|
+
}
|
316
|
+
|
317
|
+
if (*ptr == ' ' || *ptr == '\t') {
|
318
|
+
// optional whitespace before separator
|
319
|
+
*ptr = 0;
|
320
|
+
NEXT(S_KEY_WS);
|
321
|
+
}
|
322
|
+
|
323
|
+
if (strchr(TRAILER_SEPARATORS, *ptr)) {
|
324
|
+
*ptr = 0;
|
325
|
+
NEXT(S_SEP_WS);
|
326
|
+
}
|
327
|
+
|
328
|
+
// illegal character
|
329
|
+
GOTO(S_IGNORE);
|
330
|
+
}
|
331
|
+
case S_KEY_WS: {
|
332
|
+
if (*ptr == 0) {
|
333
|
+
goto ret;
|
334
|
+
}
|
335
|
+
|
336
|
+
if (*ptr == ' ' || *ptr == '\t') {
|
337
|
+
NEXT(S_KEY_WS);
|
338
|
+
}
|
339
|
+
|
340
|
+
if (strchr(TRAILER_SEPARATORS, *ptr)) {
|
341
|
+
NEXT(S_SEP_WS);
|
342
|
+
}
|
343
|
+
|
344
|
+
// illegal character
|
345
|
+
GOTO(S_IGNORE);
|
346
|
+
}
|
347
|
+
case S_SEP_WS: {
|
348
|
+
if (*ptr == 0) {
|
349
|
+
goto ret;
|
350
|
+
}
|
351
|
+
|
352
|
+
if (*ptr == ' ' || *ptr == '\t') {
|
353
|
+
NEXT(S_SEP_WS);
|
354
|
+
}
|
355
|
+
|
356
|
+
value = ptr;
|
357
|
+
NEXT(S_VALUE);
|
358
|
+
}
|
359
|
+
case S_VALUE: {
|
360
|
+
if (*ptr == 0) {
|
361
|
+
GOTO(S_VALUE_END);
|
362
|
+
}
|
363
|
+
|
364
|
+
if (*ptr == '\n') {
|
365
|
+
NEXT(S_VALUE_NL);
|
366
|
+
}
|
367
|
+
|
368
|
+
NEXT(S_VALUE);
|
369
|
+
}
|
370
|
+
case S_VALUE_NL: {
|
371
|
+
if (*ptr == ' ') {
|
372
|
+
// continuation;
|
373
|
+
NEXT(S_VALUE);
|
374
|
+
}
|
375
|
+
|
376
|
+
ptr[-1] = 0;
|
377
|
+
GOTO(S_VALUE_END);
|
378
|
+
}
|
379
|
+
case S_VALUE_END: {
|
380
|
+
git_message_trailer *t = git_array_alloc(arr);
|
381
|
+
|
382
|
+
t->key = key;
|
383
|
+
t->value = value;
|
384
|
+
|
385
|
+
key = NULL;
|
386
|
+
value = NULL;
|
387
|
+
|
388
|
+
GOTO(S_START);
|
389
|
+
}
|
390
|
+
case S_IGNORE: {
|
391
|
+
if (*ptr == 0) {
|
392
|
+
goto ret;
|
393
|
+
}
|
394
|
+
|
395
|
+
if (*ptr == '\n') {
|
396
|
+
NEXT(S_START);
|
397
|
+
}
|
398
|
+
|
399
|
+
NEXT(S_IGNORE);
|
400
|
+
}
|
401
|
+
}
|
402
|
+
}
|
403
|
+
|
404
|
+
ret:
|
405
|
+
trailer_arr->_trailer_block = trailer;
|
406
|
+
trailer_arr->trailers = arr.ptr;
|
407
|
+
trailer_arr->count = arr.size;
|
408
|
+
|
409
|
+
return rc;
|
410
|
+
}
|
411
|
+
|
412
|
+
void git_message_trailer_array_free(git_message_trailer_array *arr)
|
413
|
+
{
|
414
|
+
git__free(arr->_trailer_block);
|
415
|
+
git__free(arr->trailers);
|
416
|
+
}
|