rugged 0.17.0b2 → 0.17.0.b6
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +10 -11
- data/ext/rugged/extconf.rb +5 -13
- data/ext/rugged/rugged_commit.c +2 -5
- data/ext/rugged/rugged_reference.c +29 -28
- data/ext/rugged/rugged_remote.c +1 -1
- data/ext/rugged/rugged_repo.c +4 -1
- data/ext/rugged/rugged_tree.c +20 -19
- data/lib/rugged/commit.rb +5 -1
- data/lib/rugged/repository.rb +6 -4
- data/lib/rugged/version.rb +1 -1
- data/test/config_test.rb +1 -1
- data/test/index_test.rb +4 -2
- data/test/object_test.rb +3 -3
- data/test/reference_test.rb +66 -1
- data/test/repo_test.rb +4 -4
- data/test/tree_test.rb +1 -1
- data/test/walker_test.rb +1 -1
- data/vendor/libgit2/Makefile.embed +42 -0
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/deps/http-parser/http_parser.c +0 -0
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/deps/http-parser/http_parser.h +0 -0
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/deps/regex/config.h +0 -0
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/deps/regex/regcomp.c +0 -0
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/deps/regex/regex.c +0 -0
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/deps/regex/regex.h +0 -0
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/deps/regex/regex_internal.c +0 -0
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/deps/regex/regex_internal.h +0 -0
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/deps/regex/regexec.c +0 -0
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/deps/zlib/adler32.c +0 -0
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/deps/zlib/crc32.c +0 -0
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/deps/zlib/crc32.h +0 -0
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/deps/zlib/deflate.c +0 -0
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/deps/zlib/deflate.h +0 -0
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/deps/zlib/inffast.c +0 -0
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/deps/zlib/inffast.h +0 -0
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/deps/zlib/inffixed.h +0 -0
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/deps/zlib/inflate.c +0 -0
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/deps/zlib/inflate.h +0 -0
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/deps/zlib/inftrees.c +0 -0
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/deps/zlib/inftrees.h +0 -0
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/deps/zlib/trees.c +0 -0
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/deps/zlib/trees.h +0 -0
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/deps/zlib/zconf.h +0 -0
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/deps/zlib/zlib.h +0 -0
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/deps/zlib/zutil.c +0 -0
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/deps/zlib/zutil.h +0 -0
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/include/git2.h +6 -0
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/include/git2/attr.h +35 -20
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/include/git2/blob.h +1 -1
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/include/git2/branch.h +62 -24
- data/vendor/libgit2/include/git2/checkout.h +66 -0
- data/vendor/libgit2/include/git2/clone.h +59 -0
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/include/git2/commit.h +22 -3
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/include/git2/common.h +27 -0
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/include/git2/config.h +22 -4
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/include/git2/diff.h +20 -1
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/include/git2/errors.h +2 -37
- data/vendor/libgit2/include/git2/ignore.h +74 -0
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/include/git2/index.h +37 -5
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/include/git2/indexer.h +2 -2
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/include/git2/inttypes.h +0 -0
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/include/git2/merge.h +10 -0
- data/vendor/libgit2/include/git2/message.h +43 -0
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/include/git2/net.h +0 -0
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/include/git2/notes.h +24 -20
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/include/git2/object.h +18 -1
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/include/git2/odb.h +16 -1
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/include/git2/odb_backend.h +8 -1
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/include/git2/oid.h +26 -2
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/include/git2/reflog.h +39 -9
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/include/git2/refs.h +55 -3
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/include/git2/refspec.h +0 -0
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/include/git2/remote.h +68 -2
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/include/git2/repository.h +39 -1
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/include/git2/reset.h +0 -0
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/include/git2/revparse.h +0 -0
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/include/git2/revwalk.h +2 -2
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/include/git2/signature.h +3 -0
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/include/git2/status.h +5 -2
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/include/git2/stdint.h +0 -0
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/include/git2/submodule.h +0 -0
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/include/git2/tag.h +3 -3
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/include/git2/threads.h +0 -0
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/include/git2/tree.h +77 -20
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/include/git2/types.h +14 -0
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/include/git2/version.h +0 -0
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/include/git2/windows.h +0 -0
- data/vendor/libgit2/src/amiga/map.c +51 -0
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/attr.c +39 -6
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/attr.h +1 -0
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/attr_file.c +2 -16
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/attr_file.h +4 -0
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/blob.c +0 -0
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/blob.h +0 -0
- data/vendor/libgit2/src/branch.c +294 -0
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/bswap.h +0 -0
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/buffer.c +40 -0
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/buffer.h +22 -0
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/cache.c +1 -0
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/cache.h +0 -0
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/cc-compat.h +0 -0
- data/vendor/libgit2/src/checkout.c +230 -0
- data/vendor/libgit2/src/clone.c +254 -0
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/commit.c +42 -16
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/commit.h +0 -0
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/common.h +3 -9
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/compat/fnmatch.c +0 -0
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/compat/fnmatch.h +0 -0
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/config.c +15 -5
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/config.h +0 -0
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/config_cache.c +0 -0
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/config_file.c +86 -19
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/config_file.h +16 -1
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/crlf.c +92 -4
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/date.c +20 -20
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/delta-apply.c +0 -0
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/delta-apply.h +0 -0
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/diff.c +45 -18
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/diff.h +0 -0
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/diff_output.c +63 -46
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/errors.c +0 -0
- data/vendor/libgit2/src/fetch.c +380 -0
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/fetch.h +1 -2
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/filebuf.c +7 -2
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/filebuf.h +0 -0
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/fileops.c +16 -1
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/fileops.h +10 -0
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/filter.c +38 -2
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/filter.h +15 -0
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/global.c +5 -0
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/global.h +2 -6
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/hash.c +0 -0
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/hash.h +0 -0
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/ignore.c +50 -1
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/ignore.h +0 -0
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/index.c +95 -28
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/index.h +5 -0
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/indexer.c +27 -25
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/iterator.c +0 -0
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/iterator.h +0 -0
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/khash.h +6 -4
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/map.h +4 -0
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/message.c +27 -2
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/message.h +2 -1
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/mwindow.c +54 -10
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/mwindow.h +1 -1
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/netops.c +48 -38
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/netops.h +7 -4
- data/vendor/libgit2/src/notes.c +610 -0
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/notes.h +0 -0
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/object.c +73 -2
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/odb.c +20 -1
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/odb.h +0 -0
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/odb_loose.c +89 -3
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/odb_pack.c +61 -3
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/oid.c +1 -6
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/oidmap.h +1 -6
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/pack.c +49 -4
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/pack.h +5 -1
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/path.c +144 -21
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/path.h +46 -0
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/pkt.c +30 -8
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/pkt.h +0 -0
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/pool.c +7 -0
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/pool.h +7 -0
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/posix.c +92 -1
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/posix.h +36 -1
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/ppc/sha1.c +0 -0
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/ppc/sha1.h +0 -0
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/pqueue.c +0 -0
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/pqueue.h +0 -0
- data/vendor/libgit2/src/protocol.c +88 -0
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/protocol.h +3 -9
- data/vendor/libgit2/src/reflog.c +489 -0
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/reflog.h +3 -0
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/refs.c +95 -52
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/refs.h +0 -0
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/refspec.c +0 -0
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/refspec.h +0 -0
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/remote.c +130 -8
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/remote.h +6 -0
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/repository.c +167 -42
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/repository.h +7 -0
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/reset.c +1 -1
- data/vendor/libgit2/src/revparse.c +830 -0
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/revwalk.c +83 -15
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/sha1.c +0 -0
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/sha1.h +5 -0
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/sha1_lookup.c +0 -0
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/sha1_lookup.h +0 -0
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/signature.c +19 -5
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/signature.h +0 -0
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/status.c +24 -18
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/strmap.h +1 -1
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/submodule.c +3 -3
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/tag.c +2 -9
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/tag.h +0 -0
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/thread-utils.c +0 -0
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/thread-utils.h +0 -0
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/transport.c +0 -0
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/transport.h +13 -9
- data/vendor/libgit2/src/transports/git.c +245 -0
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/transports/http.c +93 -336
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/transports/local.c +35 -32
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/tree-cache.c +0 -0
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/tree-cache.h +0 -0
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/tree.c +214 -124
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/tree.h +7 -3
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/tsort.c +0 -0
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/unix/map.c +2 -0
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/unix/posix.h +2 -1
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/util.c +30 -0
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/util.h +13 -6
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/vector.c +1 -1
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/vector.h +5 -5
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/win32/dir.c +0 -0
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/win32/dir.h +0 -0
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/win32/map.c +0 -0
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/win32/mingw-compat.h +0 -0
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/win32/msvc-compat.h +0 -0
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/win32/posix.h +1 -0
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/win32/posix_w32.c +17 -1
- data/vendor/libgit2/src/win32/precompiled.c +1 -0
- data/vendor/libgit2/src/win32/precompiled.h +19 -0
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/win32/pthread.c +0 -0
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/win32/pthread.h +0 -0
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/win32/utf-conv.c +0 -0
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/win32/utf-conv.h +0 -0
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/xdiff/xdiff.h +0 -0
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/xdiff/xdiffi.c +0 -0
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/xdiff/xdiffi.h +0 -0
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/xdiff/xemit.c +0 -0
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/xdiff/xemit.h +0 -0
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/xdiff/xhistogram.c +0 -0
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/xdiff/xinclude.h +0 -0
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/xdiff/xmacros.h +0 -0
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/xdiff/xmerge.c +0 -0
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/xdiff/xpatience.c +0 -0
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/xdiff/xprepare.c +0 -0
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/xdiff/xprepare.h +0 -0
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/xdiff/xtypes.h +0 -0
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/xdiff/xutils.c +0 -0
- data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/xdiff/xutils.h +0 -0
- metadata +265 -348
- data/ext/rugged/vendor/libgit2-dist.tar.gz +0 -0
- data/ext/rugged/vendor/libgit2-dist/examples/diff.c +0 -238
- data/ext/rugged/vendor/libgit2-dist/examples/general.c +0 -451
- data/ext/rugged/vendor/libgit2-dist/examples/network/common.h +0 -14
- data/ext/rugged/vendor/libgit2-dist/examples/network/fetch.c +0 -113
- data/ext/rugged/vendor/libgit2-dist/examples/network/git2.c +0 -62
- data/ext/rugged/vendor/libgit2-dist/examples/network/index-pack.c +0 -102
- data/ext/rugged/vendor/libgit2-dist/examples/network/ls-remote.c +0 -76
- data/ext/rugged/vendor/libgit2-dist/examples/showindex.c +0 -43
- data/ext/rugged/vendor/libgit2-dist/src/branch.c +0 -208
- data/ext/rugged/vendor/libgit2-dist/src/branch.h +0 -17
- data/ext/rugged/vendor/libgit2-dist/src/fetch.c +0 -200
- data/ext/rugged/vendor/libgit2-dist/src/notes.c +0 -548
- data/ext/rugged/vendor/libgit2-dist/src/protocol.c +0 -58
- data/ext/rugged/vendor/libgit2-dist/src/reflog.c +0 -340
- data/ext/rugged/vendor/libgit2-dist/src/revparse.c +0 -748
- data/ext/rugged/vendor/libgit2-dist/src/transports/git.c +0 -477
- data/ext/rugged/vendor/libgit2-dist/tests-clar/attr/attr_expect.h +0 -43
- data/ext/rugged/vendor/libgit2-dist/tests-clar/attr/file.c +0 -226
- data/ext/rugged/vendor/libgit2-dist/tests-clar/attr/flags.c +0 -108
- data/ext/rugged/vendor/libgit2-dist/tests-clar/attr/lookup.c +0 -262
- data/ext/rugged/vendor/libgit2-dist/tests-clar/attr/repo.c +0 -273
- data/ext/rugged/vendor/libgit2-dist/tests-clar/buf/basic.c +0 -29
- data/ext/rugged/vendor/libgit2-dist/tests-clar/clar_helpers.c +0 -181
- data/ext/rugged/vendor/libgit2-dist/tests-clar/clar_libgit2.h +0 -55
- data/ext/rugged/vendor/libgit2-dist/tests-clar/commit/commit.c +0 -44
- data/ext/rugged/vendor/libgit2-dist/tests-clar/commit/parse.c +0 -350
- data/ext/rugged/vendor/libgit2-dist/tests-clar/commit/signature.c +0 -65
- data/ext/rugged/vendor/libgit2-dist/tests-clar/commit/write.c +0 -140
- data/ext/rugged/vendor/libgit2-dist/tests-clar/config/add.c +0 -37
- data/ext/rugged/vendor/libgit2-dist/tests-clar/config/multivar.c +0 -151
- data/ext/rugged/vendor/libgit2-dist/tests-clar/config/new.c +0 -36
- data/ext/rugged/vendor/libgit2-dist/tests-clar/config/read.c +0 -221
- data/ext/rugged/vendor/libgit2-dist/tests-clar/config/stress.c +0 -61
- data/ext/rugged/vendor/libgit2-dist/tests-clar/config/write.c +0 -92
- data/ext/rugged/vendor/libgit2-dist/tests-clar/core/buffer.c +0 -613
- data/ext/rugged/vendor/libgit2-dist/tests-clar/core/dirent.c +0 -235
- data/ext/rugged/vendor/libgit2-dist/tests-clar/core/env.c +0 -115
- data/ext/rugged/vendor/libgit2-dist/tests-clar/core/errors.c +0 -60
- data/ext/rugged/vendor/libgit2-dist/tests-clar/core/filebuf.c +0 -92
- data/ext/rugged/vendor/libgit2-dist/tests-clar/core/hex.c +0 -22
- data/ext/rugged/vendor/libgit2-dist/tests-clar/core/oid.c +0 -18
- data/ext/rugged/vendor/libgit2-dist/tests-clar/core/path.c +0 -420
- data/ext/rugged/vendor/libgit2-dist/tests-clar/core/pool.c +0 -85
- data/ext/rugged/vendor/libgit2-dist/tests-clar/core/rmdir.c +0 -68
- data/ext/rugged/vendor/libgit2-dist/tests-clar/core/string.c +0 -28
- data/ext/rugged/vendor/libgit2-dist/tests-clar/core/strmap.c +0 -102
- data/ext/rugged/vendor/libgit2-dist/tests-clar/core/strtol.c +0 -37
- data/ext/rugged/vendor/libgit2-dist/tests-clar/core/vector.c +0 -191
- data/ext/rugged/vendor/libgit2-dist/tests-clar/date/date.c +0 -15
- data/ext/rugged/vendor/libgit2-dist/tests-clar/diff/blob.c +0 -254
- data/ext/rugged/vendor/libgit2-dist/tests-clar/diff/diff_helpers.c +0 -104
- data/ext/rugged/vendor/libgit2-dist/tests-clar/diff/diff_helpers.h +0 -47
- data/ext/rugged/vendor/libgit2-dist/tests-clar/diff/index.c +0 -92
- data/ext/rugged/vendor/libgit2-dist/tests-clar/diff/iterator.c +0 -572
- data/ext/rugged/vendor/libgit2-dist/tests-clar/diff/patch.c +0 -99
- data/ext/rugged/vendor/libgit2-dist/tests-clar/diff/tree.c +0 -210
- data/ext/rugged/vendor/libgit2-dist/tests-clar/diff/workdir.c +0 -543
- data/ext/rugged/vendor/libgit2-dist/tests-clar/index/read_tree.c +0 -46
- data/ext/rugged/vendor/libgit2-dist/tests-clar/index/rename.c +0 -50
- data/ext/rugged/vendor/libgit2-dist/tests-clar/index/tests.c +0 -246
- data/ext/rugged/vendor/libgit2-dist/tests-clar/network/createremotethenload.c +0 -33
- data/ext/rugged/vendor/libgit2-dist/tests-clar/network/remotelocal.c +0 -137
- data/ext/rugged/vendor/libgit2-dist/tests-clar/network/remotes.c +0 -183
- data/ext/rugged/vendor/libgit2-dist/tests-clar/notes/notes.c +0 -133
- data/ext/rugged/vendor/libgit2-dist/tests-clar/notes/notesref.c +0 -57
- data/ext/rugged/vendor/libgit2-dist/tests-clar/object/blob/filter.c +0 -125
- data/ext/rugged/vendor/libgit2-dist/tests-clar/object/blob/fromchunks.c +0 -87
- data/ext/rugged/vendor/libgit2-dist/tests-clar/object/blob/write.c +0 -69
- data/ext/rugged/vendor/libgit2-dist/tests-clar/object/commit/commitstagedfile.c +0 -126
- data/ext/rugged/vendor/libgit2-dist/tests-clar/object/lookup.c +0 -63
- data/ext/rugged/vendor/libgit2-dist/tests-clar/object/message.c +0 -171
- data/ext/rugged/vendor/libgit2-dist/tests-clar/object/raw/chars.c +0 -41
- data/ext/rugged/vendor/libgit2-dist/tests-clar/object/raw/compare.c +0 -124
- data/ext/rugged/vendor/libgit2-dist/tests-clar/object/raw/convert.c +0 -75
- data/ext/rugged/vendor/libgit2-dist/tests-clar/object/raw/data.h +0 -323
- data/ext/rugged/vendor/libgit2-dist/tests-clar/object/raw/fromstr.c +0 -30
- data/ext/rugged/vendor/libgit2-dist/tests-clar/object/raw/hash.c +0 -166
- data/ext/rugged/vendor/libgit2-dist/tests-clar/object/raw/short.c +0 -94
- data/ext/rugged/vendor/libgit2-dist/tests-clar/object/raw/size.c +0 -13
- data/ext/rugged/vendor/libgit2-dist/tests-clar/object/raw/type2string.c +0 -54
- data/ext/rugged/vendor/libgit2-dist/tests-clar/object/raw/write.c +0 -455
- data/ext/rugged/vendor/libgit2-dist/tests-clar/object/tag/peel.c +0 -56
- data/ext/rugged/vendor/libgit2-dist/tests-clar/object/tag/read.c +0 -130
- data/ext/rugged/vendor/libgit2-dist/tests-clar/object/tag/write.c +0 -192
- data/ext/rugged/vendor/libgit2-dist/tests-clar/object/tree/frompath.c +0 -81
- data/ext/rugged/vendor/libgit2-dist/tests-clar/object/tree/read.c +0 -75
- data/ext/rugged/vendor/libgit2-dist/tests-clar/object/tree/write.c +0 -84
- data/ext/rugged/vendor/libgit2-dist/tests-clar/odb/loose.c +0 -84
- data/ext/rugged/vendor/libgit2-dist/tests-clar/odb/loose_data.h +0 -522
- data/ext/rugged/vendor/libgit2-dist/tests-clar/odb/mixed.c +0 -24
- data/ext/rugged/vendor/libgit2-dist/tests-clar/odb/pack_data.h +0 -151
- data/ext/rugged/vendor/libgit2-dist/tests-clar/odb/packed.c +0 -78
- data/ext/rugged/vendor/libgit2-dist/tests-clar/odb/sorting.c +0 -71
- data/ext/rugged/vendor/libgit2-dist/tests-clar/refs/branches/create.c +0 -113
- data/ext/rugged/vendor/libgit2-dist/tests-clar/refs/branches/delete.c +0 -91
- data/ext/rugged/vendor/libgit2-dist/tests-clar/refs/branches/listall.c +0 -78
- data/ext/rugged/vendor/libgit2-dist/tests-clar/refs/branches/move.c +0 -72
- data/ext/rugged/vendor/libgit2-dist/tests-clar/refs/crashes.c +0 -17
- data/ext/rugged/vendor/libgit2-dist/tests-clar/refs/create.c +0 -149
- data/ext/rugged/vendor/libgit2-dist/tests-clar/refs/delete.c +0 -85
- data/ext/rugged/vendor/libgit2-dist/tests-clar/refs/list.c +0 -53
- data/ext/rugged/vendor/libgit2-dist/tests-clar/refs/listall.c +0 -36
- data/ext/rugged/vendor/libgit2-dist/tests-clar/refs/lookup.c +0 -42
- data/ext/rugged/vendor/libgit2-dist/tests-clar/refs/normalize.c +0 -200
- data/ext/rugged/vendor/libgit2-dist/tests-clar/refs/overwrite.c +0 -136
- data/ext/rugged/vendor/libgit2-dist/tests-clar/refs/pack.c +0 -67
- data/ext/rugged/vendor/libgit2-dist/tests-clar/refs/read.c +0 -194
- data/ext/rugged/vendor/libgit2-dist/tests-clar/refs/reflog.c +0 -123
- data/ext/rugged/vendor/libgit2-dist/tests-clar/refs/rename.c +0 -339
- data/ext/rugged/vendor/libgit2-dist/tests-clar/refs/revparse.c +0 -174
- data/ext/rugged/vendor/libgit2-dist/tests-clar/refs/unicode.c +0 -42
- data/ext/rugged/vendor/libgit2-dist/tests-clar/repo/discover.c +0 -142
- data/ext/rugged/vendor/libgit2-dist/tests-clar/repo/getters.c +0 -86
- data/ext/rugged/vendor/libgit2-dist/tests-clar/repo/init.c +0 -249
- data/ext/rugged/vendor/libgit2-dist/tests-clar/repo/open.c +0 -282
- data/ext/rugged/vendor/libgit2-dist/tests-clar/repo/setters.c +0 -80
- data/ext/rugged/vendor/libgit2-dist/tests-clar/reset/mixed.c +0 -47
- data/ext/rugged/vendor/libgit2-dist/tests-clar/reset/reset_helpers.c +0 -10
- data/ext/rugged/vendor/libgit2-dist/tests-clar/reset/reset_helpers.h +0 -6
- data/ext/rugged/vendor/libgit2-dist/tests-clar/reset/soft.c +0 -102
- data/ext/rugged/vendor/libgit2-dist/tests-clar/revwalk/basic.c +0 -181
- data/ext/rugged/vendor/libgit2-dist/tests-clar/revwalk/mergebase.c +0 -148
- data/ext/rugged/vendor/libgit2-dist/tests-clar/status/ignore.c +0 -147
- data/ext/rugged/vendor/libgit2-dist/tests-clar/status/single.c +0 -29
- data/ext/rugged/vendor/libgit2-dist/tests-clar/status/status_data.h +0 -202
- data/ext/rugged/vendor/libgit2-dist/tests-clar/status/status_helpers.c +0 -49
- data/ext/rugged/vendor/libgit2-dist/tests-clar/status/status_helpers.h +0 -33
- data/ext/rugged/vendor/libgit2-dist/tests-clar/status/submodules.c +0 -112
- data/ext/rugged/vendor/libgit2-dist/tests-clar/status/worktree.c +0 -649
- data/ext/rugged/vendor/libgit2-dist/tests-clar/threads/basic.c +0 -20
File without changes
|
@@ -141,6 +141,42 @@ int git_buf_puts(git_buf *buf, const char *string)
|
|
141
141
|
return git_buf_put(buf, string, strlen(string));
|
142
142
|
}
|
143
143
|
|
144
|
+
int git_buf_puts_escaped(
|
145
|
+
git_buf *buf, const char *string, const char *esc_chars, const char *esc_with)
|
146
|
+
{
|
147
|
+
const char *scan = string;
|
148
|
+
size_t total = 0, esc_with_len = strlen(esc_with);
|
149
|
+
|
150
|
+
while (*scan) {
|
151
|
+
size_t count = strcspn(scan, esc_chars);
|
152
|
+
total += count + 1 + esc_with_len;
|
153
|
+
scan += count + 1;
|
154
|
+
}
|
155
|
+
|
156
|
+
ENSURE_SIZE(buf, buf->size + total + 1);
|
157
|
+
|
158
|
+
for (scan = string; *scan; ) {
|
159
|
+
size_t count = strcspn(scan, esc_chars);
|
160
|
+
|
161
|
+
memmove(buf->ptr + buf->size, scan, count);
|
162
|
+
scan += count;
|
163
|
+
buf->size += count;
|
164
|
+
|
165
|
+
if (*scan) {
|
166
|
+
memmove(buf->ptr + buf->size, esc_with, esc_with_len);
|
167
|
+
buf->size += esc_with_len;
|
168
|
+
|
169
|
+
memmove(buf->ptr + buf->size, scan, 1);
|
170
|
+
scan += 1;
|
171
|
+
buf->size += 1;
|
172
|
+
}
|
173
|
+
}
|
174
|
+
|
175
|
+
buf->ptr[buf->size] = '\0';
|
176
|
+
|
177
|
+
return 0;
|
178
|
+
}
|
179
|
+
|
144
180
|
int git_buf_vprintf(git_buf *buf, const char *format, va_list ap)
|
145
181
|
{
|
146
182
|
int len;
|
@@ -460,3 +496,7 @@ bool git_buf_is_binary(const git_buf *buf)
|
|
460
496
|
return ((printable >> 7) < nonprintable);
|
461
497
|
}
|
462
498
|
|
499
|
+
void git_buf_unescape(git_buf *buf)
|
500
|
+
{
|
501
|
+
buf->size = git__unescape(buf->ptr);
|
502
|
+
}
|
@@ -90,6 +90,18 @@ void git_buf_rtruncate_at_char(git_buf *path, char separator);
|
|
90
90
|
int git_buf_join_n(git_buf *buf, char separator, int nbuf, ...);
|
91
91
|
int git_buf_join(git_buf *buf, char separator, const char *str_a, const char *str_b);
|
92
92
|
|
93
|
+
/**
|
94
|
+
* Copy string into buf prefixing every character that is contained in the
|
95
|
+
* esc_chars string with the esc_with string.
|
96
|
+
*/
|
97
|
+
int git_buf_puts_escaped(
|
98
|
+
git_buf *buf, const char *string, const char *esc_chars, const char *esc_with);
|
99
|
+
|
100
|
+
GIT_INLINE(int) git_buf_puts_escape_regex(git_buf *buf, const char *string)
|
101
|
+
{
|
102
|
+
return git_buf_puts_escaped(buf, string, "^.[]$()|*+?{}\\", "\\");
|
103
|
+
}
|
104
|
+
|
93
105
|
/**
|
94
106
|
* Join two strings as paths, inserting a slash between as needed.
|
95
107
|
* @return 0 on success, -1 on failure
|
@@ -121,6 +133,13 @@ GIT_INLINE(ssize_t) git_buf_rfind_next(git_buf *buf, char ch)
|
|
121
133
|
return idx;
|
122
134
|
}
|
123
135
|
|
136
|
+
GIT_INLINE(ssize_t) git_buf_rfind(git_buf *buf, char ch)
|
137
|
+
{
|
138
|
+
ssize_t idx = (ssize_t)buf->size - 1;
|
139
|
+
while (idx >= 0 && buf->ptr[idx] != ch) idx--;
|
140
|
+
return idx;
|
141
|
+
}
|
142
|
+
|
124
143
|
/* Remove whitespace from the end of the buffer */
|
125
144
|
void git_buf_rtrim(git_buf *buf);
|
126
145
|
|
@@ -132,4 +151,7 @@ int git_buf_common_prefix(git_buf *buf, const git_strarray *strings);
|
|
132
151
|
/* Check if buffer looks like it contains binary data */
|
133
152
|
bool git_buf_is_binary(const git_buf *buf);
|
134
153
|
|
154
|
+
/* Unescape all characters in a buffer */
|
155
|
+
void git_buf_unescape(git_buf *buf);
|
156
|
+
|
135
157
|
#endif
|
File without changes
|
File without changes
|
@@ -0,0 +1,230 @@
|
|
1
|
+
/*
|
2
|
+
* Copyright (C) 2009-2012 the libgit2 contributors
|
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
|
+
|
8
|
+
#include <assert.h>
|
9
|
+
|
10
|
+
#include "git2/checkout.h"
|
11
|
+
#include "git2/repository.h"
|
12
|
+
#include "git2/refs.h"
|
13
|
+
#include "git2/tree.h"
|
14
|
+
#include "git2/commit.h"
|
15
|
+
#include "git2/blob.h"
|
16
|
+
#include "git2/config.h"
|
17
|
+
|
18
|
+
#include "common.h"
|
19
|
+
#include "refs.h"
|
20
|
+
#include "buffer.h"
|
21
|
+
#include "repository.h"
|
22
|
+
#include "filter.h"
|
23
|
+
#include "blob.h"
|
24
|
+
|
25
|
+
GIT_BEGIN_DECL
|
26
|
+
|
27
|
+
|
28
|
+
typedef struct tree_walk_data
|
29
|
+
{
|
30
|
+
git_indexer_stats *stats;
|
31
|
+
git_checkout_opts *opts;
|
32
|
+
git_repository *repo;
|
33
|
+
git_odb *odb;
|
34
|
+
bool do_symlinks;
|
35
|
+
} tree_walk_data;
|
36
|
+
|
37
|
+
|
38
|
+
static int blob_contents_to_link(tree_walk_data *data, git_buf *fnbuf,
|
39
|
+
const git_oid *id)
|
40
|
+
{
|
41
|
+
int retcode = GIT_ERROR;
|
42
|
+
git_blob *blob;
|
43
|
+
|
44
|
+
/* Get the link target */
|
45
|
+
if (!(retcode = git_blob_lookup(&blob, data->repo, id))) {
|
46
|
+
git_buf linktarget = GIT_BUF_INIT;
|
47
|
+
if (!(retcode = git_blob__getbuf(&linktarget, blob))) {
|
48
|
+
/* Create the link */
|
49
|
+
const char *new = git_buf_cstr(&linktarget),
|
50
|
+
*old = git_buf_cstr(fnbuf);
|
51
|
+
retcode = data->do_symlinks
|
52
|
+
? p_symlink(new, old)
|
53
|
+
: git_futils_fake_symlink(new, old);
|
54
|
+
}
|
55
|
+
git_buf_free(&linktarget);
|
56
|
+
git_blob_free(blob);
|
57
|
+
}
|
58
|
+
|
59
|
+
return retcode;
|
60
|
+
}
|
61
|
+
|
62
|
+
|
63
|
+
static int blob_contents_to_file(git_repository *repo, git_buf *fnbuf,
|
64
|
+
const git_tree_entry *entry, tree_walk_data *data)
|
65
|
+
{
|
66
|
+
int retcode = GIT_ERROR;
|
67
|
+
int fd = -1;
|
68
|
+
git_buf contents = GIT_BUF_INIT;
|
69
|
+
const git_oid *id = git_tree_entry_id(entry);
|
70
|
+
int file_mode = data->opts->file_mode;
|
71
|
+
|
72
|
+
/* Deal with pre-existing files */
|
73
|
+
if (git_path_exists(git_buf_cstr(fnbuf)) &&
|
74
|
+
data->opts->existing_file_action == GIT_CHECKOUT_SKIP_EXISTING)
|
75
|
+
return 0;
|
76
|
+
|
77
|
+
/* Allow disabling of filters */
|
78
|
+
if (data->opts->disable_filters) {
|
79
|
+
git_blob *blob;
|
80
|
+
if (!(retcode = git_blob_lookup(&blob, repo, id))) {
|
81
|
+
retcode = git_blob__getbuf(&contents, blob);
|
82
|
+
git_blob_free(blob);
|
83
|
+
}
|
84
|
+
} else {
|
85
|
+
retcode = git_filter_blob_contents(&contents, repo, id, git_buf_cstr(fnbuf));
|
86
|
+
}
|
87
|
+
if (retcode < 0) goto bctf_cleanup;
|
88
|
+
|
89
|
+
/* Allow overriding of file mode */
|
90
|
+
if (!file_mode)
|
91
|
+
file_mode = git_tree_entry_filemode(entry);
|
92
|
+
|
93
|
+
if ((retcode = git_futils_mkpath2file(git_buf_cstr(fnbuf), data->opts->dir_mode)) < 0)
|
94
|
+
goto bctf_cleanup;
|
95
|
+
|
96
|
+
fd = p_open(git_buf_cstr(fnbuf), data->opts->file_open_flags, file_mode);
|
97
|
+
if (fd < 0) goto bctf_cleanup;
|
98
|
+
|
99
|
+
if (!p_write(fd, git_buf_cstr(&contents), git_buf_len(&contents)))
|
100
|
+
retcode = 0;
|
101
|
+
else
|
102
|
+
retcode = GIT_ERROR;
|
103
|
+
p_close(fd);
|
104
|
+
|
105
|
+
bctf_cleanup:
|
106
|
+
git_buf_free(&contents);
|
107
|
+
return retcode;
|
108
|
+
}
|
109
|
+
|
110
|
+
static int checkout_walker(const char *path, const git_tree_entry *entry, void *payload)
|
111
|
+
{
|
112
|
+
int retcode = 0;
|
113
|
+
tree_walk_data *data = (tree_walk_data*)payload;
|
114
|
+
int attr = git_tree_entry_filemode(entry);
|
115
|
+
git_buf fnbuf = GIT_BUF_INIT;
|
116
|
+
git_buf_join_n(&fnbuf, '/', 3,
|
117
|
+
git_repository_workdir(data->repo),
|
118
|
+
path,
|
119
|
+
git_tree_entry_name(entry));
|
120
|
+
|
121
|
+
switch(git_tree_entry_type(entry))
|
122
|
+
{
|
123
|
+
case GIT_OBJ_TREE:
|
124
|
+
/* Nothing to do; the blob handling creates necessary directories. */
|
125
|
+
break;
|
126
|
+
|
127
|
+
case GIT_OBJ_COMMIT:
|
128
|
+
/* Submodule */
|
129
|
+
git_futils_mkpath2file(git_buf_cstr(&fnbuf), data->opts->dir_mode);
|
130
|
+
retcode = p_mkdir(git_buf_cstr(&fnbuf), data->opts->dir_mode);
|
131
|
+
break;
|
132
|
+
|
133
|
+
case GIT_OBJ_BLOB:
|
134
|
+
if (S_ISLNK(attr)) {
|
135
|
+
retcode = blob_contents_to_link(data, &fnbuf,
|
136
|
+
git_tree_entry_id(entry));
|
137
|
+
} else {
|
138
|
+
retcode = blob_contents_to_file(data->repo, &fnbuf, entry, data);
|
139
|
+
}
|
140
|
+
break;
|
141
|
+
|
142
|
+
default:
|
143
|
+
retcode = -1;
|
144
|
+
break;
|
145
|
+
}
|
146
|
+
|
147
|
+
git_buf_free(&fnbuf);
|
148
|
+
data->stats->processed++;
|
149
|
+
return retcode;
|
150
|
+
}
|
151
|
+
|
152
|
+
|
153
|
+
int git_checkout_head(git_repository *repo, git_checkout_opts *opts, git_indexer_stats *stats)
|
154
|
+
{
|
155
|
+
int retcode = GIT_ERROR;
|
156
|
+
git_indexer_stats dummy_stats;
|
157
|
+
git_checkout_opts default_opts = {0};
|
158
|
+
git_tree *tree;
|
159
|
+
tree_walk_data payload;
|
160
|
+
git_config *cfg;
|
161
|
+
|
162
|
+
assert(repo);
|
163
|
+
if (!opts) opts = &default_opts;
|
164
|
+
if (!stats) stats = &dummy_stats;
|
165
|
+
|
166
|
+
/* Default options */
|
167
|
+
if (!opts->existing_file_action)
|
168
|
+
opts->existing_file_action = GIT_CHECKOUT_OVERWRITE_EXISTING;
|
169
|
+
/* opts->disable_filters is false by default */
|
170
|
+
if (!opts->dir_mode) opts->dir_mode = GIT_DIR_MODE;
|
171
|
+
if (!opts->file_open_flags)
|
172
|
+
opts->file_open_flags = O_CREAT | O_TRUNC | O_WRONLY;
|
173
|
+
|
174
|
+
if (git_repository_is_bare(repo)) {
|
175
|
+
giterr_set(GITERR_INVALID, "Checkout is not allowed for bare repositories");
|
176
|
+
return GIT_ERROR;
|
177
|
+
}
|
178
|
+
|
179
|
+
/* Determine if symlinks should be handled */
|
180
|
+
if (!git_repository_config(&cfg, repo)) {
|
181
|
+
int temp = true;
|
182
|
+
if (!git_config_get_bool(&temp, cfg, "core.symlinks")) {
|
183
|
+
payload.do_symlinks = !!temp;
|
184
|
+
}
|
185
|
+
git_config_free(cfg);
|
186
|
+
}
|
187
|
+
|
188
|
+
stats->total = stats->processed = 0;
|
189
|
+
payload.stats = stats;
|
190
|
+
payload.opts = opts;
|
191
|
+
payload.repo = repo;
|
192
|
+
if (git_repository_odb(&payload.odb, repo) < 0) return GIT_ERROR;
|
193
|
+
|
194
|
+
if (!git_repository_head_tree(&tree, repo)) {
|
195
|
+
git_index *idx;
|
196
|
+
if (!(retcode = git_repository_index(&idx, repo))) {
|
197
|
+
if (!(retcode = git_index_read_tree(idx, tree, stats))) {
|
198
|
+
git_index_write(idx);
|
199
|
+
retcode = git_tree_walk(tree, checkout_walker, GIT_TREEWALK_POST, &payload);
|
200
|
+
}
|
201
|
+
git_index_free(idx);
|
202
|
+
}
|
203
|
+
git_tree_free(tree);
|
204
|
+
}
|
205
|
+
|
206
|
+
git_odb_free(payload.odb);
|
207
|
+
return retcode;
|
208
|
+
}
|
209
|
+
|
210
|
+
|
211
|
+
int git_checkout_reference(git_reference *ref,
|
212
|
+
git_checkout_opts *opts,
|
213
|
+
git_indexer_stats *stats)
|
214
|
+
{
|
215
|
+
git_repository *repo= git_reference_owner(ref);
|
216
|
+
git_reference *head = NULL;
|
217
|
+
int retcode = GIT_ERROR;
|
218
|
+
|
219
|
+
if ((retcode = git_reference_create_symbolic(&head, repo, GIT_HEAD_FILE,
|
220
|
+
git_reference_name(ref), true)) < 0)
|
221
|
+
return retcode;
|
222
|
+
|
223
|
+
retcode = git_checkout_head(git_reference_owner(ref), opts, stats);
|
224
|
+
|
225
|
+
git_reference_free(head);
|
226
|
+
return retcode;
|
227
|
+
}
|
228
|
+
|
229
|
+
|
230
|
+
GIT_END_DECL
|
@@ -0,0 +1,254 @@
|
|
1
|
+
/*
|
2
|
+
* Copyright (C) 2009-2012 the libgit2 contributors
|
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
|
+
|
8
|
+
#include <assert.h>
|
9
|
+
|
10
|
+
#ifndef GIT_WIN32
|
11
|
+
#include <dirent.h>
|
12
|
+
#endif
|
13
|
+
|
14
|
+
#include "git2/clone.h"
|
15
|
+
#include "git2/remote.h"
|
16
|
+
#include "git2/revparse.h"
|
17
|
+
#include "git2/branch.h"
|
18
|
+
#include "git2/config.h"
|
19
|
+
#include "git2/checkout.h"
|
20
|
+
#include "git2/commit.h"
|
21
|
+
#include "git2/tree.h"
|
22
|
+
|
23
|
+
#include "common.h"
|
24
|
+
#include "remote.h"
|
25
|
+
#include "fileops.h"
|
26
|
+
#include "refs.h"
|
27
|
+
#include "path.h"
|
28
|
+
|
29
|
+
GIT_BEGIN_DECL
|
30
|
+
|
31
|
+
struct HeadInfo {
|
32
|
+
git_repository *repo;
|
33
|
+
git_oid remote_head_oid;
|
34
|
+
git_buf branchname;
|
35
|
+
};
|
36
|
+
|
37
|
+
static int create_tracking_branch(git_repository *repo, const git_oid *target, const char *name)
|
38
|
+
{
|
39
|
+
git_object *head_obj = NULL;
|
40
|
+
git_reference *branch_ref;
|
41
|
+
int retcode = GIT_ERROR;
|
42
|
+
|
43
|
+
/* Find the target commit */
|
44
|
+
if (git_object_lookup(&head_obj, repo, target, GIT_OBJ_ANY) < 0)
|
45
|
+
return GIT_ERROR;
|
46
|
+
|
47
|
+
/* Create the new branch */
|
48
|
+
if (!git_branch_create(&branch_ref, repo, name, head_obj, 0)) {
|
49
|
+
git_config *cfg;
|
50
|
+
|
51
|
+
git_reference_free(branch_ref);
|
52
|
+
/* Set up tracking */
|
53
|
+
if (!git_repository_config(&cfg, repo)) {
|
54
|
+
git_buf remote = GIT_BUF_INIT;
|
55
|
+
git_buf merge = GIT_BUF_INIT;
|
56
|
+
git_buf merge_target = GIT_BUF_INIT;
|
57
|
+
if (!git_buf_printf(&remote, "branch.%s.remote", name) &&
|
58
|
+
!git_buf_printf(&merge, "branch.%s.merge", name) &&
|
59
|
+
!git_buf_printf(&merge_target, "refs/heads/%s", name) &&
|
60
|
+
!git_config_set_string(cfg, git_buf_cstr(&remote), "origin") &&
|
61
|
+
!git_config_set_string(cfg, git_buf_cstr(&merge), git_buf_cstr(&merge_target))) {
|
62
|
+
retcode = 0;
|
63
|
+
}
|
64
|
+
git_buf_free(&remote);
|
65
|
+
git_buf_free(&merge);
|
66
|
+
git_buf_free(&merge_target);
|
67
|
+
git_config_free(cfg);
|
68
|
+
}
|
69
|
+
}
|
70
|
+
|
71
|
+
git_object_free(head_obj);
|
72
|
+
return retcode;
|
73
|
+
}
|
74
|
+
|
75
|
+
static int reference_matches_remote_head(const char *head_name, void *payload)
|
76
|
+
{
|
77
|
+
struct HeadInfo *head_info = (struct HeadInfo *)payload;
|
78
|
+
git_oid oid;
|
79
|
+
|
80
|
+
/* Stop looking if we've already found a match */
|
81
|
+
if (git_buf_len(&head_info->branchname) > 0) return 0;
|
82
|
+
|
83
|
+
if (!git_reference_name_to_oid(&oid, head_info->repo, head_name) &&
|
84
|
+
!git_oid_cmp(&head_info->remote_head_oid, &oid)) {
|
85
|
+
git_buf_puts(&head_info->branchname,
|
86
|
+
head_name+strlen("refs/remotes/origin/"));
|
87
|
+
}
|
88
|
+
return 0;
|
89
|
+
}
|
90
|
+
|
91
|
+
static int update_head_to_new_branch(git_repository *repo, const git_oid *target, const char *name)
|
92
|
+
{
|
93
|
+
int retcode = GIT_ERROR;
|
94
|
+
|
95
|
+
if (!create_tracking_branch(repo, target, name)) {
|
96
|
+
git_reference *head;
|
97
|
+
if (!git_reference_lookup(&head, repo, GIT_HEAD_FILE)) {
|
98
|
+
git_buf targetbuf = GIT_BUF_INIT;
|
99
|
+
if (!git_buf_printf(&targetbuf, "refs/heads/%s", name)) {
|
100
|
+
retcode = git_reference_set_target(head, git_buf_cstr(&targetbuf));
|
101
|
+
}
|
102
|
+
git_buf_free(&targetbuf);
|
103
|
+
git_reference_free(head);
|
104
|
+
}
|
105
|
+
}
|
106
|
+
|
107
|
+
return retcode;
|
108
|
+
}
|
109
|
+
|
110
|
+
static int update_head_to_remote(git_repository *repo, git_remote *remote)
|
111
|
+
{
|
112
|
+
int retcode = GIT_ERROR;
|
113
|
+
git_remote_head *remote_head;
|
114
|
+
git_oid oid;
|
115
|
+
struct HeadInfo head_info;
|
116
|
+
|
117
|
+
/* Get the remote's HEAD. This is always the first ref in remote->refs. */
|
118
|
+
remote_head = remote->refs.contents[0];
|
119
|
+
git_oid_cpy(&head_info.remote_head_oid, &remote_head->oid);
|
120
|
+
git_buf_init(&head_info.branchname, 16);
|
121
|
+
head_info.repo = repo;
|
122
|
+
|
123
|
+
/* Check to see if "master" matches the remote head */
|
124
|
+
if (!git_reference_name_to_oid(&oid, repo, "refs/remotes/origin/master") &&
|
125
|
+
!git_oid_cmp(&remote_head->oid, &oid)) {
|
126
|
+
retcode = update_head_to_new_branch(repo, &oid, "master");
|
127
|
+
}
|
128
|
+
/* Not master. Check all the other refs. */
|
129
|
+
else if (!git_reference_foreach(repo, GIT_REF_LISTALL,
|
130
|
+
reference_matches_remote_head,
|
131
|
+
&head_info) &&
|
132
|
+
git_buf_len(&head_info.branchname) > 0) {
|
133
|
+
retcode = update_head_to_new_branch(repo, &head_info.remote_head_oid,
|
134
|
+
git_buf_cstr(&head_info.branchname));
|
135
|
+
}
|
136
|
+
|
137
|
+
git_buf_free(&head_info.branchname);
|
138
|
+
return retcode;
|
139
|
+
}
|
140
|
+
|
141
|
+
/*
|
142
|
+
* submodules?
|
143
|
+
*/
|
144
|
+
|
145
|
+
|
146
|
+
|
147
|
+
static int setup_remotes_and_fetch(git_repository *repo,
|
148
|
+
const char *origin_url,
|
149
|
+
git_indexer_stats *fetch_stats)
|
150
|
+
{
|
151
|
+
int retcode = GIT_ERROR;
|
152
|
+
git_remote *origin = NULL;
|
153
|
+
git_off_t bytes = 0;
|
154
|
+
git_indexer_stats dummy_stats;
|
155
|
+
|
156
|
+
if (!fetch_stats) fetch_stats = &dummy_stats;
|
157
|
+
|
158
|
+
/* Create the "origin" remote */
|
159
|
+
if (!git_remote_add(&origin, repo, "origin", origin_url)) {
|
160
|
+
/* Connect and download everything */
|
161
|
+
if (!git_remote_connect(origin, GIT_DIR_FETCH)) {
|
162
|
+
if (!git_remote_download(origin, &bytes, fetch_stats)) {
|
163
|
+
/* Create "origin/foo" branches for all remote branches */
|
164
|
+
if (!git_remote_update_tips(origin)) {
|
165
|
+
/* Point HEAD to the same ref as the remote's head */
|
166
|
+
if (!update_head_to_remote(repo, origin)) {
|
167
|
+
retcode = 0;
|
168
|
+
}
|
169
|
+
}
|
170
|
+
}
|
171
|
+
git_remote_disconnect(origin);
|
172
|
+
}
|
173
|
+
git_remote_free(origin);
|
174
|
+
}
|
175
|
+
|
176
|
+
return retcode;
|
177
|
+
}
|
178
|
+
|
179
|
+
|
180
|
+
static bool path_is_okay(const char *path)
|
181
|
+
{
|
182
|
+
/* The path must either not exist, or be an empty directory */
|
183
|
+
if (!git_path_exists(path)) return true;
|
184
|
+
if (!git_path_is_empty_dir(path)) {
|
185
|
+
giterr_set(GITERR_INVALID,
|
186
|
+
"'%s' exists and is not an empty directory", path);
|
187
|
+
return false;
|
188
|
+
}
|
189
|
+
return true;
|
190
|
+
}
|
191
|
+
|
192
|
+
|
193
|
+
static int clone_internal(git_repository **out,
|
194
|
+
const char *origin_url,
|
195
|
+
const char *path,
|
196
|
+
git_indexer_stats *fetch_stats,
|
197
|
+
int is_bare)
|
198
|
+
{
|
199
|
+
int retcode = GIT_ERROR;
|
200
|
+
git_repository *repo = NULL;
|
201
|
+
git_indexer_stats dummy_stats;
|
202
|
+
|
203
|
+
if (!fetch_stats) fetch_stats = &dummy_stats;
|
204
|
+
|
205
|
+
if (!path_is_okay(path)) {
|
206
|
+
return GIT_ERROR;
|
207
|
+
}
|
208
|
+
|
209
|
+
if (!(retcode = git_repository_init(&repo, path, is_bare))) {
|
210
|
+
if ((retcode = setup_remotes_and_fetch(repo, origin_url, fetch_stats)) < 0) {
|
211
|
+
/* Failed to fetch; clean up */
|
212
|
+
git_repository_free(repo);
|
213
|
+
git_futils_rmdir_r(path, GIT_DIRREMOVAL_FILES_AND_DIRS);
|
214
|
+
} else {
|
215
|
+
*out = repo;
|
216
|
+
retcode = 0;
|
217
|
+
}
|
218
|
+
}
|
219
|
+
|
220
|
+
return retcode;
|
221
|
+
}
|
222
|
+
|
223
|
+
int git_clone_bare(git_repository **out,
|
224
|
+
const char *origin_url,
|
225
|
+
const char *dest_path,
|
226
|
+
git_indexer_stats *fetch_stats)
|
227
|
+
{
|
228
|
+
assert(out && origin_url && dest_path);
|
229
|
+
return clone_internal(out, origin_url, dest_path, fetch_stats, 1);
|
230
|
+
}
|
231
|
+
|
232
|
+
|
233
|
+
int git_clone(git_repository **out,
|
234
|
+
const char *origin_url,
|
235
|
+
const char *workdir_path,
|
236
|
+
git_indexer_stats *fetch_stats,
|
237
|
+
git_indexer_stats *checkout_stats,
|
238
|
+
git_checkout_opts *checkout_opts)
|
239
|
+
{
|
240
|
+
int retcode = GIT_ERROR;
|
241
|
+
|
242
|
+
assert(out && origin_url && workdir_path);
|
243
|
+
|
244
|
+
if (!(retcode = clone_internal(out, origin_url, workdir_path, fetch_stats, 0))) {
|
245
|
+
retcode = git_checkout_head(*out, checkout_opts, checkout_stats);
|
246
|
+
}
|
247
|
+
|
248
|
+
return retcode;
|
249
|
+
}
|
250
|
+
|
251
|
+
|
252
|
+
|
253
|
+
|
254
|
+
GIT_END_DECL
|