rugged 0.1.2 → 0.16.0b1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +25 -36
- data/Rakefile +20 -98
- data/ext/rugged/extconf.rb +44 -4
- data/ext/rugged/remote.c +215 -0
- data/ext/rugged/rugged.c +171 -0
- data/ext/rugged/rugged.h +126 -0
- data/ext/rugged/rugged_blob.c +99 -0
- data/ext/rugged/rugged_commit.c +224 -0
- data/ext/rugged/rugged_config.c +238 -0
- data/ext/rugged/rugged_index.c +440 -0
- data/ext/rugged/rugged_object.c +203 -0
- data/ext/rugged/rugged_reference.c +401 -0
- data/ext/rugged/rugged_repo.c +482 -0
- data/ext/rugged/rugged_revwalk.c +138 -0
- data/ext/rugged/rugged_signature.c +80 -0
- data/ext/rugged/rugged_tag.c +216 -0
- data/ext/rugged/rugged_tree.c +322 -0
- data/ext/rugged/vendor/libgit2-dist.tar.gz +0 -0
- data/ext/rugged/vendor/libgit2-dist/deps/http-parser/http_parser.c +1778 -0
- data/ext/rugged/vendor/libgit2-dist/deps/http-parser/http_parser.h +267 -0
- data/ext/rugged/vendor/libgit2-dist/deps/zlib/adler32.c +169 -0
- data/ext/rugged/vendor/libgit2-dist/deps/zlib/crc32.c +442 -0
- data/ext/rugged/vendor/libgit2-dist/deps/zlib/crc32.h +441 -0
- data/ext/rugged/vendor/libgit2-dist/deps/zlib/deflate.c +1834 -0
- data/ext/rugged/vendor/libgit2-dist/deps/zlib/deflate.h +342 -0
- data/ext/rugged/vendor/libgit2-dist/deps/zlib/inffast.c +340 -0
- data/ext/rugged/vendor/libgit2-dist/deps/zlib/inffast.h +11 -0
- data/ext/rugged/vendor/libgit2-dist/deps/zlib/inffixed.h +94 -0
- data/ext/rugged/vendor/libgit2-dist/deps/zlib/inflate.c +1480 -0
- data/ext/rugged/vendor/libgit2-dist/deps/zlib/inflate.h +122 -0
- data/ext/rugged/vendor/libgit2-dist/deps/zlib/inftrees.c +330 -0
- data/ext/rugged/vendor/libgit2-dist/deps/zlib/inftrees.h +62 -0
- data/ext/rugged/vendor/libgit2-dist/deps/zlib/trees.c +1244 -0
- data/ext/rugged/vendor/libgit2-dist/deps/zlib/trees.h +128 -0
- data/ext/rugged/vendor/libgit2-dist/deps/zlib/zconf.h +54 -0
- data/ext/rugged/vendor/libgit2-dist/deps/zlib/zlib.h +1613 -0
- data/ext/rugged/vendor/libgit2-dist/deps/zlib/zutil.c +318 -0
- data/ext/rugged/vendor/libgit2-dist/deps/zlib/zutil.h +274 -0
- data/ext/rugged/vendor/libgit2-dist/examples/general.c +451 -0
- data/ext/rugged/vendor/libgit2-dist/examples/network/common.h +14 -0
- data/ext/rugged/vendor/libgit2-dist/examples/network/fetch.c +97 -0
- data/ext/rugged/vendor/libgit2-dist/examples/network/git2.c +58 -0
- data/ext/rugged/vendor/libgit2-dist/examples/network/index-pack.c +47 -0
- data/ext/rugged/vendor/libgit2-dist/examples/network/ls-remote.c +76 -0
- data/ext/rugged/vendor/libgit2-dist/examples/showindex.c +43 -0
- data/ext/rugged/vendor/libgit2-dist/include/git2.h +44 -0
- data/ext/rugged/vendor/libgit2-dist/include/git2/blob.h +120 -0
- data/ext/rugged/vendor/libgit2-dist/include/git2/branch.h +15 -0
- data/ext/rugged/vendor/libgit2-dist/include/git2/commit.h +263 -0
- data/ext/rugged/vendor/libgit2-dist/include/git2/common.h +103 -0
- data/ext/rugged/vendor/libgit2-dist/include/git2/config.h +278 -0
- data/ext/rugged/vendor/libgit2-dist/include/git2/errors.h +144 -0
- data/ext/rugged/vendor/libgit2-dist/include/git2/index.h +306 -0
- data/ext/rugged/vendor/libgit2-dist/include/git2/indexer.h +76 -0
- data/ext/rugged/vendor/libgit2-dist/include/git2/inttypes.h +305 -0
- data/ext/rugged/vendor/libgit2-dist/include/git2/net.h +51 -0
- data/ext/rugged/vendor/libgit2-dist/include/git2/object.h +173 -0
- data/ext/rugged/vendor/libgit2-dist/include/git2/odb.h +331 -0
- data/ext/rugged/vendor/libgit2-dist/include/git2/odb_backend.h +100 -0
- data/ext/rugged/vendor/libgit2-dist/include/git2/oid.h +218 -0
- data/ext/rugged/vendor/libgit2-dist/include/git2/reflog.h +128 -0
- data/ext/rugged/vendor/libgit2-dist/include/git2/refs.h +309 -0
- data/ext/rugged/vendor/libgit2-dist/include/git2/refspec.h +60 -0
- data/ext/rugged/vendor/libgit2-dist/include/git2/remote.h +176 -0
- data/ext/rugged/vendor/libgit2-dist/include/git2/repository.h +290 -0
- data/ext/rugged/vendor/libgit2-dist/include/git2/revwalk.h +169 -0
- data/ext/rugged/vendor/libgit2-dist/include/git2/signature.h +65 -0
- data/ext/rugged/vendor/libgit2-dist/include/git2/status.h +63 -0
- data/ext/rugged/vendor/libgit2-dist/include/git2/stdint.h +247 -0
- data/ext/rugged/vendor/libgit2-dist/include/git2/tag.h +279 -0
- data/ext/rugged/vendor/libgit2-dist/include/git2/threads.h +48 -0
- data/ext/rugged/vendor/libgit2-dist/include/git2/tree.h +318 -0
- data/ext/rugged/vendor/libgit2-dist/include/git2/types.h +169 -0
- data/ext/rugged/vendor/libgit2-dist/include/git2/version.h +15 -0
- data/ext/rugged/vendor/libgit2-dist/include/git2/windows.h +59 -0
- data/ext/rugged/vendor/libgit2-dist/include/git2/zlib.h +40 -0
- data/ext/rugged/vendor/libgit2-dist/src/blob.c +135 -0
- data/ext/rugged/vendor/libgit2-dist/src/blob.h +23 -0
- data/ext/rugged/vendor/libgit2-dist/src/bswap.h +97 -0
- data/ext/rugged/vendor/libgit2-dist/src/buffer.c +113 -0
- data/ext/rugged/vendor/libgit2-dist/src/buffer.h +32 -0
- data/ext/rugged/vendor/libgit2-dist/src/cache.c +111 -0
- data/ext/rugged/vendor/libgit2-dist/src/cache.h +64 -0
- data/ext/rugged/vendor/libgit2-dist/src/cc-compat.h +67 -0
- data/ext/rugged/vendor/libgit2-dist/src/commit.c +299 -0
- data/ext/rugged/vendor/libgit2-dist/src/commit.h +34 -0
- data/ext/rugged/vendor/libgit2-dist/src/common.h +64 -0
- data/ext/rugged/vendor/libgit2-dist/src/config.c +418 -0
- data/ext/rugged/vendor/libgit2-dist/src/config.h +24 -0
- data/ext/rugged/vendor/libgit2-dist/src/config_file.c +1210 -0
- data/ext/rugged/vendor/libgit2-dist/src/delta-apply.c +115 -0
- data/ext/rugged/vendor/libgit2-dist/src/delta-apply.h +33 -0
- data/ext/rugged/vendor/libgit2-dist/src/dir.h +47 -0
- data/ext/rugged/vendor/libgit2-dist/src/errors.c +104 -0
- data/ext/rugged/vendor/libgit2-dist/src/fetch.c +172 -0
- data/ext/rugged/vendor/libgit2-dist/src/fetch.h +18 -0
- data/ext/rugged/vendor/libgit2-dist/src/filebuf.c +400 -0
- data/ext/rugged/vendor/libgit2-dist/src/filebuf.h +72 -0
- data/ext/rugged/vendor/libgit2-dist/src/fileops.c +358 -0
- data/ext/rugged/vendor/libgit2-dist/src/fileops.h +151 -0
- data/ext/rugged/vendor/libgit2-dist/src/global.c +134 -0
- data/ext/rugged/vendor/libgit2-dist/src/global.h +24 -0
- data/ext/rugged/vendor/libgit2-dist/src/hash.c +74 -0
- data/ext/rugged/vendor/libgit2-dist/src/hash.h +29 -0
- data/ext/rugged/vendor/libgit2-dist/src/hashtable.c +243 -0
- data/ext/rugged/vendor/libgit2-dist/src/hashtable.h +80 -0
- data/ext/rugged/vendor/libgit2-dist/src/index.c +918 -0
- data/ext/rugged/vendor/libgit2-dist/src/index.h +34 -0
- data/ext/rugged/vendor/libgit2-dist/src/indexer.c +401 -0
- data/ext/rugged/vendor/libgit2-dist/src/map.h +37 -0
- data/ext/rugged/vendor/libgit2-dist/src/mwindow.c +272 -0
- data/ext/rugged/vendor/libgit2-dist/src/mwindow.h +45 -0
- data/ext/rugged/vendor/libgit2-dist/src/netops.c +198 -0
- data/ext/rugged/vendor/libgit2-dist/src/netops.h +36 -0
- data/ext/rugged/vendor/libgit2-dist/src/object.c +295 -0
- data/ext/rugged/vendor/libgit2-dist/src/odb.c +672 -0
- data/ext/rugged/vendor/libgit2-dist/src/odb.h +43 -0
- data/ext/rugged/vendor/libgit2-dist/src/odb_loose.c +855 -0
- data/ext/rugged/vendor/libgit2-dist/src/odb_pack.c +485 -0
- data/ext/rugged/vendor/libgit2-dist/src/oid.c +388 -0
- data/ext/rugged/vendor/libgit2-dist/src/pack.c +788 -0
- data/ext/rugged/vendor/libgit2-dist/src/pack.h +99 -0
- data/ext/rugged/vendor/libgit2-dist/src/path.c +270 -0
- data/ext/rugged/vendor/libgit2-dist/src/path.h +84 -0
- data/ext/rugged/vendor/libgit2-dist/src/pkt.c +426 -0
- data/ext/rugged/vendor/libgit2-dist/src/pkt.h +77 -0
- data/ext/rugged/vendor/libgit2-dist/src/posix.c +94 -0
- data/ext/rugged/vendor/libgit2-dist/src/posix.h +69 -0
- data/ext/rugged/vendor/libgit2-dist/src/ppc/sha1.c +70 -0
- data/ext/rugged/vendor/libgit2-dist/src/ppc/sha1.h +26 -0
- data/ext/rugged/vendor/libgit2-dist/src/pqueue.c +141 -0
- data/ext/rugged/vendor/libgit2-dist/src/pqueue.h +81 -0
- data/ext/rugged/vendor/libgit2-dist/src/protocol.c +50 -0
- data/ext/rugged/vendor/libgit2-dist/src/protocol.h +23 -0
- data/ext/rugged/vendor/libgit2-dist/src/reflog.c +318 -0
- data/ext/rugged/vendor/libgit2-dist/src/reflog.h +34 -0
- data/ext/rugged/vendor/libgit2-dist/src/refs.c +1693 -0
- data/ext/rugged/vendor/libgit2-dist/src/refs.h +58 -0
- data/ext/rugged/vendor/libgit2-dist/src/refspec.c +95 -0
- data/ext/rugged/vendor/libgit2-dist/src/refspec.h +23 -0
- data/ext/rugged/vendor/libgit2-dist/src/remote.c +339 -0
- data/ext/rugged/vendor/libgit2-dist/src/remote.h +25 -0
- data/ext/rugged/vendor/libgit2-dist/src/repository.c +849 -0
- data/ext/rugged/vendor/libgit2-dist/src/repository.h +60 -0
- data/ext/rugged/vendor/libgit2-dist/src/revwalk.c +569 -0
- data/ext/rugged/vendor/libgit2-dist/src/sha1.c +280 -0
- data/ext/rugged/vendor/libgit2-dist/src/sha1.h +21 -0
- data/ext/rugged/vendor/libgit2-dist/src/sha1_lookup.c +177 -0
- data/ext/rugged/vendor/libgit2-dist/src/sha1_lookup.h +18 -0
- data/ext/rugged/vendor/libgit2-dist/src/signature.c +335 -0
- data/ext/rugged/vendor/libgit2-dist/src/signature.h +18 -0
- data/ext/rugged/vendor/libgit2-dist/src/status.c +696 -0
- data/ext/rugged/vendor/libgit2-dist/src/tag.c +446 -0
- data/ext/rugged/vendor/libgit2-dist/src/tag.h +28 -0
- data/ext/rugged/vendor/libgit2-dist/src/thread-utils.c +55 -0
- data/ext/rugged/vendor/libgit2-dist/src/thread-utils.h +108 -0
- data/ext/rugged/vendor/libgit2-dist/src/transport.c +85 -0
- data/ext/rugged/vendor/libgit2-dist/src/transport.h +110 -0
- data/ext/rugged/vendor/libgit2-dist/src/transports/git.c +502 -0
- data/ext/rugged/vendor/libgit2-dist/src/transports/http.c +756 -0
- data/ext/rugged/vendor/libgit2-dist/src/transports/local.c +235 -0
- data/ext/rugged/vendor/libgit2-dist/src/tree-cache.c +201 -0
- data/ext/rugged/vendor/libgit2-dist/src/tree-cache.h +31 -0
- data/ext/rugged/vendor/libgit2-dist/src/tree.c +758 -0
- data/ext/rugged/vendor/libgit2-dist/src/tree.h +37 -0
- data/ext/rugged/vendor/libgit2-dist/src/tsort.c +365 -0
- data/ext/rugged/vendor/libgit2-dist/src/unix/map.c +70 -0
- data/ext/rugged/vendor/libgit2-dist/src/unix/posix.h +25 -0
- data/ext/rugged/vendor/libgit2-dist/src/util.c +381 -0
- data/ext/rugged/vendor/libgit2-dist/src/util.h +137 -0
- data/ext/rugged/vendor/libgit2-dist/src/vector.c +174 -0
- data/ext/rugged/vendor/libgit2-dist/src/vector.h +45 -0
- data/ext/rugged/vendor/libgit2-dist/src/win32/dir.c +115 -0
- data/ext/rugged/vendor/libgit2-dist/src/win32/fnmatch.c +180 -0
- data/ext/rugged/vendor/libgit2-dist/src/win32/fnmatch.h +27 -0
- data/ext/rugged/vendor/libgit2-dist/src/win32/map.c +131 -0
- data/ext/rugged/vendor/libgit2-dist/src/win32/mingw-compat.h +24 -0
- data/ext/rugged/vendor/libgit2-dist/src/win32/msvc-compat.h +38 -0
- data/ext/rugged/vendor/libgit2-dist/src/win32/posix.h +53 -0
- data/ext/rugged/vendor/libgit2-dist/src/win32/posix_w32.c +404 -0
- data/ext/rugged/vendor/libgit2-dist/src/win32/pthread.c +65 -0
- data/ext/rugged/vendor/libgit2-dist/src/win32/pthread.h +40 -0
- data/ext/rugged/vendor/libgit2-dist/src/win32/utf-conv.c +88 -0
- data/ext/rugged/vendor/libgit2-dist/src/win32/utf-conv.h +17 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clay/buf/basic.c +29 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clay/clay.h +187 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clay/clay_libgit2.h +28 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clay/clay_main.c +1073 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clay/config/add.c +37 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clay/config/new.c +36 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clay/config/read.c +209 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clay/config/stress.c +39 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clay/config/write.c +77 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clay/core/dirent.c +222 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clay/core/filebuf.c +106 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clay/core/oid.c +18 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clay/core/path.c +139 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clay/core/rmdir.c +50 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clay/core/string.c +28 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clay/core/strtol.c +37 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clay/core/vector.c +66 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clay/index/rename.c +60 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clay/network/remotes.c +50 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clay/object/raw/chars.c +52 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clay/object/raw/compare.c +124 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clay/object/raw/convert.c +75 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clay/object/raw/data.h +323 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clay/object/raw/fromstr.c +30 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clay/object/raw/hash.c +162 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clay/object/raw/short.c +94 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clay/object/raw/size.c +13 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clay/object/raw/type2string.c +54 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clay/object/tree/frompath.c +75 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clay/odb/loose.c +84 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clay/odb/loose_data.h +522 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clay/odb/pack_data.h +151 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clay/odb/packed.c +78 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clay/odb/sorting.c +71 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clay/repo/getters.c +68 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clay/repo/init.c +104 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clay/repo/open.c +54 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clay/status/single.c +38 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clay/status/status_data.h +48 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clay/status/worktree.c +124 -0
- data/ext/rugged/vendor/libgit2-dist/tests/t00-core.c +628 -0
- data/ext/rugged/vendor/libgit2-dist/tests/t01-data.h +322 -0
- data/ext/rugged/vendor/libgit2-dist/tests/t01-rawobj.c +638 -0
- data/ext/rugged/vendor/libgit2-dist/tests/t03-data.h +344 -0
- data/ext/rugged/vendor/libgit2-dist/tests/t03-objwrite.c +255 -0
- data/ext/rugged/vendor/libgit2-dist/tests/t04-commit.c +788 -0
- data/ext/rugged/vendor/libgit2-dist/tests/t05-revwalk.c +140 -0
- data/ext/rugged/vendor/libgit2-dist/tests/t06-index.c +219 -0
- data/ext/rugged/vendor/libgit2-dist/tests/t07-hashtable.c +192 -0
- data/ext/rugged/vendor/libgit2-dist/tests/t08-tag.c +357 -0
- data/ext/rugged/vendor/libgit2-dist/tests/t09-tree.c +221 -0
- data/ext/rugged/vendor/libgit2-dist/tests/t10-refs.c +1294 -0
- data/ext/rugged/vendor/libgit2-dist/tests/t12-repo.c +174 -0
- data/ext/rugged/vendor/libgit2-dist/tests/t13-threads.c +41 -0
- data/ext/rugged/vendor/libgit2-dist/tests/t17-bufs.c +61 -0
- data/ext/rugged/vendor/libgit2-dist/tests/t18-status.c +448 -0
- data/ext/rugged/vendor/libgit2-dist/tests/test_helpers.c +310 -0
- data/ext/rugged/vendor/libgit2-dist/tests/test_helpers.h +83 -0
- data/ext/rugged/vendor/libgit2-dist/tests/test_lib.c +198 -0
- data/ext/rugged/vendor/libgit2-dist/tests/test_lib.h +54 -0
- data/ext/rugged/vendor/libgit2-dist/tests/test_main.c +89 -0
- data/lib/rugged.rb +4 -3
- data/lib/rugged/index.rb +0 -8
- data/lib/rugged/objects.rb +45 -0
- data/lib/rugged/repository.rb +29 -0
- data/lib/rugged/tree.rb +16 -6
- data/lib/rugged/version.rb +1 -1
- data/lib/rugged/walker.rb +5 -0
- data/test/blob_test.rb +18 -14
- data/test/commit_test.rb +28 -26
- data/test/coverage/HEAD.json +1 -0
- data/test/coverage/cover.rb +106 -0
- data/test/fixtures/testrepo.git/refs/heads/new_name +1 -0
- data/test/index_test.rb +101 -78
- data/test/lib_test.rb +4 -4
- data/test/object_test.rb +3 -3
- data/test/reference_test.rb +75 -0
- data/test/remote_test.rb +19 -0
- data/test/repo_pack_test.rb +4 -4
- data/test/repo_test.rb +44 -15
- data/test/tag_test.rb +7 -17
- data/test/test_helper.rb +24 -5
- data/test/tree_test.rb +30 -12
- data/test/walker_test.rb +40 -31
- metadata +273 -50
- data/lib/rugged/person.rb +0 -20
- data/lib/rugged/tree_entry.rb +0 -9
- data/test/fixtures/testrepo.git/objects/1d/83f106355e4309a293e42ad2a2c4b8bdbe77ae +0 -0
- data/test/fixtures/testrepo.git/objects/2f/3321418db5b2a841375b8b70880a8ab5a4148f +0 -0
- data/test/fixtures/testrepo.git/objects/36/9b00a7700cca3a506d79e301d6ad8bf735d9ee +0 -3
- data/test/fixtures/testrepo.git/objects/3d/b1b5ceace59ff65279757003763046fd4cbbe6 +0 -0
- data/test/fixtures/testrepo.git/objects/4c/d1604907792e2c43e03dcec1216f99d63e68c4 +0 -3
- data/test/fixtures/testrepo.git/objects/e0/f46d77041c149296549b01ed4a18b02c4b7400 +0 -0
@@ -0,0 +1,174 @@
|
|
1
|
+
/*
|
2
|
+
* This file is free software; you can redistribute it and/or modify
|
3
|
+
* it under the terms of the GNU General Public License, version 2,
|
4
|
+
* as published by the Free Software Foundation.
|
5
|
+
*
|
6
|
+
* In addition to the permissions in the GNU General Public License,
|
7
|
+
* the authors give you unlimited permission to link the compiled
|
8
|
+
* version of this file into combinations with other programs,
|
9
|
+
* and to distribute those combinations without any restriction
|
10
|
+
* coming from the use of this file. (The General Public License
|
11
|
+
* restrictions do apply in other respects; for example, they cover
|
12
|
+
* modification of the file, and distribution when not linked into
|
13
|
+
* a combined executable.)
|
14
|
+
*
|
15
|
+
* This file is distributed in the hope that it will be useful, but
|
16
|
+
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
17
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
18
|
+
* General Public License for more details.
|
19
|
+
*
|
20
|
+
* You should have received a copy of the GNU General Public License
|
21
|
+
* along with this program; see the file COPYING. If not, write to
|
22
|
+
* the Free Software Foundation, 51 Franklin Street, Fifth Floor,
|
23
|
+
* Boston, MA 02110-1301, USA.
|
24
|
+
*/
|
25
|
+
#include "test_lib.h"
|
26
|
+
#include "test_helpers.h"
|
27
|
+
|
28
|
+
#include "odb.h"
|
29
|
+
#include "git2/odb_backend.h"
|
30
|
+
#include "repository.h"
|
31
|
+
|
32
|
+
#define EMPTY_BARE_REPOSITORY_FOLDER TEST_RESOURCES "/empty_bare.git/"
|
33
|
+
|
34
|
+
#define DISCOVER_FOLDER TEMP_REPO_FOLDER "discover.git"
|
35
|
+
|
36
|
+
#define SUB_REPOSITORY_FOLDER_NAME "sub_repo"
|
37
|
+
#define SUB_REPOSITORY_FOLDER DISCOVER_FOLDER "/" SUB_REPOSITORY_FOLDER_NAME
|
38
|
+
#define SUB_REPOSITORY_FOLDER_SUB SUB_REPOSITORY_FOLDER "/sub"
|
39
|
+
#define SUB_REPOSITORY_FOLDER_SUB_SUB SUB_REPOSITORY_FOLDER_SUB "/subsub"
|
40
|
+
#define SUB_REPOSITORY_FOLDER_SUB_SUB_SUB SUB_REPOSITORY_FOLDER_SUB_SUB "/subsubsub"
|
41
|
+
|
42
|
+
#define REPOSITORY_ALTERNATE_FOLDER DISCOVER_FOLDER "/alternate_sub_repo"
|
43
|
+
#define REPOSITORY_ALTERNATE_FOLDER_SUB REPOSITORY_ALTERNATE_FOLDER "/sub"
|
44
|
+
#define REPOSITORY_ALTERNATE_FOLDER_SUB_SUB REPOSITORY_ALTERNATE_FOLDER_SUB "/subsub"
|
45
|
+
#define REPOSITORY_ALTERNATE_FOLDER_SUB_SUB_SUB REPOSITORY_ALTERNATE_FOLDER_SUB_SUB "/subsubsub"
|
46
|
+
|
47
|
+
#define ALTERNATE_MALFORMED_FOLDER1 DISCOVER_FOLDER "/alternate_malformed_repo1"
|
48
|
+
#define ALTERNATE_MALFORMED_FOLDER2 DISCOVER_FOLDER "/alternate_malformed_repo2"
|
49
|
+
#define ALTERNATE_MALFORMED_FOLDER3 DISCOVER_FOLDER "/alternate_malformed_repo3"
|
50
|
+
#define ALTERNATE_NOT_FOUND_FOLDER DISCOVER_FOLDER "/alternate_not_found_repo"
|
51
|
+
|
52
|
+
static int ensure_repository_discover(const char *start_path, const char *ceiling_dirs, const char *expected_path)
|
53
|
+
{
|
54
|
+
int error;
|
55
|
+
char found_path[GIT_PATH_MAX];
|
56
|
+
|
57
|
+
error = git_repository_discover(found_path, sizeof(found_path), start_path, 0, ceiling_dirs);
|
58
|
+
//across_fs is always 0 as we can't automate the filesystem change tests
|
59
|
+
|
60
|
+
if (error < GIT_SUCCESS)
|
61
|
+
return error;
|
62
|
+
|
63
|
+
return strcmp(found_path, expected_path) ? GIT_ERROR : GIT_SUCCESS;
|
64
|
+
}
|
65
|
+
|
66
|
+
static int write_file(const char *path, const char *content)
|
67
|
+
{
|
68
|
+
int error;
|
69
|
+
git_file file;
|
70
|
+
|
71
|
+
if (git_futils_exists(path) == GIT_SUCCESS) {
|
72
|
+
error = p_unlink(path);
|
73
|
+
|
74
|
+
if (error < GIT_SUCCESS)
|
75
|
+
return error;
|
76
|
+
}
|
77
|
+
|
78
|
+
file = git_futils_creat_withpath(path, 0777, 0666);
|
79
|
+
if (file < GIT_SUCCESS)
|
80
|
+
return file;
|
81
|
+
|
82
|
+
error = p_write(file, content, strlen(content) * sizeof(char));
|
83
|
+
|
84
|
+
p_close(file);
|
85
|
+
|
86
|
+
return error;
|
87
|
+
}
|
88
|
+
|
89
|
+
//no check is performed on ceiling_dirs length, so be sure it's long enough
|
90
|
+
static int append_ceiling_dir(char *ceiling_dirs, const char *path)
|
91
|
+
{
|
92
|
+
int len = strlen(ceiling_dirs);
|
93
|
+
int error;
|
94
|
+
|
95
|
+
error = git_path_prettify_dir(ceiling_dirs + len + (len ? 1 : 0), path, NULL);
|
96
|
+
if (error < GIT_SUCCESS)
|
97
|
+
return git__rethrow(error, "Failed to append ceiling directory.");
|
98
|
+
|
99
|
+
if (len)
|
100
|
+
ceiling_dirs[len] = GIT_PATH_LIST_SEPARATOR;
|
101
|
+
|
102
|
+
return GIT_SUCCESS;
|
103
|
+
}
|
104
|
+
|
105
|
+
BEGIN_TEST(discover0, "test discover")
|
106
|
+
git_repository *repo;
|
107
|
+
char ceiling_dirs[GIT_PATH_MAX * 2] = "";
|
108
|
+
char repository_path[GIT_PATH_MAX];
|
109
|
+
char sub_repository_path[GIT_PATH_MAX];
|
110
|
+
char found_path[GIT_PATH_MAX];
|
111
|
+
const mode_t mode = 0777;
|
112
|
+
|
113
|
+
git_futils_mkdir_r(DISCOVER_FOLDER, mode);
|
114
|
+
must_pass(append_ceiling_dir(ceiling_dirs, TEMP_REPO_FOLDER));
|
115
|
+
|
116
|
+
must_be_true(git_repository_discover(repository_path, sizeof(repository_path), DISCOVER_FOLDER, 0, ceiling_dirs) == GIT_ENOTAREPO);
|
117
|
+
|
118
|
+
must_pass(git_repository_init(&repo, DISCOVER_FOLDER, 1));
|
119
|
+
must_pass(git_repository_discover(repository_path, sizeof(repository_path), DISCOVER_FOLDER, 0, ceiling_dirs));
|
120
|
+
git_repository_free(repo);
|
121
|
+
|
122
|
+
must_pass(git_repository_init(&repo, SUB_REPOSITORY_FOLDER, 0));
|
123
|
+
must_pass(git_futils_mkdir_r(SUB_REPOSITORY_FOLDER_SUB_SUB_SUB, mode));
|
124
|
+
must_pass(git_repository_discover(sub_repository_path, sizeof(sub_repository_path), SUB_REPOSITORY_FOLDER, 0, ceiling_dirs));
|
125
|
+
|
126
|
+
must_pass(git_futils_mkdir_r(SUB_REPOSITORY_FOLDER_SUB_SUB_SUB, mode));
|
127
|
+
must_pass(ensure_repository_discover(SUB_REPOSITORY_FOLDER_SUB, ceiling_dirs, sub_repository_path));
|
128
|
+
must_pass(ensure_repository_discover(SUB_REPOSITORY_FOLDER_SUB_SUB, ceiling_dirs, sub_repository_path));
|
129
|
+
must_pass(ensure_repository_discover(SUB_REPOSITORY_FOLDER_SUB_SUB_SUB, ceiling_dirs, sub_repository_path));
|
130
|
+
|
131
|
+
must_pass(git_futils_mkdir_r(REPOSITORY_ALTERNATE_FOLDER_SUB_SUB_SUB, mode));
|
132
|
+
must_pass(write_file(REPOSITORY_ALTERNATE_FOLDER "/" DOT_GIT, "gitdir: ../" SUB_REPOSITORY_FOLDER_NAME "/" DOT_GIT));
|
133
|
+
must_pass(write_file(REPOSITORY_ALTERNATE_FOLDER_SUB_SUB "/" DOT_GIT, "gitdir: ../../../" SUB_REPOSITORY_FOLDER_NAME "/" DOT_GIT));
|
134
|
+
must_pass(write_file(REPOSITORY_ALTERNATE_FOLDER_SUB_SUB_SUB "/" DOT_GIT, "gitdir: ../../../../"));
|
135
|
+
must_pass(ensure_repository_discover(REPOSITORY_ALTERNATE_FOLDER, ceiling_dirs, sub_repository_path));
|
136
|
+
must_pass(ensure_repository_discover(REPOSITORY_ALTERNATE_FOLDER_SUB, ceiling_dirs, sub_repository_path));
|
137
|
+
must_pass(ensure_repository_discover(REPOSITORY_ALTERNATE_FOLDER_SUB_SUB, ceiling_dirs, sub_repository_path));
|
138
|
+
must_pass(ensure_repository_discover(REPOSITORY_ALTERNATE_FOLDER_SUB_SUB_SUB, ceiling_dirs, repository_path));
|
139
|
+
|
140
|
+
must_pass(git_futils_mkdir_r(ALTERNATE_MALFORMED_FOLDER1, mode));
|
141
|
+
must_pass(write_file(ALTERNATE_MALFORMED_FOLDER1 "/" DOT_GIT, "Anything but not gitdir:"));
|
142
|
+
must_pass(git_futils_mkdir_r(ALTERNATE_MALFORMED_FOLDER2, mode));
|
143
|
+
must_pass(write_file(ALTERNATE_MALFORMED_FOLDER2 "/" DOT_GIT, "gitdir:"));
|
144
|
+
must_pass(git_futils_mkdir_r(ALTERNATE_MALFORMED_FOLDER3, mode));
|
145
|
+
must_pass(write_file(ALTERNATE_MALFORMED_FOLDER3 "/" DOT_GIT, "gitdir: \n\n\n"));
|
146
|
+
must_pass(git_futils_mkdir_r(ALTERNATE_NOT_FOUND_FOLDER, mode));
|
147
|
+
must_pass(write_file(ALTERNATE_NOT_FOUND_FOLDER "/" DOT_GIT, "gitdir: a_repository_that_surely_does_not_exist"));
|
148
|
+
must_fail(git_repository_discover(found_path, sizeof(found_path), ALTERNATE_MALFORMED_FOLDER1, 0, ceiling_dirs));
|
149
|
+
must_fail(git_repository_discover(found_path, sizeof(found_path), ALTERNATE_MALFORMED_FOLDER2, 0, ceiling_dirs));
|
150
|
+
must_fail(git_repository_discover(found_path, sizeof(found_path), ALTERNATE_MALFORMED_FOLDER3, 0, ceiling_dirs));
|
151
|
+
must_fail(git_repository_discover(found_path, sizeof(found_path), ALTERNATE_NOT_FOUND_FOLDER, 0, ceiling_dirs));
|
152
|
+
|
153
|
+
must_pass(append_ceiling_dir(ceiling_dirs, SUB_REPOSITORY_FOLDER));
|
154
|
+
//this must pass as ceiling_directories cannot predent the current
|
155
|
+
//working directory to be checked
|
156
|
+
must_pass(git_repository_discover(found_path, sizeof(found_path), SUB_REPOSITORY_FOLDER, 0, ceiling_dirs));
|
157
|
+
must_fail(git_repository_discover(found_path, sizeof(found_path), SUB_REPOSITORY_FOLDER_SUB, 0, ceiling_dirs));
|
158
|
+
must_fail(git_repository_discover(found_path, sizeof(found_path), SUB_REPOSITORY_FOLDER_SUB_SUB, 0, ceiling_dirs));
|
159
|
+
must_fail(git_repository_discover(found_path, sizeof(found_path), SUB_REPOSITORY_FOLDER_SUB_SUB_SUB, 0, ceiling_dirs));
|
160
|
+
|
161
|
+
//.gitfile redirection should not be affected by ceiling directories
|
162
|
+
must_pass(ensure_repository_discover(REPOSITORY_ALTERNATE_FOLDER, ceiling_dirs, sub_repository_path));
|
163
|
+
must_pass(ensure_repository_discover(REPOSITORY_ALTERNATE_FOLDER_SUB, ceiling_dirs, sub_repository_path));
|
164
|
+
must_pass(ensure_repository_discover(REPOSITORY_ALTERNATE_FOLDER_SUB_SUB, ceiling_dirs, sub_repository_path));
|
165
|
+
must_pass(ensure_repository_discover(REPOSITORY_ALTERNATE_FOLDER_SUB_SUB_SUB, ceiling_dirs, repository_path));
|
166
|
+
|
167
|
+
must_pass(git_futils_rmdir_r(TEMP_REPO_FOLDER, 1));
|
168
|
+
git_repository_free(repo);
|
169
|
+
END_TEST
|
170
|
+
|
171
|
+
BEGIN_SUITE(repository)
|
172
|
+
ADD_TEST(discover0);
|
173
|
+
END_SUITE
|
174
|
+
|
@@ -0,0 +1,41 @@
|
|
1
|
+
/*
|
2
|
+
* This file is free software; you can redistribute it and/or modify
|
3
|
+
* it under the terms of the GNU General Public License, version 2,
|
4
|
+
* as published by the Free Software Foundation.
|
5
|
+
*
|
6
|
+
* In addition to the permissions in the GNU General Public License,
|
7
|
+
* the authors give you unlimited permission to link the compiled
|
8
|
+
* version of this file into combinations with other programs,
|
9
|
+
* and to distribute those combinations without any restriction
|
10
|
+
* coming from the use of this file. (The General Public License
|
11
|
+
* restrictions do apply in other respects; for example, they cover
|
12
|
+
* modification of the file, and distribution when not linked into
|
13
|
+
* a combined executable.)
|
14
|
+
*
|
15
|
+
* This file is distributed in the hope that it will be useful, but
|
16
|
+
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
17
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
18
|
+
* General Public License for more details.
|
19
|
+
*
|
20
|
+
* You should have received a copy of the GNU General Public License
|
21
|
+
* along with this program; see the file COPYING. If not, write to
|
22
|
+
* the Free Software Foundation, 51 Franklin Street, Fifth Floor,
|
23
|
+
* Boston, MA 02110-1301, USA.
|
24
|
+
*/
|
25
|
+
#include "test_lib.h"
|
26
|
+
#include "test_helpers.h"
|
27
|
+
#include "cache.h"
|
28
|
+
|
29
|
+
|
30
|
+
typedef struct {
|
31
|
+
git_cached_obj cached;
|
32
|
+
unsigned int __dummy;
|
33
|
+
} ttest_obj;
|
34
|
+
|
35
|
+
BEGIN_TEST(cache0, "run several threads polling the cache at the same time")
|
36
|
+
|
37
|
+
END_TEST
|
38
|
+
|
39
|
+
BEGIN_SUITE(threads)
|
40
|
+
ADD_TEST(cache0);
|
41
|
+
END_SUITE
|
@@ -0,0 +1,61 @@
|
|
1
|
+
/*
|
2
|
+
* This file is free software; you can redistribute it and/or modify
|
3
|
+
* it under the terms of the GNU General Public License, version 2,
|
4
|
+
* as published by the Free Software Foundation.
|
5
|
+
*
|
6
|
+
* In addition to the permissions in the GNU General Public License,
|
7
|
+
* the authors give you unlimited permission to link the compiled
|
8
|
+
* version of this file into combinations with other programs,
|
9
|
+
* and to distribute those combinations without any restriction
|
10
|
+
* coming from the use of this file. (The General Public License
|
11
|
+
* restrictions do apply in other respects; for example, they cover
|
12
|
+
* modification of the file, and distribution when not linked into
|
13
|
+
* a combined executable.)
|
14
|
+
*
|
15
|
+
* This file is distributed in the hope that it will be useful, but
|
16
|
+
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
17
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
18
|
+
* General Public License for more details.
|
19
|
+
*
|
20
|
+
* You should have received a copy of the GNU General Public License
|
21
|
+
* along with this program; see the file COPYING. If not, write to
|
22
|
+
* the Free Software Foundation, 51 Franklin Street, Fifth Floor,
|
23
|
+
* Boston, MA 02110-1301, USA.
|
24
|
+
*/
|
25
|
+
#include "test_lib.h"
|
26
|
+
#include "test_helpers.h"
|
27
|
+
|
28
|
+
#include <git2.h>
|
29
|
+
#include "buffer.h"
|
30
|
+
|
31
|
+
const char *test_string = "Have you seen that? Have you seeeen that??";
|
32
|
+
|
33
|
+
BEGIN_TEST(buf0, "check that resizing works properly")
|
34
|
+
git_buf buf = GIT_BUF_INIT;
|
35
|
+
git_buf_puts(&buf, test_string);
|
36
|
+
|
37
|
+
must_be_true(git_buf_oom(&buf) == 0);
|
38
|
+
must_be_true(strcmp(git_buf_cstr(&buf), test_string) == 0);
|
39
|
+
|
40
|
+
git_buf_puts(&buf, test_string);
|
41
|
+
must_be_true(strlen(git_buf_cstr(&buf)) == strlen(test_string) * 2);
|
42
|
+
git_buf_free(&buf);
|
43
|
+
END_TEST
|
44
|
+
|
45
|
+
BEGIN_TEST(buf1, "check that printf works properly")
|
46
|
+
git_buf buf = GIT_BUF_INIT;
|
47
|
+
|
48
|
+
git_buf_printf(&buf, "%s %s %d ", "shoop", "da", 23);
|
49
|
+
must_be_true(git_buf_oom(&buf) == 0);
|
50
|
+
must_be_true(strcmp(git_buf_cstr(&buf), "shoop da 23 ") == 0);
|
51
|
+
|
52
|
+
git_buf_printf(&buf, "%s %d", "woop", 42);
|
53
|
+
must_be_true(git_buf_oom(&buf) == 0);
|
54
|
+
must_be_true(strcmp(git_buf_cstr(&buf), "shoop da 23 woop 42") == 0);
|
55
|
+
git_buf_free(&buf);
|
56
|
+
END_TEST
|
57
|
+
|
58
|
+
BEGIN_SUITE(buffers)
|
59
|
+
ADD_TEST(buf0)
|
60
|
+
ADD_TEST(buf1)
|
61
|
+
END_SUITE
|
@@ -0,0 +1,448 @@
|
|
1
|
+
/*
|
2
|
+
* This file is free software; you can redistribute it and/or modify
|
3
|
+
* it under the terms of the GNU General Public License, version 2,
|
4
|
+
* as published by the Free Software Foundation.
|
5
|
+
*
|
6
|
+
* In addition to the permissions in the GNU General Public License,
|
7
|
+
* the authors give you unlimited permission to link the compiled
|
8
|
+
* version of this file into combinations with other programs,
|
9
|
+
* and to distribute those combinations without any restriction
|
10
|
+
* coming from the use of this file. (The General Public License
|
11
|
+
* restrictions do apply in other respects; for example, they cover
|
12
|
+
* modification of the file, and distribution when not linked into
|
13
|
+
* a combined executable.)
|
14
|
+
*
|
15
|
+
* This file is distributed in the hope that it will be useful, but
|
16
|
+
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
17
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
18
|
+
* General Public License for more details.
|
19
|
+
*
|
20
|
+
* You should have received a copy of the GNU General Public License
|
21
|
+
* along with this program; see the file COPYING. If not, write to
|
22
|
+
* the Free Software Foundation, 51 Franklin Street, Fifth Floor,
|
23
|
+
* Boston, MA 02110-1301, USA.
|
24
|
+
*/
|
25
|
+
|
26
|
+
#include "test_lib.h"
|
27
|
+
#include "test_helpers.h"
|
28
|
+
#include "fileops.h"
|
29
|
+
#include "git2/status.h"
|
30
|
+
|
31
|
+
static const char *test_blob_oid = "d4fa8600b4f37d7516bef4816ae2c64dbf029e3a";
|
32
|
+
|
33
|
+
#define STATUS_WORKDIR_FOLDER TEST_RESOURCES "/status/"
|
34
|
+
#define STATUS_REPOSITORY_TEMP_FOLDER TEMP_REPO_FOLDER ".gitted/"
|
35
|
+
|
36
|
+
static int file_create(const char *filename, const char *content)
|
37
|
+
{
|
38
|
+
int fd;
|
39
|
+
|
40
|
+
fd = p_creat(filename, 0666);
|
41
|
+
if (fd == 0)
|
42
|
+
return GIT_ERROR;
|
43
|
+
if (p_write(fd, content, strlen(content)) != 0)
|
44
|
+
return GIT_ERROR;
|
45
|
+
if (p_close(fd) != 0)
|
46
|
+
return GIT_ERROR;
|
47
|
+
|
48
|
+
return GIT_SUCCESS;
|
49
|
+
}
|
50
|
+
|
51
|
+
BEGIN_TEST(file0, "test retrieving OID from a file apart from the ODB")
|
52
|
+
git_oid expected_id, actual_id;
|
53
|
+
char filename[] = "new_file";
|
54
|
+
|
55
|
+
must_pass(file_create(filename, "new_file\n\0"));
|
56
|
+
|
57
|
+
must_pass(git_odb_hashfile(&actual_id, filename, GIT_OBJ_BLOB));
|
58
|
+
|
59
|
+
must_pass(git_oid_fromstr(&expected_id, test_blob_oid));
|
60
|
+
must_be_true(git_oid_cmp(&expected_id, &actual_id) == 0);
|
61
|
+
|
62
|
+
must_pass(p_unlink(filename));
|
63
|
+
END_TEST
|
64
|
+
|
65
|
+
static const char *entry_paths0[] = {
|
66
|
+
"file_deleted",
|
67
|
+
"modified_file",
|
68
|
+
"new_file",
|
69
|
+
"staged_changes",
|
70
|
+
"staged_changes_file_deleted",
|
71
|
+
"staged_changes_modified_file",
|
72
|
+
"staged_delete_file_deleted",
|
73
|
+
"staged_delete_modified_file",
|
74
|
+
"staged_new_file",
|
75
|
+
"staged_new_file_deleted_file",
|
76
|
+
"staged_new_file_modified_file",
|
77
|
+
|
78
|
+
"subdir/deleted_file",
|
79
|
+
"subdir/modified_file",
|
80
|
+
"subdir/new_file",
|
81
|
+
};
|
82
|
+
|
83
|
+
static const unsigned int entry_statuses0[] = {
|
84
|
+
GIT_STATUS_WT_DELETED,
|
85
|
+
GIT_STATUS_WT_MODIFIED,
|
86
|
+
GIT_STATUS_WT_NEW,
|
87
|
+
GIT_STATUS_INDEX_MODIFIED,
|
88
|
+
GIT_STATUS_INDEX_MODIFIED | GIT_STATUS_WT_DELETED,
|
89
|
+
GIT_STATUS_INDEX_MODIFIED | GIT_STATUS_WT_MODIFIED,
|
90
|
+
GIT_STATUS_INDEX_DELETED,
|
91
|
+
GIT_STATUS_INDEX_DELETED | GIT_STATUS_WT_NEW,
|
92
|
+
GIT_STATUS_INDEX_NEW,
|
93
|
+
GIT_STATUS_INDEX_NEW | GIT_STATUS_WT_DELETED,
|
94
|
+
GIT_STATUS_INDEX_NEW | GIT_STATUS_WT_MODIFIED,
|
95
|
+
|
96
|
+
GIT_STATUS_WT_DELETED,
|
97
|
+
GIT_STATUS_WT_MODIFIED,
|
98
|
+
GIT_STATUS_WT_NEW,
|
99
|
+
};
|
100
|
+
|
101
|
+
#define ENTRY_COUNT0 14
|
102
|
+
|
103
|
+
struct status_entry_counts {
|
104
|
+
int wrong_status_flags_count;
|
105
|
+
int wrong_sorted_path;
|
106
|
+
int entry_count;
|
107
|
+
const unsigned int* expected_statuses;
|
108
|
+
const char** expected_paths;
|
109
|
+
int expected_entry_count;
|
110
|
+
};
|
111
|
+
|
112
|
+
static int status_cb(const char *path, unsigned int status_flags, void *payload)
|
113
|
+
{
|
114
|
+
struct status_entry_counts *counts = (struct status_entry_counts *)payload;
|
115
|
+
|
116
|
+
if (counts->entry_count >= counts->expected_entry_count) {
|
117
|
+
counts->wrong_status_flags_count++;
|
118
|
+
goto exit;
|
119
|
+
}
|
120
|
+
|
121
|
+
if (strcmp(path, counts->expected_paths[counts->entry_count])) {
|
122
|
+
counts->wrong_sorted_path++;
|
123
|
+
goto exit;
|
124
|
+
}
|
125
|
+
|
126
|
+
if (status_flags != counts->expected_statuses[counts->entry_count])
|
127
|
+
counts->wrong_status_flags_count++;
|
128
|
+
|
129
|
+
exit:
|
130
|
+
counts->entry_count++;
|
131
|
+
return GIT_SUCCESS;
|
132
|
+
}
|
133
|
+
|
134
|
+
BEGIN_TEST(statuscb0, "test retrieving status for worktree of repository")
|
135
|
+
git_repository *repo;
|
136
|
+
struct status_entry_counts counts;
|
137
|
+
|
138
|
+
must_pass(copydir_recurs(STATUS_WORKDIR_FOLDER, TEMP_REPO_FOLDER));
|
139
|
+
must_pass(p_rename(STATUS_REPOSITORY_TEMP_FOLDER, TEST_STD_REPO_FOLDER));
|
140
|
+
must_pass(git_repository_open(&repo, TEST_STD_REPO_FOLDER));
|
141
|
+
|
142
|
+
memset(&counts, 0x0, sizeof(struct status_entry_counts));
|
143
|
+
counts.expected_entry_count = ENTRY_COUNT0;
|
144
|
+
counts.expected_paths = entry_paths0;
|
145
|
+
counts.expected_statuses = entry_statuses0;
|
146
|
+
|
147
|
+
must_pass(git_status_foreach(repo, status_cb, &counts));
|
148
|
+
must_be_true(counts.entry_count == counts.expected_entry_count);
|
149
|
+
must_be_true(counts.wrong_status_flags_count == 0);
|
150
|
+
must_be_true(counts.wrong_sorted_path == 0);
|
151
|
+
|
152
|
+
git_repository_free(repo);
|
153
|
+
|
154
|
+
git_futils_rmdir_r(TEMP_REPO_FOLDER, 1);
|
155
|
+
END_TEST
|
156
|
+
|
157
|
+
static int status_cb1(const char *GIT_UNUSED(path), unsigned int GIT_UNUSED(status_flags), void *payload)
|
158
|
+
{
|
159
|
+
int *count = (int *)payload;;
|
160
|
+
|
161
|
+
GIT_UNUSED_ARG(path);
|
162
|
+
GIT_UNUSED_ARG(status_flags);
|
163
|
+
|
164
|
+
(void) *count++;
|
165
|
+
|
166
|
+
return GIT_SUCCESS;
|
167
|
+
}
|
168
|
+
|
169
|
+
BEGIN_TEST(statuscb1, "test retrieving status for a worktree of an empty repository")
|
170
|
+
git_repository *repo;
|
171
|
+
int count = 0;
|
172
|
+
|
173
|
+
must_pass(copydir_recurs(EMPTY_REPOSITORY_FOLDER, TEST_STD_REPO_FOLDER));
|
174
|
+
must_pass(remove_placeholders(TEST_STD_REPO_FOLDER, "dummy-marker.txt"));
|
175
|
+
must_pass(git_repository_open(&repo, TEST_STD_REPO_FOLDER));
|
176
|
+
|
177
|
+
must_pass(git_status_foreach(repo, status_cb1, &count));
|
178
|
+
must_be_true(count == 0);
|
179
|
+
|
180
|
+
git_repository_free(repo);
|
181
|
+
|
182
|
+
git_futils_rmdir_r(TEMP_REPO_FOLDER, 1);
|
183
|
+
END_TEST
|
184
|
+
|
185
|
+
static const char *entry_paths2[] = {
|
186
|
+
"current_file",
|
187
|
+
"file_deleted",
|
188
|
+
"modified_file",
|
189
|
+
"staged_changes",
|
190
|
+
"staged_changes_file_deleted",
|
191
|
+
"staged_changes_modified_file",
|
192
|
+
"staged_delete_file_deleted",
|
193
|
+
"staged_delete_modified_file",
|
194
|
+
"staged_new_file",
|
195
|
+
"staged_new_file_deleted_file",
|
196
|
+
"staged_new_file_modified_file",
|
197
|
+
"subdir/current_file",
|
198
|
+
"subdir/deleted_file",
|
199
|
+
"subdir/modified_file",
|
200
|
+
};
|
201
|
+
|
202
|
+
static const unsigned int entry_statuses2[] = {
|
203
|
+
GIT_STATUS_WT_DELETED,
|
204
|
+
GIT_STATUS_WT_DELETED,
|
205
|
+
GIT_STATUS_WT_DELETED,
|
206
|
+
GIT_STATUS_WT_DELETED | GIT_STATUS_INDEX_MODIFIED,
|
207
|
+
GIT_STATUS_WT_DELETED | GIT_STATUS_INDEX_MODIFIED,
|
208
|
+
GIT_STATUS_WT_DELETED | GIT_STATUS_INDEX_MODIFIED,
|
209
|
+
GIT_STATUS_INDEX_DELETED,
|
210
|
+
GIT_STATUS_INDEX_DELETED,
|
211
|
+
GIT_STATUS_WT_DELETED | GIT_STATUS_INDEX_NEW,
|
212
|
+
GIT_STATUS_WT_DELETED | GIT_STATUS_INDEX_NEW,
|
213
|
+
GIT_STATUS_WT_DELETED | GIT_STATUS_INDEX_NEW,
|
214
|
+
GIT_STATUS_WT_DELETED,
|
215
|
+
GIT_STATUS_WT_DELETED,
|
216
|
+
GIT_STATUS_WT_DELETED,
|
217
|
+
};
|
218
|
+
|
219
|
+
#define ENTRY_COUNT2 14
|
220
|
+
|
221
|
+
BEGIN_TEST(statuscb2, "test retrieving status for a purged worktree of an valid repository")
|
222
|
+
git_repository *repo;
|
223
|
+
struct status_entry_counts counts;
|
224
|
+
|
225
|
+
must_pass(copydir_recurs(STATUS_WORKDIR_FOLDER, TEMP_REPO_FOLDER));
|
226
|
+
must_pass(p_rename(STATUS_REPOSITORY_TEMP_FOLDER, TEST_STD_REPO_FOLDER));
|
227
|
+
must_pass(git_repository_open(&repo, TEST_STD_REPO_FOLDER));
|
228
|
+
|
229
|
+
/* Purging the working */
|
230
|
+
must_pass(p_unlink(TEMP_REPO_FOLDER "current_file"));
|
231
|
+
must_pass(p_unlink(TEMP_REPO_FOLDER "modified_file"));
|
232
|
+
must_pass(p_unlink(TEMP_REPO_FOLDER "new_file"));
|
233
|
+
must_pass(p_unlink(TEMP_REPO_FOLDER "staged_changes"));
|
234
|
+
must_pass(p_unlink(TEMP_REPO_FOLDER "staged_changes_modified_file"));
|
235
|
+
must_pass(p_unlink(TEMP_REPO_FOLDER "staged_delete_modified_file"));
|
236
|
+
must_pass(p_unlink(TEMP_REPO_FOLDER "staged_new_file"));
|
237
|
+
must_pass(p_unlink(TEMP_REPO_FOLDER "staged_new_file_modified_file"));
|
238
|
+
must_pass(git_futils_rmdir_r(TEMP_REPO_FOLDER "subdir", 1));
|
239
|
+
|
240
|
+
memset(&counts, 0x0, sizeof(struct status_entry_counts));
|
241
|
+
counts.expected_entry_count = ENTRY_COUNT2;
|
242
|
+
counts.expected_paths = entry_paths2;
|
243
|
+
counts.expected_statuses = entry_statuses2;
|
244
|
+
|
245
|
+
must_pass(git_status_foreach(repo, status_cb, &counts));
|
246
|
+
must_be_true(counts.entry_count == counts.expected_entry_count);
|
247
|
+
must_be_true(counts.wrong_status_flags_count == 0);
|
248
|
+
must_be_true(counts.wrong_sorted_path == 0);
|
249
|
+
|
250
|
+
git_repository_free(repo);
|
251
|
+
|
252
|
+
git_futils_rmdir_r(TEMP_REPO_FOLDER, 1);
|
253
|
+
END_TEST
|
254
|
+
|
255
|
+
static const char *entry_paths3[] = {
|
256
|
+
".HEADER",
|
257
|
+
"42-is-not-prime.sigh",
|
258
|
+
"README.md",
|
259
|
+
"current_file",
|
260
|
+
"current_file/current_file",
|
261
|
+
"current_file/modified_file",
|
262
|
+
"current_file/new_file",
|
263
|
+
"file_deleted",
|
264
|
+
"modified_file",
|
265
|
+
"new_file",
|
266
|
+
"staged_changes",
|
267
|
+
"staged_changes_file_deleted",
|
268
|
+
"staged_changes_modified_file",
|
269
|
+
"staged_delete_file_deleted",
|
270
|
+
"staged_delete_modified_file",
|
271
|
+
"staged_new_file",
|
272
|
+
"staged_new_file_deleted_file",
|
273
|
+
"staged_new_file_modified_file",
|
274
|
+
"subdir",
|
275
|
+
"subdir/current_file",
|
276
|
+
"subdir/deleted_file",
|
277
|
+
"subdir/modified_file",
|
278
|
+
};
|
279
|
+
|
280
|
+
static const unsigned int entry_statuses3[] = {
|
281
|
+
GIT_STATUS_WT_NEW,
|
282
|
+
GIT_STATUS_WT_NEW,
|
283
|
+
GIT_STATUS_WT_NEW,
|
284
|
+
GIT_STATUS_WT_DELETED,
|
285
|
+
GIT_STATUS_WT_NEW,
|
286
|
+
GIT_STATUS_WT_NEW,
|
287
|
+
GIT_STATUS_WT_NEW,
|
288
|
+
GIT_STATUS_WT_DELETED,
|
289
|
+
GIT_STATUS_WT_MODIFIED,
|
290
|
+
GIT_STATUS_WT_NEW,
|
291
|
+
GIT_STATUS_INDEX_MODIFIED,
|
292
|
+
GIT_STATUS_WT_DELETED | GIT_STATUS_INDEX_MODIFIED,
|
293
|
+
GIT_STATUS_WT_MODIFIED | GIT_STATUS_INDEX_MODIFIED,
|
294
|
+
GIT_STATUS_INDEX_DELETED,
|
295
|
+
GIT_STATUS_WT_NEW | GIT_STATUS_INDEX_DELETED,
|
296
|
+
GIT_STATUS_INDEX_NEW,
|
297
|
+
GIT_STATUS_WT_DELETED | GIT_STATUS_INDEX_NEW,
|
298
|
+
GIT_STATUS_WT_MODIFIED | GIT_STATUS_INDEX_NEW,
|
299
|
+
GIT_STATUS_WT_NEW,
|
300
|
+
GIT_STATUS_WT_DELETED,
|
301
|
+
GIT_STATUS_WT_DELETED,
|
302
|
+
GIT_STATUS_WT_DELETED,
|
303
|
+
};
|
304
|
+
|
305
|
+
#define ENTRY_COUNT3 22
|
306
|
+
|
307
|
+
BEGIN_TEST(statuscb3, "test retrieving status for a worktree where a file and a subdir have been renamed and some files have been added")
|
308
|
+
git_repository *repo;
|
309
|
+
struct status_entry_counts counts;
|
310
|
+
|
311
|
+
must_pass(copydir_recurs(STATUS_WORKDIR_FOLDER, TEMP_REPO_FOLDER));
|
312
|
+
must_pass(p_rename(STATUS_REPOSITORY_TEMP_FOLDER, TEST_STD_REPO_FOLDER));
|
313
|
+
must_pass(git_repository_open(&repo, TEST_STD_REPO_FOLDER));
|
314
|
+
|
315
|
+
must_pass(p_rename(TEMP_REPO_FOLDER "current_file", TEMP_REPO_FOLDER "swap"));
|
316
|
+
must_pass(p_rename(TEMP_REPO_FOLDER "subdir", TEMP_REPO_FOLDER "current_file"));
|
317
|
+
must_pass(p_rename(TEMP_REPO_FOLDER "swap", TEMP_REPO_FOLDER "subdir"));
|
318
|
+
|
319
|
+
must_pass(file_create(TEMP_REPO_FOLDER ".HEADER", "dummy"));
|
320
|
+
must_pass(file_create(TEMP_REPO_FOLDER "42-is-not-prime.sigh", "dummy"));
|
321
|
+
must_pass(file_create(TEMP_REPO_FOLDER "README.md", "dummy"));
|
322
|
+
|
323
|
+
memset(&counts, 0x0, sizeof(struct status_entry_counts));
|
324
|
+
counts.expected_entry_count = ENTRY_COUNT3;
|
325
|
+
counts.expected_paths = entry_paths3;
|
326
|
+
counts.expected_statuses = entry_statuses3;
|
327
|
+
|
328
|
+
must_pass(git_status_foreach(repo, status_cb, &counts));
|
329
|
+
must_be_true(counts.entry_count == counts.expected_entry_count);
|
330
|
+
must_be_true(counts.wrong_status_flags_count == 0);
|
331
|
+
must_be_true(counts.wrong_sorted_path == 0);
|
332
|
+
|
333
|
+
git_repository_free(repo);
|
334
|
+
|
335
|
+
git_futils_rmdir_r(TEMP_REPO_FOLDER, 1);
|
336
|
+
END_TEST
|
337
|
+
|
338
|
+
BEGIN_TEST(singlestatus0, "test retrieving status for single file")
|
339
|
+
git_repository *repo;
|
340
|
+
unsigned int status_flags;
|
341
|
+
int i;
|
342
|
+
|
343
|
+
must_pass(copydir_recurs(STATUS_WORKDIR_FOLDER, TEMP_REPO_FOLDER));
|
344
|
+
must_pass(p_rename(STATUS_REPOSITORY_TEMP_FOLDER, TEST_STD_REPO_FOLDER));
|
345
|
+
must_pass(git_repository_open(&repo, TEST_STD_REPO_FOLDER));
|
346
|
+
|
347
|
+
for (i = 0; i < ENTRY_COUNT0; ++i) {
|
348
|
+
must_pass(git_status_file(&status_flags, repo, entry_paths0[i]));
|
349
|
+
must_be_true(status_flags == entry_statuses0[i]);
|
350
|
+
}
|
351
|
+
|
352
|
+
git_repository_free(repo);
|
353
|
+
|
354
|
+
git_futils_rmdir_r(TEMP_REPO_FOLDER, 1);
|
355
|
+
END_TEST
|
356
|
+
|
357
|
+
BEGIN_TEST(singlestatus1, "test retrieving status for nonexistent file")
|
358
|
+
git_repository *repo;
|
359
|
+
unsigned int status_flags;
|
360
|
+
int error;
|
361
|
+
|
362
|
+
must_pass(copydir_recurs(STATUS_WORKDIR_FOLDER, TEMP_REPO_FOLDER));
|
363
|
+
must_pass(p_rename(STATUS_REPOSITORY_TEMP_FOLDER, TEST_STD_REPO_FOLDER));
|
364
|
+
must_pass(git_repository_open(&repo, TEST_STD_REPO_FOLDER));
|
365
|
+
|
366
|
+
// "nonexistent" does not exist in HEAD, Index or the worktree
|
367
|
+
error = git_status_file(&status_flags, repo, "nonexistent");
|
368
|
+
must_be_true(error == GIT_ENOTFOUND);
|
369
|
+
|
370
|
+
git_repository_free(repo);
|
371
|
+
|
372
|
+
git_futils_rmdir_r(TEMP_REPO_FOLDER, 1);
|
373
|
+
END_TEST
|
374
|
+
|
375
|
+
BEGIN_TEST(singlestatus2, "test retrieving status for a non existent file in an empty repository")
|
376
|
+
git_repository *repo;
|
377
|
+
unsigned int status_flags;
|
378
|
+
int error;
|
379
|
+
|
380
|
+
must_pass(copydir_recurs(EMPTY_REPOSITORY_FOLDER, TEST_STD_REPO_FOLDER));
|
381
|
+
must_pass(remove_placeholders(TEST_STD_REPO_FOLDER, "dummy-marker.txt"));
|
382
|
+
must_pass(git_repository_open(&repo, TEST_STD_REPO_FOLDER));
|
383
|
+
|
384
|
+
error = git_status_file(&status_flags, repo, "nonexistent");
|
385
|
+
must_be_true(error == GIT_ENOTFOUND);
|
386
|
+
|
387
|
+
git_repository_free(repo);
|
388
|
+
|
389
|
+
git_futils_rmdir_r(TEMP_REPO_FOLDER, 1);
|
390
|
+
END_TEST
|
391
|
+
|
392
|
+
BEGIN_TEST(singlestatus3, "test retrieving status for a new file in an empty repository")
|
393
|
+
git_repository *repo;
|
394
|
+
unsigned int status_flags;
|
395
|
+
char file_path[GIT_PATH_MAX];
|
396
|
+
char filename[] = "new_file";
|
397
|
+
int fd;
|
398
|
+
|
399
|
+
must_pass(copydir_recurs(EMPTY_REPOSITORY_FOLDER, TEST_STD_REPO_FOLDER));
|
400
|
+
must_pass(remove_placeholders(TEST_STD_REPO_FOLDER, "dummy-marker.txt"));
|
401
|
+
|
402
|
+
git_path_join(file_path, TEMP_REPO_FOLDER, filename);
|
403
|
+
fd = p_creat(file_path, 0666);
|
404
|
+
must_pass(fd);
|
405
|
+
must_pass(p_write(fd, "new_file\n", 9));
|
406
|
+
must_pass(p_close(fd));
|
407
|
+
|
408
|
+
must_pass(git_repository_open(&repo, TEST_STD_REPO_FOLDER));
|
409
|
+
|
410
|
+
must_pass(git_status_file(&status_flags, repo, filename));
|
411
|
+
must_be_true(status_flags == GIT_STATUS_WT_NEW);
|
412
|
+
|
413
|
+
git_repository_free(repo);
|
414
|
+
|
415
|
+
git_futils_rmdir_r(TEMP_REPO_FOLDER, 1);
|
416
|
+
END_TEST
|
417
|
+
|
418
|
+
BEGIN_TEST(singlestatus4, "can't determine the status for a folder")
|
419
|
+
git_repository *repo;
|
420
|
+
unsigned int status_flags;
|
421
|
+
int error;
|
422
|
+
|
423
|
+
must_pass(copydir_recurs(STATUS_WORKDIR_FOLDER, TEMP_REPO_FOLDER));
|
424
|
+
must_pass(p_rename(STATUS_REPOSITORY_TEMP_FOLDER, TEST_STD_REPO_FOLDER));
|
425
|
+
must_pass(git_repository_open(&repo, TEST_STD_REPO_FOLDER));
|
426
|
+
|
427
|
+
error = git_status_file(&status_flags, repo, "subdir");
|
428
|
+
must_be_true(error == GIT_EINVALIDPATH);
|
429
|
+
|
430
|
+
git_repository_free(repo);
|
431
|
+
|
432
|
+
git_futils_rmdir_r(TEMP_REPO_FOLDER, 1);
|
433
|
+
END_TEST
|
434
|
+
|
435
|
+
BEGIN_SUITE(status)
|
436
|
+
ADD_TEST(file0);
|
437
|
+
|
438
|
+
ADD_TEST(statuscb0);
|
439
|
+
ADD_TEST(statuscb1);
|
440
|
+
ADD_TEST(statuscb2);
|
441
|
+
ADD_TEST(statuscb3);
|
442
|
+
|
443
|
+
ADD_TEST(singlestatus0);
|
444
|
+
ADD_TEST(singlestatus1);
|
445
|
+
ADD_TEST(singlestatus2);
|
446
|
+
ADD_TEST(singlestatus3);
|
447
|
+
ADD_TEST(singlestatus4);
|
448
|
+
END_SUITE
|