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
@@ -1,58 +0,0 @@
|
|
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
|
-
#include "common.h"
|
8
|
-
#include "protocol.h"
|
9
|
-
#include "pkt.h"
|
10
|
-
#include "buffer.h"
|
11
|
-
|
12
|
-
int git_protocol_store_refs(git_protocol *p, const char *data, size_t len)
|
13
|
-
{
|
14
|
-
git_buf *buf = &p->buf;
|
15
|
-
git_vector *refs = p->refs;
|
16
|
-
int error;
|
17
|
-
const char *line_end, *ptr;
|
18
|
-
|
19
|
-
if (len == 0) { /* EOF */
|
20
|
-
if (git_buf_len(buf) != 0) {
|
21
|
-
giterr_set(GITERR_NET, "Unexpected EOF");
|
22
|
-
return p->error = -1;
|
23
|
-
} else {
|
24
|
-
return 0;
|
25
|
-
}
|
26
|
-
}
|
27
|
-
|
28
|
-
git_buf_put(buf, data, len);
|
29
|
-
ptr = buf->ptr;
|
30
|
-
while (1) {
|
31
|
-
git_pkt *pkt;
|
32
|
-
|
33
|
-
if (git_buf_len(buf) == 0)
|
34
|
-
return 0;
|
35
|
-
|
36
|
-
error = git_pkt_parse_line(&pkt, ptr, &line_end, git_buf_len(buf));
|
37
|
-
if (error == GIT_EBUFS)
|
38
|
-
return 0; /* Ask for more */
|
39
|
-
if (error < 0)
|
40
|
-
return p->error = -1;
|
41
|
-
|
42
|
-
git_buf_consume(buf, line_end);
|
43
|
-
|
44
|
-
if (pkt->type == GIT_PKT_ERR) {
|
45
|
-
giterr_set(GITERR_NET, "Remote error: %s", ((git_pkt_err *)pkt)->error);
|
46
|
-
git__free(pkt);
|
47
|
-
return -1;
|
48
|
-
}
|
49
|
-
|
50
|
-
if (git_vector_insert(refs, pkt) < 0)
|
51
|
-
return p->error = -1;
|
52
|
-
|
53
|
-
if (pkt->type == GIT_PKT_FLUSH)
|
54
|
-
p->flush = 1;
|
55
|
-
}
|
56
|
-
|
57
|
-
return 0;
|
58
|
-
}
|
@@ -1,340 +0,0 @@
|
|
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 "reflog.h"
|
9
|
-
#include "repository.h"
|
10
|
-
#include "filebuf.h"
|
11
|
-
#include "signature.h"
|
12
|
-
|
13
|
-
static int reflog_init(git_reflog **reflog, git_reference *ref)
|
14
|
-
{
|
15
|
-
git_reflog *log;
|
16
|
-
|
17
|
-
*reflog = NULL;
|
18
|
-
|
19
|
-
log = git__calloc(1, sizeof(git_reflog));
|
20
|
-
GITERR_CHECK_ALLOC(log);
|
21
|
-
|
22
|
-
log->ref_name = git__strdup(ref->name);
|
23
|
-
GITERR_CHECK_ALLOC(log->ref_name);
|
24
|
-
|
25
|
-
if (git_vector_init(&log->entries, 0, NULL) < 0) {
|
26
|
-
git__free(log->ref_name);
|
27
|
-
git__free(log);
|
28
|
-
return -1;
|
29
|
-
}
|
30
|
-
|
31
|
-
*reflog = log;
|
32
|
-
|
33
|
-
return 0;
|
34
|
-
}
|
35
|
-
|
36
|
-
static int reflog_write(const char *log_path, const char *oid_old,
|
37
|
-
const char *oid_new, const git_signature *committer,
|
38
|
-
const char *msg)
|
39
|
-
{
|
40
|
-
int error;
|
41
|
-
git_buf log = GIT_BUF_INIT;
|
42
|
-
git_filebuf fbuf = GIT_FILEBUF_INIT;
|
43
|
-
bool trailing_newline = false;
|
44
|
-
|
45
|
-
assert(log_path && oid_old && oid_new && committer);
|
46
|
-
|
47
|
-
if (msg) {
|
48
|
-
const char *newline = strchr(msg, '\n');
|
49
|
-
if (newline) {
|
50
|
-
if (*(newline + 1) == '\0')
|
51
|
-
trailing_newline = true;
|
52
|
-
else {
|
53
|
-
giterr_set(GITERR_INVALID, "Reflog message cannot contain newline");
|
54
|
-
return -1;
|
55
|
-
}
|
56
|
-
}
|
57
|
-
}
|
58
|
-
|
59
|
-
git_buf_puts(&log, oid_old);
|
60
|
-
git_buf_putc(&log, ' ');
|
61
|
-
|
62
|
-
git_buf_puts(&log, oid_new);
|
63
|
-
|
64
|
-
git_signature__writebuf(&log, " ", committer);
|
65
|
-
git_buf_truncate(&log, log.size - 1); /* drop LF */
|
66
|
-
|
67
|
-
if (msg) {
|
68
|
-
git_buf_putc(&log, '\t');
|
69
|
-
git_buf_puts(&log, msg);
|
70
|
-
}
|
71
|
-
|
72
|
-
if (!trailing_newline)
|
73
|
-
git_buf_putc(&log, '\n');
|
74
|
-
|
75
|
-
if (git_buf_oom(&log)) {
|
76
|
-
git_buf_free(&log);
|
77
|
-
return -1;
|
78
|
-
}
|
79
|
-
|
80
|
-
error = git_filebuf_open(&fbuf, log_path, GIT_FILEBUF_APPEND);
|
81
|
-
if (!error) {
|
82
|
-
if ((error = git_filebuf_write(&fbuf, log.ptr, log.size)) < 0)
|
83
|
-
git_filebuf_cleanup(&fbuf);
|
84
|
-
else
|
85
|
-
error = git_filebuf_commit(&fbuf, GIT_REFLOG_FILE_MODE);
|
86
|
-
}
|
87
|
-
|
88
|
-
git_buf_free(&log);
|
89
|
-
|
90
|
-
return error;
|
91
|
-
}
|
92
|
-
|
93
|
-
static int reflog_parse(git_reflog *log, const char *buf, size_t buf_size)
|
94
|
-
{
|
95
|
-
const char *ptr;
|
96
|
-
git_reflog_entry *entry;
|
97
|
-
|
98
|
-
#define seek_forward(_increase) do { \
|
99
|
-
if (_increase >= buf_size) { \
|
100
|
-
giterr_set(GITERR_INVALID, "Ran out of data while parsing reflog"); \
|
101
|
-
goto fail; \
|
102
|
-
} \
|
103
|
-
buf += _increase; \
|
104
|
-
buf_size -= _increase; \
|
105
|
-
} while (0)
|
106
|
-
|
107
|
-
while (buf_size > GIT_REFLOG_SIZE_MIN) {
|
108
|
-
entry = git__malloc(sizeof(git_reflog_entry));
|
109
|
-
GITERR_CHECK_ALLOC(entry);
|
110
|
-
|
111
|
-
entry->committer = git__malloc(sizeof(git_signature));
|
112
|
-
GITERR_CHECK_ALLOC(entry->committer);
|
113
|
-
|
114
|
-
if (git_oid_fromstrn(&entry->oid_old, buf, GIT_OID_HEXSZ) < 0)
|
115
|
-
goto fail;
|
116
|
-
seek_forward(GIT_OID_HEXSZ + 1);
|
117
|
-
|
118
|
-
if (git_oid_fromstrn(&entry->oid_cur, buf, GIT_OID_HEXSZ) < 0)
|
119
|
-
goto fail;
|
120
|
-
seek_forward(GIT_OID_HEXSZ + 1);
|
121
|
-
|
122
|
-
ptr = buf;
|
123
|
-
|
124
|
-
/* Seek forward to the end of the signature. */
|
125
|
-
while (*buf && *buf != '\t' && *buf != '\n')
|
126
|
-
seek_forward(1);
|
127
|
-
|
128
|
-
if (git_signature__parse(entry->committer, &ptr, buf + 1, NULL, *buf) < 0)
|
129
|
-
goto fail;
|
130
|
-
|
131
|
-
if (*buf == '\t') {
|
132
|
-
/* We got a message. Read everything till we reach LF. */
|
133
|
-
seek_forward(1);
|
134
|
-
ptr = buf;
|
135
|
-
|
136
|
-
while (*buf && *buf != '\n')
|
137
|
-
seek_forward(1);
|
138
|
-
|
139
|
-
entry->msg = git__strndup(ptr, buf - ptr);
|
140
|
-
GITERR_CHECK_ALLOC(entry->msg);
|
141
|
-
} else
|
142
|
-
entry->msg = NULL;
|
143
|
-
|
144
|
-
while (*buf && *buf == '\n' && buf_size > 1)
|
145
|
-
seek_forward(1);
|
146
|
-
|
147
|
-
if (git_vector_insert(&log->entries, entry) < 0)
|
148
|
-
goto fail;
|
149
|
-
}
|
150
|
-
|
151
|
-
return 0;
|
152
|
-
|
153
|
-
#undef seek_forward
|
154
|
-
|
155
|
-
fail:
|
156
|
-
if (entry) {
|
157
|
-
git__free(entry->committer);
|
158
|
-
git__free(entry);
|
159
|
-
}
|
160
|
-
return -1;
|
161
|
-
}
|
162
|
-
|
163
|
-
void git_reflog_free(git_reflog *reflog)
|
164
|
-
{
|
165
|
-
unsigned int i;
|
166
|
-
git_reflog_entry *entry;
|
167
|
-
|
168
|
-
for (i=0; i < reflog->entries.length; i++) {
|
169
|
-
entry = git_vector_get(&reflog->entries, i);
|
170
|
-
|
171
|
-
git_signature_free(entry->committer);
|
172
|
-
|
173
|
-
git__free(entry->msg);
|
174
|
-
git__free(entry);
|
175
|
-
}
|
176
|
-
|
177
|
-
git_vector_free(&reflog->entries);
|
178
|
-
git__free(reflog->ref_name);
|
179
|
-
git__free(reflog);
|
180
|
-
}
|
181
|
-
|
182
|
-
int git_reflog_read(git_reflog **reflog, git_reference *ref)
|
183
|
-
{
|
184
|
-
int error;
|
185
|
-
git_buf log_path = GIT_BUF_INIT;
|
186
|
-
git_buf log_file = GIT_BUF_INIT;
|
187
|
-
git_reflog *log = NULL;
|
188
|
-
|
189
|
-
*reflog = NULL;
|
190
|
-
|
191
|
-
if (reflog_init(&log, ref) < 0)
|
192
|
-
return -1;
|
193
|
-
|
194
|
-
error = git_buf_join_n(&log_path, '/', 3,
|
195
|
-
ref->owner->path_repository, GIT_REFLOG_DIR, ref->name);
|
196
|
-
|
197
|
-
if (!error)
|
198
|
-
error = git_futils_readbuffer(&log_file, log_path.ptr);
|
199
|
-
|
200
|
-
if (!error)
|
201
|
-
error = reflog_parse(log, log_file.ptr, log_file.size);
|
202
|
-
|
203
|
-
if (!error)
|
204
|
-
*reflog = log;
|
205
|
-
else
|
206
|
-
git_reflog_free(log);
|
207
|
-
|
208
|
-
git_buf_free(&log_file);
|
209
|
-
git_buf_free(&log_path);
|
210
|
-
|
211
|
-
return error;
|
212
|
-
}
|
213
|
-
|
214
|
-
int git_reflog_write(git_reference *ref, const git_oid *oid_old,
|
215
|
-
const git_signature *committer, const char *msg)
|
216
|
-
{
|
217
|
-
int error;
|
218
|
-
char old[GIT_OID_HEXSZ+1];
|
219
|
-
char new[GIT_OID_HEXSZ+1];
|
220
|
-
git_buf log_path = GIT_BUF_INIT;
|
221
|
-
git_reference *r;
|
222
|
-
const git_oid *oid;
|
223
|
-
|
224
|
-
if ((error = git_reference_resolve(&r, ref)) < 0)
|
225
|
-
return error;
|
226
|
-
|
227
|
-
oid = git_reference_oid(r);
|
228
|
-
if (oid == NULL) {
|
229
|
-
giterr_set(GITERR_REFERENCE,
|
230
|
-
"Failed to write reflog. Cannot resolve reference `%s`", r->name);
|
231
|
-
git_reference_free(r);
|
232
|
-
return -1;
|
233
|
-
}
|
234
|
-
|
235
|
-
git_oid_tostr(new, GIT_OID_HEXSZ+1, oid);
|
236
|
-
|
237
|
-
git_reference_free(r);
|
238
|
-
|
239
|
-
error = git_buf_join_n(&log_path, '/', 3,
|
240
|
-
ref->owner->path_repository, GIT_REFLOG_DIR, ref->name);
|
241
|
-
if (error < 0)
|
242
|
-
goto cleanup;
|
243
|
-
|
244
|
-
if (git_path_exists(log_path.ptr) == false) {
|
245
|
-
error = git_futils_mkpath2file(log_path.ptr, GIT_REFLOG_DIR_MODE);
|
246
|
-
} else if (git_path_isfile(log_path.ptr) == false) {
|
247
|
-
giterr_set(GITERR_REFERENCE,
|
248
|
-
"Failed to write reflog. `%s` is directory", log_path.ptr);
|
249
|
-
error = -1;
|
250
|
-
} else if (oid_old == NULL) {
|
251
|
-
giterr_set(GITERR_REFERENCE,
|
252
|
-
"Failed to write reflog. Old OID cannot be NULL for existing reference");
|
253
|
-
error = -1;
|
254
|
-
}
|
255
|
-
if (error < 0)
|
256
|
-
goto cleanup;
|
257
|
-
|
258
|
-
if (oid_old)
|
259
|
-
git_oid_tostr(old, sizeof(old), oid_old);
|
260
|
-
else
|
261
|
-
p_snprintf(old, sizeof(old), "%0*d", GIT_OID_HEXSZ, 0);
|
262
|
-
|
263
|
-
error = reflog_write(log_path.ptr, old, new, committer, msg);
|
264
|
-
|
265
|
-
cleanup:
|
266
|
-
git_buf_free(&log_path);
|
267
|
-
return error;
|
268
|
-
}
|
269
|
-
|
270
|
-
int git_reflog_rename(git_reference *ref, const char *new_name)
|
271
|
-
{
|
272
|
-
int error;
|
273
|
-
git_buf old_path = GIT_BUF_INIT;
|
274
|
-
git_buf new_path = GIT_BUF_INIT;
|
275
|
-
|
276
|
-
if (!git_buf_join_n(&old_path, '/', 3, ref->owner->path_repository,
|
277
|
-
GIT_REFLOG_DIR, ref->name) &&
|
278
|
-
!git_buf_join_n(&new_path, '/', 3, ref->owner->path_repository,
|
279
|
-
GIT_REFLOG_DIR, new_name))
|
280
|
-
error = p_rename(git_buf_cstr(&old_path), git_buf_cstr(&new_path));
|
281
|
-
else
|
282
|
-
error = -1;
|
283
|
-
|
284
|
-
git_buf_free(&old_path);
|
285
|
-
git_buf_free(&new_path);
|
286
|
-
|
287
|
-
return error;
|
288
|
-
}
|
289
|
-
|
290
|
-
int git_reflog_delete(git_reference *ref)
|
291
|
-
{
|
292
|
-
int error;
|
293
|
-
git_buf path = GIT_BUF_INIT;
|
294
|
-
|
295
|
-
error = git_buf_join_n(
|
296
|
-
&path, '/', 3, ref->owner->path_repository, GIT_REFLOG_DIR, ref->name);
|
297
|
-
|
298
|
-
if (!error && git_path_exists(path.ptr))
|
299
|
-
error = p_unlink(path.ptr);
|
300
|
-
|
301
|
-
git_buf_free(&path);
|
302
|
-
|
303
|
-
return error;
|
304
|
-
}
|
305
|
-
|
306
|
-
unsigned int git_reflog_entrycount(git_reflog *reflog)
|
307
|
-
{
|
308
|
-
assert(reflog);
|
309
|
-
return reflog->entries.length;
|
310
|
-
}
|
311
|
-
|
312
|
-
const git_reflog_entry * git_reflog_entry_byindex(git_reflog *reflog, unsigned int idx)
|
313
|
-
{
|
314
|
-
assert(reflog);
|
315
|
-
return git_vector_get(&reflog->entries, idx);
|
316
|
-
}
|
317
|
-
|
318
|
-
const git_oid * git_reflog_entry_oidold(const git_reflog_entry *entry)
|
319
|
-
{
|
320
|
-
assert(entry);
|
321
|
-
return &entry->oid_old;
|
322
|
-
}
|
323
|
-
|
324
|
-
const git_oid * git_reflog_entry_oidnew(const git_reflog_entry *entry)
|
325
|
-
{
|
326
|
-
assert(entry);
|
327
|
-
return &entry->oid_cur;
|
328
|
-
}
|
329
|
-
|
330
|
-
git_signature * git_reflog_entry_committer(const git_reflog_entry *entry)
|
331
|
-
{
|
332
|
-
assert(entry);
|
333
|
-
return entry->committer;
|
334
|
-
}
|
335
|
-
|
336
|
-
char * git_reflog_entry_msg(const git_reflog_entry *entry)
|
337
|
-
{
|
338
|
-
assert(entry);
|
339
|
-
return entry->msg;
|
340
|
-
}
|
@@ -1,748 +0,0 @@
|
|
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 "common.h"
|
11
|
-
#include "buffer.h"
|
12
|
-
#include "tree.h"
|
13
|
-
|
14
|
-
#include "git2.h"
|
15
|
-
|
16
|
-
typedef enum {
|
17
|
-
REVPARSE_STATE_INIT,
|
18
|
-
REVPARSE_STATE_CARET,
|
19
|
-
REVPARSE_STATE_LINEAR,
|
20
|
-
REVPARSE_STATE_COLON,
|
21
|
-
REVPARSE_STATE_DONE,
|
22
|
-
} revparse_state;
|
23
|
-
|
24
|
-
static void set_invalid_syntax_err(const char *spec)
|
25
|
-
{
|
26
|
-
giterr_set(GITERR_INVALID, "Refspec '%s' is not valid.", spec);
|
27
|
-
}
|
28
|
-
|
29
|
-
static int revparse_lookup_fully_qualifed_ref(git_object **out, git_repository *repo, const char*spec)
|
30
|
-
{
|
31
|
-
git_oid resolved;
|
32
|
-
|
33
|
-
if (git_reference_name_to_oid(&resolved, repo, spec) < 0)
|
34
|
-
return GIT_ERROR;
|
35
|
-
|
36
|
-
return git_object_lookup(out, repo, &resolved, GIT_OBJ_ANY);
|
37
|
-
}
|
38
|
-
|
39
|
-
/* Returns non-zero if yes */
|
40
|
-
static int spec_looks_like_describe_output(const char *spec)
|
41
|
-
{
|
42
|
-
regex_t regex;
|
43
|
-
int regex_error, retcode;
|
44
|
-
|
45
|
-
regex_error = regcomp(®ex, ".+-[0-9]+-g[0-9a-fA-F]+", REG_EXTENDED);
|
46
|
-
if (regex_error != 0) {
|
47
|
-
giterr_set_regex(®ex, regex_error);
|
48
|
-
return 1; /* To be safe */
|
49
|
-
}
|
50
|
-
retcode = regexec(®ex, spec, 0, NULL, 0);
|
51
|
-
regfree(®ex);
|
52
|
-
return retcode == 0;
|
53
|
-
}
|
54
|
-
|
55
|
-
static int revparse_lookup_object(git_object **out, git_repository *repo, const char *spec)
|
56
|
-
{
|
57
|
-
size_t speclen = strlen(spec);
|
58
|
-
git_object *obj = NULL;
|
59
|
-
git_oid oid;
|
60
|
-
git_buf refnamebuf = GIT_BUF_INIT;
|
61
|
-
static const char* formatters[] = {
|
62
|
-
"refs/%s",
|
63
|
-
"refs/tags/%s",
|
64
|
-
"refs/heads/%s",
|
65
|
-
"refs/remotes/%s",
|
66
|
-
"refs/remotes/%s/HEAD",
|
67
|
-
NULL
|
68
|
-
};
|
69
|
-
unsigned int i;
|
70
|
-
const char *substr;
|
71
|
-
|
72
|
-
/* "git describe" output; snip everything before/including "-g" */
|
73
|
-
substr = strstr(spec, "-g");
|
74
|
-
if (substr &&
|
75
|
-
spec_looks_like_describe_output(spec) &&
|
76
|
-
!revparse_lookup_object(out, repo, substr+2)) {
|
77
|
-
return 0;
|
78
|
-
}
|
79
|
-
|
80
|
-
/* SHA or prefix */
|
81
|
-
if (!git_oid_fromstrn(&oid, spec, speclen)) {
|
82
|
-
if (!git_object_lookup_prefix(&obj, repo, &oid, speclen, GIT_OBJ_ANY)) {
|
83
|
-
*out = obj;
|
84
|
-
return 0;
|
85
|
-
}
|
86
|
-
}
|
87
|
-
|
88
|
-
/* Fully-named ref */
|
89
|
-
if (!revparse_lookup_fully_qualifed_ref(&obj, repo, spec)) {
|
90
|
-
*out = obj;
|
91
|
-
return 0;
|
92
|
-
}
|
93
|
-
|
94
|
-
/* Partially-named ref; match in this order: */
|
95
|
-
for (i=0; formatters[i]; i++) {
|
96
|
-
git_buf_clear(&refnamebuf);
|
97
|
-
if (git_buf_printf(&refnamebuf, formatters[i], spec) < 0) {
|
98
|
-
return GIT_ERROR;
|
99
|
-
}
|
100
|
-
|
101
|
-
if (!revparse_lookup_fully_qualifed_ref(&obj, repo, git_buf_cstr(&refnamebuf))) {
|
102
|
-
git_buf_free(&refnamebuf);
|
103
|
-
*out = obj;
|
104
|
-
return 0;
|
105
|
-
}
|
106
|
-
}
|
107
|
-
git_buf_free(&refnamebuf);
|
108
|
-
|
109
|
-
giterr_set(GITERR_REFERENCE, "Refspec '%s' not found.", spec);
|
110
|
-
return GIT_ERROR;
|
111
|
-
}
|
112
|
-
|
113
|
-
|
114
|
-
static int all_chars_are_digits(const char *str, size_t len)
|
115
|
-
{
|
116
|
-
size_t i=0;
|
117
|
-
for (i=0; i<len; i++) {
|
118
|
-
if (str[i] < '0' || str[i] > '9') return 0;
|
119
|
-
}
|
120
|
-
return 1;
|
121
|
-
}
|
122
|
-
|
123
|
-
static void normalize_maybe_empty_refname(git_buf *buf, git_repository *repo, const char *refspec, size_t refspeclen)
|
124
|
-
{
|
125
|
-
git_reference *ref;
|
126
|
-
|
127
|
-
if (!refspeclen) {
|
128
|
-
/* Empty refspec means current branch (target of HEAD) */
|
129
|
-
git_reference_lookup(&ref, repo, "HEAD");
|
130
|
-
git_buf_puts(buf, git_reference_target(ref));
|
131
|
-
git_reference_free(ref);
|
132
|
-
} else if (strstr(refspec, "HEAD")) {
|
133
|
-
/* Explicit head */
|
134
|
-
git_buf_puts(buf, refspec);
|
135
|
-
}else {
|
136
|
-
if (git__prefixcmp(refspec, "refs/heads/") != 0) {
|
137
|
-
git_buf_printf(buf, "refs/heads/%s", refspec);
|
138
|
-
} else {
|
139
|
-
git_buf_puts(buf, refspec);
|
140
|
-
}
|
141
|
-
}
|
142
|
-
}
|
143
|
-
|
144
|
-
static int walk_ref_history(git_object **out, git_repository *repo, const char *refspec, const char *reflogspec)
|
145
|
-
{
|
146
|
-
git_reference *ref;
|
147
|
-
git_reflog *reflog = NULL;
|
148
|
-
int n, retcode = GIT_ERROR;
|
149
|
-
int i, refloglen;
|
150
|
-
const git_reflog_entry *entry;
|
151
|
-
git_buf buf = GIT_BUF_INIT;
|
152
|
-
size_t refspeclen = strlen(refspec);
|
153
|
-
size_t reflogspeclen = strlen(reflogspec);
|
154
|
-
|
155
|
-
if (git__prefixcmp(reflogspec, "@{") != 0 ||
|
156
|
-
git__suffixcmp(reflogspec, "}") != 0) {
|
157
|
-
giterr_set(GITERR_INVALID, "Bad reflogspec '%s'", reflogspec);
|
158
|
-
return GIT_ERROR;
|
159
|
-
}
|
160
|
-
|
161
|
-
/* "@{-N}" form means walk back N checkouts. That means the HEAD log. */
|
162
|
-
if (refspeclen == 0 && !git__prefixcmp(reflogspec, "@{-")) {
|
163
|
-
regex_t regex;
|
164
|
-
int regex_error;
|
165
|
-
|
166
|
-
if (git__strtol32(&n, reflogspec+3, NULL, 0) < 0 ||
|
167
|
-
n < 1) {
|
168
|
-
giterr_set(GITERR_INVALID, "Invalid reflogspec %s", reflogspec);
|
169
|
-
return GIT_ERROR;
|
170
|
-
}
|
171
|
-
|
172
|
-
if (!git_reference_lookup(&ref, repo, "HEAD")) {
|
173
|
-
if (!git_reflog_read(&reflog, ref)) {
|
174
|
-
regex_error = regcomp(®ex, "checkout: moving from (.*) to .*", REG_EXTENDED);
|
175
|
-
if (regex_error != 0) {
|
176
|
-
giterr_set_regex(®ex, regex_error);
|
177
|
-
} else {
|
178
|
-
regmatch_t regexmatches[2];
|
179
|
-
|
180
|
-
refloglen = git_reflog_entrycount(reflog);
|
181
|
-
for (i=refloglen-1; i >= 0; i--) {
|
182
|
-
const char *msg;
|
183
|
-
entry = git_reflog_entry_byindex(reflog, i);
|
184
|
-
|
185
|
-
msg = git_reflog_entry_msg(entry);
|
186
|
-
if (!regexec(®ex, msg, 2, regexmatches, 0)) {
|
187
|
-
n--;
|
188
|
-
if (!n) {
|
189
|
-
git_buf_put(&buf, msg+regexmatches[1].rm_so, regexmatches[1].rm_eo - regexmatches[1].rm_so);
|
190
|
-
retcode = revparse_lookup_object(out, repo, git_buf_cstr(&buf));
|
191
|
-
break;
|
192
|
-
}
|
193
|
-
}
|
194
|
-
}
|
195
|
-
regfree(®ex);
|
196
|
-
}
|
197
|
-
}
|
198
|
-
git_reference_free(ref);
|
199
|
-
}
|
200
|
-
} else {
|
201
|
-
int date_error = 0;
|
202
|
-
git_time_t timestamp;
|
203
|
-
git_buf datebuf = GIT_BUF_INIT;
|
204
|
-
|
205
|
-
git_buf_put(&datebuf, reflogspec+2, reflogspeclen-3);
|
206
|
-
date_error = git__date_parse(×tamp, git_buf_cstr(&datebuf));
|
207
|
-
|
208
|
-
/* @{u} or @{upstream} -> upstream branch, for a tracking branch. This is stored in the config. */
|
209
|
-
if (!strcmp(reflogspec, "@{u}") || !strcmp(reflogspec, "@{upstream}")) {
|
210
|
-
git_config *cfg;
|
211
|
-
if (!git_repository_config(&cfg, repo)) {
|
212
|
-
/* Is the ref a tracking branch? */
|
213
|
-
const char *remote;
|
214
|
-
git_buf_clear(&buf);
|
215
|
-
git_buf_printf(&buf, "branch.%s.remote", refspec);
|
216
|
-
if (!git_config_get_string(&remote, cfg, git_buf_cstr(&buf))) {
|
217
|
-
/* Yes. Find the first merge target name. */
|
218
|
-
const char *mergetarget;
|
219
|
-
git_buf_clear(&buf);
|
220
|
-
git_buf_printf(&buf, "branch.%s.merge", refspec);
|
221
|
-
if (!git_config_get_string(&mergetarget, cfg, git_buf_cstr(&buf)) &&
|
222
|
-
!git__prefixcmp(mergetarget, "refs/heads/")) {
|
223
|
-
/* Success. Look up the target and fetch the object. */
|
224
|
-
git_buf_clear(&buf);
|
225
|
-
git_buf_printf(&buf, "refs/remotes/%s/%s", remote, mergetarget+11);
|
226
|
-
retcode = revparse_lookup_fully_qualifed_ref(out, repo, git_buf_cstr(&buf));
|
227
|
-
}
|
228
|
-
}
|
229
|
-
git_config_free(cfg);
|
230
|
-
}
|
231
|
-
}
|
232
|
-
|
233
|
-
/* @{N} -> Nth prior value for the ref (from reflog) */
|
234
|
-
else if (all_chars_are_digits(reflogspec+2, reflogspeclen-3) &&
|
235
|
-
!git__strtol32(&n, reflogspec+2, NULL, 0) &&
|
236
|
-
n <= 100000000) { /* Allow integer time */
|
237
|
-
normalize_maybe_empty_refname(&buf, repo, refspec, refspeclen);
|
238
|
-
|
239
|
-
if (n == 0) {
|
240
|
-
retcode = revparse_lookup_fully_qualifed_ref(out, repo, git_buf_cstr(&buf));
|
241
|
-
} else if (!git_reference_lookup(&ref, repo, git_buf_cstr(&buf))) {
|
242
|
-
if (!git_reflog_read(&reflog, ref)) {
|
243
|
-
int numentries = git_reflog_entrycount(reflog);
|
244
|
-
if (numentries < n) {
|
245
|
-
giterr_set(GITERR_REFERENCE, "Reflog for '%s' has only %d entries, asked for %d",
|
246
|
-
git_buf_cstr(&buf), numentries, n);
|
247
|
-
retcode = GIT_ERROR;
|
248
|
-
} else {
|
249
|
-
const git_reflog_entry *entry = git_reflog_entry_byindex(reflog, n);
|
250
|
-
const git_oid *oid = git_reflog_entry_oidold(entry);
|
251
|
-
retcode = git_object_lookup(out, repo, oid, GIT_OBJ_ANY);
|
252
|
-
}
|
253
|
-
}
|
254
|
-
git_reference_free(ref);
|
255
|
-
}
|
256
|
-
}
|
257
|
-
|
258
|
-
else if (!date_error) {
|
259
|
-
/* Ref as it was on a certain date */
|
260
|
-
normalize_maybe_empty_refname(&buf, repo, refspec, refspeclen);
|
261
|
-
|
262
|
-
if (!git_reference_lookup(&ref, repo, git_buf_cstr(&buf))) {
|
263
|
-
git_reflog *reflog;
|
264
|
-
if (!git_reflog_read(&reflog, ref)) {
|
265
|
-
/* Keep walking until we find an entry older than the given date */
|
266
|
-
int numentries = git_reflog_entrycount(reflog);
|
267
|
-
int i;
|
268
|
-
|
269
|
-
/* TODO: clunky. Factor "now" into a utility */
|
270
|
-
git_signature *sig;
|
271
|
-
git_time as_of;
|
272
|
-
|
273
|
-
git_signature_now(&sig, "blah", "blah");
|
274
|
-
as_of = sig->when;
|
275
|
-
git_signature_free(sig);
|
276
|
-
|
277
|
-
as_of.time = (timestamp > 0)
|
278
|
-
? timestamp
|
279
|
-
: sig->when.time + timestamp;
|
280
|
-
|
281
|
-
for (i=numentries-1; i>0; i--) {
|
282
|
-
const git_reflog_entry *entry = git_reflog_entry_byindex(reflog, i);
|
283
|
-
git_time commit_time = git_reflog_entry_committer(entry)->when;
|
284
|
-
if (git__time_cmp(&commit_time, &as_of) <= 0 ) {
|
285
|
-
retcode = git_object_lookup(out, repo, git_reflog_entry_oidnew(entry), GIT_OBJ_ANY);
|
286
|
-
break;
|
287
|
-
}
|
288
|
-
}
|
289
|
-
|
290
|
-
if (!i) {
|
291
|
-
/* Didn't find a match. Use the oldest revision in the reflog. */
|
292
|
-
const git_reflog_entry *entry = git_reflog_entry_byindex(reflog, 0);
|
293
|
-
retcode = git_object_lookup(out, repo, git_reflog_entry_oidnew(entry), GIT_OBJ_ANY);
|
294
|
-
}
|
295
|
-
|
296
|
-
git_reflog_free(reflog);
|
297
|
-
}
|
298
|
-
|
299
|
-
git_reference_free(ref);
|
300
|
-
}
|
301
|
-
}
|
302
|
-
|
303
|
-
git_buf_free(&datebuf);
|
304
|
-
}
|
305
|
-
|
306
|
-
if (reflog) git_reflog_free(reflog);
|
307
|
-
git_buf_free(&buf);
|
308
|
-
return retcode;
|
309
|
-
}
|
310
|
-
|
311
|
-
static git_object* dereference_object(git_object *obj)
|
312
|
-
{
|
313
|
-
git_otype type = git_object_type(obj);
|
314
|
-
|
315
|
-
switch (type) {
|
316
|
-
case GIT_OBJ_COMMIT:
|
317
|
-
{
|
318
|
-
git_tree *tree = NULL;
|
319
|
-
if (0 == git_commit_tree(&tree, (git_commit*)obj)) {
|
320
|
-
return (git_object*)tree;
|
321
|
-
}
|
322
|
-
}
|
323
|
-
break;
|
324
|
-
case GIT_OBJ_TAG:
|
325
|
-
{
|
326
|
-
git_object *newobj = NULL;
|
327
|
-
if (0 == git_tag_target(&newobj, (git_tag*)obj)) {
|
328
|
-
return newobj;
|
329
|
-
}
|
330
|
-
}
|
331
|
-
break;
|
332
|
-
|
333
|
-
default:
|
334
|
-
case GIT_OBJ_TREE:
|
335
|
-
case GIT_OBJ_BLOB:
|
336
|
-
case GIT_OBJ_OFS_DELTA:
|
337
|
-
case GIT_OBJ_REF_DELTA:
|
338
|
-
break;
|
339
|
-
}
|
340
|
-
|
341
|
-
/* Can't dereference some types */
|
342
|
-
return NULL;
|
343
|
-
}
|
344
|
-
|
345
|
-
static int dereference_to_type(git_object **out, git_object *obj, git_otype target_type)
|
346
|
-
{
|
347
|
-
int retcode = 1;
|
348
|
-
git_object *obj1 = obj, *obj2 = obj;
|
349
|
-
|
350
|
-
while (retcode > 0) {
|
351
|
-
git_otype this_type = git_object_type(obj1);
|
352
|
-
|
353
|
-
if (this_type == target_type) {
|
354
|
-
*out = obj1;
|
355
|
-
retcode = 0;
|
356
|
-
} else {
|
357
|
-
/* Dereference once, if possible. */
|
358
|
-
obj2 = dereference_object(obj1);
|
359
|
-
if (!obj2) {
|
360
|
-
giterr_set(GITERR_REFERENCE, "Can't dereference to type");
|
361
|
-
retcode = GIT_ERROR;
|
362
|
-
}
|
363
|
-
}
|
364
|
-
if (obj1 != obj && obj1 != obj2) {
|
365
|
-
git_object_free(obj1);
|
366
|
-
}
|
367
|
-
obj1 = obj2;
|
368
|
-
}
|
369
|
-
return retcode;
|
370
|
-
}
|
371
|
-
|
372
|
-
static git_otype parse_obj_type(const char *str)
|
373
|
-
{
|
374
|
-
if (!strcmp(str, "{commit}")) return GIT_OBJ_COMMIT;
|
375
|
-
if (!strcmp(str, "{tree}")) return GIT_OBJ_TREE;
|
376
|
-
if (!strcmp(str, "{blob}")) return GIT_OBJ_BLOB;
|
377
|
-
if (!strcmp(str, "{tag}")) return GIT_OBJ_TAG;
|
378
|
-
return GIT_OBJ_BAD;
|
379
|
-
}
|
380
|
-
|
381
|
-
static int handle_caret_syntax(git_object **out, git_repository *repo, git_object *obj, const char *movement)
|
382
|
-
{
|
383
|
-
git_commit *commit;
|
384
|
-
size_t movementlen = strlen(movement);
|
385
|
-
int n;
|
386
|
-
|
387
|
-
if (*movement == '{') {
|
388
|
-
if (movement[movementlen-1] != '}') {
|
389
|
-
set_invalid_syntax_err(movement);
|
390
|
-
return GIT_ERROR;
|
391
|
-
}
|
392
|
-
|
393
|
-
/* {} -> Dereference until we reach an object that isn't a tag. */
|
394
|
-
if (movementlen == 2) {
|
395
|
-
git_object *newobj = obj;
|
396
|
-
git_object *newobj2 = newobj;
|
397
|
-
while (git_object_type(newobj2) == GIT_OBJ_TAG) {
|
398
|
-
newobj2 = dereference_object(newobj);
|
399
|
-
if (newobj != obj) git_object_free(newobj);
|
400
|
-
if (!newobj2) {
|
401
|
-
giterr_set(GITERR_REFERENCE, "Couldn't find object of target type.");
|
402
|
-
return GIT_ERROR;
|
403
|
-
}
|
404
|
-
newobj = newobj2;
|
405
|
-
}
|
406
|
-
*out = newobj2;
|
407
|
-
return 0;
|
408
|
-
}
|
409
|
-
|
410
|
-
/* {/...} -> Walk all commits until we see a commit msg that matches the phrase. */
|
411
|
-
if (movement[1] == '/') {
|
412
|
-
int retcode = GIT_ERROR;
|
413
|
-
git_revwalk *walk;
|
414
|
-
if (!git_revwalk_new(&walk, repo)) {
|
415
|
-
git_oid oid;
|
416
|
-
regex_t preg;
|
417
|
-
int reg_error;
|
418
|
-
git_buf buf = GIT_BUF_INIT;
|
419
|
-
|
420
|
-
git_revwalk_sorting(walk, GIT_SORT_TIME);
|
421
|
-
git_revwalk_push(walk, git_object_id(obj));
|
422
|
-
|
423
|
-
/* Extract the regex from the movement string */
|
424
|
-
git_buf_put(&buf, movement+2, strlen(movement)-3);
|
425
|
-
|
426
|
-
reg_error = regcomp(&preg, git_buf_cstr(&buf), REG_EXTENDED);
|
427
|
-
if (reg_error != 0) {
|
428
|
-
giterr_set_regex(&preg, reg_error);
|
429
|
-
} else {
|
430
|
-
while(!git_revwalk_next(&oid, walk)) {
|
431
|
-
git_object *walkobj;
|
432
|
-
|
433
|
-
/* Fetch the commit object, and check for matches in the message */
|
434
|
-
if (!git_object_lookup(&walkobj, repo, &oid, GIT_OBJ_COMMIT)) {
|
435
|
-
if (!regexec(&preg, git_commit_message((git_commit*)walkobj), 0, NULL, 0)) {
|
436
|
-
/* Found it! */
|
437
|
-
retcode = 0;
|
438
|
-
*out = walkobj;
|
439
|
-
if (obj == walkobj) {
|
440
|
-
/* Avoid leaking an object */
|
441
|
-
git_object_free(walkobj);
|
442
|
-
}
|
443
|
-
break;
|
444
|
-
}
|
445
|
-
git_object_free(walkobj);
|
446
|
-
}
|
447
|
-
}
|
448
|
-
if (retcode < 0) {
|
449
|
-
giterr_set(GITERR_REFERENCE, "Couldn't find a match for %s", movement);
|
450
|
-
}
|
451
|
-
regfree(&preg);
|
452
|
-
}
|
453
|
-
|
454
|
-
git_buf_free(&buf);
|
455
|
-
git_revwalk_free(walk);
|
456
|
-
}
|
457
|
-
return retcode;
|
458
|
-
}
|
459
|
-
|
460
|
-
/* {...} -> Dereference until we reach an object of a certain type. */
|
461
|
-
if (dereference_to_type(out, obj, parse_obj_type(movement)) < 0) {
|
462
|
-
return GIT_ERROR;
|
463
|
-
}
|
464
|
-
return 0;
|
465
|
-
}
|
466
|
-
|
467
|
-
/* Dereference until we reach a commit. */
|
468
|
-
if (dereference_to_type(&obj, obj, GIT_OBJ_COMMIT) < 0) {
|
469
|
-
/* Can't dereference to a commit; fail */
|
470
|
-
return GIT_ERROR;
|
471
|
-
}
|
472
|
-
|
473
|
-
/* "^" is the same as "^1" */
|
474
|
-
if (movementlen == 0) {
|
475
|
-
n = 1;
|
476
|
-
} else {
|
477
|
-
git__strtol32(&n, movement, NULL, 0);
|
478
|
-
}
|
479
|
-
commit = (git_commit*)obj;
|
480
|
-
|
481
|
-
/* "^0" just returns the input */
|
482
|
-
if (n == 0) {
|
483
|
-
*out = obj;
|
484
|
-
return 0;
|
485
|
-
}
|
486
|
-
|
487
|
-
if (git_commit_parent(&commit, commit, n-1) < 0) {
|
488
|
-
return GIT_ERROR;
|
489
|
-
}
|
490
|
-
|
491
|
-
*out = (git_object*)commit;
|
492
|
-
return 0;
|
493
|
-
}
|
494
|
-
|
495
|
-
static int handle_linear_syntax(git_object **out, git_object *obj, const char *movement)
|
496
|
-
{
|
497
|
-
git_commit *commit1, *commit2;
|
498
|
-
int i, n;
|
499
|
-
|
500
|
-
/* Dereference until we reach a commit. */
|
501
|
-
if (dereference_to_type(&obj, obj, GIT_OBJ_COMMIT) < 0) {
|
502
|
-
/* Can't dereference to a commit; fail */
|
503
|
-
return GIT_ERROR;
|
504
|
-
}
|
505
|
-
|
506
|
-
/* "~" is the same as "~1" */
|
507
|
-
if (*movement == '\0') {
|
508
|
-
n = 1;
|
509
|
-
} else {
|
510
|
-
git__strtol32(&n, movement, NULL, 0);
|
511
|
-
}
|
512
|
-
commit1 = (git_commit*)obj;
|
513
|
-
|
514
|
-
/* "~0" just returns the input */
|
515
|
-
if (n == 0) {
|
516
|
-
*out = obj;
|
517
|
-
return 0;
|
518
|
-
}
|
519
|
-
|
520
|
-
for (i=0; i<n; i++) {
|
521
|
-
if (git_commit_parent(&commit2, commit1, 0) < 0) {
|
522
|
-
return GIT_ERROR;
|
523
|
-
}
|
524
|
-
if (commit1 != (git_commit*)obj) {
|
525
|
-
git_commit_free(commit1);
|
526
|
-
}
|
527
|
-
commit1 = commit2;
|
528
|
-
}
|
529
|
-
|
530
|
-
*out = (git_object*)commit1;
|
531
|
-
return 0;
|
532
|
-
}
|
533
|
-
|
534
|
-
static int oid_for_tree_path(git_oid *out, git_tree *tree, git_repository *repo, const char *path)
|
535
|
-
{
|
536
|
-
char *str = git__strdup(path);
|
537
|
-
char *tok;
|
538
|
-
void *alloc = str;
|
539
|
-
git_tree *tree2 = tree;
|
540
|
-
const git_tree_entry *entry;
|
541
|
-
|
542
|
-
while ((tok = git__strtok(&str, "/\\")) != NULL) {
|
543
|
-
entry = git_tree_entry_byname(tree2, tok);
|
544
|
-
if (tree2 != tree) git_tree_free(tree2);
|
545
|
-
if (git_tree_entry__is_tree(entry)) {
|
546
|
-
if (git_tree_lookup(&tree2, repo, &entry->oid) < 0) {
|
547
|
-
git__free(alloc);
|
548
|
-
return GIT_ERROR;
|
549
|
-
}
|
550
|
-
}
|
551
|
-
}
|
552
|
-
|
553
|
-
git_oid_cpy(out, git_tree_entry_id(entry));
|
554
|
-
git__free(alloc);
|
555
|
-
return 0;
|
556
|
-
}
|
557
|
-
|
558
|
-
static int handle_colon_syntax(git_object **out,
|
559
|
-
git_repository *repo,
|
560
|
-
git_object *obj,
|
561
|
-
const char *path)
|
562
|
-
{
|
563
|
-
git_tree *tree;
|
564
|
-
git_oid oid;
|
565
|
-
|
566
|
-
/* Dereference until we reach a tree. */
|
567
|
-
if (dereference_to_type(&obj, obj, GIT_OBJ_TREE) < 0) {
|
568
|
-
return GIT_ERROR;
|
569
|
-
}
|
570
|
-
tree = (git_tree*)obj;
|
571
|
-
|
572
|
-
/* Find the blob at the given path. */
|
573
|
-
oid_for_tree_path(&oid, tree, repo, path);
|
574
|
-
git_tree_free(tree);
|
575
|
-
return git_object_lookup(out, repo, &oid, GIT_OBJ_ANY);
|
576
|
-
}
|
577
|
-
|
578
|
-
static int revparse_global_grep(git_object **out, git_repository *repo, const char *pattern)
|
579
|
-
{
|
580
|
-
git_revwalk *walk;
|
581
|
-
int retcode = GIT_ERROR;
|
582
|
-
|
583
|
-
if (!pattern[0]) {
|
584
|
-
giterr_set(GITERR_REGEX, "Empty pattern");
|
585
|
-
return GIT_ERROR;
|
586
|
-
}
|
587
|
-
|
588
|
-
if (!git_revwalk_new(&walk, repo)) {
|
589
|
-
regex_t preg;
|
590
|
-
int reg_error;
|
591
|
-
git_oid oid;
|
592
|
-
|
593
|
-
git_revwalk_sorting(walk, GIT_SORT_TIME);
|
594
|
-
git_revwalk_push_glob(walk, "refs/heads/*");
|
595
|
-
|
596
|
-
reg_error = regcomp(&preg, pattern, REG_EXTENDED);
|
597
|
-
if (reg_error != 0) {
|
598
|
-
giterr_set_regex(&preg, reg_error);
|
599
|
-
} else {
|
600
|
-
git_object *walkobj = NULL, *resultobj = NULL;
|
601
|
-
while(!git_revwalk_next(&oid, walk)) {
|
602
|
-
/* Fetch the commit object, and check for matches in the message */
|
603
|
-
if (walkobj != resultobj) git_object_free(walkobj);
|
604
|
-
if (!git_object_lookup(&walkobj, repo, &oid, GIT_OBJ_COMMIT)) {
|
605
|
-
if (!regexec(&preg, git_commit_message((git_commit*)walkobj), 0, NULL, 0)) {
|
606
|
-
/* Match! */
|
607
|
-
resultobj = walkobj;
|
608
|
-
retcode = 0;
|
609
|
-
break;
|
610
|
-
}
|
611
|
-
}
|
612
|
-
}
|
613
|
-
if (!resultobj) {
|
614
|
-
giterr_set(GITERR_REFERENCE, "Couldn't find a match for %s", pattern);
|
615
|
-
} else {
|
616
|
-
*out = resultobj;
|
617
|
-
}
|
618
|
-
regfree(&preg);
|
619
|
-
git_revwalk_free(walk);
|
620
|
-
}
|
621
|
-
}
|
622
|
-
|
623
|
-
return retcode;
|
624
|
-
}
|
625
|
-
|
626
|
-
int git_revparse_single(git_object **out, git_repository *repo, const char *spec)
|
627
|
-
{
|
628
|
-
revparse_state current_state = REVPARSE_STATE_INIT, next_state = REVPARSE_STATE_INIT;
|
629
|
-
const char *spec_cur = spec;
|
630
|
-
git_object *cur_obj = NULL, *next_obj = NULL;
|
631
|
-
git_buf specbuffer = GIT_BUF_INIT, stepbuffer = GIT_BUF_INIT;
|
632
|
-
int retcode = 0;
|
633
|
-
|
634
|
-
assert(out && repo && spec);
|
635
|
-
|
636
|
-
if (spec[0] == ':') {
|
637
|
-
if (spec[1] == '/') {
|
638
|
-
return revparse_global_grep(out, repo, spec+2);
|
639
|
-
}
|
640
|
-
/* TODO: support merge-stage path lookup (":2:Makefile"). */
|
641
|
-
giterr_set(GITERR_INVALID, "Unimplemented");
|
642
|
-
return GIT_ERROR;
|
643
|
-
}
|
644
|
-
|
645
|
-
while (current_state != REVPARSE_STATE_DONE) {
|
646
|
-
switch (current_state) {
|
647
|
-
case REVPARSE_STATE_INIT:
|
648
|
-
if (!*spec_cur) {
|
649
|
-
/* No operators, just a name. Find it and return. */
|
650
|
-
retcode = revparse_lookup_object(out, repo, spec);
|
651
|
-
next_state = REVPARSE_STATE_DONE;
|
652
|
-
} else if (*spec_cur == '@') {
|
653
|
-
/* '@' syntax doesn't allow chaining */
|
654
|
-
git_buf_puts(&stepbuffer, spec_cur);
|
655
|
-
retcode = walk_ref_history(out, repo, git_buf_cstr(&specbuffer), git_buf_cstr(&stepbuffer));
|
656
|
-
next_state = REVPARSE_STATE_DONE;
|
657
|
-
} else if (*spec_cur == '^') {
|
658
|
-
next_state = REVPARSE_STATE_CARET;
|
659
|
-
} else if (*spec_cur == '~') {
|
660
|
-
next_state = REVPARSE_STATE_LINEAR;
|
661
|
-
} else if (*spec_cur == ':') {
|
662
|
-
next_state = REVPARSE_STATE_COLON;
|
663
|
-
} else {
|
664
|
-
git_buf_putc(&specbuffer, *spec_cur);
|
665
|
-
}
|
666
|
-
spec_cur++;
|
667
|
-
|
668
|
-
if (current_state != next_state && next_state != REVPARSE_STATE_DONE) {
|
669
|
-
/* Leaving INIT state, find the object specified, in case that state needs it */
|
670
|
-
if (revparse_lookup_object(&next_obj, repo, git_buf_cstr(&specbuffer)) < 0) {
|
671
|
-
retcode = GIT_ERROR;
|
672
|
-
next_state = REVPARSE_STATE_DONE;
|
673
|
-
}
|
674
|
-
}
|
675
|
-
break;
|
676
|
-
|
677
|
-
|
678
|
-
case REVPARSE_STATE_CARET:
|
679
|
-
/* Gather characters until NULL, '~', or '^' */
|
680
|
-
if (!*spec_cur) {
|
681
|
-
retcode = handle_caret_syntax(out, repo, cur_obj, git_buf_cstr(&stepbuffer));
|
682
|
-
next_state = REVPARSE_STATE_DONE;
|
683
|
-
} else if (*spec_cur == '~') {
|
684
|
-
retcode = handle_caret_syntax(&next_obj, repo, cur_obj, git_buf_cstr(&stepbuffer));
|
685
|
-
git_buf_clear(&stepbuffer);
|
686
|
-
next_state = !retcode ? REVPARSE_STATE_LINEAR : REVPARSE_STATE_DONE;
|
687
|
-
} else if (*spec_cur == '^') {
|
688
|
-
retcode = handle_caret_syntax(&next_obj, repo, cur_obj, git_buf_cstr(&stepbuffer));
|
689
|
-
git_buf_clear(&stepbuffer);
|
690
|
-
if (retcode < 0) {
|
691
|
-
next_state = REVPARSE_STATE_DONE;
|
692
|
-
}
|
693
|
-
} else {
|
694
|
-
git_buf_putc(&stepbuffer, *spec_cur);
|
695
|
-
}
|
696
|
-
spec_cur++;
|
697
|
-
break;
|
698
|
-
|
699
|
-
case REVPARSE_STATE_LINEAR:
|
700
|
-
if (!*spec_cur) {
|
701
|
-
retcode = handle_linear_syntax(out, cur_obj, git_buf_cstr(&stepbuffer));
|
702
|
-
next_state = REVPARSE_STATE_DONE;
|
703
|
-
} else if (*spec_cur == '~') {
|
704
|
-
retcode = handle_linear_syntax(&next_obj, cur_obj, git_buf_cstr(&stepbuffer));
|
705
|
-
git_buf_clear(&stepbuffer);
|
706
|
-
if (retcode < 0) {
|
707
|
-
next_state = REVPARSE_STATE_DONE;
|
708
|
-
}
|
709
|
-
} else if (*spec_cur == '^') {
|
710
|
-
retcode = handle_linear_syntax(&next_obj, cur_obj, git_buf_cstr(&stepbuffer));
|
711
|
-
git_buf_clear(&stepbuffer);
|
712
|
-
next_state = !retcode ? REVPARSE_STATE_CARET : REVPARSE_STATE_DONE;
|
713
|
-
} else {
|
714
|
-
git_buf_putc(&stepbuffer, *spec_cur);
|
715
|
-
}
|
716
|
-
spec_cur++;
|
717
|
-
break;
|
718
|
-
|
719
|
-
case REVPARSE_STATE_COLON:
|
720
|
-
if (*spec_cur) {
|
721
|
-
git_buf_putc(&stepbuffer, *spec_cur);
|
722
|
-
} else {
|
723
|
-
retcode = handle_colon_syntax(out, repo, cur_obj, git_buf_cstr(&stepbuffer));
|
724
|
-
next_state = REVPARSE_STATE_DONE;
|
725
|
-
}
|
726
|
-
spec_cur++;
|
727
|
-
break;
|
728
|
-
|
729
|
-
case REVPARSE_STATE_DONE:
|
730
|
-
if (cur_obj && *out != cur_obj) git_object_free(cur_obj);
|
731
|
-
if (next_obj && *out != next_obj) git_object_free(next_obj);
|
732
|
-
break;
|
733
|
-
}
|
734
|
-
|
735
|
-
current_state = next_state;
|
736
|
-
if (cur_obj != next_obj) {
|
737
|
-
if (cur_obj) git_object_free(cur_obj);
|
738
|
-
cur_obj = next_obj;
|
739
|
-
}
|
740
|
-
}
|
741
|
-
|
742
|
-
if (*out != cur_obj) git_object_free(cur_obj);
|
743
|
-
if (*out != next_obj && next_obj != cur_obj) git_object_free(next_obj);
|
744
|
-
|
745
|
-
git_buf_free(&specbuffer);
|
746
|
-
git_buf_free(&stepbuffer);
|
747
|
-
return retcode;
|
748
|
-
}
|