rugged 0.27.10.1 → 0.28.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ext/rugged/extconf.rb +23 -2
- data/ext/rugged/rugged.c +48 -2
- data/ext/rugged/rugged.h +5 -0
- data/ext/rugged/rugged_allocator.c +89 -0
- data/ext/rugged/rugged_blob.c +3 -3
- data/ext/rugged/rugged_branch.c +1 -1
- data/ext/rugged/rugged_commit.c +8 -8
- data/ext/rugged/rugged_config.c +1 -1
- data/ext/rugged/rugged_diff.c +24 -4
- data/ext/rugged/rugged_note.c +1 -1
- data/ext/rugged/rugged_repo.c +10 -10
- data/ext/rugged/rugged_settings.c +1 -1
- data/lib/rugged/version.rb +1 -1
- data/vendor/libgit2/CMakeLists.txt +69 -47
- data/vendor/libgit2/cmake/Modules/AddCFlagIfSupported.cmake +15 -1
- data/vendor/libgit2/cmake/Modules/EnableWarnings.cmake +5 -8
- data/vendor/libgit2/cmake/Modules/FindmbedTLS.cmake +93 -0
- data/vendor/libgit2/deps/http-parser/CMakeLists.txt +2 -0
- data/vendor/libgit2/deps/http-parser/{LICENSE-MIT → COPYING} +0 -0
- data/vendor/libgit2/deps/regex/COPYING +502 -0
- data/vendor/libgit2/deps/winhttp/COPYING.GPL +993 -0
- data/vendor/libgit2/deps/winhttp/COPYING.LGPL +502 -0
- data/vendor/libgit2/deps/zlib/CMakeLists.txt +1 -0
- data/vendor/libgit2/deps/zlib/COPYING +27 -0
- data/vendor/libgit2/include/git2.h +3 -0
- data/vendor/libgit2/include/git2/annotated_commit.h +9 -0
- data/vendor/libgit2/include/git2/apply.h +129 -0
- data/vendor/libgit2/include/git2/attr.h +19 -8
- data/vendor/libgit2/include/git2/blame.h +41 -24
- data/vendor/libgit2/include/git2/blob.h +1 -1
- data/vendor/libgit2/include/git2/branch.h +1 -1
- data/vendor/libgit2/include/git2/buffer.h +2 -2
- data/vendor/libgit2/include/git2/checkout.h +20 -19
- data/vendor/libgit2/include/git2/cherrypick.h +6 -4
- data/vendor/libgit2/include/git2/clone.h +11 -9
- data/vendor/libgit2/include/git2/commit.h +30 -2
- data/vendor/libgit2/include/git2/common.h +54 -4
- data/vendor/libgit2/include/git2/config.h +18 -7
- data/vendor/libgit2/include/git2/deprecated.h +253 -0
- data/vendor/libgit2/include/git2/describe.h +30 -7
- data/vendor/libgit2/include/git2/diff.h +193 -143
- data/vendor/libgit2/include/git2/errors.h +54 -46
- data/vendor/libgit2/include/git2/ignore.h +2 -2
- data/vendor/libgit2/include/git2/index.h +72 -51
- data/vendor/libgit2/include/git2/indexer.h +30 -4
- data/vendor/libgit2/include/git2/mailmap.h +115 -0
- data/vendor/libgit2/include/git2/merge.h +29 -8
- data/vendor/libgit2/include/git2/net.h +1 -1
- data/vendor/libgit2/include/git2/notes.h +1 -1
- data/vendor/libgit2/include/git2/object.h +16 -16
- data/vendor/libgit2/include/git2/odb.h +10 -10
- data/vendor/libgit2/include/git2/odb_backend.h +7 -7
- data/vendor/libgit2/include/git2/oid.h +1 -1
- data/vendor/libgit2/include/git2/pack.h +2 -2
- data/vendor/libgit2/include/git2/proxy.h +9 -5
- data/vendor/libgit2/include/git2/rebase.h +7 -4
- data/vendor/libgit2/include/git2/refs.h +14 -15
- data/vendor/libgit2/include/git2/refspec.h +17 -0
- data/vendor/libgit2/include/git2/remote.h +92 -16
- data/vendor/libgit2/include/git2/repository.h +52 -37
- data/vendor/libgit2/include/git2/revert.h +5 -3
- data/vendor/libgit2/include/git2/revwalk.h +7 -7
- data/vendor/libgit2/include/git2/signature.h +2 -2
- data/vendor/libgit2/include/git2/stash.h +13 -10
- data/vendor/libgit2/include/git2/status.h +8 -4
- data/vendor/libgit2/include/git2/submodule.h +11 -10
- data/vendor/libgit2/include/git2/sys/alloc.h +101 -0
- data/vendor/libgit2/include/git2/sys/commit.h +1 -1
- data/vendor/libgit2/include/git2/sys/config.h +13 -13
- data/vendor/libgit2/include/git2/sys/filter.h +6 -6
- data/vendor/libgit2/include/git2/sys/index.h +3 -0
- data/vendor/libgit2/include/git2/sys/mempack.h +35 -35
- data/vendor/libgit2/include/git2/sys/merge.h +9 -4
- data/vendor/libgit2/include/git2/sys/odb_backend.h +19 -19
- data/vendor/libgit2/include/git2/sys/path.h +64 -0
- data/vendor/libgit2/include/git2/sys/refdb_backend.h +19 -19
- data/vendor/libgit2/include/git2/sys/stream.h +92 -12
- data/vendor/libgit2/include/git2/sys/transport.h +127 -81
- data/vendor/libgit2/include/git2/tag.h +2 -2
- data/vendor/libgit2/include/git2/trace.h +1 -1
- data/vendor/libgit2/include/git2/transaction.h +1 -0
- data/vendor/libgit2/include/git2/transport.h +47 -18
- data/vendor/libgit2/include/git2/tree.h +3 -3
- data/vendor/libgit2/include/git2/types.h +35 -28
- data/vendor/libgit2/include/git2/version.h +4 -4
- data/vendor/libgit2/include/git2/worktree.h +47 -12
- data/vendor/libgit2/src/CMakeLists.txt +87 -26
- data/vendor/libgit2/src/alloc.c +55 -0
- data/vendor/libgit2/src/alloc.h +40 -0
- data/vendor/libgit2/src/annotated_commit.c +15 -8
- data/vendor/libgit2/src/apply.c +490 -14
- data/vendor/libgit2/src/apply.h +3 -1
- data/vendor/libgit2/src/array.h +2 -2
- data/vendor/libgit2/src/attr.c +11 -11
- data/vendor/libgit2/src/attr_file.c +20 -15
- data/vendor/libgit2/src/attrcache.c +11 -11
- data/vendor/libgit2/src/blame.c +30 -15
- data/vendor/libgit2/src/blame.h +1 -0
- data/vendor/libgit2/src/blame_git.c +16 -13
- data/vendor/libgit2/src/blob.c +50 -28
- data/vendor/libgit2/src/blob.h +18 -1
- data/vendor/libgit2/src/branch.c +38 -38
- data/vendor/libgit2/src/buf_text.c +7 -6
- data/vendor/libgit2/src/buffer.c +55 -50
- data/vendor/libgit2/src/buffer.h +1 -1
- data/vendor/libgit2/src/cache.c +16 -16
- data/vendor/libgit2/src/cache.h +2 -2
- data/vendor/libgit2/src/cc-compat.h +15 -3
- data/vendor/libgit2/src/checkout.c +83 -74
- data/vendor/libgit2/src/cherrypick.c +6 -6
- data/vendor/libgit2/src/clone.c +20 -20
- data/vendor/libgit2/src/commit.c +53 -33
- data/vendor/libgit2/src/commit.h +1 -0
- data/vendor/libgit2/src/commit_list.c +6 -10
- data/vendor/libgit2/src/common.h +32 -30
- data/vendor/libgit2/src/config.c +167 -147
- data/vendor/libgit2/src/config.h +1 -14
- data/vendor/libgit2/src/config_backend.h +84 -0
- data/vendor/libgit2/src/config_cache.c +7 -1
- data/vendor/libgit2/src/config_entries.c +259 -0
- data/vendor/libgit2/src/config_entries.h +23 -0
- data/vendor/libgit2/src/config_file.c +167 -439
- data/vendor/libgit2/src/config_mem.c +224 -0
- data/vendor/libgit2/src/config_parse.c +69 -38
- data/vendor/libgit2/src/config_parse.h +4 -4
- data/vendor/libgit2/src/crlf.c +215 -186
- data/vendor/libgit2/src/delta.c +25 -18
- data/vendor/libgit2/src/describe.c +23 -23
- data/vendor/libgit2/src/diff.c +12 -12
- data/vendor/libgit2/src/diff_driver.c +14 -15
- data/vendor/libgit2/src/diff_file.c +10 -10
- data/vendor/libgit2/src/diff_generate.c +29 -23
- data/vendor/libgit2/src/diff_generate.h +1 -1
- data/vendor/libgit2/src/diff_parse.c +3 -3
- data/vendor/libgit2/src/diff_print.c +17 -17
- data/vendor/libgit2/src/diff_stats.c +22 -7
- data/vendor/libgit2/src/diff_tform.c +12 -12
- data/vendor/libgit2/src/diff_xdiff.c +15 -3
- data/vendor/libgit2/src/errors.c +42 -20
- data/vendor/libgit2/src/features.h.in +2 -1
- data/vendor/libgit2/src/fetch.c +3 -3
- data/vendor/libgit2/src/fetchhead.c +16 -16
- data/vendor/libgit2/src/filebuf.c +28 -28
- data/vendor/libgit2/src/fileops.c +54 -54
- data/vendor/libgit2/src/fileops.h +1 -1
- data/vendor/libgit2/src/filter.c +30 -30
- data/vendor/libgit2/src/filter.h +0 -10
- data/vendor/libgit2/src/global.c +36 -23
- data/vendor/libgit2/src/hash.h +4 -1
- data/vendor/libgit2/src/hash/hash_collisiondetect.h +6 -2
- data/vendor/libgit2/src/hash/hash_common_crypto.h +5 -1
- data/vendor/libgit2/src/hash/hash_generic.h +5 -1
- data/vendor/libgit2/src/hash/hash_mbedtls.c +38 -0
- data/vendor/libgit2/src/hash/hash_mbedtls.h +24 -0
- data/vendor/libgit2/src/hash/hash_openssl.h +8 -4
- data/vendor/libgit2/src/hash/hash_win32.c +13 -13
- data/vendor/libgit2/src/hashsig.c +4 -4
- data/vendor/libgit2/src/idxmap.c +25 -5
- data/vendor/libgit2/src/idxmap.h +4 -18
- data/vendor/libgit2/src/ignore.c +9 -9
- data/vendor/libgit2/src/index.c +280 -198
- data/vendor/libgit2/src/index.h +16 -0
- data/vendor/libgit2/src/indexer.c +311 -139
- data/vendor/libgit2/src/integer.h +32 -22
- data/vendor/libgit2/src/iterator.c +116 -49
- data/vendor/libgit2/src/iterator.h +15 -0
- data/vendor/libgit2/src/khash.h +3 -1
- data/vendor/libgit2/src/mailmap.c +485 -0
- data/vendor/libgit2/src/mailmap.h +35 -0
- data/vendor/libgit2/src/merge.c +89 -59
- data/vendor/libgit2/src/merge_driver.c +7 -7
- data/vendor/libgit2/src/merge_file.c +1 -1
- data/vendor/libgit2/src/mwindow.c +8 -8
- data/vendor/libgit2/src/netops.c +22 -13
- data/vendor/libgit2/src/netops.h +2 -0
- data/vendor/libgit2/src/notes.c +15 -10
- data/vendor/libgit2/src/object.c +118 -67
- data/vendor/libgit2/src/object.h +20 -9
- data/vendor/libgit2/src/object_api.c +8 -8
- data/vendor/libgit2/src/odb.c +72 -72
- data/vendor/libgit2/src/odb.h +7 -7
- data/vendor/libgit2/src/odb_loose.c +46 -46
- data/vendor/libgit2/src/odb_mempack.c +14 -14
- data/vendor/libgit2/src/odb_pack.c +14 -10
- data/vendor/libgit2/src/offmap.c +30 -0
- data/vendor/libgit2/src/offmap.h +20 -11
- data/vendor/libgit2/src/oid.c +6 -6
- data/vendor/libgit2/src/oidmap.c +20 -0
- data/vendor/libgit2/src/oidmap.h +9 -12
- data/vendor/libgit2/src/pack-objects.c +71 -63
- data/vendor/libgit2/src/pack-objects.h +1 -7
- data/vendor/libgit2/src/pack.c +58 -58
- data/vendor/libgit2/src/pack.h +6 -6
- data/vendor/libgit2/src/parse.h +1 -1
- data/vendor/libgit2/src/patch.c +3 -3
- data/vendor/libgit2/src/patch_generate.c +18 -18
- data/vendor/libgit2/src/patch_parse.c +13 -13
- data/vendor/libgit2/src/path.c +93 -225
- data/vendor/libgit2/src/path.h +2 -84
- data/vendor/libgit2/src/pathspec.c +6 -6
- data/vendor/libgit2/src/posix.c +3 -3
- data/vendor/libgit2/src/proxy.c +1 -1
- data/vendor/libgit2/src/push.c +27 -26
- data/vendor/libgit2/src/push.h +2 -1
- data/vendor/libgit2/src/reader.c +265 -0
- data/vendor/libgit2/src/reader.h +107 -0
- data/vendor/libgit2/src/rebase.c +49 -52
- data/vendor/libgit2/src/refdb.c +3 -3
- data/vendor/libgit2/src/refdb_fs.c +181 -103
- data/vendor/libgit2/src/reflog.c +3 -3
- data/vendor/libgit2/src/refs.c +98 -74
- data/vendor/libgit2/src/refs.h +5 -3
- data/vendor/libgit2/src/refspec.c +47 -21
- data/vendor/libgit2/src/refspec.h +1 -1
- data/vendor/libgit2/src/remote.c +219 -166
- data/vendor/libgit2/src/remote.h +9 -0
- data/vendor/libgit2/src/repository.c +173 -133
- data/vendor/libgit2/src/repository.h +6 -3
- data/vendor/libgit2/src/reset.c +8 -8
- data/vendor/libgit2/src/revert.c +6 -6
- data/vendor/libgit2/src/revparse.c +30 -30
- data/vendor/libgit2/src/revwalk.c +60 -30
- data/vendor/libgit2/src/revwalk.h +2 -1
- data/vendor/libgit2/src/settings.c +42 -10
- data/vendor/libgit2/src/signature.c +11 -11
- data/vendor/libgit2/src/sortedcache.c +13 -13
- data/vendor/libgit2/src/stash.c +91 -45
- data/vendor/libgit2/src/status.c +13 -13
- data/vendor/libgit2/src/stdalloc.c +120 -0
- data/vendor/libgit2/src/{streams/curl.h → stdalloc.h} +6 -6
- data/vendor/libgit2/src/stream.h +17 -2
- data/vendor/libgit2/src/streams/mbedtls.c +483 -0
- data/vendor/libgit2/src/streams/mbedtls.h +23 -0
- data/vendor/libgit2/src/streams/openssl.c +204 -114
- data/vendor/libgit2/src/streams/openssl.h +4 -108
- data/vendor/libgit2/src/streams/registry.c +118 -0
- data/vendor/libgit2/src/streams/registry.h +19 -0
- data/vendor/libgit2/src/streams/socket.c +54 -29
- data/vendor/libgit2/src/streams/stransport.c +57 -32
- data/vendor/libgit2/src/streams/stransport.h +5 -0
- data/vendor/libgit2/src/streams/tls.c +50 -19
- data/vendor/libgit2/src/streams/tls.h +12 -4
- data/vendor/libgit2/src/strmap.c +22 -2
- data/vendor/libgit2/src/strmap.h +18 -15
- data/vendor/libgit2/src/submodule.c +179 -155
- data/vendor/libgit2/src/sysdir.c +18 -18
- data/vendor/libgit2/src/tag.c +31 -26
- data/vendor/libgit2/src/tag.h +2 -1
- data/vendor/libgit2/src/trace.c +1 -1
- data/vendor/libgit2/src/trace.h +1 -1
- data/vendor/libgit2/src/trailer.c +6 -6
- data/vendor/libgit2/src/transaction.c +23 -23
- data/vendor/libgit2/src/transport.c +5 -5
- data/vendor/libgit2/src/transports/auth.c +7 -4
- data/vendor/libgit2/src/transports/auth.h +1 -1
- data/vendor/libgit2/src/transports/auth_negotiate.c +12 -11
- data/vendor/libgit2/src/transports/cred.c +18 -18
- data/vendor/libgit2/src/transports/git.c +15 -15
- data/vendor/libgit2/src/transports/http.c +606 -216
- data/vendor/libgit2/src/transports/http.h +2 -0
- data/vendor/libgit2/src/transports/local.c +26 -26
- data/vendor/libgit2/src/transports/smart.c +54 -31
- data/vendor/libgit2/src/transports/smart.h +1 -2
- data/vendor/libgit2/src/transports/smart_pkt.c +43 -40
- data/vendor/libgit2/src/transports/smart_protocol.c +61 -57
- data/vendor/libgit2/src/transports/ssh.c +34 -33
- data/vendor/libgit2/src/transports/winhttp.c +99 -119
- data/vendor/libgit2/src/tree-cache.c +5 -5
- data/vendor/libgit2/src/tree.c +96 -121
- data/vendor/libgit2/src/tree.h +1 -12
- data/vendor/libgit2/src/unix/map.c +2 -2
- data/vendor/libgit2/src/util.c +22 -6
- data/vendor/libgit2/src/util.h +12 -135
- data/vendor/libgit2/src/vector.c +4 -4
- data/vendor/libgit2/src/win32/dir.c +3 -3
- data/vendor/libgit2/src/win32/findfile.c +3 -3
- data/vendor/libgit2/src/win32/map.c +6 -6
- data/vendor/libgit2/src/win32/msvc-compat.h +6 -0
- data/vendor/libgit2/src/win32/path_w32.c +101 -7
- data/vendor/libgit2/src/win32/path_w32.h +18 -0
- data/vendor/libgit2/src/win32/posix_w32.c +24 -43
- data/vendor/libgit2/src/win32/w32_buffer.c +2 -2
- data/vendor/libgit2/src/win32/w32_crtdbg_stacktrace.c +96 -2
- data/vendor/libgit2/src/win32/w32_crtdbg_stacktrace.h +28 -75
- data/vendor/libgit2/src/win32/w32_stack.c +2 -2
- data/vendor/libgit2/src/win32/w32_util.c +1 -69
- data/vendor/libgit2/src/win32/w32_util.h +1 -19
- data/vendor/libgit2/src/worktree.c +75 -54
- data/vendor/libgit2/src/worktree.h +2 -0
- data/vendor/libgit2/src/xdiff/xdiffi.c +7 -5
- data/vendor/libgit2/src/xdiff/xhistogram.c +1 -1
- data/vendor/libgit2/src/xdiff/xmerge.c +15 -15
- data/vendor/libgit2/src/zstream.c +4 -4
- metadata +33 -7
- data/vendor/libgit2/src/config_file.h +0 -73
- data/vendor/libgit2/src/streams/curl.c +0 -385
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 28cda5c3e68cfdf6edcf8efb20157b83af045c61009b9d84ef45d04307222f68
|
4
|
+
data.tar.gz: 6136a85649898880308af6d3ae92d3c3ac1802fe3b4595b826129ad4bdb9375d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4893ace2448d29b3945a0d45bc0770d2543dc5c40f8fafd9530fe41d9f52715f008f7c88510115bb9c1413fd5a434ef60d636f7544f96a0057fc65051a4d8efa
|
7
|
+
data.tar.gz: d3df3dad58a2405fa3da033bb5d3debb25d80f37563c342247099a390b663b807ca75b993cbde772e27d108e56b6590bfe921b3e1fcd9e64c897e97345c614af
|
data/ext/rugged/extconf.rb
CHANGED
@@ -4,6 +4,7 @@
|
|
4
4
|
# For full terms see the included LICENSE file.
|
5
5
|
|
6
6
|
require 'mkmf'
|
7
|
+
require 'timeout'
|
7
8
|
|
8
9
|
RbConfig::MAKEFILE_CONFIG['CC'] = ENV['CC'] if ENV['CC']
|
9
10
|
|
@@ -23,6 +24,26 @@ def sys(cmd)
|
|
23
24
|
ret
|
24
25
|
end
|
25
26
|
|
27
|
+
# Thrown when we detect CMake is taking too long and we killed it
|
28
|
+
class CMakeTimeout < StandardError
|
29
|
+
end
|
30
|
+
|
31
|
+
def self.run_cmake(timeout, args)
|
32
|
+
# Set to process group so we can kill it and its children
|
33
|
+
pid = Process.spawn("cmake #{args}", pgroup: true)
|
34
|
+
|
35
|
+
Timeout.timeout(timeout) do
|
36
|
+
Process.waitpid(pid)
|
37
|
+
end
|
38
|
+
|
39
|
+
rescue Timeout::Error
|
40
|
+
# Kill it, #detach is essentially a background wait, since we don't actually
|
41
|
+
# care about waiting for it now
|
42
|
+
Process.kill(-9, pid)
|
43
|
+
Process.detach(pid)
|
44
|
+
raise CMakeTimeout.new("cmake has exceeded its timeout of #{timeout}s")
|
45
|
+
end
|
46
|
+
|
26
47
|
MAKE = if Gem.win_platform?
|
27
48
|
# On Windows, Ruby-DevKit only has 'make'.
|
28
49
|
find_executable('make')
|
@@ -80,7 +101,7 @@ else
|
|
80
101
|
Dir.chdir("build") do
|
81
102
|
# On Windows, Ruby-DevKit is MSYS-based, so ensure to use MSYS Makefiles.
|
82
103
|
generator = "-G \"MSYS Makefiles\"" if Gem.win_platform?
|
83
|
-
|
104
|
+
run_cmake(5 * 60, ".. -DBUILD_CLAR=OFF -DTHREADSAFE=ON -DBUILD_SHARED_LIBS=OFF -DCMAKE_C_FLAGS=-fPIC -DCMAKE_BUILD_TYPE=RelWithDebInfo #{cmake_flags.join(' ')} #{generator}")
|
84
105
|
sys(MAKE)
|
85
106
|
|
86
107
|
# "normal" libraries (and libgit2 builds) get all these when they build but we're doing it
|
@@ -88,7 +109,7 @@ else
|
|
88
109
|
# in $LIBS or the final linking stage won't pick them up
|
89
110
|
if Gem.win_platform?
|
90
111
|
$LDFLAGS << " " + "-L#{Dir.pwd}/deps/winhttp"
|
91
|
-
$LIBS << " -lwinhttp -lcrypt32 -lrpcrt4 -lole32 -lz"
|
112
|
+
$LIBS << " -lwinhttp -lcrypt32 -lrpcrt4 -lole32 -lz -lssh2"
|
92
113
|
else
|
93
114
|
pcfile = File.join(LIBGIT2_DIR, "build", "libgit2.pc")
|
94
115
|
$LDFLAGS << " " + `pkg-config --libs --static #{pcfile}`.strip
|
data/ext/rugged/rugged.c
CHANGED
@@ -210,7 +210,7 @@ static VALUE rb_git_prettify_message(int argc, VALUE *argv, VALUE self)
|
|
210
210
|
if (!error)
|
211
211
|
result = rb_enc_str_new(message.ptr, message.size, rb_utf8_encoding());
|
212
212
|
|
213
|
-
|
213
|
+
git_buf_dispose(&message);
|
214
214
|
rugged_exception_check(error);
|
215
215
|
|
216
216
|
return result;
|
@@ -515,6 +515,48 @@ VALUE rb_merge_file_result_fromC(const git_merge_file_result *result)
|
|
515
515
|
return rb_result;
|
516
516
|
}
|
517
517
|
|
518
|
+
static VALUE rb_git_path_is_dotgit_modules(VALUE self, VALUE rb_path)
|
519
|
+
{
|
520
|
+
const char *path;
|
521
|
+
int is_dotgit;
|
522
|
+
|
523
|
+
Check_Type(rb_path, T_STRING);
|
524
|
+
|
525
|
+
path = StringValueCStr(rb_path);
|
526
|
+
|
527
|
+
is_dotgit = git_path_is_gitfile(path, strlen(path), GIT_PATH_GITFILE_GITMODULES, GIT_PATH_FS_GENERIC);
|
528
|
+
|
529
|
+
return is_dotgit ? Qtrue : Qfalse;
|
530
|
+
}
|
531
|
+
|
532
|
+
static VALUE rb_git_path_is_dotgit_ignore(VALUE self, VALUE rb_path)
|
533
|
+
{
|
534
|
+
const char *path;
|
535
|
+
int is_dotgit;
|
536
|
+
|
537
|
+
Check_Type(rb_path, T_STRING);
|
538
|
+
|
539
|
+
path = StringValueCStr(rb_path);
|
540
|
+
|
541
|
+
is_dotgit = git_path_is_gitfile(path, strlen(path), GIT_PATH_GITFILE_GITIGNORE, GIT_PATH_FS_GENERIC);
|
542
|
+
|
543
|
+
return is_dotgit ? Qtrue : Qfalse;
|
544
|
+
}
|
545
|
+
|
546
|
+
static VALUE rb_git_path_is_dotgit_attributes(VALUE self, VALUE rb_path)
|
547
|
+
{
|
548
|
+
const char *path;
|
549
|
+
int is_dotgit;
|
550
|
+
|
551
|
+
Check_Type(rb_path, T_STRING);
|
552
|
+
|
553
|
+
path = StringValueCStr(rb_path);
|
554
|
+
|
555
|
+
is_dotgit = git_path_is_gitfile(path, strlen(path), GIT_PATH_GITFILE_GITATTRIBUTES, GIT_PATH_FS_GENERIC);
|
556
|
+
|
557
|
+
return is_dotgit ? Qtrue : Qfalse;
|
558
|
+
}
|
559
|
+
|
518
560
|
void Init_rugged(void)
|
519
561
|
{
|
520
562
|
rb_mRugged = rb_define_module("Rugged");
|
@@ -544,6 +586,9 @@ void Init_rugged(void)
|
|
544
586
|
rb_define_module_function(rb_mRugged, "prettify_message", rb_git_prettify_message, -1);
|
545
587
|
rb_define_module_function(rb_mRugged, "__cache_usage__", rb_git_cache_usage, 0);
|
546
588
|
rb_define_module_function(rb_mRugged, "signature_from_buffer", rb_git_signature_from_buffer, -1);
|
589
|
+
rb_define_module_function(rb_mRugged, "dotgit_modules?", rb_git_path_is_dotgit_modules, 1);
|
590
|
+
rb_define_module_function(rb_mRugged, "dotgit_ignore?", rb_git_path_is_dotgit_ignore, 1);
|
591
|
+
rb_define_module_function(rb_mRugged, "dotgit_attributes?", rb_git_path_is_dotgit_attributes, 1);
|
547
592
|
|
548
593
|
Init_rugged_reference();
|
549
594
|
Init_rugged_reference_collection();
|
@@ -604,7 +649,8 @@ void Init_rugged(void)
|
|
604
649
|
*/
|
605
650
|
rb_define_const(rb_mRugged, "SORT_REVERSE", INT2FIX(GIT_SORT_REVERSE));
|
606
651
|
|
607
|
-
/*
|
652
|
+
/* Set the allocator and initialize libgit2 */
|
653
|
+
rugged_set_allocator();
|
608
654
|
git_libgit2_init();
|
609
655
|
|
610
656
|
/* Hook a global object to cleanup the library
|
data/ext/rugged/rugged.h
CHANGED
@@ -20,9 +20,12 @@
|
|
20
20
|
#include <ruby/encoding.h>
|
21
21
|
#endif
|
22
22
|
|
23
|
+
#include <ruby/util.h>
|
24
|
+
|
23
25
|
#include <assert.h>
|
24
26
|
#include <git2.h>
|
25
27
|
#include <git2/odb_backend.h>
|
28
|
+
#include <git2/sys/path.h>
|
26
29
|
|
27
30
|
#define rb_str_new_utf8(str) rb_enc_str_new(str, strlen(str), rb_utf8_encoding())
|
28
31
|
#define CSTR2SYM(s) (ID2SYM(rb_intern((s))))
|
@@ -173,4 +176,6 @@ typedef struct _rugged_backend {
|
|
173
176
|
int (* refdb_backend)(git_refdb_backend **backend_out, struct _rugged_backend *backend, const char* path);
|
174
177
|
} rugged_backend;
|
175
178
|
|
179
|
+
extern void rugged_set_allocator(void);
|
180
|
+
|
176
181
|
#endif
|
@@ -0,0 +1,89 @@
|
|
1
|
+
/*
|
2
|
+
* Copyright (C) the Rugged contributors. All rights reserved.
|
3
|
+
*
|
4
|
+
* This file is part of Rugged, distributed under the MIT license.
|
5
|
+
* For full terms see the included LICENSE file.
|
6
|
+
*/
|
7
|
+
|
8
|
+
#include "rugged.h"
|
9
|
+
#include <git2/sys/alloc.h>
|
10
|
+
|
11
|
+
static void *rugged_gmalloc(size_t n, const char *file, int line)
|
12
|
+
{
|
13
|
+
return xmalloc(n);
|
14
|
+
}
|
15
|
+
|
16
|
+
static void *rugged_gcalloc(size_t nelem, size_t elsize, const char *file, int line)
|
17
|
+
{
|
18
|
+
return xcalloc(nelem, elsize);
|
19
|
+
}
|
20
|
+
|
21
|
+
static char *rugged_gstrdup(const char *str, const char *file, int line)
|
22
|
+
{
|
23
|
+
return ruby_strdup(str);
|
24
|
+
}
|
25
|
+
|
26
|
+
static char *rugged_gstrndup(const char *str, size_t n, const char *file, int line)
|
27
|
+
{
|
28
|
+
size_t len;
|
29
|
+
char *newstr;
|
30
|
+
|
31
|
+
len = strnlen(str, n);
|
32
|
+
if (len < n)
|
33
|
+
n = len;
|
34
|
+
|
35
|
+
newstr = xmalloc(n+1);
|
36
|
+
memcpy(newstr, str, n);
|
37
|
+
newstr[n] = '\0';
|
38
|
+
|
39
|
+
return newstr;
|
40
|
+
}
|
41
|
+
|
42
|
+
static char *rugged_gsubstrdup(const char *str, size_t n, const char *file, int line)
|
43
|
+
{
|
44
|
+
char *newstr;
|
45
|
+
|
46
|
+
newstr = xmalloc(n+1);
|
47
|
+
memcpy(newstr, str, n);
|
48
|
+
newstr[n] = '\0';
|
49
|
+
|
50
|
+
return newstr;
|
51
|
+
}
|
52
|
+
|
53
|
+
static void *rugged_grealloc(void *ptr, size_t size, const char *file, int line)
|
54
|
+
{
|
55
|
+
return xrealloc(ptr, size);
|
56
|
+
}
|
57
|
+
|
58
|
+
static void *rugged_greallocarray(void *ptr, size_t nelem, size_t elsize, const char *file, int line)
|
59
|
+
{
|
60
|
+
return xrealloc2(ptr, nelem, elsize);
|
61
|
+
}
|
62
|
+
|
63
|
+
static void *rugged_gmallocarray(size_t nelem, size_t elsize, const char *file, int line)
|
64
|
+
{
|
65
|
+
return xmalloc2(nelem, elsize);
|
66
|
+
}
|
67
|
+
|
68
|
+
static void rugged_gfree(void *ptr)
|
69
|
+
{
|
70
|
+
xfree(ptr);
|
71
|
+
}
|
72
|
+
|
73
|
+
void rugged_set_allocator(void)
|
74
|
+
{
|
75
|
+
git_allocator allocator;
|
76
|
+
|
77
|
+
allocator.gmalloc = rugged_gmalloc;
|
78
|
+
allocator.gcalloc = rugged_gcalloc;
|
79
|
+
allocator.gstrdup = rugged_gstrdup;
|
80
|
+
allocator.gstrndup = rugged_gstrndup;
|
81
|
+
allocator.gstrndup = rugged_gstrndup;
|
82
|
+
allocator.gsubstrdup = rugged_gsubstrdup;
|
83
|
+
allocator.grealloc = rugged_grealloc;
|
84
|
+
allocator.greallocarray = rugged_greallocarray;
|
85
|
+
allocator.gmallocarray = rugged_gmallocarray;
|
86
|
+
allocator.gfree = rugged_gfree;
|
87
|
+
|
88
|
+
git_libgit2_opts(GIT_OPT_SET_ALLOCATOR, &allocator);
|
89
|
+
}
|
data/ext/rugged/rugged_blob.c
CHANGED
@@ -165,7 +165,7 @@ static VALUE rb_git_blob_from_workdir(VALUE self, VALUE rb_repo, VALUE rb_path)
|
|
165
165
|
git_oid oid;
|
166
166
|
git_repository *repo;
|
167
167
|
|
168
|
-
|
168
|
+
FilePathValue(rb_path);
|
169
169
|
rugged_check_repo(rb_repo);
|
170
170
|
|
171
171
|
Data_Get_Struct(rb_repo, git_repository, repo);
|
@@ -193,7 +193,7 @@ static VALUE rb_git_blob_from_disk(VALUE self, VALUE rb_repo, VALUE rb_path)
|
|
193
193
|
git_oid oid;
|
194
194
|
git_repository *repo;
|
195
195
|
|
196
|
-
|
196
|
+
FilePathValue(rb_path);
|
197
197
|
rugged_check_repo(rb_repo);
|
198
198
|
|
199
199
|
Data_Get_Struct(rb_repo, git_repository, repo);
|
@@ -254,7 +254,7 @@ static VALUE rb_git_blob_from_io(int argc, VALUE *argv, VALUE klass)
|
|
254
254
|
Data_Get_Struct(rb_repo, git_repository, repo);
|
255
255
|
|
256
256
|
if (!NIL_P(rb_hint_path)) {
|
257
|
-
|
257
|
+
FilePathValue(rb_hint_path);
|
258
258
|
hint_path = StringValueCStr(rb_hint_path);
|
259
259
|
}
|
260
260
|
|
data/ext/rugged/rugged_branch.c
CHANGED
@@ -63,7 +63,7 @@ static VALUE rb_git_branch__remote_name(VALUE rb_repo, const char *canonical_nam
|
|
63
63
|
if ((error = git_branch_remote_name(&remote_name, repo, canonical_name)) == GIT_OK)
|
64
64
|
result = rb_enc_str_new(remote_name.ptr, remote_name.size, rb_utf8_encoding());
|
65
65
|
|
66
|
-
|
66
|
+
git_buf_dispose(&remote_name);
|
67
67
|
rugged_exception_check(error);
|
68
68
|
|
69
69
|
return result;
|
data/ext/rugged/rugged_commit.c
CHANGED
@@ -649,7 +649,7 @@ static VALUE rb_git_commit_to_mbox(int argc, VALUE *argv, VALUE self)
|
|
649
649
|
cleanup:
|
650
650
|
|
651
651
|
xfree(opts.pathspec.strings);
|
652
|
-
|
652
|
+
git_buf_dispose(&email_patch);
|
653
653
|
rugged_exception_check(error);
|
654
654
|
|
655
655
|
return rb_email_patch;
|
@@ -678,7 +678,7 @@ static VALUE rb_git_commit_header_field(VALUE self, VALUE rb_field)
|
|
678
678
|
error = git_commit_header_field(&header_field, commit, StringValueCStr(rb_field));
|
679
679
|
|
680
680
|
if (error < 0) {
|
681
|
-
|
681
|
+
git_buf_dispose(&header_field);
|
682
682
|
if (error == GIT_ENOTFOUND)
|
683
683
|
return Qnil;
|
684
684
|
rugged_exception_check(error);
|
@@ -689,7 +689,7 @@ static VALUE rb_git_commit_header_field(VALUE self, VALUE rb_field)
|
|
689
689
|
encoding = rb_enc_find(encoding_name);
|
690
690
|
|
691
691
|
rb_result = rb_enc_str_new(header_field.ptr, header_field.size, encoding);
|
692
|
-
|
692
|
+
git_buf_dispose(&header_field);
|
693
693
|
return rb_result;
|
694
694
|
}
|
695
695
|
|
@@ -741,8 +741,8 @@ static VALUE rb_git_commit_extract_signature(int argc, VALUE *argv, VALUE self)
|
|
741
741
|
field = NIL_P(rb_field) ? NULL : StringValueCStr(rb_field);
|
742
742
|
error = git_commit_extract_signature(&signature, &signed_data, repo, &commit_id, field);
|
743
743
|
if (error < 0) {
|
744
|
-
|
745
|
-
|
744
|
+
git_buf_dispose(&signature);
|
745
|
+
git_buf_dispose(&signed_data);
|
746
746
|
}
|
747
747
|
|
748
748
|
if (error == GIT_ENOTFOUND && giterr_last()->klass == GITERR_OBJECT ) {
|
@@ -754,8 +754,8 @@ static VALUE rb_git_commit_extract_signature(int argc, VALUE *argv, VALUE self)
|
|
754
754
|
rb_str_new(signed_data.ptr, signed_data.size));
|
755
755
|
}
|
756
756
|
|
757
|
-
|
758
|
-
|
757
|
+
git_buf_dispose(&signature);
|
758
|
+
git_buf_dispose(&signed_data);
|
759
759
|
|
760
760
|
return ret;
|
761
761
|
}
|
@@ -821,7 +821,7 @@ cleanup:
|
|
821
821
|
rugged_exception_check(error);
|
822
822
|
|
823
823
|
ret = rb_str_new_utf8(buf.ptr);
|
824
|
-
|
824
|
+
git_buf_dispose(&buf);
|
825
825
|
|
826
826
|
return ret;
|
827
827
|
}
|
data/ext/rugged/rugged_config.c
CHANGED
data/ext/rugged/rugged_diff.c
CHANGED
@@ -6,6 +6,7 @@
|
|
6
6
|
*/
|
7
7
|
|
8
8
|
#include "rugged.h"
|
9
|
+
#include <ruby/thread.h>
|
9
10
|
|
10
11
|
extern VALUE rb_mRugged;
|
11
12
|
VALUE rb_cRuggedDiff;
|
@@ -197,6 +198,20 @@ static int diff_print_cb(
|
|
197
198
|
return GIT_OK;
|
198
199
|
}
|
199
200
|
|
201
|
+
struct nogvl_diff_patch_args {
|
202
|
+
git_diff * diff;
|
203
|
+
git_diff_format_t format;
|
204
|
+
VALUE rb_str;
|
205
|
+
};
|
206
|
+
|
207
|
+
static void rb_git_diff_patch_nogvl(void * _args)
|
208
|
+
{
|
209
|
+
struct nogvl_diff_patch_args * args;
|
210
|
+
|
211
|
+
args = (struct nogvl_diff_patch_args *)_args;
|
212
|
+
git_diff_print(args->diff, args->format, diff_print_cb, (void*) args->rb_str);
|
213
|
+
}
|
214
|
+
|
200
215
|
/*
|
201
216
|
* call-seq:
|
202
217
|
* diff.patch -> patch
|
@@ -209,6 +224,8 @@ static VALUE rb_git_diff_patch(int argc, VALUE *argv, VALUE self)
|
|
209
224
|
git_diff *diff;
|
210
225
|
VALUE rb_str = rb_str_new(NULL, 0);
|
211
226
|
VALUE rb_opts;
|
227
|
+
struct nogvl_diff_patch_args args;
|
228
|
+
git_diff_format_t format = GIT_DIFF_FORMAT_PATCH;
|
212
229
|
|
213
230
|
rb_scan_args(argc, argv, "00:", &rb_opts);
|
214
231
|
|
@@ -216,13 +233,16 @@ static VALUE rb_git_diff_patch(int argc, VALUE *argv, VALUE self)
|
|
216
233
|
|
217
234
|
if (!NIL_P(rb_opts)) {
|
218
235
|
if (rb_hash_aref(rb_opts, CSTR2SYM("compact")) == Qtrue)
|
219
|
-
|
236
|
+
format = GIT_DIFF_FORMAT_NAME_STATUS;
|
220
237
|
else
|
221
|
-
|
222
|
-
} else {
|
223
|
-
git_diff_print(diff, GIT_DIFF_FORMAT_PATCH, diff_print_cb, (void*)rb_str);
|
238
|
+
format = GIT_DIFF_FORMAT_PATCH;
|
224
239
|
}
|
225
240
|
|
241
|
+
args.diff = diff;
|
242
|
+
args.format = format;
|
243
|
+
args.rb_str = rb_str;
|
244
|
+
rb_thread_call_without_gvl(rb_git_diff_patch_nogvl, &args, RUBY_UBF_PROCESS, NULL);
|
245
|
+
|
226
246
|
return rb_str;
|
227
247
|
}
|
228
248
|
|
data/ext/rugged/rugged_note.c
CHANGED
data/ext/rugged/rugged_repo.c
CHANGED
@@ -182,7 +182,7 @@ static void rugged_repo_new_with_backend(git_repository **repo, VALUE rb_path, V
|
|
182
182
|
|
183
183
|
int error = 0;
|
184
184
|
|
185
|
-
|
185
|
+
FilePathValue(rb_path);
|
186
186
|
path = StringValueCStr(rb_path);
|
187
187
|
|
188
188
|
if (rb_obj_is_kind_of(rb_backend, rb_cRuggedBackend) == Qfalse) {
|
@@ -291,7 +291,7 @@ static VALUE rb_git_repo_open_bare(int argc, VALUE *argv, VALUE klass)
|
|
291
291
|
}
|
292
292
|
|
293
293
|
if (!repo) {
|
294
|
-
|
294
|
+
FilePathValue(rb_path);
|
295
295
|
|
296
296
|
error = git_repository_open_bare(&repo, StringValueCStr(rb_path));
|
297
297
|
rugged_exception_check(error);
|
@@ -335,7 +335,7 @@ static VALUE rb_git_repo_new(int argc, VALUE *argv, VALUE klass)
|
|
335
335
|
VALUE rb_path, rb_options;
|
336
336
|
|
337
337
|
rb_scan_args(argc, argv, "10:", &rb_path, &rb_options);
|
338
|
-
|
338
|
+
FilePathValue(rb_path);
|
339
339
|
|
340
340
|
error = git_repository_open(&repo, StringValueCStr(rb_path));
|
341
341
|
rugged_exception_check(error);
|
@@ -377,7 +377,7 @@ static VALUE rb_git_repo_init_at(int argc, VALUE *argv, VALUE klass)
|
|
377
377
|
int error;
|
378
378
|
|
379
379
|
rb_scan_args(argc, argv, "11:", &rb_path, &rb_is_bare, &rb_options);
|
380
|
-
|
380
|
+
FilePathValue(rb_path);
|
381
381
|
|
382
382
|
if (!NIL_P(rb_options)) {
|
383
383
|
/* Check for `:backend` */
|
@@ -474,7 +474,7 @@ static VALUE rb_git_repo_clone_at(int argc, VALUE *argv, VALUE klass)
|
|
474
474
|
|
475
475
|
rb_scan_args(argc, argv, "21", &url, &local_path, &rb_options_hash);
|
476
476
|
Check_Type(url, T_STRING);
|
477
|
-
|
477
|
+
FilePathValue(local_path);
|
478
478
|
|
479
479
|
parse_clone_options(&options, rb_options_hash, &remote_payload);
|
480
480
|
|
@@ -1180,7 +1180,7 @@ static VALUE rb_git_repo_hashfile(VALUE self, VALUE rb_path, VALUE rb_type)
|
|
1180
1180
|
int error;
|
1181
1181
|
git_oid oid;
|
1182
1182
|
|
1183
|
-
|
1183
|
+
FilePathValue(rb_path);
|
1184
1184
|
|
1185
1185
|
error = git_odb_hashfile(&oid,
|
1186
1186
|
StringValueCStr(rb_path),
|
@@ -1455,7 +1455,7 @@ static VALUE rb_git_repo_discover(int argc, VALUE *argv, VALUE klass)
|
|
1455
1455
|
across_fs = rugged_parse_bool(rb_across_fs);
|
1456
1456
|
}
|
1457
1457
|
|
1458
|
-
|
1458
|
+
FilePathValue(rb_path);
|
1459
1459
|
|
1460
1460
|
error = git_repository_discover(
|
1461
1461
|
&repository_path,
|
@@ -1467,7 +1467,7 @@ static VALUE rb_git_repo_discover(int argc, VALUE *argv, VALUE klass)
|
|
1467
1467
|
rugged_exception_check(error);
|
1468
1468
|
|
1469
1469
|
error = git_repository_open(&repo, repository_path.ptr);
|
1470
|
-
|
1470
|
+
git_buf_dispose(&repository_path);
|
1471
1471
|
|
1472
1472
|
rugged_exception_check(error);
|
1473
1473
|
|
@@ -1518,7 +1518,7 @@ static VALUE rb_git_repo_file_status(VALUE self, VALUE rb_path)
|
|
1518
1518
|
git_repository *repo;
|
1519
1519
|
|
1520
1520
|
Data_Get_Struct(self, git_repository, repo);
|
1521
|
-
|
1521
|
+
FilePathValue(rb_path);
|
1522
1522
|
error = git_status_file(&flags, repo, StringValueCStr(rb_path));
|
1523
1523
|
rugged_exception_check(error);
|
1524
1524
|
|
@@ -2365,7 +2365,7 @@ static VALUE rb_git_repo_attributes(int argc, VALUE *argv, VALUE self)
|
|
2365
2365
|
rb_scan_args(argc, argv, "12", &rb_path, &rb_names, &rb_options);
|
2366
2366
|
|
2367
2367
|
Data_Get_Struct(self, git_repository, repo);
|
2368
|
-
|
2368
|
+
FilePathValue(rb_path);
|
2369
2369
|
|
2370
2370
|
if (!NIL_P(rb_options)) {
|
2371
2371
|
Check_Type(rb_options, T_FIXNUM);
|