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
Binary file
|
@@ -1,238 +0,0 @@
|
|
1
|
-
#include <stdio.h>
|
2
|
-
#include <git2.h>
|
3
|
-
#include <stdlib.h>
|
4
|
-
#include <string.h>
|
5
|
-
|
6
|
-
void check(int error, const char *message)
|
7
|
-
{
|
8
|
-
if (error) {
|
9
|
-
fprintf(stderr, "%s (%d)\n", message, error);
|
10
|
-
exit(1);
|
11
|
-
}
|
12
|
-
}
|
13
|
-
|
14
|
-
int resolve_to_tree(git_repository *repo, const char *identifier, git_tree **tree)
|
15
|
-
{
|
16
|
-
int err = 0;
|
17
|
-
size_t len = strlen(identifier);
|
18
|
-
git_oid oid;
|
19
|
-
git_object *obj = NULL;
|
20
|
-
|
21
|
-
/* try to resolve as OID */
|
22
|
-
if (git_oid_fromstrn(&oid, identifier, len) == 0)
|
23
|
-
git_object_lookup_prefix(&obj, repo, &oid, len, GIT_OBJ_ANY);
|
24
|
-
|
25
|
-
/* try to resolve as reference */
|
26
|
-
if (obj == NULL) {
|
27
|
-
git_reference *ref, *resolved;
|
28
|
-
if (git_reference_lookup(&ref, repo, identifier) == 0) {
|
29
|
-
git_reference_resolve(&resolved, ref);
|
30
|
-
git_reference_free(ref);
|
31
|
-
if (resolved) {
|
32
|
-
git_object_lookup(&obj, repo, git_reference_oid(resolved), GIT_OBJ_ANY);
|
33
|
-
git_reference_free(resolved);
|
34
|
-
}
|
35
|
-
}
|
36
|
-
}
|
37
|
-
|
38
|
-
if (obj == NULL)
|
39
|
-
return GIT_ENOTFOUND;
|
40
|
-
|
41
|
-
switch (git_object_type(obj)) {
|
42
|
-
case GIT_OBJ_TREE:
|
43
|
-
*tree = (git_tree *)obj;
|
44
|
-
break;
|
45
|
-
case GIT_OBJ_COMMIT:
|
46
|
-
err = git_commit_tree(tree, (git_commit *)obj);
|
47
|
-
git_object_free(obj);
|
48
|
-
break;
|
49
|
-
default:
|
50
|
-
err = GIT_ENOTFOUND;
|
51
|
-
}
|
52
|
-
|
53
|
-
return err;
|
54
|
-
}
|
55
|
-
|
56
|
-
char *colors[] = {
|
57
|
-
"\033[m", /* reset */
|
58
|
-
"\033[1m", /* bold */
|
59
|
-
"\033[31m", /* red */
|
60
|
-
"\033[32m", /* green */
|
61
|
-
"\033[36m" /* cyan */
|
62
|
-
};
|
63
|
-
|
64
|
-
int printer(
|
65
|
-
void *data,
|
66
|
-
git_diff_delta *delta,
|
67
|
-
git_diff_range *range,
|
68
|
-
char usage,
|
69
|
-
const char *line,
|
70
|
-
size_t line_len)
|
71
|
-
{
|
72
|
-
int *last_color = data, color = 0;
|
73
|
-
|
74
|
-
if (*last_color >= 0) {
|
75
|
-
switch (usage) {
|
76
|
-
case GIT_DIFF_LINE_ADDITION: color = 3; break;
|
77
|
-
case GIT_DIFF_LINE_DELETION: color = 2; break;
|
78
|
-
case GIT_DIFF_LINE_ADD_EOFNL: color = 3; break;
|
79
|
-
case GIT_DIFF_LINE_DEL_EOFNL: color = 2; break;
|
80
|
-
case GIT_DIFF_LINE_FILE_HDR: color = 1; break;
|
81
|
-
case GIT_DIFF_LINE_HUNK_HDR: color = 4; break;
|
82
|
-
default: color = 0;
|
83
|
-
}
|
84
|
-
if (color != *last_color) {
|
85
|
-
if (*last_color == 1 || color == 1)
|
86
|
-
fputs(colors[0], stdout);
|
87
|
-
fputs(colors[color], stdout);
|
88
|
-
*last_color = color;
|
89
|
-
}
|
90
|
-
}
|
91
|
-
|
92
|
-
fputs(line, stdout);
|
93
|
-
return 0;
|
94
|
-
}
|
95
|
-
|
96
|
-
int check_uint16_param(const char *arg, const char *pattern, uint16_t *val)
|
97
|
-
{
|
98
|
-
size_t len = strlen(pattern);
|
99
|
-
uint16_t strval;
|
100
|
-
char *endptr = NULL;
|
101
|
-
if (strncmp(arg, pattern, len))
|
102
|
-
return 0;
|
103
|
-
strval = strtoul(arg + len, &endptr, 0);
|
104
|
-
if (endptr == arg)
|
105
|
-
return 0;
|
106
|
-
*val = strval;
|
107
|
-
return 1;
|
108
|
-
}
|
109
|
-
|
110
|
-
int check_str_param(const char *arg, const char *pattern, char **val)
|
111
|
-
{
|
112
|
-
size_t len = strlen(pattern);
|
113
|
-
if (strncmp(arg, pattern, len))
|
114
|
-
return 0;
|
115
|
-
*val = (char *)(arg + len);
|
116
|
-
return 1;
|
117
|
-
}
|
118
|
-
|
119
|
-
void usage(const char *message, const char *arg)
|
120
|
-
{
|
121
|
-
if (message && arg)
|
122
|
-
fprintf(stderr, "%s: %s\n", message, arg);
|
123
|
-
else if (message)
|
124
|
-
fprintf(stderr, "%s\n", message);
|
125
|
-
fprintf(stderr, "usage: diff [<tree-oid> [<tree-oid>]]\n");
|
126
|
-
exit(1);
|
127
|
-
}
|
128
|
-
|
129
|
-
int main(int argc, char *argv[])
|
130
|
-
{
|
131
|
-
char path[GIT_PATH_MAX];
|
132
|
-
git_repository *repo = NULL;
|
133
|
-
git_tree *t1 = NULL, *t2 = NULL;
|
134
|
-
git_diff_options opts = {0};
|
135
|
-
git_diff_list *diff;
|
136
|
-
int i, color = -1, compact = 0, cached = 0;
|
137
|
-
char *a, *dir = ".", *treeish1 = NULL, *treeish2 = NULL;
|
138
|
-
|
139
|
-
/* parse arguments as copied from git-diff */
|
140
|
-
|
141
|
-
for (i = 1; i < argc; ++i) {
|
142
|
-
a = argv[i];
|
143
|
-
|
144
|
-
if (a[0] != '-') {
|
145
|
-
if (treeish1 == NULL)
|
146
|
-
treeish1 = a;
|
147
|
-
else if (treeish2 == NULL)
|
148
|
-
treeish2 = a;
|
149
|
-
else
|
150
|
-
usage("Only one or two tree identifiers can be provided", NULL);
|
151
|
-
}
|
152
|
-
else if (!strcmp(a, "-p") || !strcmp(a, "-u") ||
|
153
|
-
!strcmp(a, "--patch"))
|
154
|
-
compact = 0;
|
155
|
-
else if (!strcmp(a, "--cached"))
|
156
|
-
cached = 1;
|
157
|
-
else if (!strcmp(a, "--name-status"))
|
158
|
-
compact = 1;
|
159
|
-
else if (!strcmp(a, "--color"))
|
160
|
-
color = 0;
|
161
|
-
else if (!strcmp(a, "--no-color"))
|
162
|
-
color = -1;
|
163
|
-
else if (!strcmp(a, "-R"))
|
164
|
-
opts.flags |= GIT_DIFF_REVERSE;
|
165
|
-
else if (!strcmp(a, "-a") || !strcmp(a, "--text"))
|
166
|
-
opts.flags |= GIT_DIFF_FORCE_TEXT;
|
167
|
-
else if (!strcmp(a, "--ignore-space-at-eol"))
|
168
|
-
opts.flags |= GIT_DIFF_IGNORE_WHITESPACE_EOL;
|
169
|
-
else if (!strcmp(a, "-b") || !strcmp(a, "--ignore-space-change"))
|
170
|
-
opts.flags |= GIT_DIFF_IGNORE_WHITESPACE_CHANGE;
|
171
|
-
else if (!strcmp(a, "-w") || !strcmp(a, "--ignore-all-space"))
|
172
|
-
opts.flags |= GIT_DIFF_IGNORE_WHITESPACE;
|
173
|
-
else if (!strcmp(a, "--ignored"))
|
174
|
-
opts.flags |= GIT_DIFF_INCLUDE_IGNORED;
|
175
|
-
else if (!strcmp(a, "--untracked"))
|
176
|
-
opts.flags |= GIT_DIFF_INCLUDE_UNTRACKED;
|
177
|
-
else if (!check_uint16_param(a, "-U", &opts.context_lines) &&
|
178
|
-
!check_uint16_param(a, "--unified=", &opts.context_lines) &&
|
179
|
-
!check_uint16_param(a, "--inter-hunk-context=",
|
180
|
-
&opts.interhunk_lines) &&
|
181
|
-
!check_str_param(a, "--src-prefix=", &opts.old_prefix) &&
|
182
|
-
!check_str_param(a, "--dst-prefix=", &opts.new_prefix))
|
183
|
-
usage("Unknown arg", a);
|
184
|
-
}
|
185
|
-
|
186
|
-
/* open repo */
|
187
|
-
|
188
|
-
check(git_repository_open_ext(&repo, dir, 0, NULL),
|
189
|
-
"Could not open repository");
|
190
|
-
|
191
|
-
if (treeish1)
|
192
|
-
check(resolve_to_tree(repo, treeish1, &t1), "Looking up first tree");
|
193
|
-
if (treeish2)
|
194
|
-
check(resolve_to_tree(repo, treeish2, &t2), "Looking up second tree");
|
195
|
-
|
196
|
-
/* <sha1> <sha2> */
|
197
|
-
/* <sha1> --cached */
|
198
|
-
/* <sha1> */
|
199
|
-
/* --cached */
|
200
|
-
/* nothing */
|
201
|
-
|
202
|
-
if (t1 && t2)
|
203
|
-
check(git_diff_tree_to_tree(repo, &opts, t1, t2, &diff), "Diff");
|
204
|
-
else if (t1 && cached)
|
205
|
-
check(git_diff_index_to_tree(repo, &opts, t1, &diff), "Diff");
|
206
|
-
else if (t1) {
|
207
|
-
git_diff_list *diff2;
|
208
|
-
check(git_diff_index_to_tree(repo, &opts, t1, &diff), "Diff");
|
209
|
-
check(git_diff_workdir_to_index(repo, &opts, &diff2), "Diff");
|
210
|
-
check(git_diff_merge(diff, diff2), "Merge diffs");
|
211
|
-
git_diff_list_free(diff2);
|
212
|
-
}
|
213
|
-
else if (cached) {
|
214
|
-
check(resolve_to_tree(repo, "HEAD", &t1), "looking up HEAD");
|
215
|
-
check(git_diff_index_to_tree(repo, &opts, t1, &diff), "Diff");
|
216
|
-
}
|
217
|
-
else
|
218
|
-
check(git_diff_workdir_to_index(repo, &opts, &diff), "Diff");
|
219
|
-
|
220
|
-
if (color >= 0)
|
221
|
-
fputs(colors[0], stdout);
|
222
|
-
|
223
|
-
if (compact)
|
224
|
-
check(git_diff_print_compact(diff, &color, printer), "Displaying diff");
|
225
|
-
else
|
226
|
-
check(git_diff_print_patch(diff, &color, printer), "Displaying diff");
|
227
|
-
|
228
|
-
if (color >= 0)
|
229
|
-
fputs(colors[0], stdout);
|
230
|
-
|
231
|
-
git_diff_list_free(diff);
|
232
|
-
git_tree_free(t1);
|
233
|
-
git_tree_free(t2);
|
234
|
-
git_repository_free(repo);
|
235
|
-
|
236
|
-
return 0;
|
237
|
-
}
|
238
|
-
|
@@ -1,451 +0,0 @@
|
|
1
|
-
// [**libgit2**][lg] is a portable, pure C implementation of the Git core methods
|
2
|
-
// provided as a re-entrant linkable library with a solid API, allowing you
|
3
|
-
// to write native speed custom Git applications in any language which
|
4
|
-
// supports C bindings.
|
5
|
-
//
|
6
|
-
// This file is an example of using that API in a real, compilable C file.
|
7
|
-
// As the API is updated, this file will be updated to demonstrate the
|
8
|
-
// new functionality.
|
9
|
-
//
|
10
|
-
// If you're trying to write something in C using [libgit2][lg], you will also want
|
11
|
-
// to check out the generated [API documentation][ap] and the [Usage Guide][ug]. We've
|
12
|
-
// tried to link to the relevant sections of the API docs in each section in this file.
|
13
|
-
//
|
14
|
-
// **libgit2** only implements the core plumbing functions, not really the higher
|
15
|
-
// level porcelain stuff. For a primer on Git Internals that you will need to know
|
16
|
-
// to work with Git at this level, check out [Chapter 9][pg] of the Pro Git book.
|
17
|
-
//
|
18
|
-
// [lg]: http://libgit2.github.com
|
19
|
-
// [ap]: http://libgit2.github.com/libgit2
|
20
|
-
// [ug]: http://libgit2.github.com/api.html
|
21
|
-
// [pg]: http://progit.org/book/ch9-0.html
|
22
|
-
|
23
|
-
// ### Includes
|
24
|
-
|
25
|
-
// Including the `git2.h` header will include all the other libgit2 headers that you need.
|
26
|
-
// It should be the only thing you need to include in order to compile properly and get
|
27
|
-
// all the libgit2 API.
|
28
|
-
#include <git2.h>
|
29
|
-
#include <stdio.h>
|
30
|
-
|
31
|
-
int main (int argc, char** argv)
|
32
|
-
{
|
33
|
-
// ### Opening the Repository
|
34
|
-
|
35
|
-
// There are a couple of methods for opening a repository, this being the simplest.
|
36
|
-
// There are also [methods][me] for specifying the index file and work tree locations, here
|
37
|
-
// we are assuming they are in the normal places.
|
38
|
-
//
|
39
|
-
// [me]: http://libgit2.github.com/libgit2/#HEAD/group/repository
|
40
|
-
git_repository *repo;
|
41
|
-
if (argc > 1) {
|
42
|
-
git_repository_open(&repo, argv[1]);
|
43
|
-
} else {
|
44
|
-
git_repository_open(&repo, "/opt/libgit2-test/.git");
|
45
|
-
}
|
46
|
-
|
47
|
-
// ### SHA-1 Value Conversions
|
48
|
-
|
49
|
-
// For our first example, we will convert a 40 character hex value to the 20 byte raw SHA1 value.
|
50
|
-
printf("*Hex to Raw*\n");
|
51
|
-
char hex[] = "fd6e612585290339ea8bf39c692a7ff6a29cb7c3";
|
52
|
-
|
53
|
-
// The `git_oid` is the structure that keeps the SHA value. We will use this throughout the example
|
54
|
-
// for storing the value of the current SHA key we're working with.
|
55
|
-
git_oid oid;
|
56
|
-
git_oid_fromstr(&oid, hex);
|
57
|
-
|
58
|
-
// Once we've converted the string into the oid value, we can get the raw value of the SHA.
|
59
|
-
printf("Raw 20 bytes: [%.20s]\n", (&oid)->id);
|
60
|
-
|
61
|
-
// Next we will convert the 20 byte raw SHA1 value to a human readable 40 char hex value.
|
62
|
-
printf("\n*Raw to Hex*\n");
|
63
|
-
char out[41];
|
64
|
-
out[40] = '\0';
|
65
|
-
|
66
|
-
// If you have a oid, you can easily get the hex value of the SHA as well.
|
67
|
-
git_oid_fmt(out, &oid);
|
68
|
-
printf("SHA hex string: %s\n", out);
|
69
|
-
|
70
|
-
// ### Working with the Object Database
|
71
|
-
// **libgit2** provides [direct access][odb] to the object database.
|
72
|
-
// The object database is where the actual objects are stored in Git. For
|
73
|
-
// working with raw objects, we'll need to get this structure from the
|
74
|
-
// repository.
|
75
|
-
// [odb]: http://libgit2.github.com/libgit2/#HEAD/group/odb
|
76
|
-
git_odb *odb;
|
77
|
-
git_repository_odb(&odb, repo);
|
78
|
-
|
79
|
-
// #### Raw Object Reading
|
80
|
-
|
81
|
-
printf("\n*Raw Object Read*\n");
|
82
|
-
git_odb_object *obj;
|
83
|
-
git_otype otype;
|
84
|
-
const unsigned char *data;
|
85
|
-
const char *str_type;
|
86
|
-
int error;
|
87
|
-
|
88
|
-
// We can read raw objects directly from the object database if we have the oid (SHA)
|
89
|
-
// of the object. This allows us to access objects without knowing thier type and inspect
|
90
|
-
// the raw bytes unparsed.
|
91
|
-
error = git_odb_read(&obj, odb, &oid);
|
92
|
-
|
93
|
-
// A raw object only has three properties - the type (commit, blob, tree or tag), the size
|
94
|
-
// of the raw data and the raw, unparsed data itself. For a commit or tag, that raw data
|
95
|
-
// is human readable plain ASCII text. For a blob it is just file contents, so it could be
|
96
|
-
// text or binary data. For a tree it is a special binary format, so it's unlikely to be
|
97
|
-
// hugely helpful as a raw object.
|
98
|
-
data = (const unsigned char *)git_odb_object_data(obj);
|
99
|
-
otype = git_odb_object_type(obj);
|
100
|
-
|
101
|
-
// We provide methods to convert from the object type which is an enum, to a string
|
102
|
-
// representation of that value (and vice-versa).
|
103
|
-
str_type = git_object_type2string(otype);
|
104
|
-
printf("object length and type: %d, %s\n",
|
105
|
-
(int)git_odb_object_size(obj),
|
106
|
-
str_type);
|
107
|
-
|
108
|
-
// For proper memory management, close the object when you are done with it or it will leak
|
109
|
-
// memory.
|
110
|
-
git_odb_object_free(obj);
|
111
|
-
|
112
|
-
// #### Raw Object Writing
|
113
|
-
|
114
|
-
printf("\n*Raw Object Write*\n");
|
115
|
-
|
116
|
-
// You can also write raw object data to Git. This is pretty cool because it gives you
|
117
|
-
// direct access to the key/value properties of Git. Here we'll write a new blob object
|
118
|
-
// that just contains a simple string. Notice that we have to specify the object type as
|
119
|
-
// the `git_otype` enum.
|
120
|
-
git_odb_write(&oid, odb, "test data", sizeof("test data") - 1, GIT_OBJ_BLOB);
|
121
|
-
|
122
|
-
// Now that we've written the object, we can check out what SHA1 was generated when the
|
123
|
-
// object was written to our database.
|
124
|
-
git_oid_fmt(out, &oid);
|
125
|
-
printf("Written Object: %s\n", out);
|
126
|
-
|
127
|
-
// ### Object Parsing
|
128
|
-
// libgit2 has methods to parse every object type in Git so you don't have to work directly
|
129
|
-
// with the raw data. This is much faster and simpler than trying to deal with the raw data
|
130
|
-
// yourself.
|
131
|
-
|
132
|
-
// #### Commit Parsing
|
133
|
-
// [Parsing commit objects][pco] is simple and gives you access to all the data in the commit
|
134
|
-
// - the // author (name, email, datetime), committer (same), tree, message, encoding and parent(s).
|
135
|
-
// [pco]: http://libgit2.github.com/libgit2/#HEAD/group/commit
|
136
|
-
|
137
|
-
printf("\n*Commit Parsing*\n");
|
138
|
-
|
139
|
-
git_commit *commit;
|
140
|
-
git_oid_fromstr(&oid, "f0877d0b841d75172ec404fc9370173dfffc20d1");
|
141
|
-
|
142
|
-
error = git_commit_lookup(&commit, repo, &oid);
|
143
|
-
|
144
|
-
const git_signature *author, *cmtter;
|
145
|
-
const char *message;
|
146
|
-
time_t ctime;
|
147
|
-
unsigned int parents, p;
|
148
|
-
|
149
|
-
// Each of the properties of the commit object are accessible via methods, including commonly
|
150
|
-
// needed variations, such as `git_commit_time` which returns the author time and `_message`
|
151
|
-
// which gives you the commit message.
|
152
|
-
message = git_commit_message(commit);
|
153
|
-
author = git_commit_author(commit);
|
154
|
-
cmtter = git_commit_committer(commit);
|
155
|
-
ctime = git_commit_time(commit);
|
156
|
-
|
157
|
-
// The author and committer methods return [git_signature] structures, which give you name, email
|
158
|
-
// and `when`, which is a `git_time` structure, giving you a timestamp and timezone offset.
|
159
|
-
printf("Author: %s (%s)\n", author->name, author->email);
|
160
|
-
|
161
|
-
// Commits can have zero or more parents. The first (root) commit will have no parents, most commits
|
162
|
-
// will have one, which is the commit it was based on, and merge commits will have two or more.
|
163
|
-
// Commits can technically have any number, though it's pretty rare to have more than two.
|
164
|
-
parents = git_commit_parentcount(commit);
|
165
|
-
for (p = 0;p < parents;p++) {
|
166
|
-
git_commit *parent;
|
167
|
-
git_commit_parent(&parent, commit, p);
|
168
|
-
git_oid_fmt(out, git_commit_id(parent));
|
169
|
-
printf("Parent: %s\n", out);
|
170
|
-
git_commit_free(parent);
|
171
|
-
}
|
172
|
-
|
173
|
-
// Don't forget to close the object to prevent memory leaks. You will have to do this for
|
174
|
-
// all the objects you open and parse.
|
175
|
-
git_commit_free(commit);
|
176
|
-
|
177
|
-
// #### Writing Commits
|
178
|
-
//
|
179
|
-
// libgit2 provides a couple of methods to create commit objects easily as well. There are four
|
180
|
-
// different create signatures, we'll just show one of them here. You can read about the other
|
181
|
-
// ones in the [commit API docs][cd].
|
182
|
-
// [cd]: http://libgit2.github.com/libgit2/#HEAD/group/commit
|
183
|
-
|
184
|
-
printf("\n*Commit Writing*\n");
|
185
|
-
git_oid tree_id, parent_id, commit_id;
|
186
|
-
git_tree *tree;
|
187
|
-
git_commit *parent;
|
188
|
-
|
189
|
-
// Creating signatures for an authoring identity and time is pretty simple - you will need to have
|
190
|
-
// this to create a commit in order to specify who created it and when. Default values for the name
|
191
|
-
// and email should be found in the `user.name` and `user.email` configuration options. See the `config`
|
192
|
-
// section of this example file to see how to access config values.
|
193
|
-
git_signature_new((git_signature **)&author, "Scott Chacon", "schacon@gmail.com",
|
194
|
-
123456789, 60);
|
195
|
-
git_signature_new((git_signature **)&cmtter, "Scott A Chacon", "scott@github.com",
|
196
|
-
987654321, 90);
|
197
|
-
|
198
|
-
// Commit objects need a tree to point to and optionally one or more parents. Here we're creating oid
|
199
|
-
// objects to create the commit with, but you can also use
|
200
|
-
git_oid_fromstr(&tree_id, "28873d96b4e8f4e33ea30f4c682fd325f7ba56ac");
|
201
|
-
git_tree_lookup(&tree, repo, &tree_id);
|
202
|
-
git_oid_fromstr(&parent_id, "f0877d0b841d75172ec404fc9370173dfffc20d1");
|
203
|
-
git_commit_lookup(&parent, repo, &parent_id);
|
204
|
-
|
205
|
-
// Here we actually create the commit object with a single call with all the values we need to create
|
206
|
-
// the commit. The SHA key is written to the `commit_id` variable here.
|
207
|
-
git_commit_create_v(
|
208
|
-
&commit_id, /* out id */
|
209
|
-
repo,
|
210
|
-
NULL, /* do not update the HEAD */
|
211
|
-
author,
|
212
|
-
cmtter,
|
213
|
-
NULL, /* use default message encoding */
|
214
|
-
"example commit",
|
215
|
-
tree,
|
216
|
-
1, parent);
|
217
|
-
|
218
|
-
// Now we can take a look at the commit SHA we've generated.
|
219
|
-
git_oid_fmt(out, &commit_id);
|
220
|
-
printf("New Commit: %s\n", out);
|
221
|
-
|
222
|
-
// #### Tag Parsing
|
223
|
-
// You can parse and create tags with the [tag management API][tm], which functions very similarly
|
224
|
-
// to the commit lookup, parsing and creation methods, since the objects themselves are very similar.
|
225
|
-
// [tm]: http://libgit2.github.com/libgit2/#HEAD/group/tag
|
226
|
-
printf("\n*Tag Parsing*\n");
|
227
|
-
git_tag *tag;
|
228
|
-
const char *tmessage, *tname;
|
229
|
-
git_otype ttype;
|
230
|
-
|
231
|
-
// We create an oid for the tag object if we know the SHA and look it up in the repository the same
|
232
|
-
// way that we would a commit (or any other) object.
|
233
|
-
git_oid_fromstr(&oid, "bc422d45275aca289c51d79830b45cecebff7c3a");
|
234
|
-
|
235
|
-
error = git_tag_lookup(&tag, repo, &oid);
|
236
|
-
|
237
|
-
// Now that we have the tag object, we can extract the information it generally contains: the target
|
238
|
-
// (usually a commit object), the type of the target object (usually 'commit'), the name ('v1.0'),
|
239
|
-
// the tagger (a git_signature - name, email, timestamp), and the tag message.
|
240
|
-
git_tag_target((git_object **)&commit, tag);
|
241
|
-
tname = git_tag_name(tag); // "test"
|
242
|
-
ttype = git_tag_type(tag); // GIT_OBJ_COMMIT (otype enum)
|
243
|
-
tmessage = git_tag_message(tag); // "tag message\n"
|
244
|
-
printf("Tag Message: %s\n", tmessage);
|
245
|
-
|
246
|
-
git_commit_free(commit);
|
247
|
-
|
248
|
-
// #### Tree Parsing
|
249
|
-
// [Tree parsing][tp] is a bit different than the other objects, in that we have a subtype which is the
|
250
|
-
// tree entry. This is not an actual object type in Git, but a useful structure for parsing and
|
251
|
-
// traversing tree entries.
|
252
|
-
//
|
253
|
-
// [tp]: http://libgit2.github.com/libgit2/#HEAD/group/tree
|
254
|
-
printf("\n*Tree Parsing*\n");
|
255
|
-
|
256
|
-
const git_tree_entry *entry;
|
257
|
-
git_object *objt;
|
258
|
-
|
259
|
-
// Create the oid and lookup the tree object just like the other objects.
|
260
|
-
git_oid_fromstr(&oid, "2a741c18ac5ff082a7caaec6e74db3075a1906b5");
|
261
|
-
git_tree_lookup(&tree, repo, &oid);
|
262
|
-
|
263
|
-
// Getting the count of entries in the tree so you can iterate over them if you want to.
|
264
|
-
int cnt = git_tree_entrycount(tree); // 3
|
265
|
-
printf("tree entries: %d\n", cnt);
|
266
|
-
|
267
|
-
entry = git_tree_entry_byindex(tree, 0);
|
268
|
-
printf("Entry name: %s\n", git_tree_entry_name(entry)); // "hello.c"
|
269
|
-
|
270
|
-
// You can also access tree entries by name if you know the name of the entry you're looking for.
|
271
|
-
entry = git_tree_entry_byname(tree, "hello.c");
|
272
|
-
git_tree_entry_name(entry); // "hello.c"
|
273
|
-
|
274
|
-
// Once you have the entry object, you can access the content or subtree (or commit, in the case
|
275
|
-
// of submodules) that it points to. You can also get the mode if you want.
|
276
|
-
git_tree_entry_to_object(&objt, repo, entry); // blob
|
277
|
-
|
278
|
-
// Remember to close the looked-up object once you are done using it
|
279
|
-
git_object_free(objt);
|
280
|
-
|
281
|
-
// #### Blob Parsing
|
282
|
-
//
|
283
|
-
// The last object type is the simplest and requires the least parsing help. Blobs are just file
|
284
|
-
// contents and can contain anything, there is no structure to it. The main advantage to using the
|
285
|
-
// [simple blob api][ba] is that when you're creating blobs you don't have to calculate the size
|
286
|
-
// of the content. There is also a helper for reading a file from disk and writing it to the db and
|
287
|
-
// getting the oid back so you don't have to do all those steps yourself.
|
288
|
-
//
|
289
|
-
// [ba]: http://libgit2.github.com/libgit2/#HEAD/group/blob
|
290
|
-
|
291
|
-
printf("\n*Blob Parsing*\n");
|
292
|
-
git_blob *blob;
|
293
|
-
|
294
|
-
git_oid_fromstr(&oid, "af7574ea73f7b166f869ef1a39be126d9a186ae0");
|
295
|
-
git_blob_lookup(&blob, repo, &oid);
|
296
|
-
|
297
|
-
// You can access a buffer with the raw contents of the blob directly.
|
298
|
-
// Note that this buffer may not be contain ASCII data for certain blobs (e.g. binary files):
|
299
|
-
// do not consider the buffer a NULL-terminated string, and use the `git_blob_rawsize` attribute to
|
300
|
-
// find out its exact size in bytes
|
301
|
-
printf("Blob Size: %ld\n", git_blob_rawsize(blob)); // 8
|
302
|
-
git_blob_rawcontent(blob); // "content"
|
303
|
-
|
304
|
-
// ### Revwalking
|
305
|
-
//
|
306
|
-
// The libgit2 [revision walking api][rw] provides methods to traverse the directed graph created
|
307
|
-
// by the parent pointers of the commit objects. Since all commits point back to the commit that
|
308
|
-
// came directly before them, you can walk this parentage as a graph and find all the commits that
|
309
|
-
// were ancestors of (reachable from) a given starting point. This can allow you to create `git log`
|
310
|
-
// type functionality.
|
311
|
-
//
|
312
|
-
// [rw]: http://libgit2.github.com/libgit2/#HEAD/group/revwalk
|
313
|
-
|
314
|
-
printf("\n*Revwalking*\n");
|
315
|
-
git_revwalk *walk;
|
316
|
-
git_commit *wcommit;
|
317
|
-
|
318
|
-
git_oid_fromstr(&oid, "f0877d0b841d75172ec404fc9370173dfffc20d1");
|
319
|
-
|
320
|
-
// To use the revwalker, create a new walker, tell it how you want to sort the output and then push
|
321
|
-
// one or more starting points onto the walker. If you want to emulate the output of `git log` you
|
322
|
-
// would push the SHA of the commit that HEAD points to into the walker and then start traversing them.
|
323
|
-
// You can also 'hide' commits that you want to stop at or not see any of their ancestors. So if you
|
324
|
-
// want to emulate `git log branch1..branch2`, you would push the oid of `branch2` and hide the oid
|
325
|
-
// of `branch1`.
|
326
|
-
git_revwalk_new(&walk, repo);
|
327
|
-
git_revwalk_sorting(walk, GIT_SORT_TOPOLOGICAL | GIT_SORT_REVERSE);
|
328
|
-
git_revwalk_push(walk, &oid);
|
329
|
-
|
330
|
-
const git_signature *cauth;
|
331
|
-
const char *cmsg;
|
332
|
-
|
333
|
-
// Now that we have the starting point pushed onto the walker, we can start asking for ancestors. It
|
334
|
-
// will return them in the sorting order we asked for as commit oids.
|
335
|
-
// We can then lookup and parse the commited pointed at by the returned OID;
|
336
|
-
// note that this operation is specially fast since the raw contents of the commit object will
|
337
|
-
// be cached in memory
|
338
|
-
while ((git_revwalk_next(&oid, walk)) == 0) {
|
339
|
-
error = git_commit_lookup(&wcommit, repo, &oid);
|
340
|
-
cmsg = git_commit_message(wcommit);
|
341
|
-
cauth = git_commit_author(wcommit);
|
342
|
-
printf("%s (%s)\n", cmsg, cauth->email);
|
343
|
-
git_commit_free(wcommit);
|
344
|
-
}
|
345
|
-
|
346
|
-
// Like the other objects, be sure to free the revwalker when you're done to prevent memory leaks.
|
347
|
-
// Also, make sure that the repository being walked it not deallocated while the walk is in
|
348
|
-
// progress, or it will result in undefined behavior
|
349
|
-
git_revwalk_free(walk);
|
350
|
-
|
351
|
-
// ### Index File Manipulation
|
352
|
-
//
|
353
|
-
// The [index file API][gi] allows you to read, traverse, update and write the Git index file
|
354
|
-
// (sometimes thought of as the staging area).
|
355
|
-
//
|
356
|
-
// [gi]: http://libgit2.github.com/libgit2/#HEAD/group/index
|
357
|
-
|
358
|
-
printf("\n*Index Walking*\n");
|
359
|
-
|
360
|
-
git_index *index;
|
361
|
-
unsigned int i, ecount;
|
362
|
-
|
363
|
-
// You can either open the index from the standard location in an open repository, as we're doing
|
364
|
-
// here, or you can open and manipulate any index file with `git_index_open_bare()`. The index
|
365
|
-
// for the repository will be located and loaded from disk.
|
366
|
-
git_repository_index(&index, repo);
|
367
|
-
|
368
|
-
// For each entry in the index, you can get a bunch of information including the SHA (oid), path
|
369
|
-
// and mode which map to the tree objects that are written out. It also has filesystem properties
|
370
|
-
// to help determine what to inspect for changes (ctime, mtime, dev, ino, uid, gid, file_size and flags)
|
371
|
-
// All these properties are exported publicly in the `git_index_entry` struct
|
372
|
-
ecount = git_index_entrycount(index);
|
373
|
-
for (i = 0; i < ecount; ++i) {
|
374
|
-
git_index_entry *e = git_index_get(index, i);
|
375
|
-
|
376
|
-
printf("path: %s\n", e->path);
|
377
|
-
printf("mtime: %d\n", (int)e->mtime.seconds);
|
378
|
-
printf("fs: %d\n", (int)e->file_size);
|
379
|
-
}
|
380
|
-
|
381
|
-
git_index_free(index);
|
382
|
-
|
383
|
-
// ### References
|
384
|
-
//
|
385
|
-
// The [reference API][ref] allows you to list, resolve, create and update references such as
|
386
|
-
// branches, tags and remote references (everything in the .git/refs directory).
|
387
|
-
//
|
388
|
-
// [ref]: http://libgit2.github.com/libgit2/#HEAD/group/reference
|
389
|
-
|
390
|
-
printf("\n*Reference Listing*\n");
|
391
|
-
|
392
|
-
// Here we will implement something like `git for-each-ref` simply listing out all available
|
393
|
-
// references and the object SHA they resolve to.
|
394
|
-
git_strarray ref_list;
|
395
|
-
git_reference_list(&ref_list, repo, GIT_REF_LISTALL);
|
396
|
-
|
397
|
-
const char *refname;
|
398
|
-
git_reference *ref;
|
399
|
-
|
400
|
-
// Now that we have the list of reference names, we can lookup each ref one at a time and
|
401
|
-
// resolve them to the SHA, then print both values out.
|
402
|
-
for (i = 0; i < ref_list.count; ++i) {
|
403
|
-
refname = ref_list.strings[i];
|
404
|
-
git_reference_lookup(&ref, repo, refname);
|
405
|
-
|
406
|
-
switch (git_reference_type(ref)) {
|
407
|
-
case GIT_REF_OID:
|
408
|
-
git_oid_fmt(out, git_reference_oid(ref));
|
409
|
-
printf("%s [%s]\n", refname, out);
|
410
|
-
break;
|
411
|
-
|
412
|
-
case GIT_REF_SYMBOLIC:
|
413
|
-
printf("%s => %s\n", refname, git_reference_target(ref));
|
414
|
-
break;
|
415
|
-
default:
|
416
|
-
fprintf(stderr, "Unexpected reference type\n");
|
417
|
-
exit(1);
|
418
|
-
}
|
419
|
-
}
|
420
|
-
|
421
|
-
git_strarray_free(&ref_list);
|
422
|
-
|
423
|
-
// ### Config Files
|
424
|
-
//
|
425
|
-
// The [config API][config] allows you to list and updatee config values in
|
426
|
-
// any of the accessible config file locations (system, global, local).
|
427
|
-
//
|
428
|
-
// [config]: http://libgit2.github.com/libgit2/#HEAD/group/config
|
429
|
-
|
430
|
-
printf("\n*Config Listing*\n");
|
431
|
-
|
432
|
-
const char *email;
|
433
|
-
int32_t j;
|
434
|
-
|
435
|
-
git_config *cfg;
|
436
|
-
|
437
|
-
// Open a config object so we can read global values from it.
|
438
|
-
git_config_open_ondisk(&cfg, "~/.gitconfig");
|
439
|
-
|
440
|
-
git_config_get_int32(cfg, "help.autocorrect", &j);
|
441
|
-
printf("Autocorrect: %d\n", j);
|
442
|
-
|
443
|
-
git_config_get_string(cfg, "user.email", &email);
|
444
|
-
printf("Email: %s\n", email);
|
445
|
-
|
446
|
-
// Finally, when you're done with the repository, you can free it as well.
|
447
|
-
git_repository_free(repo);
|
448
|
-
|
449
|
-
return 0;
|
450
|
-
}
|
451
|
-
|