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,1294 @@
|
|
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 "repository.h"
|
29
|
+
|
30
|
+
#include "git2/reflog.h"
|
31
|
+
#include "reflog.h"
|
32
|
+
|
33
|
+
static const char *loose_tag_ref_name = "refs/tags/e90810b";
|
34
|
+
static const char *non_existing_tag_ref_name = "refs/tags/i-do-not-exist";
|
35
|
+
|
36
|
+
BEGIN_TEST(readtag0, "lookup a loose tag reference")
|
37
|
+
git_repository *repo;
|
38
|
+
git_reference *reference;
|
39
|
+
git_object *object;
|
40
|
+
char ref_name_from_tag_name[GIT_REFNAME_MAX];
|
41
|
+
|
42
|
+
must_pass(git_repository_open(&repo, REPOSITORY_FOLDER));
|
43
|
+
|
44
|
+
must_pass(git_reference_lookup(&reference, repo, loose_tag_ref_name));
|
45
|
+
must_be_true(git_reference_type(reference) & GIT_REF_OID);
|
46
|
+
must_be_true(git_reference_is_packed(reference) == 0);
|
47
|
+
must_be_true(strcmp(reference->name, loose_tag_ref_name) == 0);
|
48
|
+
|
49
|
+
must_pass(git_object_lookup(&object, repo, git_reference_oid(reference), GIT_OBJ_ANY));
|
50
|
+
must_be_true(object != NULL);
|
51
|
+
must_be_true(git_object_type(object) == GIT_OBJ_TAG);
|
52
|
+
|
53
|
+
/* Ensure the name of the tag matches the name of the reference */
|
54
|
+
git_path_join(ref_name_from_tag_name, GIT_REFS_TAGS_DIR, git_tag_name((git_tag *)object));
|
55
|
+
must_be_true(strcmp(ref_name_from_tag_name, loose_tag_ref_name) == 0);
|
56
|
+
|
57
|
+
git_object_free(object);
|
58
|
+
git_repository_free(repo);
|
59
|
+
|
60
|
+
git_reference_free(reference);
|
61
|
+
END_TEST
|
62
|
+
|
63
|
+
BEGIN_TEST(readtag1, "lookup a loose tag reference that doesn't exist")
|
64
|
+
git_repository *repo;
|
65
|
+
git_reference *reference;
|
66
|
+
|
67
|
+
must_pass(git_repository_open(&repo, REPOSITORY_FOLDER));
|
68
|
+
must_fail(git_reference_lookup(&reference, repo, non_existing_tag_ref_name));
|
69
|
+
|
70
|
+
git_repository_free(repo);
|
71
|
+
|
72
|
+
git_reference_free(reference);
|
73
|
+
END_TEST
|
74
|
+
|
75
|
+
static const char *head_tracker_sym_ref_name = "head-tracker";
|
76
|
+
static const char *current_head_target = "refs/heads/master";
|
77
|
+
static const char *current_master_tip = "a65fedf39aefe402d3bb6e24df4d4f5fe4547750";
|
78
|
+
|
79
|
+
BEGIN_TEST(readsym0, "lookup a symbolic reference")
|
80
|
+
git_repository *repo;
|
81
|
+
git_reference *reference, *resolved_ref;
|
82
|
+
git_object *object;
|
83
|
+
git_oid id;
|
84
|
+
|
85
|
+
must_pass(git_repository_open(&repo, REPOSITORY_FOLDER));
|
86
|
+
|
87
|
+
must_pass(git_reference_lookup(&reference, repo, GIT_HEAD_FILE));
|
88
|
+
must_be_true(git_reference_type(reference) & GIT_REF_SYMBOLIC);
|
89
|
+
must_be_true(git_reference_is_packed(reference) == 0);
|
90
|
+
must_be_true(strcmp(reference->name, GIT_HEAD_FILE) == 0);
|
91
|
+
|
92
|
+
must_pass(git_reference_resolve(&resolved_ref, reference));
|
93
|
+
must_be_true(git_reference_type(resolved_ref) == GIT_REF_OID);
|
94
|
+
|
95
|
+
must_pass(git_object_lookup(&object, repo, git_reference_oid(resolved_ref), GIT_OBJ_ANY));
|
96
|
+
must_be_true(object != NULL);
|
97
|
+
must_be_true(git_object_type(object) == GIT_OBJ_COMMIT);
|
98
|
+
|
99
|
+
git_oid_fromstr(&id, current_master_tip);
|
100
|
+
must_be_true(git_oid_cmp(&id, git_object_id(object)) == 0);
|
101
|
+
|
102
|
+
git_object_free(object);
|
103
|
+
git_repository_free(repo);
|
104
|
+
|
105
|
+
git_reference_free(reference);
|
106
|
+
git_reference_free(resolved_ref);
|
107
|
+
END_TEST
|
108
|
+
|
109
|
+
BEGIN_TEST(readsym1, "lookup a nested symbolic reference")
|
110
|
+
git_repository *repo;
|
111
|
+
git_reference *reference, *resolved_ref;
|
112
|
+
git_object *object;
|
113
|
+
git_oid id;
|
114
|
+
|
115
|
+
must_pass(git_repository_open(&repo, REPOSITORY_FOLDER));
|
116
|
+
|
117
|
+
must_pass(git_reference_lookup(&reference, repo, head_tracker_sym_ref_name));
|
118
|
+
must_be_true(git_reference_type(reference) & GIT_REF_SYMBOLIC);
|
119
|
+
must_be_true(git_reference_is_packed(reference) == 0);
|
120
|
+
must_be_true(strcmp(reference->name, head_tracker_sym_ref_name) == 0);
|
121
|
+
|
122
|
+
must_pass(git_reference_resolve(&resolved_ref, reference));
|
123
|
+
must_be_true(git_reference_type(resolved_ref) == GIT_REF_OID);
|
124
|
+
|
125
|
+
must_pass(git_object_lookup(&object, repo, git_reference_oid(resolved_ref), GIT_OBJ_ANY));
|
126
|
+
must_be_true(object != NULL);
|
127
|
+
must_be_true(git_object_type(object) == GIT_OBJ_COMMIT);
|
128
|
+
|
129
|
+
git_oid_fromstr(&id, current_master_tip);
|
130
|
+
must_be_true(git_oid_cmp(&id, git_object_id(object)) == 0);
|
131
|
+
|
132
|
+
git_object_free(object);
|
133
|
+
git_repository_free(repo);
|
134
|
+
|
135
|
+
git_reference_free(reference);
|
136
|
+
git_reference_free(resolved_ref);
|
137
|
+
END_TEST
|
138
|
+
|
139
|
+
BEGIN_TEST(readsym2, "lookup the HEAD and resolve the master branch")
|
140
|
+
git_repository *repo;
|
141
|
+
git_reference *reference, *resolved_ref, *comp_base_ref;
|
142
|
+
|
143
|
+
must_pass(git_repository_open(&repo, REPOSITORY_FOLDER));
|
144
|
+
|
145
|
+
must_pass(git_reference_lookup(&reference, repo, head_tracker_sym_ref_name));
|
146
|
+
must_pass(git_reference_resolve(&comp_base_ref, reference));
|
147
|
+
git_reference_free(reference);
|
148
|
+
|
149
|
+
must_pass(git_reference_lookup(&reference, repo, GIT_HEAD_FILE));
|
150
|
+
must_pass(git_reference_resolve(&resolved_ref, reference));
|
151
|
+
must_pass(git_oid_cmp(git_reference_oid(comp_base_ref), git_reference_oid(resolved_ref)));
|
152
|
+
git_reference_free(reference);
|
153
|
+
git_reference_free(resolved_ref);
|
154
|
+
|
155
|
+
must_pass(git_reference_lookup(&reference, repo, current_head_target));
|
156
|
+
must_pass(git_reference_resolve(&resolved_ref, reference));
|
157
|
+
must_pass(git_oid_cmp(git_reference_oid(comp_base_ref), git_reference_oid(resolved_ref)));
|
158
|
+
git_reference_free(reference);
|
159
|
+
git_reference_free(resolved_ref);
|
160
|
+
|
161
|
+
git_reference_free(comp_base_ref);
|
162
|
+
git_repository_free(repo);
|
163
|
+
END_TEST
|
164
|
+
|
165
|
+
BEGIN_TEST(readsym3, "lookup the master branch and then the HEAD")
|
166
|
+
git_repository *repo;
|
167
|
+
git_reference *reference, *master_ref, *resolved_ref;
|
168
|
+
|
169
|
+
must_pass(git_repository_open(&repo, REPOSITORY_FOLDER));
|
170
|
+
|
171
|
+
must_pass(git_reference_lookup(&master_ref, repo, current_head_target));
|
172
|
+
must_pass(git_reference_lookup(&reference, repo, GIT_HEAD_FILE));
|
173
|
+
|
174
|
+
must_pass(git_reference_resolve(&resolved_ref, reference));
|
175
|
+
must_pass(git_oid_cmp(git_reference_oid(master_ref), git_reference_oid(resolved_ref)));
|
176
|
+
|
177
|
+
git_repository_free(repo);
|
178
|
+
|
179
|
+
git_reference_free(reference);
|
180
|
+
git_reference_free(resolved_ref);
|
181
|
+
git_reference_free(master_ref);
|
182
|
+
END_TEST
|
183
|
+
|
184
|
+
static const char *packed_head_name = "refs/heads/packed";
|
185
|
+
static const char *packed_test_head_name = "refs/heads/packed-test";
|
186
|
+
|
187
|
+
BEGIN_TEST(readpacked0, "lookup a packed reference")
|
188
|
+
git_repository *repo;
|
189
|
+
git_reference *reference;
|
190
|
+
git_object *object;
|
191
|
+
|
192
|
+
must_pass(git_repository_open(&repo, REPOSITORY_FOLDER));
|
193
|
+
|
194
|
+
must_pass(git_reference_lookup(&reference, repo, packed_head_name));
|
195
|
+
must_be_true(git_reference_type(reference) & GIT_REF_OID);
|
196
|
+
must_be_true(git_reference_is_packed(reference));
|
197
|
+
must_be_true(strcmp(reference->name, packed_head_name) == 0);
|
198
|
+
|
199
|
+
must_pass(git_object_lookup(&object, repo, git_reference_oid(reference), GIT_OBJ_ANY));
|
200
|
+
must_be_true(object != NULL);
|
201
|
+
must_be_true(git_object_type(object) == GIT_OBJ_COMMIT);
|
202
|
+
|
203
|
+
git_object_free(object);
|
204
|
+
git_repository_free(repo);
|
205
|
+
|
206
|
+
git_reference_free(reference);
|
207
|
+
END_TEST
|
208
|
+
|
209
|
+
BEGIN_TEST(readpacked1, "assure that a loose reference is looked up before a packed reference")
|
210
|
+
git_repository *repo;
|
211
|
+
git_reference *reference;
|
212
|
+
|
213
|
+
must_pass(git_repository_open(&repo, REPOSITORY_FOLDER));
|
214
|
+
must_pass(git_reference_lookup(&reference, repo, packed_head_name));
|
215
|
+
must_pass(git_reference_lookup(&reference, repo, packed_test_head_name));
|
216
|
+
must_be_true(git_reference_type(reference) & GIT_REF_OID);
|
217
|
+
must_be_true(git_reference_is_packed(reference) == 0);
|
218
|
+
must_be_true(strcmp(reference->name, packed_test_head_name) == 0);
|
219
|
+
|
220
|
+
git_repository_free(repo);
|
221
|
+
|
222
|
+
git_reference_free(reference);
|
223
|
+
END_TEST
|
224
|
+
|
225
|
+
BEGIN_TEST(create0, "create a new symbolic reference")
|
226
|
+
git_reference *new_reference, *looked_up_ref, *resolved_ref;
|
227
|
+
git_repository *repo, *repo2;
|
228
|
+
git_oid id;
|
229
|
+
char ref_path[GIT_PATH_MAX];
|
230
|
+
|
231
|
+
const char *new_head_tracker = "another-head-tracker";
|
232
|
+
|
233
|
+
git_oid_fromstr(&id, current_master_tip);
|
234
|
+
|
235
|
+
must_pass(open_temp_repo(&repo, REPOSITORY_FOLDER));
|
236
|
+
|
237
|
+
/* Retrieve the physical path to the symbolic ref for further cleaning */
|
238
|
+
git_path_join(ref_path, repo->path_repository, new_head_tracker);
|
239
|
+
|
240
|
+
/* Create and write the new symbolic reference */
|
241
|
+
must_pass(git_reference_create_symbolic(&new_reference, repo, new_head_tracker, current_head_target, 0));
|
242
|
+
|
243
|
+
/* Ensure the reference can be looked-up... */
|
244
|
+
must_pass(git_reference_lookup(&looked_up_ref, repo, new_head_tracker));
|
245
|
+
must_be_true(git_reference_type(looked_up_ref) & GIT_REF_SYMBOLIC);
|
246
|
+
must_be_true(git_reference_is_packed(looked_up_ref) == 0);
|
247
|
+
must_be_true(strcmp(looked_up_ref->name, new_head_tracker) == 0);
|
248
|
+
|
249
|
+
/* ...peeled.. */
|
250
|
+
must_pass(git_reference_resolve(&resolved_ref, looked_up_ref));
|
251
|
+
must_be_true(git_reference_type(resolved_ref) == GIT_REF_OID);
|
252
|
+
|
253
|
+
/* ...and that it points to the current master tip */
|
254
|
+
must_be_true(git_oid_cmp(&id, git_reference_oid(resolved_ref)) == 0);
|
255
|
+
|
256
|
+
git_repository_free(repo);
|
257
|
+
|
258
|
+
/* Similar test with a fresh new repository */
|
259
|
+
must_pass(git_repository_open(&repo2, TEMP_REPO_FOLDER));
|
260
|
+
|
261
|
+
must_pass(git_reference_lookup(&looked_up_ref, repo2, new_head_tracker));
|
262
|
+
must_pass(git_reference_resolve(&resolved_ref, looked_up_ref));
|
263
|
+
must_be_true(git_oid_cmp(&id, git_reference_oid(resolved_ref)) == 0);
|
264
|
+
|
265
|
+
close_temp_repo(repo2);
|
266
|
+
|
267
|
+
git_reference_free(new_reference);
|
268
|
+
git_reference_free(looked_up_ref);
|
269
|
+
git_reference_free(resolved_ref);
|
270
|
+
END_TEST
|
271
|
+
|
272
|
+
BEGIN_TEST(create1, "create a deep symbolic reference")
|
273
|
+
git_reference *new_reference, *looked_up_ref, *resolved_ref;
|
274
|
+
git_repository *repo;
|
275
|
+
git_oid id;
|
276
|
+
char ref_path[GIT_PATH_MAX];
|
277
|
+
|
278
|
+
const char *new_head_tracker = "deep/rooted/tracker";
|
279
|
+
|
280
|
+
git_oid_fromstr(&id, current_master_tip);
|
281
|
+
|
282
|
+
must_pass(open_temp_repo(&repo, REPOSITORY_FOLDER));
|
283
|
+
|
284
|
+
git_path_join(ref_path, repo->path_repository, new_head_tracker);
|
285
|
+
must_pass(git_reference_create_symbolic(&new_reference, repo, new_head_tracker, current_head_target, 0));
|
286
|
+
must_pass(git_reference_lookup(&looked_up_ref, repo, new_head_tracker));
|
287
|
+
must_pass(git_reference_resolve(&resolved_ref, looked_up_ref));
|
288
|
+
must_be_true(git_oid_cmp(&id, git_reference_oid(resolved_ref)) == 0);
|
289
|
+
|
290
|
+
close_temp_repo(repo);
|
291
|
+
|
292
|
+
git_reference_free(new_reference);
|
293
|
+
git_reference_free(looked_up_ref);
|
294
|
+
git_reference_free(resolved_ref);
|
295
|
+
END_TEST
|
296
|
+
|
297
|
+
BEGIN_TEST(create2, "create a new OID reference")
|
298
|
+
git_reference *new_reference, *looked_up_ref;
|
299
|
+
git_repository *repo, *repo2;
|
300
|
+
git_oid id;
|
301
|
+
char ref_path[GIT_PATH_MAX];
|
302
|
+
|
303
|
+
const char *new_head = "refs/heads/new-head";
|
304
|
+
|
305
|
+
git_oid_fromstr(&id, current_master_tip);
|
306
|
+
|
307
|
+
must_pass(open_temp_repo(&repo, REPOSITORY_FOLDER));
|
308
|
+
|
309
|
+
/* Retrieve the physical path to the symbolic ref for further cleaning */
|
310
|
+
git_path_join(ref_path, repo->path_repository, new_head);
|
311
|
+
|
312
|
+
/* Create and write the new object id reference */
|
313
|
+
must_pass(git_reference_create_oid(&new_reference, repo, new_head, &id, 0));
|
314
|
+
|
315
|
+
/* Ensure the reference can be looked-up... */
|
316
|
+
must_pass(git_reference_lookup(&looked_up_ref, repo, new_head));
|
317
|
+
must_be_true(git_reference_type(looked_up_ref) & GIT_REF_OID);
|
318
|
+
must_be_true(git_reference_is_packed(looked_up_ref) == 0);
|
319
|
+
must_be_true(strcmp(looked_up_ref->name, new_head) == 0);
|
320
|
+
|
321
|
+
/* ...and that it points to the current master tip */
|
322
|
+
must_be_true(git_oid_cmp(&id, git_reference_oid(looked_up_ref)) == 0);
|
323
|
+
|
324
|
+
git_repository_free(repo);
|
325
|
+
|
326
|
+
/* Similar test with a fresh new repository */
|
327
|
+
must_pass(git_repository_open(&repo2, TEMP_REPO_FOLDER));
|
328
|
+
|
329
|
+
must_pass(git_reference_lookup(&looked_up_ref, repo2, new_head));
|
330
|
+
must_be_true(git_oid_cmp(&id, git_reference_oid(looked_up_ref)) == 0);
|
331
|
+
|
332
|
+
close_temp_repo(repo2);
|
333
|
+
|
334
|
+
git_reference_free(new_reference);
|
335
|
+
git_reference_free(looked_up_ref);
|
336
|
+
END_TEST
|
337
|
+
|
338
|
+
BEGIN_TEST(create3, "Can not create a new OID reference which targets at an unknown id")
|
339
|
+
git_reference *new_reference, *looked_up_ref;
|
340
|
+
git_repository *repo;
|
341
|
+
git_oid id;
|
342
|
+
|
343
|
+
const char *new_head = "refs/heads/new-head";
|
344
|
+
|
345
|
+
git_oid_fromstr(&id, "deadbeef3f795b2b4353bcce3a527ad0a4f7f644");
|
346
|
+
|
347
|
+
must_pass(git_repository_open(&repo, REPOSITORY_FOLDER));
|
348
|
+
|
349
|
+
/* Create and write the new object id reference */
|
350
|
+
must_fail(git_reference_create_oid(&new_reference, repo, new_head, &id, 0));
|
351
|
+
|
352
|
+
/* Ensure the reference can't be looked-up... */
|
353
|
+
must_fail(git_reference_lookup(&looked_up_ref, repo, new_head));
|
354
|
+
|
355
|
+
git_repository_free(repo);
|
356
|
+
END_TEST
|
357
|
+
|
358
|
+
static const char *ref_name = "refs/heads/other";
|
359
|
+
static const char *ref_master_name = "refs/heads/master";
|
360
|
+
static const char *ref_branch_name = "refs/heads/branch";
|
361
|
+
static const char *ref_test_name = "refs/heads/test";
|
362
|
+
BEGIN_TEST(overwrite0, "Overwrite an existing symbolic reference")
|
363
|
+
git_reference *ref, *branch_ref;
|
364
|
+
git_repository *repo;
|
365
|
+
|
366
|
+
must_pass(open_temp_repo(&repo, REPOSITORY_FOLDER));
|
367
|
+
|
368
|
+
/* The target needds to exist and we need to check the name has changed */
|
369
|
+
must_pass(git_reference_create_symbolic(&branch_ref, repo, ref_branch_name, ref_master_name, 0));
|
370
|
+
must_pass(git_reference_create_symbolic(&ref, repo, ref_name, ref_branch_name, 0));
|
371
|
+
/* Ensure it points to the right place*/
|
372
|
+
must_pass(git_reference_lookup(&ref, repo, ref_name));
|
373
|
+
must_be_true(git_reference_type(ref) & GIT_REF_SYMBOLIC);
|
374
|
+
must_be_true(!strcmp(git_reference_target(ref), ref_branch_name));
|
375
|
+
|
376
|
+
/* Ensure we can't create it unless we force it to */
|
377
|
+
must_fail(git_reference_create_symbolic(&ref, repo, ref_name, ref_master_name, 0));
|
378
|
+
must_pass(git_reference_create_symbolic(&ref, repo, ref_name, ref_master_name, 1));
|
379
|
+
|
380
|
+
/* Ensure it points to the right place */
|
381
|
+
must_pass(git_reference_lookup(&ref, repo, ref_name));
|
382
|
+
must_be_true(git_reference_type(ref) & GIT_REF_SYMBOLIC);
|
383
|
+
must_be_true(!strcmp(git_reference_target(ref), ref_master_name));
|
384
|
+
|
385
|
+
close_temp_repo(repo);
|
386
|
+
|
387
|
+
git_reference_free(ref);
|
388
|
+
git_reference_free(branch_ref);
|
389
|
+
END_TEST
|
390
|
+
|
391
|
+
BEGIN_TEST(overwrite1, "Overwrite an existing object id reference")
|
392
|
+
git_reference *ref;
|
393
|
+
git_repository *repo;
|
394
|
+
git_oid id;
|
395
|
+
|
396
|
+
must_pass(open_temp_repo(&repo, REPOSITORY_FOLDER));
|
397
|
+
|
398
|
+
must_pass(git_reference_lookup(&ref, repo, ref_master_name));
|
399
|
+
must_be_true(git_reference_type(ref) & GIT_REF_OID);
|
400
|
+
git_oid_cpy(&id, git_reference_oid(ref));
|
401
|
+
|
402
|
+
/* Create it */
|
403
|
+
must_pass(git_reference_create_oid(&ref, repo, ref_name, &id, 0));
|
404
|
+
|
405
|
+
must_pass(git_reference_lookup(&ref, repo, ref_test_name));
|
406
|
+
must_be_true(git_reference_type(ref) & GIT_REF_OID);
|
407
|
+
git_oid_cpy(&id, git_reference_oid(ref));
|
408
|
+
|
409
|
+
/* Ensure we can't overwrite unless we force it */
|
410
|
+
must_fail(git_reference_create_oid(&ref, repo, ref_name, &id, 0));
|
411
|
+
must_pass(git_reference_create_oid(&ref, repo, ref_name, &id, 1));
|
412
|
+
|
413
|
+
/* Ensure it has been overwritten */
|
414
|
+
must_pass(git_reference_lookup(&ref, repo, ref_name));
|
415
|
+
must_be_true(!git_oid_cmp(&id, git_reference_oid(ref)));
|
416
|
+
|
417
|
+
close_temp_repo(repo);
|
418
|
+
|
419
|
+
git_reference_free(ref);
|
420
|
+
END_TEST
|
421
|
+
|
422
|
+
BEGIN_TEST(overwrite2, "Overwrite an existing object id reference with a symbolic one")
|
423
|
+
git_reference *ref;
|
424
|
+
git_repository *repo;
|
425
|
+
git_oid id;
|
426
|
+
|
427
|
+
must_pass(open_temp_repo(&repo, REPOSITORY_FOLDER));
|
428
|
+
|
429
|
+
must_pass(git_reference_lookup(&ref, repo, ref_master_name));
|
430
|
+
must_be_true(git_reference_type(ref) & GIT_REF_OID);
|
431
|
+
git_oid_cpy(&id, git_reference_oid(ref));
|
432
|
+
|
433
|
+
must_pass(git_reference_create_oid(&ref, repo, ref_name, &id, 0));
|
434
|
+
must_fail(git_reference_create_symbolic(&ref, repo, ref_name, ref_master_name, 0));
|
435
|
+
must_pass(git_reference_create_symbolic(&ref, repo, ref_name, ref_master_name, 1));
|
436
|
+
|
437
|
+
/* Ensure it points to the right place */
|
438
|
+
must_pass(git_reference_lookup(&ref, repo, ref_name));
|
439
|
+
must_be_true(git_reference_type(ref) & GIT_REF_SYMBOLIC);
|
440
|
+
must_be_true(!strcmp(git_reference_target(ref), ref_master_name));
|
441
|
+
|
442
|
+
close_temp_repo(repo);
|
443
|
+
|
444
|
+
git_reference_free(ref);
|
445
|
+
END_TEST
|
446
|
+
|
447
|
+
BEGIN_TEST(overwrite3, "Overwrite an existing symbolic reference with an object id one")
|
448
|
+
git_reference *ref;
|
449
|
+
git_repository *repo;
|
450
|
+
git_oid id;
|
451
|
+
|
452
|
+
must_pass(open_temp_repo(&repo, REPOSITORY_FOLDER));
|
453
|
+
|
454
|
+
must_pass(git_reference_lookup(&ref, repo, ref_master_name));
|
455
|
+
must_be_true(git_reference_type(ref) & GIT_REF_OID);
|
456
|
+
git_oid_cpy(&id, git_reference_oid(ref));
|
457
|
+
|
458
|
+
/* Create the symbolic ref */
|
459
|
+
must_pass(git_reference_create_symbolic(&ref, repo, ref_name, ref_master_name, 0));
|
460
|
+
/* It shouldn't overwrite unless we tell it to */
|
461
|
+
must_fail(git_reference_create_oid(&ref, repo, ref_name, &id, 0));
|
462
|
+
must_pass(git_reference_create_oid(&ref, repo, ref_name, &id, 1));
|
463
|
+
|
464
|
+
/* Ensure it points to the right place */
|
465
|
+
must_pass(git_reference_lookup(&ref, repo, ref_name));
|
466
|
+
must_be_true(git_reference_type(ref) & GIT_REF_OID);
|
467
|
+
must_be_true(!git_oid_cmp(git_reference_oid(ref), &id));
|
468
|
+
|
469
|
+
close_temp_repo(repo);
|
470
|
+
|
471
|
+
git_reference_free(ref);
|
472
|
+
END_TEST
|
473
|
+
|
474
|
+
BEGIN_TEST(pack0, "create a packfile for an empty folder")
|
475
|
+
git_repository *repo;
|
476
|
+
char temp_path[GIT_PATH_MAX];
|
477
|
+
|
478
|
+
must_pass(open_temp_repo(&repo, REPOSITORY_FOLDER));
|
479
|
+
|
480
|
+
git_path_join_n(temp_path, 3, repo->path_repository, GIT_REFS_HEADS_DIR, "empty_dir");
|
481
|
+
must_pass(git_futils_mkdir_r(temp_path, GIT_REFS_DIR_MODE));
|
482
|
+
|
483
|
+
must_pass(git_reference_packall(repo));
|
484
|
+
|
485
|
+
close_temp_repo(repo);
|
486
|
+
END_TEST
|
487
|
+
|
488
|
+
BEGIN_TEST(pack1, "create a packfile from all the loose rn a repo")
|
489
|
+
git_repository *repo;
|
490
|
+
git_reference *reference;
|
491
|
+
char temp_path[GIT_PATH_MAX];
|
492
|
+
|
493
|
+
must_pass(open_temp_repo(&repo, REPOSITORY_FOLDER));
|
494
|
+
|
495
|
+
/* Ensure a known loose ref can be looked up */
|
496
|
+
must_pass(git_reference_lookup(&reference, repo, loose_tag_ref_name));
|
497
|
+
must_be_true(git_reference_is_packed(reference) == 0);
|
498
|
+
must_be_true(strcmp(reference->name, loose_tag_ref_name) == 0);
|
499
|
+
|
500
|
+
/*
|
501
|
+
* We are now trying to pack also a loose reference
|
502
|
+
* called `points_to_blob`, to make sure we can properly
|
503
|
+
* pack weak tags
|
504
|
+
*/
|
505
|
+
must_pass(git_reference_packall(repo));
|
506
|
+
|
507
|
+
/* Ensure the packed-refs file exists */
|
508
|
+
git_path_join(temp_path, repo->path_repository, GIT_PACKEDREFS_FILE);
|
509
|
+
must_pass(git_futils_exists(temp_path));
|
510
|
+
|
511
|
+
/* Ensure the known ref can still be looked up but is now packed */
|
512
|
+
must_pass(git_reference_lookup(&reference, repo, loose_tag_ref_name));
|
513
|
+
must_be_true(git_reference_is_packed(reference));
|
514
|
+
must_be_true(strcmp(reference->name, loose_tag_ref_name) == 0);
|
515
|
+
|
516
|
+
/* Ensure the known ref has been removed from the loose folder structure */
|
517
|
+
git_path_join(temp_path, repo->path_repository, loose_tag_ref_name);
|
518
|
+
must_pass(!git_futils_exists(temp_path));
|
519
|
+
|
520
|
+
close_temp_repo(repo);
|
521
|
+
|
522
|
+
git_reference_free(reference);
|
523
|
+
END_TEST
|
524
|
+
|
525
|
+
BEGIN_TEST(rename0, "rename a loose reference")
|
526
|
+
git_reference *looked_up_ref, *another_looked_up_ref;
|
527
|
+
git_repository *repo;
|
528
|
+
char temp_path[GIT_PATH_MAX];
|
529
|
+
const char *new_name = "refs/tags/Nemo/knows/refs.kung-fu";
|
530
|
+
|
531
|
+
must_pass(open_temp_repo(&repo, REPOSITORY_FOLDER));
|
532
|
+
|
533
|
+
/* Ensure the ref doesn't exist on the file system */
|
534
|
+
git_path_join(temp_path, repo->path_repository, new_name);
|
535
|
+
must_pass(!git_futils_exists(temp_path));
|
536
|
+
|
537
|
+
/* Retrieval of the reference to rename */
|
538
|
+
must_pass(git_reference_lookup(&looked_up_ref, repo, loose_tag_ref_name));
|
539
|
+
|
540
|
+
/* ... which is indeed loose */
|
541
|
+
must_be_true(git_reference_is_packed(looked_up_ref) == 0);
|
542
|
+
|
543
|
+
/* Now that the reference is renamed... */
|
544
|
+
must_pass(git_reference_rename(looked_up_ref, new_name, 0));
|
545
|
+
must_be_true(!strcmp(looked_up_ref->name, new_name));
|
546
|
+
|
547
|
+
/* ...It can't be looked-up with the old name... */
|
548
|
+
must_fail(git_reference_lookup(&another_looked_up_ref, repo, loose_tag_ref_name));
|
549
|
+
|
550
|
+
/* ...but the new name works ok... */
|
551
|
+
must_pass(git_reference_lookup(&another_looked_up_ref, repo, new_name));
|
552
|
+
must_be_true(!strcmp(another_looked_up_ref->name, new_name));
|
553
|
+
|
554
|
+
/* .. the ref is still loose... */
|
555
|
+
must_be_true(git_reference_is_packed(another_looked_up_ref) == 0);
|
556
|
+
must_be_true(git_reference_is_packed(looked_up_ref) == 0);
|
557
|
+
|
558
|
+
/* ...and the ref can be found in the file system */
|
559
|
+
git_path_join(temp_path, repo->path_repository, new_name);
|
560
|
+
must_pass(git_futils_exists(temp_path));
|
561
|
+
|
562
|
+
close_temp_repo(repo);
|
563
|
+
|
564
|
+
git_reference_free(looked_up_ref);
|
565
|
+
git_reference_free(another_looked_up_ref);
|
566
|
+
END_TEST
|
567
|
+
|
568
|
+
BEGIN_TEST(rename1, "rename a packed reference (should make it loose)")
|
569
|
+
git_reference *looked_up_ref, *another_looked_up_ref;
|
570
|
+
git_repository *repo;
|
571
|
+
char temp_path[GIT_PATH_MAX];
|
572
|
+
const char *brand_new_name = "refs/heads/brand_new_name";
|
573
|
+
|
574
|
+
must_pass(open_temp_repo(&repo, REPOSITORY_FOLDER));
|
575
|
+
|
576
|
+
/* Ensure the ref doesn't exist on the file system */
|
577
|
+
git_path_join(temp_path, repo->path_repository, packed_head_name);
|
578
|
+
must_pass(!git_futils_exists(temp_path));
|
579
|
+
|
580
|
+
/* The reference can however be looked-up... */
|
581
|
+
must_pass(git_reference_lookup(&looked_up_ref, repo, packed_head_name));
|
582
|
+
|
583
|
+
/* .. and it's packed */
|
584
|
+
must_be_true(git_reference_is_packed(looked_up_ref) != 0);
|
585
|
+
|
586
|
+
/* Now that the reference is renamed... */
|
587
|
+
must_pass(git_reference_rename(looked_up_ref, brand_new_name, 0));
|
588
|
+
must_be_true(!strcmp(looked_up_ref->name, brand_new_name));
|
589
|
+
|
590
|
+
/* ...It can't be looked-up with the old name... */
|
591
|
+
must_fail(git_reference_lookup(&another_looked_up_ref, repo, packed_head_name));
|
592
|
+
|
593
|
+
/* ...but the new name works ok... */
|
594
|
+
must_pass(git_reference_lookup(&another_looked_up_ref, repo, brand_new_name));
|
595
|
+
must_be_true(!strcmp(another_looked_up_ref->name, brand_new_name));
|
596
|
+
|
597
|
+
/* .. the ref is no longer packed... */
|
598
|
+
must_be_true(git_reference_is_packed(another_looked_up_ref) == 0);
|
599
|
+
must_be_true(git_reference_is_packed(looked_up_ref) == 0);
|
600
|
+
|
601
|
+
/* ...and the ref now happily lives in the file system */
|
602
|
+
git_path_join(temp_path, repo->path_repository, brand_new_name);
|
603
|
+
must_pass(git_futils_exists(temp_path));
|
604
|
+
|
605
|
+
close_temp_repo(repo);
|
606
|
+
|
607
|
+
git_reference_free(looked_up_ref);
|
608
|
+
git_reference_free(another_looked_up_ref);
|
609
|
+
END_TEST
|
610
|
+
|
611
|
+
BEGIN_TEST(rename2, "renaming a packed reference does not pack another reference which happens to be in both loose and pack state")
|
612
|
+
git_reference *looked_up_ref, *another_looked_up_ref;
|
613
|
+
git_repository *repo;
|
614
|
+
char temp_path[GIT_PATH_MAX];
|
615
|
+
const char *brand_new_name = "refs/heads/brand_new_name";
|
616
|
+
|
617
|
+
must_pass(open_temp_repo(&repo, REPOSITORY_FOLDER));
|
618
|
+
|
619
|
+
/* Ensure the other reference exists on the file system */
|
620
|
+
git_path_join(temp_path, repo->path_repository, packed_test_head_name);
|
621
|
+
must_pass(git_futils_exists(temp_path));
|
622
|
+
|
623
|
+
/* Lookup the other reference */
|
624
|
+
must_pass(git_reference_lookup(&another_looked_up_ref, repo, packed_test_head_name));
|
625
|
+
|
626
|
+
/* Ensure it's loose */
|
627
|
+
must_be_true(git_reference_is_packed(another_looked_up_ref) == 0);
|
628
|
+
|
629
|
+
/* Lookup the reference to rename */
|
630
|
+
must_pass(git_reference_lookup(&looked_up_ref, repo, packed_head_name));
|
631
|
+
|
632
|
+
/* Ensure it's packed */
|
633
|
+
must_be_true(git_reference_is_packed(looked_up_ref) != 0);
|
634
|
+
|
635
|
+
/* Now that the reference is renamed... */
|
636
|
+
must_pass(git_reference_rename(looked_up_ref, brand_new_name, 0));
|
637
|
+
|
638
|
+
/* Lookup the other reference */
|
639
|
+
must_pass(git_reference_lookup(&another_looked_up_ref, repo, packed_test_head_name));
|
640
|
+
|
641
|
+
/* Ensure it's loose */
|
642
|
+
must_be_true(git_reference_is_packed(another_looked_up_ref) == 0);
|
643
|
+
|
644
|
+
/* Ensure the other ref still exists on the file system */
|
645
|
+
must_pass(git_futils_exists(temp_path));
|
646
|
+
|
647
|
+
close_temp_repo(repo);
|
648
|
+
|
649
|
+
git_reference_free(looked_up_ref);
|
650
|
+
git_reference_free(another_looked_up_ref);
|
651
|
+
END_TEST
|
652
|
+
|
653
|
+
BEGIN_TEST(rename3, "can not rename a reference with the name of an existing reference")
|
654
|
+
git_reference *looked_up_ref;
|
655
|
+
git_repository *repo;
|
656
|
+
|
657
|
+
must_pass(open_temp_repo(&repo, REPOSITORY_FOLDER));
|
658
|
+
|
659
|
+
/* An existing reference... */
|
660
|
+
must_pass(git_reference_lookup(&looked_up_ref, repo, packed_head_name));
|
661
|
+
|
662
|
+
/* Can not be renamed to the name of another existing reference. */
|
663
|
+
must_fail(git_reference_rename(looked_up_ref, packed_test_head_name, 0));
|
664
|
+
|
665
|
+
/* Failure to rename it hasn't corrupted its state */
|
666
|
+
must_pass(git_reference_lookup(&looked_up_ref, repo, packed_head_name));
|
667
|
+
must_be_true(!strcmp(looked_up_ref->name, packed_head_name));
|
668
|
+
|
669
|
+
close_temp_repo(repo);
|
670
|
+
|
671
|
+
git_reference_free(looked_up_ref);
|
672
|
+
END_TEST
|
673
|
+
|
674
|
+
BEGIN_TEST(rename4, "can not rename a reference with an invalid name")
|
675
|
+
git_reference *looked_up_ref;
|
676
|
+
git_repository *repo;
|
677
|
+
|
678
|
+
must_pass(open_temp_repo(&repo, REPOSITORY_FOLDER));
|
679
|
+
|
680
|
+
/* An existing oid reference... */
|
681
|
+
must_pass(git_reference_lookup(&looked_up_ref, repo, packed_test_head_name));
|
682
|
+
|
683
|
+
/* Can not be renamed with an invalid name. */
|
684
|
+
must_fail(git_reference_rename(looked_up_ref, "Hello! I'm a very invalid name.", 0));
|
685
|
+
|
686
|
+
/* Can not be renamed outside of the refs hierarchy. */
|
687
|
+
must_fail(git_reference_rename(looked_up_ref, "i-will-sudo-you", 0));
|
688
|
+
|
689
|
+
/* Failure to rename it hasn't corrupted its state */
|
690
|
+
must_pass(git_reference_lookup(&looked_up_ref, repo, packed_test_head_name));
|
691
|
+
must_be_true(!strcmp(looked_up_ref->name, packed_test_head_name));
|
692
|
+
|
693
|
+
close_temp_repo(repo);
|
694
|
+
|
695
|
+
git_reference_free(looked_up_ref);
|
696
|
+
END_TEST
|
697
|
+
|
698
|
+
BEGIN_TEST(rename5, "can force-rename a packed reference with the name of an existing loose and packed reference")
|
699
|
+
git_reference *looked_up_ref;
|
700
|
+
git_repository *repo;
|
701
|
+
git_oid oid;
|
702
|
+
|
703
|
+
must_pass(open_temp_repo(&repo, REPOSITORY_FOLDER));
|
704
|
+
|
705
|
+
/* An existing reference... */
|
706
|
+
must_pass(git_reference_lookup(&looked_up_ref, repo, packed_head_name));
|
707
|
+
git_oid_cpy(&oid, git_reference_oid(looked_up_ref));
|
708
|
+
|
709
|
+
/* Can be force-renamed to the name of another existing reference. */
|
710
|
+
must_pass(git_reference_rename(looked_up_ref, packed_test_head_name, 1));
|
711
|
+
|
712
|
+
/* Check we actually renamed it */
|
713
|
+
must_pass(git_reference_lookup(&looked_up_ref, repo, packed_test_head_name));
|
714
|
+
must_be_true(!strcmp(looked_up_ref->name, packed_test_head_name));
|
715
|
+
must_be_true(!git_oid_cmp(&oid, git_reference_oid(looked_up_ref)));
|
716
|
+
|
717
|
+
/* And that the previous one doesn't exist any longer */
|
718
|
+
must_fail(git_reference_lookup(&looked_up_ref, repo, packed_head_name));
|
719
|
+
|
720
|
+
close_temp_repo(repo);
|
721
|
+
|
722
|
+
git_reference_free(looked_up_ref);
|
723
|
+
END_TEST
|
724
|
+
|
725
|
+
BEGIN_TEST(rename6, "can force-rename a loose reference with the name of an existing loose reference")
|
726
|
+
git_reference *looked_up_ref;
|
727
|
+
git_repository *repo;
|
728
|
+
git_oid oid;
|
729
|
+
|
730
|
+
must_pass(open_temp_repo(&repo, REPOSITORY_FOLDER));
|
731
|
+
|
732
|
+
/* An existing reference... */
|
733
|
+
must_pass(git_reference_lookup(&looked_up_ref, repo, "refs/heads/br2"));
|
734
|
+
git_oid_cpy(&oid, git_reference_oid(looked_up_ref));
|
735
|
+
|
736
|
+
/* Can be force-renamed to the name of another existing reference. */
|
737
|
+
must_pass(git_reference_rename(looked_up_ref, "refs/heads/test", 1));
|
738
|
+
|
739
|
+
/* Check we actually renamed it */
|
740
|
+
must_pass(git_reference_lookup(&looked_up_ref, repo, "refs/heads/test"));
|
741
|
+
must_be_true(!strcmp(looked_up_ref->name, "refs/heads/test"));
|
742
|
+
must_be_true(!git_oid_cmp(&oid, git_reference_oid(looked_up_ref)));
|
743
|
+
|
744
|
+
/* And that the previous one doesn't exist any longer */
|
745
|
+
must_fail(git_reference_lookup(&looked_up_ref, repo, "refs/heads/br2"));
|
746
|
+
|
747
|
+
close_temp_repo(repo);
|
748
|
+
|
749
|
+
git_reference_free(looked_up_ref);
|
750
|
+
END_TEST
|
751
|
+
|
752
|
+
static const char *ref_one_name = "refs/heads/one/branch";
|
753
|
+
static const char *ref_one_name_new = "refs/heads/two/branch";
|
754
|
+
static const char *ref_two_name = "refs/heads/two";
|
755
|
+
|
756
|
+
BEGIN_TEST(rename7, "can not overwrite name of existing reference")
|
757
|
+
git_reference *ref, *ref_one, *ref_one_new, *ref_two;
|
758
|
+
git_repository *repo;
|
759
|
+
git_oid id;
|
760
|
+
|
761
|
+
must_pass(open_temp_repo(&repo, REPOSITORY_FOLDER));
|
762
|
+
|
763
|
+
must_pass(git_reference_lookup(&ref, repo, ref_master_name));
|
764
|
+
must_be_true(git_reference_type(ref) & GIT_REF_OID);
|
765
|
+
|
766
|
+
git_oid_cpy(&id, git_reference_oid(ref));
|
767
|
+
|
768
|
+
/* Create loose references */
|
769
|
+
must_pass(git_reference_create_oid(&ref_one, repo, ref_one_name, &id, 0));
|
770
|
+
must_pass(git_reference_create_oid(&ref_two, repo, ref_two_name, &id, 0));
|
771
|
+
|
772
|
+
/* Pack everything */
|
773
|
+
must_pass(git_reference_packall(repo));
|
774
|
+
|
775
|
+
/* Attempt to create illegal reference */
|
776
|
+
must_fail(git_reference_create_oid(&ref_one_new, repo, ref_one_name_new, &id, 0));
|
777
|
+
|
778
|
+
/* Illegal reference couldn't be created so this is supposed to fail */
|
779
|
+
must_fail(git_reference_lookup(&ref_one_new, repo, ref_one_name_new));
|
780
|
+
|
781
|
+
close_temp_repo(repo);
|
782
|
+
|
783
|
+
git_reference_free(ref);
|
784
|
+
git_reference_free(ref_one);
|
785
|
+
git_reference_free(ref_one_new);
|
786
|
+
git_reference_free(ref_two);
|
787
|
+
END_TEST
|
788
|
+
|
789
|
+
static const char *ref_two_name_new = "refs/heads/two/two";
|
790
|
+
|
791
|
+
BEGIN_TEST(rename8, "can be renamed to a new name prefixed with the old name")
|
792
|
+
git_reference *ref, *ref_two, *looked_up_ref;
|
793
|
+
git_repository *repo;
|
794
|
+
git_oid id;
|
795
|
+
|
796
|
+
must_pass(open_temp_repo(&repo, REPOSITORY_FOLDER));
|
797
|
+
|
798
|
+
must_pass(git_reference_lookup(&ref, repo, ref_master_name));
|
799
|
+
must_be_true(git_reference_type(ref) & GIT_REF_OID);
|
800
|
+
|
801
|
+
git_oid_cpy(&id, git_reference_oid(ref));
|
802
|
+
|
803
|
+
/* Create loose references */
|
804
|
+
must_pass(git_reference_create_oid(&ref_two, repo, ref_two_name, &id, 0));
|
805
|
+
|
806
|
+
/* An existing reference... */
|
807
|
+
must_pass(git_reference_lookup(&looked_up_ref, repo, ref_two_name));
|
808
|
+
|
809
|
+
/* Can be rename to a new name starting with the old name. */
|
810
|
+
must_pass(git_reference_rename(looked_up_ref, ref_two_name_new, 0));
|
811
|
+
|
812
|
+
/* Check we actually renamed it */
|
813
|
+
must_pass(git_reference_lookup(&looked_up_ref, repo, ref_two_name_new));
|
814
|
+
must_be_true(!strcmp(looked_up_ref->name, ref_two_name_new));
|
815
|
+
must_fail(git_reference_lookup(&looked_up_ref, repo, ref_two_name));
|
816
|
+
|
817
|
+
close_temp_repo(repo);
|
818
|
+
|
819
|
+
git_reference_free(ref);
|
820
|
+
git_reference_free(ref_two);
|
821
|
+
git_reference_free(looked_up_ref);
|
822
|
+
END_TEST
|
823
|
+
|
824
|
+
BEGIN_TEST(rename9, "can move a reference to a upper reference hierarchy")
|
825
|
+
git_reference *ref, *ref_two, *looked_up_ref;
|
826
|
+
git_repository *repo;
|
827
|
+
git_oid id;
|
828
|
+
|
829
|
+
must_pass(open_temp_repo(&repo, REPOSITORY_FOLDER));
|
830
|
+
|
831
|
+
must_pass(git_reference_lookup(&ref, repo, ref_master_name));
|
832
|
+
must_be_true(git_reference_type(ref) & GIT_REF_OID);
|
833
|
+
|
834
|
+
git_oid_cpy(&id, git_reference_oid(ref));
|
835
|
+
|
836
|
+
/* Create loose references */
|
837
|
+
must_pass(git_reference_create_oid(&ref_two, repo, ref_two_name_new, &id, 0));
|
838
|
+
|
839
|
+
/* An existing reference... */
|
840
|
+
must_pass(git_reference_lookup(&looked_up_ref, repo, ref_two_name_new));
|
841
|
+
|
842
|
+
/* Can be renamed upward the reference tree. */
|
843
|
+
must_pass(git_reference_rename(looked_up_ref, ref_two_name, 0));
|
844
|
+
|
845
|
+
/* Check we actually renamed it */
|
846
|
+
must_pass(git_reference_lookup(&looked_up_ref, repo, ref_two_name));
|
847
|
+
must_be_true(!strcmp(looked_up_ref->name, ref_two_name));
|
848
|
+
must_fail(git_reference_lookup(&looked_up_ref, repo, ref_two_name_new));
|
849
|
+
|
850
|
+
close_temp_repo(repo);
|
851
|
+
END_TEST
|
852
|
+
|
853
|
+
BEGIN_TEST(delete0, "deleting a ref which is both packed and loose should remove both tracks in the filesystem")
|
854
|
+
git_reference *looked_up_ref, *another_looked_up_ref;
|
855
|
+
git_repository *repo;
|
856
|
+
char temp_path[GIT_PATH_MAX];
|
857
|
+
|
858
|
+
must_pass(open_temp_repo(&repo, REPOSITORY_FOLDER));
|
859
|
+
|
860
|
+
/* Ensure the loose reference exists on the file system */
|
861
|
+
git_path_join(temp_path, repo->path_repository, packed_test_head_name);
|
862
|
+
must_pass(git_futils_exists(temp_path));
|
863
|
+
|
864
|
+
/* Lookup the reference */
|
865
|
+
must_pass(git_reference_lookup(&looked_up_ref, repo, packed_test_head_name));
|
866
|
+
|
867
|
+
/* Ensure it's the loose version that has been found */
|
868
|
+
must_be_true(git_reference_is_packed(looked_up_ref) == 0);
|
869
|
+
|
870
|
+
/* Now that the reference is deleted... */
|
871
|
+
must_pass(git_reference_delete(looked_up_ref));
|
872
|
+
|
873
|
+
/* Looking up the reference once again should not retrieve it */
|
874
|
+
must_fail(git_reference_lookup(&another_looked_up_ref, repo, packed_test_head_name));
|
875
|
+
|
876
|
+
/* Ensure the loose reference doesn't exist any longer on the file system */
|
877
|
+
must_pass(!git_futils_exists(temp_path));
|
878
|
+
|
879
|
+
close_temp_repo(repo);
|
880
|
+
|
881
|
+
git_reference_free(another_looked_up_ref);
|
882
|
+
END_TEST
|
883
|
+
|
884
|
+
BEGIN_TEST(delete1, "can delete a just packed reference")
|
885
|
+
git_reference *ref;
|
886
|
+
git_repository *repo;
|
887
|
+
git_oid id;
|
888
|
+
const char *new_ref = "refs/heads/new_ref";
|
889
|
+
|
890
|
+
git_oid_fromstr(&id, current_master_tip);
|
891
|
+
|
892
|
+
must_pass(open_temp_repo(&repo, REPOSITORY_FOLDER));
|
893
|
+
|
894
|
+
/* Create and write the new object id reference */
|
895
|
+
must_pass(git_reference_create_oid(&ref, repo, new_ref, &id, 0));
|
896
|
+
|
897
|
+
/* Lookup the reference */
|
898
|
+
must_pass(git_reference_lookup(&ref, repo, new_ref));
|
899
|
+
|
900
|
+
/* Ensure it's a loose reference */
|
901
|
+
must_be_true(git_reference_is_packed(ref) == 0);
|
902
|
+
|
903
|
+
/* Pack all existing references */
|
904
|
+
must_pass(git_reference_packall(repo));
|
905
|
+
|
906
|
+
/* Reload the reference from disk */
|
907
|
+
must_pass(git_reference_reload(ref));
|
908
|
+
|
909
|
+
/* Ensure it's a packed reference */
|
910
|
+
must_be_true(git_reference_is_packed(ref) == 1);
|
911
|
+
|
912
|
+
/* This should pass */
|
913
|
+
must_pass(git_reference_delete(ref));
|
914
|
+
|
915
|
+
close_temp_repo(repo);
|
916
|
+
END_TEST
|
917
|
+
|
918
|
+
static int ensure_refname_normalized(int is_oid_ref, const char *input_refname, const char *expected_refname)
|
919
|
+
{
|
920
|
+
int error = GIT_SUCCESS;
|
921
|
+
char buffer_out[GIT_REFNAME_MAX];
|
922
|
+
|
923
|
+
if (is_oid_ref)
|
924
|
+
error = git_reference__normalize_name_oid(buffer_out, sizeof(buffer_out), input_refname);
|
925
|
+
else
|
926
|
+
error = git_reference__normalize_name(buffer_out, sizeof(buffer_out), input_refname);
|
927
|
+
|
928
|
+
if (error < GIT_SUCCESS)
|
929
|
+
return error;
|
930
|
+
|
931
|
+
if (expected_refname == NULL)
|
932
|
+
return error;
|
933
|
+
|
934
|
+
if (strcmp(buffer_out, expected_refname))
|
935
|
+
error = GIT_ERROR;
|
936
|
+
|
937
|
+
return error;
|
938
|
+
}
|
939
|
+
|
940
|
+
#define OID_REF 1
|
941
|
+
#define SYM_REF 0
|
942
|
+
|
943
|
+
BEGIN_TEST(normalize0, "normalize a direct (OID) reference name")
|
944
|
+
must_fail(ensure_refname_normalized(OID_REF, "a", NULL));
|
945
|
+
must_fail(ensure_refname_normalized(OID_REF, "", NULL));
|
946
|
+
must_fail(ensure_refname_normalized(OID_REF, "refs/heads/a/", NULL));
|
947
|
+
must_fail(ensure_refname_normalized(OID_REF, "refs/heads/a.", NULL));
|
948
|
+
must_fail(ensure_refname_normalized(OID_REF, "refs/heads/a.lock", NULL));
|
949
|
+
must_pass(ensure_refname_normalized(OID_REF, "refs/dummy/a", NULL));
|
950
|
+
must_pass(ensure_refname_normalized(OID_REF, "refs/stash", NULL));
|
951
|
+
must_pass(ensure_refname_normalized(OID_REF, "refs/tags/a", "refs/tags/a"));
|
952
|
+
must_pass(ensure_refname_normalized(OID_REF, "refs/heads/a/b", "refs/heads/a/b"));
|
953
|
+
must_pass(ensure_refname_normalized(OID_REF, "refs/heads/a./b", "refs/heads/a./b"));
|
954
|
+
must_fail(ensure_refname_normalized(OID_REF, "refs/heads/foo?bar", NULL));
|
955
|
+
must_fail(ensure_refname_normalized(OID_REF, "refs/heads\foo", NULL));
|
956
|
+
must_pass(ensure_refname_normalized(OID_REF, "refs/heads/v@ation", "refs/heads/v@ation"));
|
957
|
+
must_pass(ensure_refname_normalized(OID_REF, "refs///heads///a", "refs/heads/a"));
|
958
|
+
must_fail(ensure_refname_normalized(OID_REF, "refs/heads/.a/b", NULL));
|
959
|
+
must_fail(ensure_refname_normalized(OID_REF, "refs/heads/foo/../bar", NULL));
|
960
|
+
must_fail(ensure_refname_normalized(OID_REF, "refs/heads/foo..bar", NULL));
|
961
|
+
must_fail(ensure_refname_normalized(OID_REF, "refs/heads/./foo", NULL));
|
962
|
+
must_fail(ensure_refname_normalized(OID_REF, "refs/heads/v@{ation", NULL));
|
963
|
+
END_TEST
|
964
|
+
|
965
|
+
BEGIN_TEST(normalize1, "normalize a symbolic reference name")
|
966
|
+
must_pass(ensure_refname_normalized(SYM_REF, "a", "a"));
|
967
|
+
must_pass(ensure_refname_normalized(SYM_REF, "a/b", "a/b"));
|
968
|
+
must_pass(ensure_refname_normalized(SYM_REF, "refs///heads///a", "refs/heads/a"));
|
969
|
+
must_fail(ensure_refname_normalized(SYM_REF, "", NULL));
|
970
|
+
must_fail(ensure_refname_normalized(SYM_REF, "heads\foo", NULL));
|
971
|
+
END_TEST
|
972
|
+
|
973
|
+
/* Ported from JGit, BSD licence.
|
974
|
+
* See https://github.com/spearce/JGit/commit/e4bf8f6957bbb29362575d641d1e77a02d906739 */
|
975
|
+
BEGIN_TEST(normalize2, "tests borrowed from JGit")
|
976
|
+
|
977
|
+
/* EmptyString */
|
978
|
+
must_fail(ensure_refname_normalized(SYM_REF, "", NULL));
|
979
|
+
must_fail(ensure_refname_normalized(SYM_REF, "/", NULL));
|
980
|
+
|
981
|
+
/* MustHaveTwoComponents */
|
982
|
+
must_fail(ensure_refname_normalized(OID_REF, "master", NULL));
|
983
|
+
must_pass(ensure_refname_normalized(SYM_REF, "heads/master", "heads/master"));
|
984
|
+
|
985
|
+
/* ValidHead */
|
986
|
+
|
987
|
+
must_pass(ensure_refname_normalized(SYM_REF, "refs/heads/master", "refs/heads/master"));
|
988
|
+
must_pass(ensure_refname_normalized(SYM_REF, "refs/heads/pu", "refs/heads/pu"));
|
989
|
+
must_pass(ensure_refname_normalized(SYM_REF, "refs/heads/z", "refs/heads/z"));
|
990
|
+
must_pass(ensure_refname_normalized(SYM_REF, "refs/heads/FoO", "refs/heads/FoO"));
|
991
|
+
|
992
|
+
/* ValidTag */
|
993
|
+
must_pass(ensure_refname_normalized(SYM_REF, "refs/tags/v1.0", "refs/tags/v1.0"));
|
994
|
+
|
995
|
+
/* NoLockSuffix */
|
996
|
+
must_fail(ensure_refname_normalized(SYM_REF, "refs/heads/master.lock", NULL));
|
997
|
+
|
998
|
+
/* NoDirectorySuffix */
|
999
|
+
must_fail(ensure_refname_normalized(SYM_REF, "refs/heads/master/", NULL));
|
1000
|
+
|
1001
|
+
/* NoSpace */
|
1002
|
+
must_fail(ensure_refname_normalized(SYM_REF, "refs/heads/i haz space", NULL));
|
1003
|
+
|
1004
|
+
/* NoAsciiControlCharacters */
|
1005
|
+
{
|
1006
|
+
char c;
|
1007
|
+
char buffer[GIT_REFNAME_MAX];
|
1008
|
+
for (c = '\1'; c < ' '; c++) {
|
1009
|
+
strncpy(buffer, "refs/heads/mast", 15);
|
1010
|
+
strncpy(buffer + 15, (const char *)&c, 1);
|
1011
|
+
strncpy(buffer + 16, "er", 2);
|
1012
|
+
buffer[18 - 1] = '\0';
|
1013
|
+
must_fail(ensure_refname_normalized(SYM_REF, buffer, NULL));
|
1014
|
+
}
|
1015
|
+
}
|
1016
|
+
|
1017
|
+
/* NoBareDot */
|
1018
|
+
must_fail(ensure_refname_normalized(SYM_REF, "refs/heads/.", NULL));
|
1019
|
+
must_fail(ensure_refname_normalized(SYM_REF, "refs/heads/..", NULL));
|
1020
|
+
must_fail(ensure_refname_normalized(SYM_REF, "refs/heads/./master", NULL));
|
1021
|
+
must_fail(ensure_refname_normalized(SYM_REF, "refs/heads/../master", NULL));
|
1022
|
+
|
1023
|
+
/* NoLeadingOrTrailingDot */
|
1024
|
+
must_fail(ensure_refname_normalized(SYM_REF, ".", NULL));
|
1025
|
+
must_fail(ensure_refname_normalized(SYM_REF, "refs/heads/.bar", NULL));
|
1026
|
+
must_fail(ensure_refname_normalized(SYM_REF, "refs/heads/..bar", NULL));
|
1027
|
+
must_fail(ensure_refname_normalized(SYM_REF, "refs/heads/bar.", NULL));
|
1028
|
+
|
1029
|
+
/* ContainsDot */
|
1030
|
+
must_pass(ensure_refname_normalized(SYM_REF, "refs/heads/m.a.s.t.e.r", "refs/heads/m.a.s.t.e.r"));
|
1031
|
+
must_fail(ensure_refname_normalized(SYM_REF, "refs/heads/master..pu", NULL));
|
1032
|
+
|
1033
|
+
/* NoMagicRefCharacters */
|
1034
|
+
must_fail(ensure_refname_normalized(SYM_REF, "refs/heads/master^", NULL));
|
1035
|
+
must_fail(ensure_refname_normalized(SYM_REF, "refs/heads/^master", NULL));
|
1036
|
+
must_fail(ensure_refname_normalized(SYM_REF, "^refs/heads/master", NULL));
|
1037
|
+
|
1038
|
+
must_fail(ensure_refname_normalized(SYM_REF, "refs/heads/master~", NULL));
|
1039
|
+
must_fail(ensure_refname_normalized(SYM_REF, "refs/heads/~master", NULL));
|
1040
|
+
must_fail(ensure_refname_normalized(SYM_REF, "~refs/heads/master", NULL));
|
1041
|
+
|
1042
|
+
must_fail(ensure_refname_normalized(SYM_REF, "refs/heads/master:", NULL));
|
1043
|
+
must_fail(ensure_refname_normalized(SYM_REF, "refs/heads/:master", NULL));
|
1044
|
+
must_fail(ensure_refname_normalized(SYM_REF, ":refs/heads/master", NULL));
|
1045
|
+
|
1046
|
+
/* ShellGlob */
|
1047
|
+
must_fail(ensure_refname_normalized(SYM_REF, "refs/heads/master?", NULL));
|
1048
|
+
must_fail(ensure_refname_normalized(SYM_REF, "refs/heads/?master", NULL));
|
1049
|
+
must_fail(ensure_refname_normalized(SYM_REF, "?refs/heads/master", NULL));
|
1050
|
+
|
1051
|
+
must_fail(ensure_refname_normalized(SYM_REF, "refs/heads/master[", NULL));
|
1052
|
+
must_fail(ensure_refname_normalized(SYM_REF, "refs/heads/[master", NULL));
|
1053
|
+
must_fail(ensure_refname_normalized(SYM_REF, "[refs/heads/master", NULL));
|
1054
|
+
|
1055
|
+
must_fail(ensure_refname_normalized(SYM_REF, "refs/heads/master*", NULL));
|
1056
|
+
must_fail(ensure_refname_normalized(SYM_REF, "refs/heads/*master", NULL));
|
1057
|
+
must_fail(ensure_refname_normalized(SYM_REF, "*refs/heads/master", NULL));
|
1058
|
+
|
1059
|
+
/* ValidSpecialCharacters */
|
1060
|
+
must_pass(ensure_refname_normalized(SYM_REF, "refs/heads/!", "refs/heads/!"));
|
1061
|
+
must_pass(ensure_refname_normalized(SYM_REF, "refs/heads/\"", "refs/heads/\""));
|
1062
|
+
must_pass(ensure_refname_normalized(SYM_REF, "refs/heads/#", "refs/heads/#"));
|
1063
|
+
must_pass(ensure_refname_normalized(SYM_REF, "refs/heads/$", "refs/heads/$"));
|
1064
|
+
must_pass(ensure_refname_normalized(SYM_REF, "refs/heads/%", "refs/heads/%"));
|
1065
|
+
must_pass(ensure_refname_normalized(SYM_REF, "refs/heads/&", "refs/heads/&"));
|
1066
|
+
must_pass(ensure_refname_normalized(SYM_REF, "refs/heads/'", "refs/heads/'"));
|
1067
|
+
must_pass(ensure_refname_normalized(SYM_REF, "refs/heads/(", "refs/heads/("));
|
1068
|
+
must_pass(ensure_refname_normalized(SYM_REF, "refs/heads/)", "refs/heads/)"));
|
1069
|
+
must_pass(ensure_refname_normalized(SYM_REF, "refs/heads/+", "refs/heads/+"));
|
1070
|
+
must_pass(ensure_refname_normalized(SYM_REF, "refs/heads/,", "refs/heads/,"));
|
1071
|
+
must_pass(ensure_refname_normalized(SYM_REF, "refs/heads/-", "refs/heads/-"));
|
1072
|
+
must_pass(ensure_refname_normalized(SYM_REF, "refs/heads/;", "refs/heads/;"));
|
1073
|
+
must_pass(ensure_refname_normalized(SYM_REF, "refs/heads/<", "refs/heads/<"));
|
1074
|
+
must_pass(ensure_refname_normalized(SYM_REF, "refs/heads/=", "refs/heads/="));
|
1075
|
+
must_pass(ensure_refname_normalized(SYM_REF, "refs/heads/>", "refs/heads/>"));
|
1076
|
+
must_pass(ensure_refname_normalized(SYM_REF, "refs/heads/@", "refs/heads/@"));
|
1077
|
+
must_pass(ensure_refname_normalized(SYM_REF, "refs/heads/]", "refs/heads/]"));
|
1078
|
+
must_pass(ensure_refname_normalized(SYM_REF, "refs/heads/_", "refs/heads/_"));
|
1079
|
+
must_pass(ensure_refname_normalized(SYM_REF, "refs/heads/`", "refs/heads/`"));
|
1080
|
+
must_pass(ensure_refname_normalized(SYM_REF, "refs/heads/{", "refs/heads/{"));
|
1081
|
+
must_pass(ensure_refname_normalized(SYM_REF, "refs/heads/|", "refs/heads/|"));
|
1082
|
+
must_pass(ensure_refname_normalized(SYM_REF, "refs/heads/}", "refs/heads/}"));
|
1083
|
+
|
1084
|
+
// This is valid on UNIX, but not on Windows
|
1085
|
+
// hence we make in invalid due to non-portability
|
1086
|
+
//
|
1087
|
+
must_fail(ensure_refname_normalized(SYM_REF, "refs/heads/\\", NULL));
|
1088
|
+
|
1089
|
+
/* UnicodeNames */
|
1090
|
+
/*
|
1091
|
+
* Currently this fails.
|
1092
|
+
* must_pass(ensure_refname_normalized(SYM_REF, "refs/heads/\u00e5ngstr\u00f6m", "refs/heads/\u00e5ngstr\u00f6m"));
|
1093
|
+
*/
|
1094
|
+
|
1095
|
+
/* RefLogQueryIsValidRef */
|
1096
|
+
must_fail(ensure_refname_normalized(SYM_REF, "refs/heads/master@{1}", NULL));
|
1097
|
+
must_fail(ensure_refname_normalized(SYM_REF, "refs/heads/master@{1.hour.ago}", NULL));
|
1098
|
+
END_TEST
|
1099
|
+
|
1100
|
+
BEGIN_TEST(list0, "try to list all the references in our test repo")
|
1101
|
+
git_repository *repo;
|
1102
|
+
git_strarray ref_list;
|
1103
|
+
|
1104
|
+
must_pass(git_repository_open(&repo, REPOSITORY_FOLDER));
|
1105
|
+
must_pass(git_reference_listall(&ref_list, repo, GIT_REF_LISTALL));
|
1106
|
+
|
1107
|
+
/*{
|
1108
|
+
unsigned short i;
|
1109
|
+
for (i = 0; i < ref_list.count; ++i)
|
1110
|
+
printf("# %s\n", ref_list.strings[i]);
|
1111
|
+
}*/
|
1112
|
+
|
1113
|
+
/* We have exactly 9 refs in total if we include the packed ones:
|
1114
|
+
* there is a reference that exists both in the packfile and as
|
1115
|
+
* loose, but we only list it once */
|
1116
|
+
must_be_true(ref_list.count == 9);
|
1117
|
+
|
1118
|
+
git_strarray_free(&ref_list);
|
1119
|
+
git_repository_free(repo);
|
1120
|
+
END_TEST
|
1121
|
+
|
1122
|
+
BEGIN_TEST(list1, "try to list only the symbolic references")
|
1123
|
+
git_repository *repo;
|
1124
|
+
git_strarray ref_list;
|
1125
|
+
|
1126
|
+
must_pass(git_repository_open(&repo, REPOSITORY_FOLDER));
|
1127
|
+
must_pass(git_reference_listall(&ref_list, repo, GIT_REF_SYMBOLIC));
|
1128
|
+
must_be_true(ref_list.count == 0); /* no symrefs in the test repo */
|
1129
|
+
|
1130
|
+
git_strarray_free(&ref_list);
|
1131
|
+
git_repository_free(repo);
|
1132
|
+
END_TEST
|
1133
|
+
|
1134
|
+
static const char *new_ref = "refs/heads/test-reflog";
|
1135
|
+
#define commit_msg "commit: bla bla"
|
1136
|
+
|
1137
|
+
static int assert_signature(git_signature *expected, git_signature *actual)
|
1138
|
+
{
|
1139
|
+
if (actual == NULL)
|
1140
|
+
return GIT_ERROR;
|
1141
|
+
|
1142
|
+
if (strcmp(expected->name, actual->name) != 0)
|
1143
|
+
return GIT_ERROR;
|
1144
|
+
|
1145
|
+
if (strcmp(expected->email, actual->email) != 0)
|
1146
|
+
return GIT_ERROR;
|
1147
|
+
|
1148
|
+
if (expected->when.offset != actual->when.offset)
|
1149
|
+
return GIT_ERROR;
|
1150
|
+
|
1151
|
+
if (expected->when.time != actual->when.time)
|
1152
|
+
return GIT_ERROR;
|
1153
|
+
|
1154
|
+
return GIT_SUCCESS;
|
1155
|
+
}
|
1156
|
+
|
1157
|
+
BEGIN_TEST(reflog0, "write a reflog for a given reference and ensure it can be read back")
|
1158
|
+
git_repository *repo, *repo2;
|
1159
|
+
git_reference *ref, *lookedup_ref;
|
1160
|
+
git_oid oid;
|
1161
|
+
git_signature *committer;
|
1162
|
+
git_reflog *reflog;
|
1163
|
+
git_reflog_entry *entry;
|
1164
|
+
char oid_str[GIT_OID_HEXSZ+1];
|
1165
|
+
|
1166
|
+
must_pass(open_temp_repo(&repo, REPOSITORY_FOLDER));
|
1167
|
+
|
1168
|
+
/* Create a new branch pointing at the HEAD */
|
1169
|
+
git_oid_fromstr(&oid, current_master_tip);
|
1170
|
+
must_pass(git_reference_create_oid(&ref, repo, new_ref, &oid, 0));
|
1171
|
+
must_pass(git_reference_lookup(&ref, repo, new_ref));
|
1172
|
+
|
1173
|
+
must_pass(git_signature_now(&committer, "foo", "foo@bar"));
|
1174
|
+
|
1175
|
+
must_pass(git_reflog_write(ref, NULL, committer, NULL));
|
1176
|
+
must_fail(git_reflog_write(ref, NULL, committer, "no ancestor NULL for an existing reflog"));
|
1177
|
+
must_fail(git_reflog_write(ref, NULL, committer, "no\nnewline"));
|
1178
|
+
must_pass(git_reflog_write(ref, &oid, committer, commit_msg));
|
1179
|
+
|
1180
|
+
git_repository_free(repo);
|
1181
|
+
|
1182
|
+
/* Reopen a new instance of the repository */
|
1183
|
+
must_pass(git_repository_open(&repo2, TEMP_REPO_FOLDER));
|
1184
|
+
|
1185
|
+
/* Lookup the preivously created branch */
|
1186
|
+
must_pass(git_reference_lookup(&lookedup_ref, repo2, new_ref));
|
1187
|
+
|
1188
|
+
/* Read and parse the reflog for this branch */
|
1189
|
+
must_pass(git_reflog_read(&reflog, lookedup_ref));
|
1190
|
+
must_be_true(reflog->entries.length == 2);
|
1191
|
+
|
1192
|
+
entry = (git_reflog_entry *)git_vector_get(&reflog->entries, 0);
|
1193
|
+
must_pass(assert_signature(committer, entry->committer));
|
1194
|
+
git_oid_to_string(oid_str, GIT_OID_HEXSZ+1, &entry->oid_old);
|
1195
|
+
must_be_true(strcmp("0000000000000000000000000000000000000000", oid_str) == 0);
|
1196
|
+
git_oid_to_string(oid_str, GIT_OID_HEXSZ+1, &entry->oid_cur);
|
1197
|
+
must_be_true(strcmp(current_master_tip, oid_str) == 0);
|
1198
|
+
must_be_true(entry->msg == NULL);
|
1199
|
+
|
1200
|
+
entry = (git_reflog_entry *)git_vector_get(&reflog->entries, 1);
|
1201
|
+
must_pass(assert_signature(committer, entry->committer));
|
1202
|
+
git_oid_to_string(oid_str, GIT_OID_HEXSZ+1, &entry->oid_old);
|
1203
|
+
must_be_true(strcmp(current_master_tip, oid_str) == 0);
|
1204
|
+
git_oid_to_string(oid_str, GIT_OID_HEXSZ+1, &entry->oid_cur);
|
1205
|
+
must_be_true(strcmp(current_master_tip, oid_str) == 0);
|
1206
|
+
must_be_true(strcmp(commit_msg, entry->msg) == 0);
|
1207
|
+
|
1208
|
+
git_signature_free(committer);
|
1209
|
+
git_reflog_free(reflog);
|
1210
|
+
close_temp_repo(repo2);
|
1211
|
+
|
1212
|
+
git_reference_free(ref);
|
1213
|
+
git_reference_free(lookedup_ref);
|
1214
|
+
END_TEST
|
1215
|
+
|
1216
|
+
BEGIN_TEST(reflog1, "avoid writing an obviously wrong reflog")
|
1217
|
+
git_repository *repo;
|
1218
|
+
git_reference *ref;
|
1219
|
+
git_oid oid;
|
1220
|
+
git_signature *committer;
|
1221
|
+
|
1222
|
+
must_pass(open_temp_repo(&repo, REPOSITORY_FOLDER));
|
1223
|
+
|
1224
|
+
/* Create a new branch pointing at the HEAD */
|
1225
|
+
git_oid_fromstr(&oid, current_master_tip);
|
1226
|
+
must_pass(git_reference_create_oid(&ref, repo, new_ref, &oid, 0));
|
1227
|
+
must_pass(git_reference_lookup(&ref, repo, new_ref));
|
1228
|
+
|
1229
|
+
must_pass(git_signature_now(&committer, "foo", "foo@bar"));
|
1230
|
+
|
1231
|
+
/* Write the reflog for the new branch */
|
1232
|
+
must_pass(git_reflog_write(ref, NULL, committer, NULL));
|
1233
|
+
|
1234
|
+
/* Try to update the reflog with wrong information:
|
1235
|
+
* It's no new reference, so the ancestor OID cannot
|
1236
|
+
* be NULL. */
|
1237
|
+
must_fail(git_reflog_write(ref, NULL, committer, NULL));
|
1238
|
+
|
1239
|
+
git_signature_free(committer);
|
1240
|
+
|
1241
|
+
close_temp_repo(repo);
|
1242
|
+
|
1243
|
+
git_reference_free(ref);
|
1244
|
+
END_TEST
|
1245
|
+
|
1246
|
+
BEGIN_SUITE(refs)
|
1247
|
+
ADD_TEST(readtag0);
|
1248
|
+
ADD_TEST(readtag1);
|
1249
|
+
|
1250
|
+
ADD_TEST(readsym0);
|
1251
|
+
ADD_TEST(readsym1);
|
1252
|
+
ADD_TEST(readsym2);
|
1253
|
+
ADD_TEST(readsym3);
|
1254
|
+
|
1255
|
+
ADD_TEST(readpacked0);
|
1256
|
+
ADD_TEST(readpacked1);
|
1257
|
+
|
1258
|
+
ADD_TEST(create0);
|
1259
|
+
ADD_TEST(create1);
|
1260
|
+
ADD_TEST(create2);
|
1261
|
+
ADD_TEST(create3);
|
1262
|
+
|
1263
|
+
ADD_TEST(overwrite0);
|
1264
|
+
ADD_TEST(overwrite1);
|
1265
|
+
ADD_TEST(overwrite2);
|
1266
|
+
ADD_TEST(overwrite3);
|
1267
|
+
|
1268
|
+
ADD_TEST(normalize0);
|
1269
|
+
ADD_TEST(normalize1);
|
1270
|
+
ADD_TEST(normalize2);
|
1271
|
+
|
1272
|
+
ADD_TEST(pack0);
|
1273
|
+
ADD_TEST(pack1);
|
1274
|
+
|
1275
|
+
ADD_TEST(rename0);
|
1276
|
+
ADD_TEST(rename1);
|
1277
|
+
ADD_TEST(rename2);
|
1278
|
+
ADD_TEST(rename3);
|
1279
|
+
ADD_TEST(rename4);
|
1280
|
+
ADD_TEST(rename5);
|
1281
|
+
ADD_TEST(rename6);
|
1282
|
+
ADD_TEST(rename7);
|
1283
|
+
ADD_TEST(rename8);
|
1284
|
+
ADD_TEST(rename9);
|
1285
|
+
|
1286
|
+
ADD_TEST(delete0);
|
1287
|
+
ADD_TEST(delete1);
|
1288
|
+
|
1289
|
+
ADD_TEST(list0);
|
1290
|
+
ADD_TEST(list1);
|
1291
|
+
|
1292
|
+
ADD_TEST(reflog0);
|
1293
|
+
ADD_TEST(reflog1);
|
1294
|
+
END_SUITE
|