rugged 0.19.0 → 0.21.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE +1 -1
- data/README.md +151 -25
- data/ext/rugged/extconf.rb +48 -27
- data/ext/rugged/rugged.c +107 -35
- data/ext/rugged/rugged.h +44 -8
- data/ext/rugged/rugged_blame.c +292 -0
- data/ext/rugged/rugged_blob.c +84 -31
- data/ext/rugged/rugged_branch.c +90 -223
- data/ext/rugged/rugged_branch_collection.c +445 -0
- data/ext/rugged/rugged_commit.c +190 -9
- data/ext/rugged/rugged_config.c +1 -1
- data/ext/rugged/rugged_cred.c +125 -0
- data/ext/rugged/rugged_diff.c +267 -94
- data/ext/rugged/rugged_diff_delta.c +14 -3
- data/ext/rugged/rugged_diff_hunk.c +31 -28
- data/ext/rugged/rugged_diff_line.c +21 -17
- data/ext/rugged/rugged_index.c +326 -6
- data/ext/rugged/rugged_note.c +39 -34
- data/ext/rugged/rugged_object.c +9 -9
- data/ext/rugged/rugged_patch.c +245 -0
- data/ext/rugged/rugged_reference.c +67 -332
- data/ext/rugged/rugged_reference_collection.c +490 -0
- data/ext/rugged/rugged_remote.c +447 -351
- data/ext/rugged/rugged_remote_collection.c +285 -0
- data/ext/rugged/rugged_repo.c +752 -203
- data/ext/rugged/rugged_revwalk.c +119 -27
- data/ext/rugged/rugged_settings.c +48 -1
- data/ext/rugged/rugged_signature.c +30 -16
- data/ext/rugged/rugged_tag.c +86 -191
- data/ext/rugged/rugged_tag_collection.c +279 -0
- data/ext/rugged/rugged_tree.c +159 -22
- data/lib/rugged/branch.rb +8 -17
- data/lib/rugged/credentials.rb +43 -0
- data/lib/rugged/diff/delta.rb +1 -2
- data/lib/rugged/diff/hunk.rb +4 -9
- data/lib/rugged/diff/line.rb +23 -3
- data/lib/rugged/diff.rb +3 -1
- data/lib/rugged/patch.rb +26 -0
- data/lib/rugged/reference.rb +1 -3
- data/lib/rugged/remote.rb +0 -9
- data/lib/rugged/repository.rb +70 -13
- data/lib/rugged/tag.rb +23 -18
- data/lib/rugged/tree.rb +7 -0
- data/lib/rugged/version.rb +1 -1
- data/lib/rugged.rb +8 -1
- data/vendor/libgit2/AUTHORS +75 -0
- data/vendor/libgit2/CMakeLists.txt +490 -0
- data/vendor/libgit2/COPYING +920 -0
- data/vendor/libgit2/Makefile.embed +25 -7
- data/vendor/libgit2/cmake/Modules/AddCFlagIfSupported.cmake +16 -0
- data/vendor/libgit2/cmake/Modules/FindHTTP_Parser.cmake +39 -0
- data/vendor/libgit2/cmake/Modules/FindIconv.cmake +43 -0
- data/vendor/libgit2/cmake/Modules/FindLIBSSH2.cmake +44 -0
- data/vendor/libgit2/deps/http-parser/LICENSE-MIT +23 -0
- data/vendor/libgit2/deps/regex/regex.c +10 -3
- data/vendor/libgit2/include/git2/attr.h +2 -1
- data/vendor/libgit2/include/git2/blame.h +213 -0
- data/vendor/libgit2/include/git2/blob.h +57 -29
- data/vendor/libgit2/include/git2/branch.h +56 -44
- data/vendor/libgit2/include/git2/buffer.h +112 -0
- data/vendor/libgit2/include/git2/checkout.h +72 -37
- data/vendor/libgit2/include/git2/cherrypick.h +87 -0
- data/vendor/libgit2/include/git2/clone.h +153 -56
- data/vendor/libgit2/include/git2/commit.h +82 -12
- data/vendor/libgit2/include/git2/common.h +31 -19
- data/vendor/libgit2/include/git2/config.h +124 -19
- data/vendor/libgit2/include/git2/cred_helpers.h +1 -1
- data/vendor/libgit2/include/git2/diff.h +636 -494
- data/vendor/libgit2/include/git2/errors.h +48 -15
- data/vendor/libgit2/include/git2/filter.h +149 -0
- data/vendor/libgit2/include/git2/graph.h +14 -0
- data/vendor/libgit2/include/git2/index.h +95 -54
- data/vendor/libgit2/include/git2/indexer.h +15 -9
- data/vendor/libgit2/include/git2/merge.h +402 -39
- data/vendor/libgit2/include/git2/message.h +9 -14
- data/vendor/libgit2/include/git2/net.h +5 -0
- data/vendor/libgit2/include/git2/notes.h +6 -6
- data/vendor/libgit2/include/git2/object.h +34 -2
- data/vendor/libgit2/include/git2/odb.h +77 -14
- data/vendor/libgit2/include/git2/odb_backend.h +50 -6
- data/vendor/libgit2/include/git2/oid.h +4 -8
- data/vendor/libgit2/include/git2/pack.h +58 -4
- data/vendor/libgit2/include/git2/patch.h +277 -0
- data/vendor/libgit2/include/git2/pathspec.h +263 -0
- data/vendor/libgit2/include/git2/push.h +55 -5
- data/vendor/libgit2/include/git2/reflog.h +11 -8
- data/vendor/libgit2/include/git2/refs.h +219 -33
- data/vendor/libgit2/include/git2/refspec.h +3 -4
- data/vendor/libgit2/include/git2/remote.h +216 -76
- data/vendor/libgit2/include/git2/repository.h +85 -40
- data/vendor/libgit2/include/git2/reset.h +15 -4
- data/vendor/libgit2/include/git2/revert.h +86 -0
- data/vendor/libgit2/include/git2/revparse.h +27 -16
- data/vendor/libgit2/include/git2/revwalk.h +44 -6
- data/vendor/libgit2/include/git2/signature.h +17 -3
- data/vendor/libgit2/include/git2/stash.h +8 -12
- data/vendor/libgit2/include/git2/status.h +67 -18
- data/vendor/libgit2/include/git2/submodule.h +100 -85
- data/vendor/libgit2/include/git2/sys/commit.h +38 -4
- data/vendor/libgit2/include/git2/sys/config.h +44 -3
- data/vendor/libgit2/include/git2/sys/diff.h +91 -0
- data/vendor/libgit2/include/git2/sys/filter.h +301 -0
- data/vendor/libgit2/include/git2/sys/index.h +0 -2
- data/vendor/libgit2/include/git2/sys/mempack.h +85 -0
- data/vendor/libgit2/include/git2/sys/odb_backend.h +33 -11
- data/vendor/libgit2/include/git2/sys/refdb_backend.h +51 -5
- data/vendor/libgit2/include/git2/sys/reflog.h +21 -0
- data/vendor/libgit2/include/git2/sys/refs.h +2 -2
- data/vendor/libgit2/include/git2/sys/repository.h +19 -1
- data/vendor/libgit2/include/git2/transport.h +216 -75
- data/vendor/libgit2/include/git2/tree.h +32 -11
- data/vendor/libgit2/include/git2/types.h +124 -10
- data/vendor/libgit2/include/git2/version.h +4 -2
- data/vendor/libgit2/include/git2.h +41 -40
- data/vendor/libgit2/libgit2.pc.in +10 -0
- data/vendor/libgit2/src/array.h +16 -8
- data/vendor/libgit2/src/attr.c +140 -402
- data/vendor/libgit2/src/attr.h +1 -33
- data/vendor/libgit2/src/attr_file.c +298 -135
- data/vendor/libgit2/src/attr_file.h +61 -22
- data/vendor/libgit2/src/attrcache.c +449 -0
- data/vendor/libgit2/src/attrcache.h +38 -6
- data/vendor/libgit2/src/bitvec.h +75 -0
- data/vendor/libgit2/src/blame.c +488 -0
- data/vendor/libgit2/src/blame.h +93 -0
- data/vendor/libgit2/src/blame_git.c +624 -0
- data/vendor/libgit2/src/blame_git.h +20 -0
- data/vendor/libgit2/src/blob.c +137 -92
- data/vendor/libgit2/src/blob.h +9 -0
- data/vendor/libgit2/src/branch.c +175 -156
- data/vendor/libgit2/src/buf_text.c +29 -14
- data/vendor/libgit2/src/buf_text.h +5 -4
- data/vendor/libgit2/src/buffer.c +158 -15
- data/vendor/libgit2/src/buffer.h +33 -20
- data/vendor/libgit2/src/cc-compat.h +8 -2
- data/vendor/libgit2/src/checkout.c +1081 -287
- data/vendor/libgit2/src/checkout.h +1 -1
- data/vendor/libgit2/src/cherrypick.c +226 -0
- data/vendor/libgit2/src/clone.c +297 -245
- data/vendor/libgit2/src/{compress.h → clone.h} +4 -8
- data/vendor/libgit2/src/commit.c +313 -101
- data/vendor/libgit2/src/commit.h +6 -3
- data/vendor/libgit2/src/commit_list.c +3 -3
- data/vendor/libgit2/src/commit_list.h +1 -1
- data/vendor/libgit2/src/common.h +74 -1
- data/vendor/libgit2/src/config.c +570 -145
- data/vendor/libgit2/src/config.h +39 -6
- data/vendor/libgit2/src/config_cache.c +32 -18
- data/vendor/libgit2/src/config_file.c +711 -424
- data/vendor/libgit2/src/config_file.h +4 -3
- data/vendor/libgit2/src/crlf.c +149 -109
- data/vendor/libgit2/src/date.c +35 -7
- data/vendor/libgit2/src/delta.c +1 -1
- data/vendor/libgit2/src/diff.c +719 -414
- data/vendor/libgit2/src/diff.h +52 -7
- data/vendor/libgit2/src/diff_driver.c +183 -85
- data/vendor/libgit2/src/diff_driver.h +1 -1
- data/vendor/libgit2/src/diff_file.c +65 -84
- data/vendor/libgit2/src/diff_file.h +12 -10
- data/vendor/libgit2/src/diff_patch.c +274 -333
- data/vendor/libgit2/src/diff_patch.h +10 -9
- data/vendor/libgit2/src/diff_print.c +381 -179
- data/vendor/libgit2/src/diff_stats.c +336 -0
- data/vendor/libgit2/src/diff_tform.c +393 -215
- data/vendor/libgit2/src/diff_xdiff.c +117 -42
- data/vendor/libgit2/src/errors.c +59 -4
- data/vendor/libgit2/src/fetch.c +40 -34
- data/vendor/libgit2/src/fetch.h +2 -5
- data/vendor/libgit2/src/fetchhead.c +14 -7
- data/vendor/libgit2/src/filebuf.c +13 -24
- data/vendor/libgit2/src/filebuf.h +3 -3
- data/vendor/libgit2/src/fileops.c +104 -296
- data/vendor/libgit2/src/fileops.h +23 -94
- data/vendor/libgit2/src/filter.c +642 -43
- data/vendor/libgit2/src/filter.h +7 -66
- data/vendor/libgit2/src/fnmatch.c +46 -3
- data/vendor/libgit2/src/fnmatch.h +24 -3
- data/vendor/libgit2/src/global.c +158 -42
- data/vendor/libgit2/src/global.h +9 -0
- data/vendor/libgit2/src/graph.c +34 -20
- data/vendor/libgit2/src/hash/hash_generic.h +0 -1
- data/vendor/libgit2/src/hash/hash_openssl.h +0 -1
- data/vendor/libgit2/src/hash/hash_win32.c +14 -29
- data/vendor/libgit2/src/hash.h +0 -2
- data/vendor/libgit2/src/hashsig.c +97 -117
- data/vendor/libgit2/src/ident.c +125 -0
- data/vendor/libgit2/src/ignore.c +159 -110
- data/vendor/libgit2/src/ignore.h +13 -3
- data/vendor/libgit2/src/index.c +803 -445
- data/vendor/libgit2/src/index.h +43 -6
- data/vendor/libgit2/src/indexer.c +475 -157
- data/vendor/libgit2/src/iterator.c +198 -55
- data/vendor/libgit2/src/iterator.h +28 -4
- data/vendor/libgit2/src/map.h +1 -0
- data/vendor/libgit2/src/merge.c +849 -142
- data/vendor/libgit2/src/merge.h +11 -4
- data/vendor/libgit2/src/merge_file.c +183 -78
- data/vendor/libgit2/src/merge_file.h +0 -57
- data/vendor/libgit2/src/message.c +4 -28
- data/vendor/libgit2/src/mwindow.c +117 -8
- data/vendor/libgit2/src/mwindow.h +9 -1
- data/vendor/libgit2/src/netops.c +164 -59
- data/vendor/libgit2/src/netops.h +37 -1
- data/vendor/libgit2/src/notes.c +9 -18
- data/vendor/libgit2/src/notes.h +1 -1
- data/vendor/libgit2/src/object.c +78 -2
- data/vendor/libgit2/src/odb.c +191 -59
- data/vendor/libgit2/src/odb.h +2 -1
- data/vendor/libgit2/src/odb_loose.c +66 -51
- data/vendor/libgit2/src/odb_mempack.c +182 -0
- data/vendor/libgit2/src/odb_pack.c +151 -61
- data/vendor/libgit2/src/oid.c +30 -19
- data/vendor/libgit2/src/oid.h +13 -10
- data/vendor/libgit2/src/pack-objects.c +198 -147
- data/vendor/libgit2/src/pack-objects.h +7 -0
- data/vendor/libgit2/src/pack.c +272 -101
- data/vendor/libgit2/src/pack.h +15 -1
- data/vendor/libgit2/src/path.c +359 -117
- data/vendor/libgit2/src/path.h +110 -20
- data/vendor/libgit2/src/pathspec.c +583 -57
- data/vendor/libgit2/src/pathspec.h +36 -15
- data/vendor/libgit2/src/pool.c +4 -5
- data/vendor/libgit2/src/posix.c +45 -2
- data/vendor/libgit2/src/posix.h +13 -5
- data/vendor/libgit2/src/pqueue.c +73 -119
- data/vendor/libgit2/src/pqueue.h +35 -82
- data/vendor/libgit2/src/push.c +116 -48
- data/vendor/libgit2/src/push.h +5 -0
- data/vendor/libgit2/src/refdb.c +45 -6
- data/vendor/libgit2/src/refdb.h +13 -3
- data/vendor/libgit2/src/refdb_fs.c +1130 -551
- data/vendor/libgit2/src/reflog.c +36 -327
- data/vendor/libgit2/src/reflog.h +6 -1
- data/vendor/libgit2/src/refs.c +345 -142
- data/vendor/libgit2/src/refs.h +9 -2
- data/vendor/libgit2/src/refspec.c +90 -62
- data/vendor/libgit2/src/refspec.h +7 -24
- data/vendor/libgit2/src/remote.c +815 -415
- data/vendor/libgit2/src/remote.h +3 -4
- data/vendor/libgit2/src/repository.c +360 -207
- data/vendor/libgit2/src/repository.h +16 -10
- data/vendor/libgit2/src/reset.c +28 -13
- data/vendor/libgit2/src/revert.c +228 -0
- data/vendor/libgit2/src/revparse.c +29 -30
- data/vendor/libgit2/src/revwalk.c +141 -96
- data/vendor/libgit2/src/revwalk.h +6 -1
- data/vendor/libgit2/src/settings.c +140 -0
- data/vendor/libgit2/src/sha1_lookup.c +71 -0
- data/vendor/libgit2/src/sha1_lookup.h +5 -0
- data/vendor/libgit2/src/signature.c +38 -10
- data/vendor/libgit2/src/sortedcache.c +378 -0
- data/vendor/libgit2/src/sortedcache.h +178 -0
- data/vendor/libgit2/src/stash.c +98 -116
- data/vendor/libgit2/src/status.c +88 -60
- data/vendor/libgit2/src/status.h +2 -2
- data/vendor/libgit2/src/strmap.c +32 -0
- data/vendor/libgit2/src/strmap.h +14 -1
- data/vendor/libgit2/src/strnlen.h +23 -0
- data/vendor/libgit2/src/submodule.c +1073 -615
- data/vendor/libgit2/src/submodule.h +89 -21
- data/vendor/libgit2/src/sysdir.c +252 -0
- data/vendor/libgit2/src/sysdir.h +101 -0
- data/vendor/libgit2/src/tag.c +31 -20
- data/vendor/libgit2/src/thread-utils.h +98 -17
- data/vendor/libgit2/src/trace.h +0 -2
- data/vendor/libgit2/src/transport.c +76 -6
- data/vendor/libgit2/src/transports/cred.c +164 -61
- data/vendor/libgit2/src/transports/git.c +41 -48
- data/vendor/libgit2/src/transports/http.c +65 -109
- data/vendor/libgit2/src/transports/local.c +88 -65
- data/vendor/libgit2/src/transports/smart.c +91 -19
- data/vendor/libgit2/src/transports/smart.h +13 -5
- data/vendor/libgit2/src/transports/smart_pkt.c +24 -14
- data/vendor/libgit2/src/transports/smart_protocol.c +268 -113
- data/vendor/libgit2/src/transports/ssh.c +284 -186
- data/vendor/libgit2/src/transports/winhttp.c +279 -198
- data/vendor/libgit2/src/tree-cache.c +21 -23
- data/vendor/libgit2/src/tree-cache.h +1 -0
- data/vendor/libgit2/src/tree.c +109 -92
- data/vendor/libgit2/src/tree.h +2 -3
- data/vendor/libgit2/src/unix/map.c +7 -1
- data/vendor/libgit2/src/unix/posix.h +0 -1
- data/vendor/libgit2/src/userdiff.h +208 -0
- data/vendor/libgit2/src/util.c +16 -112
- data/vendor/libgit2/src/util.h +107 -3
- data/vendor/libgit2/src/vector.c +72 -17
- data/vendor/libgit2/src/vector.h +32 -5
- data/vendor/libgit2/src/win32/dir.c +15 -40
- data/vendor/libgit2/src/win32/dir.h +3 -2
- data/vendor/libgit2/src/win32/error.c +5 -31
- data/vendor/libgit2/src/win32/findfile.c +47 -66
- data/vendor/libgit2/src/win32/findfile.h +1 -12
- data/vendor/libgit2/src/win32/git2.rc +40 -0
- data/vendor/libgit2/src/win32/map.c +7 -1
- data/vendor/libgit2/src/win32/mingw-compat.h +3 -0
- data/vendor/libgit2/src/win32/posix.h +17 -11
- data/vendor/libgit2/src/win32/posix_w32.c +424 -292
- data/vendor/libgit2/src/win32/precompiled.h +6 -2
- data/vendor/libgit2/src/win32/pthread.c +141 -18
- data/vendor/libgit2/src/win32/pthread.h +50 -8
- data/vendor/libgit2/src/win32/reparse.h +57 -0
- data/vendor/libgit2/src/win32/utf-conv.c +117 -60
- data/vendor/libgit2/src/win32/utf-conv.h +81 -6
- data/vendor/libgit2/src/win32/version.h +21 -4
- data/vendor/libgit2/src/win32/w32_util.c +139 -0
- data/vendor/libgit2/src/win32/w32_util.h +54 -0
- data/vendor/libgit2/src/zstream.c +156 -0
- data/vendor/libgit2/src/zstream.h +39 -0
- metadata +84 -167
- data/Rakefile +0 -61
- data/ext/rugged/rugged_diff_patch.c +0 -169
- data/lib/rugged/diff/patch.rb +0 -28
- data/test/blob_test.rb +0 -341
- data/test/branch_test.rb +0 -199
- data/test/commit_test.rb +0 -104
- data/test/config_test.rb +0 -45
- data/test/coverage/cover.rb +0 -133
- data/test/diff_test.rb +0 -777
- data/test/errors_test.rb +0 -34
- data/test/fixtures/alternate/objects/14/6ae76773c91e3b1d00cf7a338ec55ae58297e2 +0 -0
- data/test/fixtures/alternate/objects/14/9c32d47e99d0a3572ff1e70a2e0051bbf347a9 +0 -0
- data/test/fixtures/alternate/objects/14/fb3108588f9421bf764041e5e3ac305eb6277f +0 -0
- data/test/fixtures/archive.tar.gz +0 -0
- data/test/fixtures/attr/attr0 +0 -1
- data/test/fixtures/attr/attr1 +0 -29
- data/test/fixtures/attr/attr2 +0 -21
- data/test/fixtures/attr/attr3 +0 -4
- data/test/fixtures/attr/binfile +0 -1
- data/test/fixtures/attr/dir/file +0 -0
- data/test/fixtures/attr/file +0 -1
- data/test/fixtures/attr/gitattributes +0 -29
- data/test/fixtures/attr/gitignore +0 -2
- data/test/fixtures/attr/ign +0 -1
- data/test/fixtures/attr/macro_bad +0 -1
- data/test/fixtures/attr/macro_test +0 -1
- data/test/fixtures/attr/root_test1 +0 -1
- data/test/fixtures/attr/root_test2 +0 -6
- data/test/fixtures/attr/root_test3 +0 -19
- data/test/fixtures/attr/root_test4.txt +0 -14
- data/test/fixtures/attr/sub/abc +0 -37
- data/test/fixtures/attr/sub/dir/file +0 -0
- data/test/fixtures/attr/sub/file +0 -1
- data/test/fixtures/attr/sub/ign/file +0 -1
- data/test/fixtures/attr/sub/ign/sub/file +0 -1
- data/test/fixtures/attr/sub/sub/dir +0 -0
- data/test/fixtures/attr/sub/sub/file +0 -1
- data/test/fixtures/attr/sub/sub/subsub.txt +0 -1
- data/test/fixtures/attr/sub/subdir_test1 +0 -2
- data/test/fixtures/attr/sub/subdir_test2.txt +0 -1
- data/test/fixtures/diff/another.txt +0 -38
- data/test/fixtures/diff/readme.txt +0 -36
- data/test/fixtures/mergedrepo/conflicts-one.txt +0 -5
- data/test/fixtures/mergedrepo/conflicts-two.txt +0 -5
- data/test/fixtures/mergedrepo/one.txt +0 -10
- data/test/fixtures/mergedrepo/two.txt +0 -12
- data/test/fixtures/status/current_file +0 -1
- data/test/fixtures/status/ignored_file +0 -1
- data/test/fixtures/status/modified_file +0 -2
- data/test/fixtures/status/new_file +0 -1
- data/test/fixtures/status/staged_changes +0 -2
- data/test/fixtures/status/staged_changes_modified_file +0 -3
- data/test/fixtures/status/staged_delete_modified_file +0 -1
- data/test/fixtures/status/staged_new_file +0 -1
- data/test/fixtures/status/staged_new_file_modified_file +0 -2
- data/test/fixtures/status/subdir/current_file +0 -1
- data/test/fixtures/status/subdir/modified_file +0 -2
- data/test/fixtures/status/subdir/new_file +0 -1
- data/test/fixtures/status/subdir.txt +0 -2
- data/test/fixtures/status//350/277/231 +0 -1
- data/test/fixtures/testrepo.git/HEAD +0 -1
- data/test/fixtures/testrepo.git/config +0 -13
- data/test/fixtures/testrepo.git/description +0 -1
- data/test/fixtures/testrepo.git/index +0 -0
- data/test/fixtures/testrepo.git/info/exclude +0 -6
- data/test/fixtures/testrepo.git/logs/HEAD +0 -3
- data/test/fixtures/testrepo.git/logs/refs/heads/master +0 -3
- data/test/fixtures/testrepo.git/logs/refs/notes/commits +0 -1
- data/test/fixtures/testrepo.git/objects/0c/37a5391bbff43c37f0d0371823a5509eed5b1d +0 -0
- data/test/fixtures/testrepo.git/objects/13/85f264afb75a56a5bec74243be9b367ba4ca08 +0 -0
- data/test/fixtures/testrepo.git/objects/18/1037049a54a1eb5fab404658a3a250b44335d7 +0 -0
- data/test/fixtures/testrepo.git/objects/18/10dff58d8a660512d4832e740f692884338ccd +0 -0
- data/test/fixtures/testrepo.git/objects/2d/2eff63372b08adf0a9eb84109ccf7d19e2f3a2 +0 -0
- data/test/fixtures/testrepo.git/objects/36/060c58702ed4c2a40832c51758d5344201d89a +0 -2
- data/test/fixtures/testrepo.git/objects/44/1034f860c1d5d90e4188d11ae0d325176869a8 +0 -1
- data/test/fixtures/testrepo.git/objects/45/b983be36b73c0788dc9cbcb76cbb80fc7bb057 +0 -0
- data/test/fixtures/testrepo.git/objects/4a/202b346bb0fb0db7eff3cffeb3c70babbd2045 +0 -2
- data/test/fixtures/testrepo.git/objects/5b/5b025afb0b4c913b4c338a42934a3863bf3644 +0 -2
- data/test/fixtures/testrepo.git/objects/60/d415052a33de2150bf68757f6461df4f563ae4 +0 -0
- data/test/fixtures/testrepo.git/objects/61/9f9935957e010c419cb9d15621916ddfcc0b96 +0 -0
- data/test/fixtures/testrepo.git/objects/68/8a8f4ef7496901d15322972f96e212a9e466cc +0 -1
- data/test/fixtures/testrepo.git/objects/75/057dd4114e74cca1d750d0aee1647c903cb60a +0 -0
- data/test/fixtures/testrepo.git/objects/77/71329dfa3002caf8c61a0ceb62a31d09023f37 +0 -0
- data/test/fixtures/testrepo.git/objects/81/4889a078c031f61ed08ab5fa863aea9314344d +0 -0
- data/test/fixtures/testrepo.git/objects/84/96071c1b46c854b31185ea97743be6a8774479 +0 -0
- data/test/fixtures/testrepo.git/objects/94/eca2de348d5f672faf56b0decafa5937e3235e +0 -0
- data/test/fixtures/testrepo.git/objects/9b/7384fe1676186192842f5d3e129457b62db9e3 +0 -0
- data/test/fixtures/testrepo.git/objects/9f/d738e8f7967c078dceed8190330fc8648ee56a +0 -3
- data/test/fixtures/testrepo.git/objects/a4/a7dce85cf63874e984719f4fdd239f5145052f +0 -2
- data/test/fixtures/testrepo.git/objects/a7/1586c1dfe8a71c6cbf6c129f404c5642ff31bd +0 -0
- data/test/fixtures/testrepo.git/objects/a8/233120f6ad708f843d861ce2b7228ec4e3dec6 +0 -0
- data/test/fixtures/testrepo.git/objects/b7/4713326bc972cc15751ed504dca6f6f3b91f7a +0 -3
- data/test/fixtures/testrepo.git/objects/be/3563ae3f795b2b4353bcce3a527ad0a4f7f644 +0 -3
- data/test/fixtures/testrepo.git/objects/c4/7800c7266a2be04c571c04d5a6614691ea99bd +0 -3
- data/test/fixtures/testrepo.git/objects/c4/dc1555e4d4fa0e0c9c3fc46734c7c35b3ce90b +0 -0
- data/test/fixtures/testrepo.git/objects/e6/9de29bb2d1d6434b8b29ae775ad8c2e48c5391 +0 -0
- data/test/fixtures/testrepo.git/objects/f6/0079018b664e4e79329a7ef9559c8d9e0378d1 +0 -0
- data/test/fixtures/testrepo.git/objects/fa/49b077972391ad58037050f2a75f74e3671e92 +0 -0
- data/test/fixtures/testrepo.git/objects/fd/093bff70906175335656e6ce6ae05783708765 +0 -0
- data/test/fixtures/testrepo.git/objects/pack/pack-d7c6adf9f61318f041845b01440d09aa7a91e1b5.idx +0 -0
- data/test/fixtures/testrepo.git/objects/pack/pack-d7c6adf9f61318f041845b01440d09aa7a91e1b5.pack +0 -0
- data/test/fixtures/testrepo.git/packed-refs +0 -2
- data/test/fixtures/testrepo.git/refs/heads/master +0 -1
- data/test/fixtures/testrepo.git/refs/notes/commits +0 -1
- data/test/fixtures/testrepo.git/refs/tags/v0.9 +0 -1
- data/test/fixtures/testrepo.git/refs/tags/v1.0 +0 -1
- data/test/fixtures/text_file.md +0 -464
- data/test/fixtures/unsymlinked.git/HEAD +0 -1
- data/test/fixtures/unsymlinked.git/config +0 -6
- data/test/fixtures/unsymlinked.git/description +0 -1
- data/test/fixtures/unsymlinked.git/info/exclude +0 -2
- data/test/fixtures/unsymlinked.git/objects/08/8b64704e0d6b8bd061dea879418cb5442a3fbf +0 -0
- data/test/fixtures/unsymlinked.git/objects/13/a5e939bca25940c069fd2169d993dba328e30b +0 -0
- data/test/fixtures/unsymlinked.git/objects/19/bf568e59e3a0b363cafb4106226e62d4a4c41c +0 -0
- data/test/fixtures/unsymlinked.git/objects/58/1fadd35b4cf320d102a152f918729011604773 +0 -0
- data/test/fixtures/unsymlinked.git/objects/5c/87b6791e8b13da658a14d1ef7e09b5dc3bac8c +0 -0
- data/test/fixtures/unsymlinked.git/objects/6f/e5f5398af85fb3de8a6aba0339b6d3bfa26a27 +0 -0
- data/test/fixtures/unsymlinked.git/objects/7f/ccd75616ec188b8f1b23d67506a334cc34a49d +0 -0
- data/test/fixtures/unsymlinked.git/objects/80/6999882bf91d24241e4077906b9017605eb1f3 +0 -0
- data/test/fixtures/unsymlinked.git/objects/83/7d176303c5005505ec1e4a30231c40930c0230 +0 -0
- data/test/fixtures/unsymlinked.git/objects/a8/595ccca04f40818ae0155c8f9c77a230e597b6 +0 -2
- data/test/fixtures/unsymlinked.git/objects/cf/8f1cf5cce859c438d6cc067284cb5e161206e7 +0 -0
- data/test/fixtures/unsymlinked.git/objects/d5/278d05c8607ec420bfee4cf219fbc0eeebfd6a +0 -0
- data/test/fixtures/unsymlinked.git/objects/f4/e16fb76536591a41454194058d048d8e4dd2e9 +0 -0
- data/test/fixtures/unsymlinked.git/objects/f9/e65619d93fdf2673882e0a261c5e93b1a84006 +0 -0
- data/test/fixtures/unsymlinked.git/refs/heads/exe-file +0 -1
- data/test/fixtures/unsymlinked.git/refs/heads/master +0 -1
- data/test/fixtures/unsymlinked.git/refs/heads/reg-file +0 -1
- data/test/index_test.rb +0 -333
- data/test/lib_test.rb +0 -127
- data/test/note_test.rb +0 -158
- data/test/object_test.rb +0 -43
- data/test/reference_test.rb +0 -207
- data/test/remote_test.rb +0 -324
- data/test/repo_pack_test.rb +0 -24
- data/test/repo_reset_test.rb +0 -82
- data/test/repo_test.rb +0 -402
- data/test/tag_test.rb +0 -68
- data/test/test_helper.rb +0 -92
- data/test/tree_test.rb +0 -91
- data/test/walker_test.rb +0 -88
- data/vendor/libgit2/src/amiga/map.c +0 -48
- data/vendor/libgit2/src/compress.c +0 -53
data/vendor/libgit2/src/attr.c
CHANGED
@@ -1,7 +1,8 @@
|
|
1
|
+
#include "common.h"
|
1
2
|
#include "repository.h"
|
2
|
-
#include "
|
3
|
+
#include "sysdir.h"
|
3
4
|
#include "config.h"
|
4
|
-
#include "
|
5
|
+
#include "attr_file.h"
|
5
6
|
#include "ignore.h"
|
6
7
|
#include "git2/oid.h"
|
7
8
|
#include <ctype.h>
|
@@ -26,13 +27,13 @@ git_attr_t git_attr_value(const char *attr)
|
|
26
27
|
return GIT_ATTR_VALUE_T;
|
27
28
|
}
|
28
29
|
|
29
|
-
|
30
30
|
static int collect_attr_files(
|
31
31
|
git_repository *repo,
|
32
32
|
uint32_t flags,
|
33
33
|
const char *path,
|
34
34
|
git_vector *files);
|
35
35
|
|
36
|
+
static void release_attr_files(git_vector *files);
|
36
37
|
|
37
38
|
int git_attr_get(
|
38
39
|
const char **value,
|
@@ -49,6 +50,8 @@ int git_attr_get(
|
|
49
50
|
git_attr_name attr;
|
50
51
|
git_attr_rule *rule;
|
51
52
|
|
53
|
+
assert(value && repo && name);
|
54
|
+
|
52
55
|
*value = NULL;
|
53
56
|
|
54
57
|
if (git_attr_path__init(&path, pathname, git_repository_workdir(repo)) < 0)
|
@@ -57,6 +60,7 @@ int git_attr_get(
|
|
57
60
|
if ((error = collect_attr_files(repo, flags, pathname, &files)) < 0)
|
58
61
|
goto cleanup;
|
59
62
|
|
63
|
+
memset(&attr, 0, sizeof(attr));
|
60
64
|
attr.name = name;
|
61
65
|
attr.name_hash = git_attr_file__name_hash(name);
|
62
66
|
|
@@ -74,7 +78,7 @@ int git_attr_get(
|
|
74
78
|
}
|
75
79
|
|
76
80
|
cleanup:
|
77
|
-
|
81
|
+
release_attr_files(&files);
|
78
82
|
git_attr_path__free(&path);
|
79
83
|
|
80
84
|
return error;
|
@@ -103,7 +107,10 @@ int git_attr_get_many(
|
|
103
107
|
attr_get_many_info *info = NULL;
|
104
108
|
size_t num_found = 0;
|
105
109
|
|
106
|
-
|
110
|
+
if (!num_attr)
|
111
|
+
return 0;
|
112
|
+
|
113
|
+
assert(values && repo && names);
|
107
114
|
|
108
115
|
if (git_attr_path__init(&path, pathname, git_repository_workdir(repo)) < 0)
|
109
116
|
return -1;
|
@@ -141,8 +148,13 @@ int git_attr_get_many(
|
|
141
148
|
}
|
142
149
|
}
|
143
150
|
|
151
|
+
for (k = 0; k < num_attr; k++) {
|
152
|
+
if (!info[k].found)
|
153
|
+
values[k] = NULL;
|
154
|
+
}
|
155
|
+
|
144
156
|
cleanup:
|
145
|
-
|
157
|
+
release_attr_files(&files);
|
146
158
|
git_attr_path__free(&path);
|
147
159
|
git__free(info);
|
148
160
|
|
@@ -166,15 +178,15 @@ int git_attr_foreach(
|
|
166
178
|
git_attr_assignment *assign;
|
167
179
|
git_strmap *seen = NULL;
|
168
180
|
|
181
|
+
assert(repo && callback);
|
182
|
+
|
169
183
|
if (git_attr_path__init(&path, pathname, git_repository_workdir(repo)) < 0)
|
170
184
|
return -1;
|
171
185
|
|
172
|
-
if ((error = collect_attr_files(repo, flags, pathname, &files)) < 0
|
186
|
+
if ((error = collect_attr_files(repo, flags, pathname, &files)) < 0 ||
|
187
|
+
(error = git_strmap_alloc(&seen)) < 0)
|
173
188
|
goto cleanup;
|
174
189
|
|
175
|
-
seen = git_strmap_alloc();
|
176
|
-
GITERR_CHECK_ALLOC(seen);
|
177
|
-
|
178
190
|
git_vector_foreach(&files, i, file) {
|
179
191
|
|
180
192
|
git_attr_file__foreach_matching_rule(file, &path, j, rule) {
|
@@ -190,8 +202,7 @@ int git_attr_foreach(
|
|
190
202
|
|
191
203
|
error = callback(assign->name, assign->value, payload);
|
192
204
|
if (error) {
|
193
|
-
|
194
|
-
error = GIT_EUSER;
|
205
|
+
giterr_set_after_callback(error);
|
195
206
|
goto cleanup;
|
196
207
|
}
|
197
208
|
}
|
@@ -200,278 +211,114 @@ int git_attr_foreach(
|
|
200
211
|
|
201
212
|
cleanup:
|
202
213
|
git_strmap_free(seen);
|
203
|
-
|
214
|
+
release_attr_files(&files);
|
204
215
|
git_attr_path__free(&path);
|
205
216
|
|
206
217
|
return error;
|
207
218
|
}
|
208
219
|
|
209
|
-
|
210
|
-
int git_attr_add_macro(
|
220
|
+
static int preload_attr_file(
|
211
221
|
git_repository *repo,
|
212
|
-
|
213
|
-
const char *
|
222
|
+
git_attr_file_source source,
|
223
|
+
const char *base,
|
224
|
+
const char *file)
|
214
225
|
{
|
215
226
|
int error;
|
216
|
-
|
217
|
-
git_pool *pool;
|
218
|
-
|
219
|
-
if (git_attr_cache__init(repo) < 0)
|
220
|
-
return -1;
|
221
|
-
|
222
|
-
macro = git__calloc(1, sizeof(git_attr_rule));
|
223
|
-
GITERR_CHECK_ALLOC(macro);
|
227
|
+
git_attr_file *preload = NULL;
|
224
228
|
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
macro->match.length = strlen(macro->match.pattern);
|
231
|
-
macro->match.flags = GIT_ATTR_FNMATCH_MACRO;
|
232
|
-
|
233
|
-
error = git_attr_assignment__parse(repo, pool, ¯o->assigns, &values);
|
234
|
-
|
235
|
-
if (!error)
|
236
|
-
error = git_attr_cache__insert_macro(repo, macro);
|
237
|
-
|
238
|
-
if (error < 0)
|
239
|
-
git_attr_rule__free(macro);
|
229
|
+
if (!file)
|
230
|
+
return 0;
|
231
|
+
if (!(error = git_attr_cache__get(
|
232
|
+
&preload, repo, source, base, file, git_attr_file__parse_buffer)))
|
233
|
+
git_attr_file__free(preload);
|
240
234
|
|
241
235
|
return error;
|
242
236
|
}
|
243
237
|
|
244
|
-
|
245
|
-
git_repository *repo, git_attr_file_source source, const char *path)
|
238
|
+
static int attr_setup(git_repository *repo)
|
246
239
|
{
|
247
|
-
|
248
|
-
git_strmap *files = git_repository_attr_cache(repo)->files;
|
240
|
+
int error = 0;
|
249
241
|
const char *workdir = git_repository_workdir(repo);
|
250
|
-
|
251
|
-
|
252
|
-
if (workdir && git__prefixcmp(path, workdir) == 0)
|
253
|
-
path += strlen(workdir);
|
254
|
-
if (git_buf_printf(&cache_key, "%d#%s", (int)source, path) < 0)
|
255
|
-
return false;
|
256
|
-
|
257
|
-
rval = git_strmap_exists(files, git_buf_cstr(&cache_key));
|
258
|
-
|
259
|
-
git_buf_free(&cache_key);
|
260
|
-
|
261
|
-
return rval;
|
262
|
-
}
|
242
|
+
git_index *idx = NULL;
|
243
|
+
git_buf sys = GIT_BUF_INIT;
|
263
244
|
|
264
|
-
|
265
|
-
const char **data,
|
266
|
-
git_futils_filestamp *stamp,
|
267
|
-
const char *filename)
|
268
|
-
{
|
269
|
-
int error;
|
270
|
-
git_buf content = GIT_BUF_INIT;
|
271
|
-
|
272
|
-
error = git_futils_filestamp_check(stamp, filename);
|
273
|
-
if (error < 0)
|
245
|
+
if ((error = git_attr_cache__init(repo)) < 0)
|
274
246
|
return error;
|
275
247
|
|
276
|
-
/*
|
277
|
-
*
|
248
|
+
/* preload attribute files that could contain macros so the
|
249
|
+
* definitions will be available for later file parsing
|
278
250
|
*/
|
279
|
-
if (!error)
|
280
|
-
return GIT_ENOTFOUND;
|
281
251
|
|
282
|
-
error =
|
252
|
+
if (!(error = git_sysdir_find_system_file(&sys, GIT_ATTR_FILE_SYSTEM))) {
|
253
|
+
error = preload_attr_file(
|
254
|
+
repo, GIT_ATTR_FILE__FROM_FILE, NULL, sys.ptr);
|
255
|
+
git_buf_free(&sys);
|
256
|
+
}
|
283
257
|
if (error < 0) {
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
/* TODO: once warnings are available, issue a warning callback */
|
258
|
+
if (error == GIT_ENOTFOUND) {
|
259
|
+
giterr_clear();
|
260
|
+
error = 0;
|
261
|
+
} else
|
262
|
+
return error;
|
290
263
|
}
|
291
264
|
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
}
|
296
|
-
|
297
|
-
static int load_attr_blob_from_index(
|
298
|
-
const char **content,
|
299
|
-
git_blob **blob,
|
300
|
-
git_repository *repo,
|
301
|
-
const git_oid *old_oid,
|
302
|
-
const char *relfile)
|
303
|
-
{
|
304
|
-
int error;
|
305
|
-
size_t pos;
|
306
|
-
git_index *index;
|
307
|
-
const git_index_entry *entry;
|
308
|
-
|
309
|
-
if ((error = git_repository_index__weakptr(&index, repo)) < 0 ||
|
310
|
-
(error = git_index_find(&pos, index, relfile)) < 0)
|
265
|
+
if ((error = preload_attr_file(
|
266
|
+
repo, GIT_ATTR_FILE__FROM_FILE,
|
267
|
+
NULL, git_repository_attr_cache(repo)->cfg_attr_file)) < 0)
|
311
268
|
return error;
|
312
269
|
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
return GIT_ENOTFOUND;
|
317
|
-
|
318
|
-
if ((error = git_blob_lookup(blob, repo, &entry->oid)) < 0)
|
270
|
+
if ((error = preload_attr_file(
|
271
|
+
repo, GIT_ATTR_FILE__FROM_FILE,
|
272
|
+
git_repository_path(repo), GIT_ATTR_FILE_INREPO)) < 0)
|
319
273
|
return error;
|
320
274
|
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
static int load_attr_from_cache(
|
326
|
-
git_attr_file **file,
|
327
|
-
git_attr_cache *cache,
|
328
|
-
git_attr_file_source source,
|
329
|
-
const char *relative_path)
|
330
|
-
{
|
331
|
-
git_buf cache_key = GIT_BUF_INIT;
|
332
|
-
khiter_t cache_pos;
|
333
|
-
|
334
|
-
*file = NULL;
|
335
|
-
|
336
|
-
if (!cache || !cache->files)
|
337
|
-
return 0;
|
338
|
-
|
339
|
-
if (git_buf_printf(&cache_key, "%d#%s", (int)source, relative_path) < 0)
|
340
|
-
return -1;
|
341
|
-
|
342
|
-
cache_pos = git_strmap_lookup_index(cache->files, cache_key.ptr);
|
343
|
-
|
344
|
-
git_buf_free(&cache_key);
|
345
|
-
|
346
|
-
if (git_strmap_valid_index(cache->files, cache_pos))
|
347
|
-
*file = git_strmap_value_at(cache->files, cache_pos);
|
348
|
-
|
349
|
-
return 0;
|
350
|
-
}
|
351
|
-
|
352
|
-
int git_attr_cache__internal_file(
|
353
|
-
git_repository *repo,
|
354
|
-
const char *filename,
|
355
|
-
git_attr_file **file)
|
356
|
-
{
|
357
|
-
int error = 0;
|
358
|
-
git_attr_cache *cache = git_repository_attr_cache(repo);
|
359
|
-
khiter_t cache_pos = git_strmap_lookup_index(cache->files, filename);
|
360
|
-
|
361
|
-
if (git_strmap_valid_index(cache->files, cache_pos)) {
|
362
|
-
*file = git_strmap_value_at(cache->files, cache_pos);
|
363
|
-
return 0;
|
364
|
-
}
|
365
|
-
|
366
|
-
if (git_attr_file__new(file, 0, filename, &cache->pool) < 0)
|
367
|
-
return -1;
|
275
|
+
if (workdir != NULL &&
|
276
|
+
(error = preload_attr_file(
|
277
|
+
repo, GIT_ATTR_FILE__FROM_FILE, workdir, GIT_ATTR_FILE)) < 0)
|
278
|
+
return error;
|
368
279
|
|
369
|
-
|
370
|
-
|
371
|
-
|
280
|
+
if ((error = git_repository_index__weakptr(&idx, repo)) < 0 ||
|
281
|
+
(error = preload_attr_file(
|
282
|
+
repo, GIT_ATTR_FILE__FROM_INDEX, NULL, GIT_ATTR_FILE)) < 0)
|
283
|
+
return error;
|
372
284
|
|
373
285
|
return error;
|
374
286
|
}
|
375
287
|
|
376
|
-
int
|
288
|
+
int git_attr_add_macro(
|
377
289
|
git_repository *repo,
|
378
|
-
const char *
|
379
|
-
const char *
|
380
|
-
git_attr_file_source source,
|
381
|
-
git_attr_file_parser parse,
|
382
|
-
void* parsedata,
|
383
|
-
git_vector *stack)
|
290
|
+
const char *name,
|
291
|
+
const char *values)
|
384
292
|
{
|
385
|
-
int error
|
386
|
-
|
387
|
-
|
388
|
-
const char *relfile, *content = NULL;
|
389
|
-
git_attr_cache *cache = git_repository_attr_cache(repo);
|
390
|
-
git_attr_file *file = NULL;
|
391
|
-
git_blob *blob = NULL;
|
392
|
-
git_futils_filestamp stamp;
|
393
|
-
|
394
|
-
assert(filename && stack);
|
395
|
-
|
396
|
-
/* join base and path as needed */
|
397
|
-
if (base != NULL && git_path_root(filename) < 0) {
|
398
|
-
if (git_buf_joinpath(&path, base, filename) < 0)
|
399
|
-
return -1;
|
400
|
-
filename = path.ptr;
|
401
|
-
}
|
402
|
-
|
403
|
-
relfile = filename;
|
404
|
-
if (workdir && git__prefixcmp(relfile, workdir) == 0)
|
405
|
-
relfile += strlen(workdir);
|
406
|
-
|
407
|
-
/* check cache */
|
408
|
-
if (load_attr_from_cache(&file, cache, source, relfile) < 0)
|
409
|
-
return -1;
|
410
|
-
|
411
|
-
/* if not in cache, load data, parse, and cache */
|
412
|
-
|
413
|
-
if (source == GIT_ATTR_FILE_FROM_FILE) {
|
414
|
-
git_futils_filestamp_set(
|
415
|
-
&stamp, file ? &file->cache_data.stamp : NULL);
|
416
|
-
|
417
|
-
error = load_attr_file(&content, &stamp, filename);
|
418
|
-
} else {
|
419
|
-
error = load_attr_blob_from_index(&content, &blob,
|
420
|
-
repo, file ? &file->cache_data.oid : NULL, relfile);
|
421
|
-
}
|
422
|
-
|
423
|
-
if (error) {
|
424
|
-
/* not finding a file is not an error for this function */
|
425
|
-
if (error == GIT_ENOTFOUND) {
|
426
|
-
giterr_clear();
|
427
|
-
error = 0;
|
428
|
-
}
|
429
|
-
goto finish;
|
430
|
-
}
|
293
|
+
int error;
|
294
|
+
git_attr_rule *macro = NULL;
|
295
|
+
git_pool *pool;
|
431
296
|
|
432
|
-
|
433
|
-
|
434
|
-
git_attr_file__clear_rules(file);
|
435
|
-
else {
|
436
|
-
error = git_attr_file__new(&file, source, relfile, &cache->pool);
|
437
|
-
if (error < 0)
|
438
|
-
goto finish;
|
439
|
-
}
|
297
|
+
if ((error = git_attr_cache__init(repo)) < 0)
|
298
|
+
return error;
|
440
299
|
|
441
|
-
|
442
|
-
|
300
|
+
macro = git__calloc(1, sizeof(git_attr_rule));
|
301
|
+
GITERR_CHECK_ALLOC(macro);
|
443
302
|
|
444
|
-
|
445
|
-
if (error > 0)
|
446
|
-
error = 0;
|
303
|
+
pool = &git_repository_attr_cache(repo)->pool;
|
447
304
|
|
448
|
-
|
449
|
-
|
450
|
-
git_oid_cpy(&file->cache_data.oid, git_object_id((git_object *)blob));
|
451
|
-
else
|
452
|
-
git_futils_filestamp_set(&file->cache_data.stamp, &stamp);
|
305
|
+
macro->match.pattern = git_pool_strdup(pool, name);
|
306
|
+
GITERR_CHECK_ALLOC(macro->match.pattern);
|
453
307
|
|
454
|
-
|
455
|
-
|
456
|
-
if (!error && file != NULL)
|
457
|
-
error = git_vector_insert(stack, file);
|
308
|
+
macro->match.length = strlen(macro->match.pattern);
|
309
|
+
macro->match.flags = GIT_ATTR_FNMATCH_MACRO;
|
458
310
|
|
459
|
-
|
460
|
-
git_attr_file__free(file);
|
311
|
+
error = git_attr_assignment__parse(repo, pool, ¯o->assigns, &values);
|
461
312
|
|
462
|
-
if (
|
463
|
-
|
464
|
-
else
|
465
|
-
git__free((void *)content);
|
313
|
+
if (!error)
|
314
|
+
error = git_attr_cache__insert_macro(repo, macro);
|
466
315
|
|
467
|
-
|
316
|
+
if (error < 0)
|
317
|
+
git_attr_rule__free(macro);
|
468
318
|
|
469
319
|
return error;
|
470
320
|
}
|
471
321
|
|
472
|
-
#define push_attr_file(R,S,B,F) \
|
473
|
-
git_attr_cache__push_file((R),(B),(F),GIT_ATTR_FILE_FROM_FILE,git_attr_file__parse_buffer,NULL,(S))
|
474
|
-
|
475
322
|
typedef struct {
|
476
323
|
git_repository *repo;
|
477
324
|
uint32_t flags;
|
@@ -480,7 +327,7 @@ typedef struct {
|
|
480
327
|
git_vector *files;
|
481
328
|
} attr_walk_up_info;
|
482
329
|
|
483
|
-
int
|
330
|
+
static int attr_decide_sources(
|
484
331
|
uint32_t flags, bool has_wd, bool has_index, git_attr_file_source *srcs)
|
485
332
|
{
|
486
333
|
int count = 0;
|
@@ -488,42 +335,76 @@ int git_attr_cache__decide_sources(
|
|
488
335
|
switch (flags & 0x03) {
|
489
336
|
case GIT_ATTR_CHECK_FILE_THEN_INDEX:
|
490
337
|
if (has_wd)
|
491
|
-
srcs[count++] =
|
338
|
+
srcs[count++] = GIT_ATTR_FILE__FROM_FILE;
|
492
339
|
if (has_index)
|
493
|
-
srcs[count++] =
|
340
|
+
srcs[count++] = GIT_ATTR_FILE__FROM_INDEX;
|
494
341
|
break;
|
495
342
|
case GIT_ATTR_CHECK_INDEX_THEN_FILE:
|
496
343
|
if (has_index)
|
497
|
-
srcs[count++] =
|
344
|
+
srcs[count++] = GIT_ATTR_FILE__FROM_INDEX;
|
498
345
|
if (has_wd)
|
499
|
-
srcs[count++] =
|
346
|
+
srcs[count++] = GIT_ATTR_FILE__FROM_FILE;
|
500
347
|
break;
|
501
348
|
case GIT_ATTR_CHECK_INDEX_ONLY:
|
502
349
|
if (has_index)
|
503
|
-
srcs[count++] =
|
350
|
+
srcs[count++] = GIT_ATTR_FILE__FROM_INDEX;
|
504
351
|
break;
|
505
352
|
}
|
506
353
|
|
507
354
|
return count;
|
508
355
|
}
|
509
356
|
|
357
|
+
static int push_attr_file(
|
358
|
+
git_repository *repo,
|
359
|
+
git_vector *list,
|
360
|
+
git_attr_file_source source,
|
361
|
+
const char *base,
|
362
|
+
const char *filename)
|
363
|
+
{
|
364
|
+
int error = 0;
|
365
|
+
git_attr_file *file = NULL;
|
366
|
+
|
367
|
+
error = git_attr_cache__get(
|
368
|
+
&file, repo, source, base, filename, git_attr_file__parse_buffer);
|
369
|
+
if (error < 0)
|
370
|
+
return error;
|
371
|
+
|
372
|
+
if (file != NULL) {
|
373
|
+
if ((error = git_vector_insert(list, file)) < 0)
|
374
|
+
git_attr_file__free(file);
|
375
|
+
}
|
376
|
+
|
377
|
+
return error;
|
378
|
+
}
|
379
|
+
|
510
380
|
static int push_one_attr(void *ref, git_buf *path)
|
511
381
|
{
|
512
382
|
int error = 0, n_src, i;
|
513
383
|
attr_walk_up_info *info = (attr_walk_up_info *)ref;
|
514
384
|
git_attr_file_source src[2];
|
515
385
|
|
516
|
-
n_src =
|
386
|
+
n_src = attr_decide_sources(
|
517
387
|
info->flags, info->workdir != NULL, info->index != NULL, src);
|
518
388
|
|
519
389
|
for (i = 0; !error && i < n_src; ++i)
|
520
|
-
error =
|
521
|
-
info->repo,
|
522
|
-
git_attr_file__parse_buffer, NULL, info->files);
|
390
|
+
error = push_attr_file(
|
391
|
+
info->repo, info->files, src[i], path->ptr, GIT_ATTR_FILE);
|
523
392
|
|
524
393
|
return error;
|
525
394
|
}
|
526
395
|
|
396
|
+
static void release_attr_files(git_vector *files)
|
397
|
+
{
|
398
|
+
size_t i;
|
399
|
+
git_attr_file *file;
|
400
|
+
|
401
|
+
git_vector_foreach(files, i, file) {
|
402
|
+
git_attr_file__free(file);
|
403
|
+
files->contents[i] = NULL;
|
404
|
+
}
|
405
|
+
git_vector_free(files);
|
406
|
+
}
|
407
|
+
|
527
408
|
static int collect_attr_files(
|
528
409
|
git_repository *repo,
|
529
410
|
uint32_t flags,
|
@@ -533,11 +414,10 @@ static int collect_attr_files(
|
|
533
414
|
int error;
|
534
415
|
git_buf dir = GIT_BUF_INIT;
|
535
416
|
const char *workdir = git_repository_workdir(repo);
|
536
|
-
attr_walk_up_info info;
|
417
|
+
attr_walk_up_info info = { NULL };
|
537
418
|
|
538
|
-
if (
|
539
|
-
|
540
|
-
return -1;
|
419
|
+
if ((error = attr_setup(repo)) < 0)
|
420
|
+
return error;
|
541
421
|
|
542
422
|
/* Resolve path in a non-bare repo */
|
543
423
|
if (workdir != NULL)
|
@@ -555,7 +435,8 @@ static int collect_attr_files(
|
|
555
435
|
*/
|
556
436
|
|
557
437
|
error = push_attr_file(
|
558
|
-
repo, files,
|
438
|
+
repo, files, GIT_ATTR_FILE__FROM_FILE,
|
439
|
+
git_repository_path(repo), GIT_ATTR_FILE_INREPO);
|
559
440
|
if (error < 0)
|
560
441
|
goto cleanup;
|
561
442
|
|
@@ -572,15 +453,17 @@ static int collect_attr_files(
|
|
572
453
|
|
573
454
|
if (git_repository_attr_cache(repo)->cfg_attr_file != NULL) {
|
574
455
|
error = push_attr_file(
|
575
|
-
repo, files,
|
456
|
+
repo, files, GIT_ATTR_FILE__FROM_FILE,
|
457
|
+
NULL, git_repository_attr_cache(repo)->cfg_attr_file);
|
576
458
|
if (error < 0)
|
577
459
|
goto cleanup;
|
578
460
|
}
|
579
461
|
|
580
462
|
if ((flags & GIT_ATTR_CHECK_NO_SYSTEM) == 0) {
|
581
|
-
error =
|
463
|
+
error = git_sysdir_find_system_file(&dir, GIT_ATTR_FILE_SYSTEM);
|
582
464
|
if (!error)
|
583
|
-
error = push_attr_file(
|
465
|
+
error = push_attr_file(
|
466
|
+
repo, files, GIT_ATTR_FILE__FROM_FILE, NULL, dir.ptr);
|
584
467
|
else if (error == GIT_ENOTFOUND) {
|
585
468
|
giterr_clear();
|
586
469
|
error = 0;
|
@@ -589,153 +472,8 @@ static int collect_attr_files(
|
|
589
472
|
|
590
473
|
cleanup:
|
591
474
|
if (error < 0)
|
592
|
-
|
475
|
+
release_attr_files(files);
|
593
476
|
git_buf_free(&dir);
|
594
477
|
|
595
478
|
return error;
|
596
479
|
}
|
597
|
-
|
598
|
-
static int attr_cache__lookup_path(
|
599
|
-
char **out, git_config *cfg, const char *key, const char *fallback)
|
600
|
-
{
|
601
|
-
git_buf buf = GIT_BUF_INIT;
|
602
|
-
int error;
|
603
|
-
const char *cfgval = NULL;
|
604
|
-
|
605
|
-
*out = NULL;
|
606
|
-
|
607
|
-
if (!(error = git_config_get_string(&cfgval, cfg, key))) {
|
608
|
-
|
609
|
-
/* expand leading ~/ as needed */
|
610
|
-
if (cfgval && cfgval[0] == '~' && cfgval[1] == '/' &&
|
611
|
-
!git_futils_find_global_file(&buf, &cfgval[2]))
|
612
|
-
*out = git_buf_detach(&buf);
|
613
|
-
else if (cfgval)
|
614
|
-
*out = git__strdup(cfgval);
|
615
|
-
|
616
|
-
} else if (error == GIT_ENOTFOUND) {
|
617
|
-
giterr_clear();
|
618
|
-
error = 0;
|
619
|
-
|
620
|
-
if (!git_futils_find_xdg_file(&buf, fallback))
|
621
|
-
*out = git_buf_detach(&buf);
|
622
|
-
}
|
623
|
-
|
624
|
-
git_buf_free(&buf);
|
625
|
-
|
626
|
-
return error;
|
627
|
-
}
|
628
|
-
|
629
|
-
int git_attr_cache__init(git_repository *repo)
|
630
|
-
{
|
631
|
-
int ret;
|
632
|
-
git_attr_cache *cache = git_repository_attr_cache(repo);
|
633
|
-
git_config *cfg;
|
634
|
-
|
635
|
-
if (cache->initialized)
|
636
|
-
return 0;
|
637
|
-
|
638
|
-
/* cache config settings for attributes and ignores */
|
639
|
-
if (git_repository_config__weakptr(&cfg, repo) < 0)
|
640
|
-
return -1;
|
641
|
-
|
642
|
-
ret = attr_cache__lookup_path(
|
643
|
-
&cache->cfg_attr_file, cfg, GIT_ATTR_CONFIG, GIT_ATTR_FILE_XDG);
|
644
|
-
if (ret < 0)
|
645
|
-
return ret;
|
646
|
-
|
647
|
-
ret = attr_cache__lookup_path(
|
648
|
-
&cache->cfg_excl_file, cfg, GIT_IGNORE_CONFIG, GIT_IGNORE_FILE_XDG);
|
649
|
-
if (ret < 0)
|
650
|
-
return ret;
|
651
|
-
|
652
|
-
/* allocate hashtable for attribute and ignore file contents */
|
653
|
-
if (cache->files == NULL) {
|
654
|
-
cache->files = git_strmap_alloc();
|
655
|
-
GITERR_CHECK_ALLOC(cache->files);
|
656
|
-
}
|
657
|
-
|
658
|
-
/* allocate hashtable for attribute macros */
|
659
|
-
if (cache->macros == NULL) {
|
660
|
-
cache->macros = git_strmap_alloc();
|
661
|
-
GITERR_CHECK_ALLOC(cache->macros);
|
662
|
-
}
|
663
|
-
|
664
|
-
/* allocate string pool */
|
665
|
-
if (git_pool_init(&cache->pool, 1, 0) < 0)
|
666
|
-
return -1;
|
667
|
-
|
668
|
-
cache->initialized = 1;
|
669
|
-
|
670
|
-
/* insert default macros */
|
671
|
-
return git_attr_add_macro(repo, "binary", "-diff -crlf -text");
|
672
|
-
}
|
673
|
-
|
674
|
-
void git_attr_cache_flush(
|
675
|
-
git_repository *repo)
|
676
|
-
{
|
677
|
-
git_attr_cache *cache;
|
678
|
-
|
679
|
-
if (!repo)
|
680
|
-
return;
|
681
|
-
|
682
|
-
cache = git_repository_attr_cache(repo);
|
683
|
-
|
684
|
-
if (cache->files != NULL) {
|
685
|
-
git_attr_file *file;
|
686
|
-
|
687
|
-
git_strmap_foreach_value(cache->files, file, {
|
688
|
-
git_attr_file__free(file);
|
689
|
-
});
|
690
|
-
|
691
|
-
git_strmap_free(cache->files);
|
692
|
-
}
|
693
|
-
|
694
|
-
if (cache->macros != NULL) {
|
695
|
-
git_attr_rule *rule;
|
696
|
-
|
697
|
-
git_strmap_foreach_value(cache->macros, rule, {
|
698
|
-
git_attr_rule__free(rule);
|
699
|
-
});
|
700
|
-
|
701
|
-
git_strmap_free(cache->macros);
|
702
|
-
}
|
703
|
-
|
704
|
-
git_pool_clear(&cache->pool);
|
705
|
-
|
706
|
-
git__free(cache->cfg_attr_file);
|
707
|
-
cache->cfg_attr_file = NULL;
|
708
|
-
|
709
|
-
git__free(cache->cfg_excl_file);
|
710
|
-
cache->cfg_excl_file = NULL;
|
711
|
-
|
712
|
-
cache->initialized = 0;
|
713
|
-
}
|
714
|
-
|
715
|
-
int git_attr_cache__insert_macro(git_repository *repo, git_attr_rule *macro)
|
716
|
-
{
|
717
|
-
git_strmap *macros = git_repository_attr_cache(repo)->macros;
|
718
|
-
int error;
|
719
|
-
|
720
|
-
/* TODO: generate warning log if (macro->assigns.length == 0) */
|
721
|
-
if (macro->assigns.length == 0)
|
722
|
-
return 0;
|
723
|
-
|
724
|
-
git_strmap_insert(macros, macro->match.pattern, macro, error);
|
725
|
-
return (error < 0) ? -1 : 0;
|
726
|
-
}
|
727
|
-
|
728
|
-
git_attr_rule *git_attr_cache__lookup_macro(
|
729
|
-
git_repository *repo, const char *name)
|
730
|
-
{
|
731
|
-
git_strmap *macros = git_repository_attr_cache(repo)->macros;
|
732
|
-
khiter_t pos;
|
733
|
-
|
734
|
-
pos = git_strmap_lookup_index(macros, name);
|
735
|
-
|
736
|
-
if (!git_strmap_valid_index(macros, pos))
|
737
|
-
return NULL;
|
738
|
-
|
739
|
-
return (git_attr_rule *)git_strmap_value_at(macros, pos);
|
740
|
-
}
|
741
|
-
|