rugged 0.19.0 → 0.28.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 +184 -33
- data/ext/rugged/extconf.rb +111 -28
- data/ext/rugged/rugged.c +327 -89
- data/ext/rugged/rugged.h +64 -28
- data/ext/rugged/rugged_allocator.c +89 -0
- data/ext/rugged/rugged_backend.c +17 -0
- data/ext/rugged/rugged_blame.c +278 -0
- data/ext/rugged/rugged_blob.c +301 -75
- data/ext/rugged/rugged_branch.c +92 -242
- data/ext/rugged/rugged_branch_collection.c +388 -0
- data/ext/rugged/rugged_commit.c +575 -79
- data/ext/rugged/rugged_config.c +129 -36
- data/ext/rugged/rugged_cred.c +131 -0
- data/ext/rugged/rugged_diff.c +291 -122
- data/ext/rugged/rugged_diff_delta.c +16 -22
- data/ext/rugged/rugged_diff_hunk.c +35 -51
- data/ext/rugged/rugged_diff_line.c +23 -36
- data/ext/rugged/rugged_index.c +289 -152
- data/ext/rugged/rugged_note.c +50 -60
- data/ext/rugged/rugged_object.c +13 -30
- data/ext/rugged/rugged_patch.c +400 -0
- data/ext/rugged/rugged_rebase.c +397 -0
- data/ext/rugged/rugged_reference.c +76 -346
- data/ext/rugged/rugged_reference_collection.c +423 -0
- data/ext/rugged/rugged_remote.c +438 -461
- data/ext/rugged/rugged_remote_collection.c +435 -0
- data/ext/rugged/rugged_repo.c +1548 -365
- data/ext/rugged/rugged_revwalk.c +378 -99
- data/ext/rugged/rugged_settings.c +86 -23
- data/ext/rugged/rugged_signature.c +47 -37
- data/ext/rugged/rugged_submodule.c +835 -0
- data/ext/rugged/rugged_submodule_collection.c +366 -0
- data/ext/rugged/rugged_tag.c +88 -210
- data/ext/rugged/rugged_tag_collection.c +326 -0
- data/ext/rugged/rugged_tree.c +460 -217
- data/lib/rugged/attributes.rb +46 -0
- data/lib/rugged/blob.rb +33 -0
- data/lib/rugged/branch.rb +12 -16
- data/lib/rugged/commit.rb +9 -0
- data/lib/rugged/console.rb +5 -0
- data/lib/rugged/credentials.rb +48 -0
- data/lib/rugged/diff/delta.rb +6 -2
- data/lib/rugged/diff/hunk.rb +9 -9
- data/lib/rugged/diff/line.rb +28 -5
- data/lib/rugged/diff.rb +7 -1
- data/lib/rugged/index.rb +120 -0
- data/lib/rugged/object.rb +5 -0
- data/lib/rugged/patch.rb +41 -0
- data/lib/rugged/reference.rb +6 -3
- data/lib/rugged/remote.rb +5 -9
- data/lib/rugged/repository.rb +126 -14
- data/lib/rugged/submodule_collection.rb +53 -0
- data/lib/rugged/tag.rb +45 -16
- data/lib/rugged/tree.rb +163 -1
- data/lib/rugged/version.rb +6 -1
- data/lib/rugged/walker.rb +5 -0
- data/lib/rugged.rb +16 -1
- data/vendor/libgit2/AUTHORS +77 -0
- data/vendor/libgit2/CMakeLists.txt +317 -0
- data/vendor/libgit2/COPYING +993 -0
- data/vendor/libgit2/cmake/Modules/AddCFlagIfSupported.cmake +30 -0
- data/vendor/libgit2/cmake/Modules/CheckPrototypeDefinition.c.in +29 -0
- data/vendor/libgit2/cmake/Modules/CheckPrototypeDefinition.cmake +96 -0
- data/vendor/libgit2/cmake/Modules/EnableWarnings.cmake +11 -0
- data/vendor/libgit2/cmake/Modules/FindCoreFoundation.cmake +26 -0
- data/vendor/libgit2/cmake/Modules/FindGSSAPI.cmake +324 -0
- data/vendor/libgit2/cmake/Modules/FindHTTP_Parser.cmake +39 -0
- data/vendor/libgit2/cmake/Modules/FindIconv.cmake +45 -0
- data/vendor/libgit2/cmake/Modules/FindPkgLibraries.cmake +28 -0
- data/vendor/libgit2/cmake/Modules/FindSecurity.cmake +28 -0
- data/vendor/libgit2/cmake/Modules/FindStatNsec.cmake +20 -0
- data/vendor/libgit2/cmake/Modules/FindmbedTLS.cmake +93 -0
- data/vendor/libgit2/cmake/Modules/IdeSplitSources.cmake +22 -0
- data/vendor/libgit2/deps/http-parser/CMakeLists.txt +5 -0
- data/vendor/libgit2/deps/http-parser/COPYING +23 -0
- data/vendor/libgit2/deps/http-parser/http_parser.c +5 -2
- data/vendor/libgit2/deps/http-parser/http_parser.h +2 -0
- data/vendor/libgit2/deps/regex/CMakeLists.txt +2 -0
- data/vendor/libgit2/deps/regex/COPYING +502 -0
- data/vendor/libgit2/deps/regex/regex.c +10 -3
- data/vendor/libgit2/deps/winhttp/CMakeLists.txt +26 -0
- data/vendor/libgit2/deps/winhttp/COPYING.GPL +993 -0
- data/vendor/libgit2/deps/winhttp/COPYING.LGPL +502 -0
- data/vendor/libgit2/deps/winhttp/urlmon.h +45 -0
- data/vendor/libgit2/deps/winhttp/winhttp.def +29 -0
- data/vendor/libgit2/deps/winhttp/winhttp.h +594 -0
- data/vendor/libgit2/deps/winhttp/winhttp64.def +29 -0
- data/vendor/libgit2/deps/zlib/CMakeLists.txt +5 -0
- data/vendor/libgit2/deps/zlib/COPYING +27 -0
- data/vendor/libgit2/deps/zlib/adler32.c +51 -34
- data/vendor/libgit2/deps/zlib/crc32.c +61 -61
- data/vendor/libgit2/deps/zlib/crc32.h +1 -1
- data/vendor/libgit2/deps/zlib/deflate.c +681 -352
- data/vendor/libgit2/deps/zlib/deflate.h +25 -18
- data/vendor/libgit2/deps/zlib/gzguts.h +218 -0
- data/vendor/libgit2/deps/zlib/infback.c +640 -0
- data/vendor/libgit2/deps/zlib/inffast.c +36 -53
- data/vendor/libgit2/deps/zlib/inffixed.h +3 -3
- data/vendor/libgit2/deps/zlib/inflate.c +167 -86
- data/vendor/libgit2/deps/zlib/inflate.h +7 -4
- data/vendor/libgit2/deps/zlib/inftrees.c +24 -50
- data/vendor/libgit2/deps/zlib/trees.c +55 -96
- data/vendor/libgit2/deps/zlib/zconf.h +499 -19
- data/vendor/libgit2/deps/zlib/zlib.h +526 -227
- data/vendor/libgit2/deps/zlib/zutil.c +39 -32
- data/vendor/libgit2/deps/zlib/zutil.h +75 -78
- data/vendor/libgit2/include/git2/annotated_commit.h +125 -0
- data/vendor/libgit2/include/git2/apply.h +129 -0
- data/vendor/libgit2/include/git2/attr.h +36 -21
- data/vendor/libgit2/include/git2/blame.h +229 -0
- data/vendor/libgit2/include/git2/blob.h +81 -44
- data/vendor/libgit2/include/git2/branch.h +81 -42
- data/vendor/libgit2/include/git2/buffer.h +128 -0
- data/vendor/libgit2/include/git2/checkout.h +141 -67
- data/vendor/libgit2/include/git2/cherrypick.h +92 -0
- data/vendor/libgit2/include/git2/clone.h +157 -58
- data/vendor/libgit2/include/git2/commit.h +231 -12
- data/vendor/libgit2/include/git2/common.h +216 -30
- data/vendor/libgit2/include/git2/config.h +274 -48
- data/vendor/libgit2/include/git2/cred_helpers.h +4 -4
- data/vendor/libgit2/include/git2/deprecated.h +253 -0
- data/vendor/libgit2/include/git2/describe.h +189 -0
- data/vendor/libgit2/include/git2/diff.h +985 -575
- data/vendor/libgit2/include/git2/errors.h +93 -52
- data/vendor/libgit2/include/git2/filter.h +217 -0
- data/vendor/libgit2/include/git2/global.h +44 -0
- data/vendor/libgit2/include/git2/graph.h +17 -0
- data/vendor/libgit2/include/git2/ignore.h +2 -2
- data/vendor/libgit2/include/git2/index.h +269 -94
- data/vendor/libgit2/include/git2/indexer.h +44 -12
- data/vendor/libgit2/include/git2/mailmap.h +115 -0
- data/vendor/libgit2/include/git2/merge.h +501 -64
- data/vendor/libgit2/include/git2/message.h +52 -17
- data/vendor/libgit2/include/git2/net.h +11 -5
- data/vendor/libgit2/include/git2/notes.h +120 -16
- data/vendor/libgit2/include/git2/object.h +62 -23
- data/vendor/libgit2/include/git2/odb.h +140 -24
- data/vendor/libgit2/include/git2/odb_backend.h +56 -12
- data/vendor/libgit2/include/git2/oid.h +17 -18
- data/vendor/libgit2/include/git2/oidarray.h +40 -0
- data/vendor/libgit2/include/git2/pack.h +86 -7
- data/vendor/libgit2/include/git2/patch.h +274 -0
- data/vendor/libgit2/include/git2/pathspec.h +280 -0
- data/vendor/libgit2/include/git2/proxy.h +96 -0
- data/vendor/libgit2/include/git2/rebase.h +323 -0
- data/vendor/libgit2/include/git2/reflog.h +12 -9
- data/vendor/libgit2/include/git2/refs.h +241 -46
- data/vendor/libgit2/include/git2/refspec.h +20 -4
- data/vendor/libgit2/include/git2/remote.h +636 -209
- data/vendor/libgit2/include/git2/repository.h +267 -57
- data/vendor/libgit2/include/git2/reset.h +36 -6
- data/vendor/libgit2/include/git2/revert.h +91 -0
- data/vendor/libgit2/include/git2/revparse.h +27 -16
- data/vendor/libgit2/include/git2/revwalk.h +78 -35
- data/vendor/libgit2/include/git2/signature.h +32 -5
- data/vendor/libgit2/include/git2/stash.h +160 -21
- data/vendor/libgit2/include/git2/status.h +92 -30
- data/vendor/libgit2/include/git2/submodule.h +226 -133
- data/vendor/libgit2/include/git2/sys/alloc.h +101 -0
- data/vendor/libgit2/include/git2/sys/commit.h +38 -4
- data/vendor/libgit2/include/git2/sys/config.h +68 -9
- data/vendor/libgit2/include/git2/sys/diff.h +94 -0
- data/vendor/libgit2/include/git2/sys/filter.h +332 -0
- data/vendor/libgit2/include/git2/sys/hashsig.h +106 -0
- data/vendor/libgit2/include/git2/sys/index.h +6 -5
- data/vendor/libgit2/include/git2/sys/mempack.h +86 -0
- data/vendor/libgit2/include/git2/sys/merge.h +182 -0
- data/vendor/libgit2/include/git2/sys/odb_backend.h +66 -28
- data/vendor/libgit2/include/git2/sys/openssl.h +38 -0
- data/vendor/libgit2/include/git2/sys/path.h +64 -0
- data/vendor/libgit2/include/git2/sys/refdb_backend.h +79 -19
- data/vendor/libgit2/include/git2/sys/reflog.h +21 -0
- data/vendor/libgit2/include/git2/sys/refs.h +13 -2
- data/vendor/libgit2/include/git2/sys/repository.h +64 -1
- data/vendor/libgit2/include/git2/sys/stream.h +138 -0
- data/vendor/libgit2/include/git2/sys/time.h +31 -0
- data/vendor/libgit2/include/git2/sys/transport.h +439 -0
- data/vendor/libgit2/include/git2/tag.h +11 -2
- data/vendor/libgit2/include/git2/trace.h +1 -1
- data/vendor/libgit2/include/git2/transaction.h +121 -0
- data/vendor/libgit2/include/git2/transport.h +261 -292
- data/vendor/libgit2/include/git2/tree.h +111 -21
- data/vendor/libgit2/include/git2/types.h +244 -32
- data/vendor/libgit2/include/git2/version.h +5 -2
- data/vendor/libgit2/include/git2/worktree.h +255 -0
- data/vendor/libgit2/include/git2.h +50 -40
- data/vendor/libgit2/libgit2.pc.in +13 -0
- data/vendor/libgit2/src/CMakeLists.txt +525 -0
- data/vendor/libgit2/src/alloc.c +55 -0
- data/vendor/libgit2/src/alloc.h +40 -0
- data/vendor/libgit2/src/annotated_commit.c +228 -0
- data/vendor/libgit2/src/annotated_commit.h +52 -0
- data/vendor/libgit2/src/apply.c +855 -0
- data/vendor/libgit2/src/apply.h +25 -0
- data/vendor/libgit2/src/array.h +74 -16
- data/vendor/libgit2/src/attr.c +239 -408
- data/vendor/libgit2/src/attr.h +3 -33
- data/vendor/libgit2/src/attr_file.c +424 -156
- data/vendor/libgit2/src/attr_file.h +95 -23
- data/vendor/libgit2/src/attrcache.c +469 -0
- data/vendor/libgit2/src/attrcache.h +37 -5
- data/vendor/libgit2/src/bitvec.h +75 -0
- data/vendor/libgit2/src/blame.c +532 -0
- data/vendor/libgit2/src/blame.h +95 -0
- data/vendor/libgit2/src/blame_git.c +668 -0
- data/vendor/libgit2/src/blame_git.h +22 -0
- data/vendor/libgit2/src/blob.c +233 -129
- data/vendor/libgit2/src/blob.h +29 -1
- data/vendor/libgit2/src/branch.c +295 -197
- data/vendor/libgit2/src/branch.h +2 -0
- data/vendor/libgit2/src/buf_text.c +52 -27
- data/vendor/libgit2/src/buf_text.h +7 -7
- data/vendor/libgit2/src/buffer.c +609 -52
- data/vendor/libgit2/src/buffer.h +68 -23
- data/vendor/libgit2/src/cache.c +48 -51
- data/vendor/libgit2/src/cache.h +6 -4
- data/vendor/libgit2/src/cc-compat.h +35 -7
- data/vendor/libgit2/src/checkout.c +1827 -483
- data/vendor/libgit2/src/checkout.h +4 -1
- data/vendor/libgit2/src/cherrypick.c +230 -0
- data/vendor/libgit2/src/clone.c +338 -258
- data/vendor/libgit2/src/{compress.h → clone.h} +5 -5
- data/vendor/libgit2/src/commit.c +711 -124
- data/vendor/libgit2/src/commit.h +10 -3
- data/vendor/libgit2/src/commit_list.c +21 -14
- data/vendor/libgit2/src/commit_list.h +9 -3
- data/vendor/libgit2/src/common.h +153 -13
- data/vendor/libgit2/src/config.c +871 -242
- data/vendor/libgit2/src/config.h +58 -14
- data/vendor/libgit2/src/config_backend.h +84 -0
- data/vendor/libgit2/src/config_cache.c +44 -18
- data/vendor/libgit2/src/config_entries.c +259 -0
- data/vendor/libgit2/src/config_entries.h +23 -0
- data/vendor/libgit2/src/config_file.c +837 -1113
- data/vendor/libgit2/src/config_mem.c +224 -0
- data/vendor/libgit2/src/config_parse.c +558 -0
- data/vendor/libgit2/src/config_parse.h +64 -0
- data/vendor/libgit2/src/crlf.c +290 -195
- data/vendor/libgit2/src/date.c +35 -7
- data/vendor/libgit2/src/delta.c +275 -71
- data/vendor/libgit2/src/delta.h +80 -58
- data/vendor/libgit2/src/describe.c +893 -0
- data/vendor/libgit2/src/diff.c +330 -1128
- data/vendor/libgit2/src/diff.h +25 -67
- data/vendor/libgit2/src/diff_driver.c +225 -109
- data/vendor/libgit2/src/diff_driver.h +5 -2
- data/vendor/libgit2/src/diff_file.c +128 -103
- data/vendor/libgit2/src/diff_file.h +17 -12
- data/vendor/libgit2/src/diff_generate.c +1622 -0
- data/vendor/libgit2/src/diff_generate.h +128 -0
- data/vendor/libgit2/src/diff_parse.c +108 -0
- data/vendor/libgit2/src/diff_parse.h +20 -0
- data/vendor/libgit2/src/diff_print.c +578 -218
- data/vendor/libgit2/src/diff_stats.c +362 -0
- data/vendor/libgit2/src/diff_tform.c +429 -257
- data/vendor/libgit2/src/diff_tform.h +25 -0
- data/vendor/libgit2/src/diff_xdiff.c +143 -46
- data/vendor/libgit2/src/diff_xdiff.h +12 -5
- data/vendor/libgit2/src/errors.c +150 -34
- data/vendor/libgit2/src/features.h.in +37 -0
- data/vendor/libgit2/src/fetch.c +69 -46
- data/vendor/libgit2/src/fetch.h +6 -12
- data/vendor/libgit2/src/fetchhead.c +40 -33
- data/vendor/libgit2/src/fetchhead.h +5 -4
- data/vendor/libgit2/src/filebuf.c +163 -61
- data/vendor/libgit2/src/filebuf.h +13 -7
- data/vendor/libgit2/src/fileops.c +549 -407
- data/vendor/libgit2/src/fileops.h +97 -106
- data/vendor/libgit2/src/filter.c +989 -46
- data/vendor/libgit2/src/filter.h +21 -70
- data/vendor/libgit2/src/fnmatch.c +67 -11
- data/vendor/libgit2/src/fnmatch.h +27 -7
- data/vendor/libgit2/src/global.c +257 -63
- data/vendor/libgit2/src/global.h +19 -0
- data/vendor/libgit2/src/graph.c +39 -23
- data/vendor/libgit2/src/hash/hash_collisiondetect.h +51 -0
- data/vendor/libgit2/src/hash/hash_common_crypto.h +61 -0
- data/vendor/libgit2/src/hash/hash_generic.c +3 -3
- data/vendor/libgit2/src/hash/hash_generic.h +10 -5
- data/vendor/libgit2/src/hash/hash_mbedtls.c +38 -0
- data/vendor/libgit2/src/hash/hash_mbedtls.h +24 -0
- data/vendor/libgit2/src/hash/hash_openssl.h +26 -8
- data/vendor/libgit2/src/hash/hash_win32.c +71 -43
- data/vendor/libgit2/src/hash/hash_win32.h +4 -3
- data/vendor/libgit2/src/hash/sha1dc/sha1.c +1900 -0
- data/vendor/libgit2/src/hash/sha1dc/sha1.h +110 -0
- data/vendor/libgit2/src/hash/sha1dc/ubc_check.c +372 -0
- data/vendor/libgit2/src/hash/sha1dc/ubc_check.h +52 -0
- data/vendor/libgit2/src/hash.c +0 -1
- data/vendor/libgit2/src/hash.h +13 -6
- data/vendor/libgit2/src/hashsig.c +121 -126
- data/vendor/libgit2/src/ident.c +129 -0
- data/vendor/libgit2/src/idxmap.c +153 -0
- data/vendor/libgit2/src/idxmap.h +41 -0
- data/vendor/libgit2/src/ignore.c +362 -123
- data/vendor/libgit2/src/ignore.h +16 -4
- data/vendor/libgit2/src/index.c +2131 -692
- data/vendor/libgit2/src/index.h +138 -6
- data/vendor/libgit2/src/indexer.c +866 -266
- data/vendor/libgit2/src/indexer.h +16 -0
- data/vendor/libgit2/src/integer.h +106 -0
- data/vendor/libgit2/src/iterator.c +1888 -967
- data/vendor/libgit2/src/iterator.h +130 -67
- data/vendor/libgit2/src/khash.h +43 -29
- data/vendor/libgit2/src/mailmap.c +485 -0
- data/vendor/libgit2/src/mailmap.h +35 -0
- data/vendor/libgit2/src/map.h +1 -1
- data/vendor/libgit2/src/merge.c +1679 -479
- data/vendor/libgit2/src/merge.h +89 -22
- data/vendor/libgit2/src/merge_driver.c +426 -0
- data/vendor/libgit2/src/merge_driver.h +62 -0
- data/vendor/libgit2/src/merge_file.c +238 -101
- data/vendor/libgit2/src/message.c +4 -28
- data/vendor/libgit2/src/message.h +3 -1
- data/vendor/libgit2/src/mwindow.c +123 -15
- data/vendor/libgit2/src/mwindow.h +10 -1
- data/vendor/libgit2/src/netops.c +178 -499
- data/vendor/libgit2/src/netops.h +51 -27
- data/vendor/libgit2/src/notes.c +251 -94
- data/vendor/libgit2/src/notes.h +5 -2
- data/vendor/libgit2/src/object.c +253 -67
- data/vendor/libgit2/src/object.h +40 -2
- data/vendor/libgit2/src/object_api.c +30 -11
- data/vendor/libgit2/src/odb.c +765 -201
- data/vendor/libgit2/src/odb.h +40 -8
- data/vendor/libgit2/src/odb_loose.c +560 -346
- data/vendor/libgit2/src/odb_mempack.c +185 -0
- data/vendor/libgit2/src/odb_pack.c +117 -73
- data/vendor/libgit2/src/offmap.c +113 -0
- data/vendor/libgit2/src/offmap.h +32 -42
- data/vendor/libgit2/src/oid.c +45 -25
- data/vendor/libgit2/src/oid.h +26 -8
- data/vendor/libgit2/src/oidarray.c +34 -0
- data/vendor/libgit2/src/oidarray.h +20 -0
- data/vendor/libgit2/src/oidmap.c +125 -0
- data/vendor/libgit2/src/oidmap.h +30 -17
- data/vendor/libgit2/src/pack-objects.c +688 -265
- data/vendor/libgit2/src/pack-objects.h +27 -13
- data/vendor/libgit2/src/pack.c +418 -202
- data/vendor/libgit2/src/pack.h +25 -16
- data/vendor/libgit2/src/parse.c +124 -0
- data/vendor/libgit2/src/parse.h +61 -0
- data/vendor/libgit2/src/patch.c +223 -0
- data/vendor/libgit2/src/patch.h +68 -0
- data/vendor/libgit2/src/patch_generate.c +901 -0
- data/vendor/libgit2/src/patch_generate.h +69 -0
- data/vendor/libgit2/src/patch_parse.c +1136 -0
- data/vendor/libgit2/src/patch_parse.h +51 -0
- data/vendor/libgit2/src/path.c +1247 -241
- data/vendor/libgit2/src/path.h +353 -57
- data/vendor/libgit2/src/pathspec.c +586 -58
- data/vendor/libgit2/src/pathspec.h +37 -15
- data/vendor/libgit2/src/pool.c +134 -221
- data/vendor/libgit2/src/pool.h +38 -50
- data/vendor/libgit2/src/posix.c +76 -10
- data/vendor/libgit2/src/posix.h +74 -32
- data/vendor/libgit2/src/pqueue.c +79 -117
- data/vendor/libgit2/src/pqueue.h +38 -82
- data/vendor/libgit2/src/proxy.c +39 -0
- data/vendor/libgit2/src/proxy.h +17 -0
- data/vendor/libgit2/src/push.c +178 -279
- data/vendor/libgit2/src/push.h +93 -4
- data/vendor/libgit2/src/reader.c +265 -0
- data/vendor/libgit2/src/reader.h +107 -0
- data/vendor/libgit2/src/rebase.c +1364 -0
- data/vendor/libgit2/src/refdb.c +74 -19
- data/vendor/libgit2/src/refdb.h +16 -3
- data/vendor/libgit2/src/refdb_fs.c +1472 -603
- data/vendor/libgit2/src/refdb_fs.h +4 -0
- data/vendor/libgit2/src/reflog.c +40 -330
- data/vendor/libgit2/src/reflog.h +8 -2
- data/vendor/libgit2/src/refs.c +641 -225
- data/vendor/libgit2/src/refs.h +53 -6
- data/vendor/libgit2/src/refspec.c +175 -62
- data/vendor/libgit2/src/refspec.h +10 -25
- data/vendor/libgit2/src/remote.c +1741 -723
- data/vendor/libgit2/src/remote.h +17 -5
- data/vendor/libgit2/src/repository.c +1505 -421
- data/vendor/libgit2/src/repository.h +95 -15
- data/vendor/libgit2/src/reset.c +63 -26
- data/vendor/libgit2/src/revert.c +232 -0
- data/vendor/libgit2/src/revparse.c +94 -80
- data/vendor/libgit2/src/revwalk.c +427 -194
- data/vendor/libgit2/src/revwalk.h +14 -5
- data/vendor/libgit2/src/settings.c +290 -0
- data/vendor/libgit2/src/sha1_lookup.c +16 -159
- data/vendor/libgit2/src/sha1_lookup.h +5 -4
- data/vendor/libgit2/src/signature.c +138 -26
- data/vendor/libgit2/src/signature.h +5 -0
- data/vendor/libgit2/src/sortedcache.c +395 -0
- data/vendor/libgit2/src/sortedcache.h +180 -0
- data/vendor/libgit2/src/stash.c +629 -168
- data/vendor/libgit2/src/status.c +125 -75
- data/vendor/libgit2/src/status.h +4 -2
- data/vendor/libgit2/src/stdalloc.c +120 -0
- data/vendor/libgit2/src/stdalloc.h +17 -0
- data/vendor/libgit2/src/stream.h +86 -0
- data/vendor/libgit2/src/streams/mbedtls.c +483 -0
- data/vendor/libgit2/src/streams/mbedtls.h +23 -0
- data/vendor/libgit2/src/streams/openssl.c +789 -0
- data/vendor/libgit2/src/streams/openssl.h +23 -0
- data/vendor/libgit2/src/streams/registry.c +118 -0
- data/vendor/libgit2/src/streams/registry.h +19 -0
- data/vendor/libgit2/src/streams/socket.c +235 -0
- data/vendor/libgit2/src/streams/socket.h +23 -0
- data/vendor/libgit2/src/streams/stransport.c +323 -0
- data/vendor/libgit2/src/streams/stransport.h +21 -0
- data/vendor/libgit2/src/streams/tls.c +73 -0
- data/vendor/libgit2/src/streams/tls.h +31 -0
- data/vendor/libgit2/src/strmap.c +147 -0
- data/vendor/libgit2/src/strmap.h +46 -51
- data/vendor/libgit2/src/strnlen.h +24 -0
- data/vendor/libgit2/src/submodule.c +1633 -877
- data/vendor/libgit2/src/submodule.h +83 -21
- data/vendor/libgit2/src/sysdir.c +355 -0
- data/vendor/libgit2/src/sysdir.h +119 -0
- data/vendor/libgit2/src/tag.c +87 -62
- data/vendor/libgit2/src/tag.h +4 -1
- data/vendor/libgit2/src/thread-utils.c +3 -0
- data/vendor/libgit2/src/thread-utils.h +71 -35
- data/vendor/libgit2/src/trace.c +4 -4
- data/vendor/libgit2/src/trace.h +11 -3
- data/vendor/libgit2/src/trailer.c +416 -0
- data/vendor/libgit2/src/transaction.c +382 -0
- data/vendor/libgit2/src/transaction.h +14 -0
- data/vendor/libgit2/src/transport.c +133 -67
- data/vendor/libgit2/src/transports/auth.c +75 -0
- data/vendor/libgit2/src/transports/auth.h +64 -0
- data/vendor/libgit2/src/transports/auth_negotiate.c +277 -0
- data/vendor/libgit2/src/transports/auth_negotiate.h +27 -0
- data/vendor/libgit2/src/transports/cred.c +296 -68
- data/vendor/libgit2/src/transports/cred.h +16 -0
- data/vendor/libgit2/src/transports/cred_helpers.c +4 -0
- data/vendor/libgit2/src/transports/git.c +108 -90
- data/vendor/libgit2/src/transports/http.c +803 -258
- data/vendor/libgit2/src/transports/http.h +25 -0
- data/vendor/libgit2/src/transports/local.c +265 -169
- data/vendor/libgit2/src/transports/smart.c +255 -45
- data/vendor/libgit2/src/transports/smart.h +42 -22
- data/vendor/libgit2/src/transports/smart_pkt.c +250 -159
- data/vendor/libgit2/src/transports/smart_protocol.c +414 -196
- data/vendor/libgit2/src/transports/ssh.c +645 -236
- data/vendor/libgit2/src/transports/ssh.h +14 -0
- data/vendor/libgit2/src/transports/winhttp.c +809 -353
- data/vendor/libgit2/src/tree-cache.c +138 -52
- data/vendor/libgit2/src/tree-cache.h +14 -7
- data/vendor/libgit2/src/tree.c +620 -259
- data/vendor/libgit2/src/tree.h +12 -19
- data/vendor/libgit2/src/tsort.c +3 -2
- data/vendor/libgit2/src/unix/map.c +25 -7
- data/vendor/libgit2/src/unix/posix.h +77 -12
- data/vendor/libgit2/src/unix/pthread.h +56 -0
- data/vendor/libgit2/src/unix/realpath.c +12 -8
- data/vendor/libgit2/src/userdiff.h +208 -0
- data/vendor/libgit2/src/util.c +349 -165
- data/vendor/libgit2/src/util.h +167 -85
- data/vendor/libgit2/src/varint.c +43 -0
- data/vendor/libgit2/src/varint.h +17 -0
- data/vendor/libgit2/src/vector.c +156 -33
- data/vendor/libgit2/src/vector.h +41 -5
- data/vendor/libgit2/src/win32/dir.c +22 -42
- data/vendor/libgit2/src/win32/dir.h +7 -5
- data/vendor/libgit2/src/win32/error.c +6 -32
- data/vendor/libgit2/src/win32/error.h +4 -2
- data/vendor/libgit2/src/win32/findfile.c +62 -69
- data/vendor/libgit2/src/win32/findfile.h +5 -13
- data/vendor/libgit2/src/win32/git2.rc +44 -0
- data/vendor/libgit2/src/win32/map.c +39 -11
- data/vendor/libgit2/src/win32/mingw-compat.h +10 -11
- data/vendor/libgit2/src/win32/msvc-compat.h +10 -33
- data/vendor/libgit2/src/win32/path_w32.c +476 -0
- data/vendor/libgit2/src/win32/path_w32.h +104 -0
- data/vendor/libgit2/src/win32/posix.h +35 -30
- data/vendor/libgit2/src/win32/posix_w32.c +659 -327
- data/vendor/libgit2/src/win32/precompiled.h +7 -2
- data/vendor/libgit2/src/win32/reparse.h +57 -0
- data/vendor/libgit2/src/win32/thread.c +258 -0
- data/vendor/libgit2/src/win32/thread.h +64 -0
- data/vendor/libgit2/src/win32/utf-conv.c +127 -62
- data/vendor/libgit2/src/win32/utf-conv.h +47 -6
- data/vendor/libgit2/src/win32/version.h +21 -4
- data/vendor/libgit2/src/win32/w32_buffer.c +54 -0
- data/vendor/libgit2/src/win32/w32_buffer.h +20 -0
- data/vendor/libgit2/src/win32/w32_crtdbg_stacktrace.c +438 -0
- data/vendor/libgit2/src/win32/w32_crtdbg_stacktrace.h +129 -0
- data/vendor/libgit2/src/win32/w32_stack.c +193 -0
- data/vendor/libgit2/src/win32/w32_stack.h +140 -0
- data/vendor/libgit2/src/win32/w32_util.c +95 -0
- data/vendor/libgit2/src/win32/w32_util.h +170 -0
- data/vendor/libgit2/src/win32/win32-compat.h +52 -0
- data/vendor/libgit2/src/worktree.c +578 -0
- data/vendor/libgit2/src/worktree.h +39 -0
- data/vendor/libgit2/src/xdiff/xdiff.h +33 -18
- data/vendor/libgit2/src/xdiff/xdiffi.c +578 -88
- data/vendor/libgit2/src/xdiff/xdiffi.h +3 -2
- data/vendor/libgit2/src/xdiff/xemit.c +106 -45
- data/vendor/libgit2/src/xdiff/xemit.h +3 -3
- data/vendor/libgit2/src/xdiff/xhistogram.c +5 -4
- data/vendor/libgit2/src/xdiff/xinclude.h +3 -2
- data/vendor/libgit2/src/xdiff/xmacros.h +2 -2
- data/vendor/libgit2/src/xdiff/xmerge.c +167 -48
- data/vendor/libgit2/src/xdiff/xpatience.c +42 -10
- data/vendor/libgit2/src/xdiff/xprepare.c +14 -14
- data/vendor/libgit2/src/xdiff/xprepare.h +2 -2
- data/vendor/libgit2/src/xdiff/xtypes.h +2 -2
- data/vendor/libgit2/src/xdiff/xutils.c +60 -56
- data/vendor/libgit2/src/xdiff/xutils.h +3 -5
- data/vendor/libgit2/src/zstream.c +205 -0
- data/vendor/libgit2/src/zstream.h +53 -0
- metadata +281 -233
- 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/Makefile.embed +0 -42
- data/vendor/libgit2/include/git2/push.h +0 -131
- data/vendor/libgit2/include/git2/threads.h +0 -50
- data/vendor/libgit2/src/amiga/map.c +0 -48
- data/vendor/libgit2/src/bswap.h +0 -97
- data/vendor/libgit2/src/compress.c +0 -53
- data/vendor/libgit2/src/config_file.h +0 -60
- data/vendor/libgit2/src/delta-apply.c +0 -134
- data/vendor/libgit2/src/delta-apply.h +0 -50
- data/vendor/libgit2/src/diff_patch.c +0 -995
- data/vendor/libgit2/src/diff_patch.h +0 -46
- data/vendor/libgit2/src/hashsig.h +0 -72
- data/vendor/libgit2/src/merge_file.h +0 -71
- data/vendor/libgit2/src/win32/pthread.c +0 -144
- data/vendor/libgit2/src/win32/pthread.h +0 -50
data/vendor/libgit2/src/diff.c
CHANGED
@@ -4,235 +4,20 @@
|
|
4
4
|
* This file is part of libgit2, distributed under the GNU GPL v2 with
|
5
5
|
* a Linking Exception. For full terms see the included COPYING file.
|
6
6
|
*/
|
7
|
-
#include "common.h"
|
8
|
-
#include "diff.h"
|
9
|
-
#include "fileops.h"
|
10
|
-
#include "config.h"
|
11
|
-
#include "attr_file.h"
|
12
|
-
#include "filter.h"
|
13
|
-
#include "pathspec.h"
|
14
|
-
#include "index.h"
|
15
|
-
#include "odb.h"
|
16
|
-
|
17
|
-
#define DIFF_FLAG_IS_SET(DIFF,FLAG) (((DIFF)->opts.flags & (FLAG)) != 0)
|
18
|
-
#define DIFF_FLAG_ISNT_SET(DIFF,FLAG) (((DIFF)->opts.flags & (FLAG)) == 0)
|
19
|
-
#define DIFF_FLAG_SET(DIFF,FLAG,VAL) (DIFF)->opts.flags = \
|
20
|
-
(VAL) ? ((DIFF)->opts.flags | (FLAG)) : ((DIFF)->opts.flags & ~(VAL))
|
21
|
-
|
22
|
-
static git_diff_delta *diff_delta__alloc(
|
23
|
-
git_diff_list *diff,
|
24
|
-
git_delta_t status,
|
25
|
-
const char *path)
|
26
|
-
{
|
27
|
-
git_diff_delta *delta = git__calloc(1, sizeof(git_diff_delta));
|
28
|
-
if (!delta)
|
29
|
-
return NULL;
|
30
|
-
|
31
|
-
delta->old_file.path = git_pool_strdup(&diff->pool, path);
|
32
|
-
if (delta->old_file.path == NULL) {
|
33
|
-
git__free(delta);
|
34
|
-
return NULL;
|
35
|
-
}
|
36
|
-
|
37
|
-
delta->new_file.path = delta->old_file.path;
|
38
|
-
|
39
|
-
if (DIFF_FLAG_IS_SET(diff, GIT_DIFF_REVERSE)) {
|
40
|
-
switch (status) {
|
41
|
-
case GIT_DELTA_ADDED: status = GIT_DELTA_DELETED; break;
|
42
|
-
case GIT_DELTA_DELETED: status = GIT_DELTA_ADDED; break;
|
43
|
-
default: break; /* leave other status values alone */
|
44
|
-
}
|
45
|
-
}
|
46
|
-
delta->status = status;
|
47
|
-
|
48
|
-
return delta;
|
49
|
-
}
|
50
|
-
|
51
|
-
static int diff_notify(
|
52
|
-
const git_diff_list *diff,
|
53
|
-
const git_diff_delta *delta,
|
54
|
-
const char *matched_pathspec)
|
55
|
-
{
|
56
|
-
if (!diff->opts.notify_cb)
|
57
|
-
return 0;
|
58
|
-
|
59
|
-
return diff->opts.notify_cb(
|
60
|
-
diff, delta, matched_pathspec, diff->opts.notify_payload);
|
61
|
-
}
|
62
|
-
|
63
|
-
static int diff_delta__from_one(
|
64
|
-
git_diff_list *diff,
|
65
|
-
git_delta_t status,
|
66
|
-
const git_index_entry *entry)
|
67
|
-
{
|
68
|
-
git_diff_delta *delta;
|
69
|
-
const char *matched_pathspec;
|
70
|
-
int notify_res;
|
71
|
-
|
72
|
-
if (status == GIT_DELTA_IGNORED &&
|
73
|
-
DIFF_FLAG_ISNT_SET(diff, GIT_DIFF_INCLUDE_IGNORED))
|
74
|
-
return 0;
|
75
|
-
|
76
|
-
if (status == GIT_DELTA_UNTRACKED &&
|
77
|
-
DIFF_FLAG_ISNT_SET(diff, GIT_DIFF_INCLUDE_UNTRACKED))
|
78
|
-
return 0;
|
79
|
-
|
80
|
-
if (entry->mode == GIT_FILEMODE_COMMIT &&
|
81
|
-
DIFF_FLAG_IS_SET(diff, GIT_DIFF_IGNORE_SUBMODULES))
|
82
|
-
return 0;
|
83
|
-
|
84
|
-
if (!git_pathspec_match_path(
|
85
|
-
&diff->pathspec, entry->path,
|
86
|
-
DIFF_FLAG_IS_SET(diff, GIT_DIFF_DISABLE_PATHSPEC_MATCH),
|
87
|
-
DIFF_FLAG_IS_SET(diff, GIT_DIFF_DELTAS_ARE_ICASE),
|
88
|
-
&matched_pathspec))
|
89
|
-
return 0;
|
90
|
-
|
91
|
-
delta = diff_delta__alloc(diff, status, entry->path);
|
92
|
-
GITERR_CHECK_ALLOC(delta);
|
93
|
-
|
94
|
-
/* This fn is just for single-sided diffs */
|
95
|
-
assert(status != GIT_DELTA_MODIFIED);
|
96
|
-
|
97
|
-
if (delta->status == GIT_DELTA_DELETED) {
|
98
|
-
delta->old_file.mode = entry->mode;
|
99
|
-
delta->old_file.size = entry->file_size;
|
100
|
-
git_oid_cpy(&delta->old_file.oid, &entry->oid);
|
101
|
-
} else /* ADDED, IGNORED, UNTRACKED */ {
|
102
|
-
delta->new_file.mode = entry->mode;
|
103
|
-
delta->new_file.size = entry->file_size;
|
104
|
-
git_oid_cpy(&delta->new_file.oid, &entry->oid);
|
105
|
-
}
|
106
|
-
|
107
|
-
delta->old_file.flags |= GIT_DIFF_FLAG_VALID_OID;
|
108
|
-
|
109
|
-
if (delta->status == GIT_DELTA_DELETED ||
|
110
|
-
!git_oid_iszero(&delta->new_file.oid))
|
111
|
-
delta->new_file.flags |= GIT_DIFF_FLAG_VALID_OID;
|
112
|
-
|
113
|
-
notify_res = diff_notify(diff, delta, matched_pathspec);
|
114
|
-
|
115
|
-
if (notify_res)
|
116
|
-
git__free(delta);
|
117
|
-
else if (git_vector_insert(&diff->deltas, delta) < 0) {
|
118
|
-
git__free(delta);
|
119
|
-
return -1;
|
120
|
-
}
|
121
|
-
|
122
|
-
return notify_res < 0 ? GIT_EUSER : 0;
|
123
|
-
}
|
124
|
-
|
125
|
-
static int diff_delta__from_two(
|
126
|
-
git_diff_list *diff,
|
127
|
-
git_delta_t status,
|
128
|
-
const git_index_entry *old_entry,
|
129
|
-
uint32_t old_mode,
|
130
|
-
const git_index_entry *new_entry,
|
131
|
-
uint32_t new_mode,
|
132
|
-
git_oid *new_oid,
|
133
|
-
const char *matched_pathspec)
|
134
|
-
{
|
135
|
-
git_diff_delta *delta;
|
136
|
-
int notify_res;
|
137
|
-
const char *canonical_path = old_entry->path;
|
138
|
-
|
139
|
-
if (status == GIT_DELTA_UNMODIFIED &&
|
140
|
-
DIFF_FLAG_ISNT_SET(diff, GIT_DIFF_INCLUDE_UNMODIFIED))
|
141
|
-
return 0;
|
142
|
-
|
143
|
-
if (old_entry->mode == GIT_FILEMODE_COMMIT &&
|
144
|
-
new_entry->mode == GIT_FILEMODE_COMMIT &&
|
145
|
-
DIFF_FLAG_IS_SET(diff, GIT_DIFF_IGNORE_SUBMODULES))
|
146
|
-
return 0;
|
147
|
-
|
148
|
-
if (DIFF_FLAG_IS_SET(diff, GIT_DIFF_REVERSE)) {
|
149
|
-
uint32_t temp_mode = old_mode;
|
150
|
-
const git_index_entry *temp_entry = old_entry;
|
151
|
-
old_entry = new_entry;
|
152
|
-
new_entry = temp_entry;
|
153
|
-
old_mode = new_mode;
|
154
|
-
new_mode = temp_mode;
|
155
|
-
}
|
156
|
-
|
157
|
-
delta = diff_delta__alloc(diff, status, canonical_path);
|
158
|
-
GITERR_CHECK_ALLOC(delta);
|
159
7
|
|
160
|
-
|
161
|
-
delta->old_file.size = old_entry->file_size;
|
162
|
-
delta->old_file.mode = old_mode;
|
163
|
-
delta->old_file.flags |= GIT_DIFF_FLAG_VALID_OID;
|
164
|
-
|
165
|
-
git_oid_cpy(&delta->new_file.oid, &new_entry->oid);
|
166
|
-
delta->new_file.size = new_entry->file_size;
|
167
|
-
delta->new_file.mode = new_mode;
|
168
|
-
|
169
|
-
if (new_oid) {
|
170
|
-
if (DIFF_FLAG_IS_SET(diff, GIT_DIFF_REVERSE))
|
171
|
-
git_oid_cpy(&delta->old_file.oid, new_oid);
|
172
|
-
else
|
173
|
-
git_oid_cpy(&delta->new_file.oid, new_oid);
|
174
|
-
}
|
175
|
-
|
176
|
-
if (new_oid || !git_oid_iszero(&new_entry->oid))
|
177
|
-
delta->new_file.flags |= GIT_DIFF_FLAG_VALID_OID;
|
178
|
-
|
179
|
-
notify_res = diff_notify(diff, delta, matched_pathspec);
|
180
|
-
|
181
|
-
if (notify_res)
|
182
|
-
git__free(delta);
|
183
|
-
else if (git_vector_insert(&diff->deltas, delta) < 0) {
|
184
|
-
git__free(delta);
|
185
|
-
return -1;
|
186
|
-
}
|
187
|
-
|
188
|
-
return notify_res < 0 ? GIT_EUSER : 0;
|
189
|
-
}
|
190
|
-
|
191
|
-
static git_diff_delta *diff_delta__last_for_item(
|
192
|
-
git_diff_list *diff,
|
193
|
-
const git_index_entry *item)
|
194
|
-
{
|
195
|
-
git_diff_delta *delta = git_vector_last(&diff->deltas);
|
196
|
-
if (!delta)
|
197
|
-
return NULL;
|
198
|
-
|
199
|
-
switch (delta->status) {
|
200
|
-
case GIT_DELTA_UNMODIFIED:
|
201
|
-
case GIT_DELTA_DELETED:
|
202
|
-
if (git_oid__cmp(&delta->old_file.oid, &item->oid) == 0)
|
203
|
-
return delta;
|
204
|
-
break;
|
205
|
-
case GIT_DELTA_ADDED:
|
206
|
-
if (git_oid__cmp(&delta->new_file.oid, &item->oid) == 0)
|
207
|
-
return delta;
|
208
|
-
break;
|
209
|
-
case GIT_DELTA_UNTRACKED:
|
210
|
-
if (diff->strcomp(delta->new_file.path, item->path) == 0 &&
|
211
|
-
git_oid__cmp(&delta->new_file.oid, &item->oid) == 0)
|
212
|
-
return delta;
|
213
|
-
break;
|
214
|
-
case GIT_DELTA_MODIFIED:
|
215
|
-
if (git_oid__cmp(&delta->old_file.oid, &item->oid) == 0 ||
|
216
|
-
git_oid__cmp(&delta->new_file.oid, &item->oid) == 0)
|
217
|
-
return delta;
|
218
|
-
break;
|
219
|
-
default:
|
220
|
-
break;
|
221
|
-
}
|
222
|
-
|
223
|
-
return NULL;
|
224
|
-
}
|
8
|
+
#include "diff.h"
|
225
9
|
|
226
|
-
|
227
|
-
|
228
|
-
|
10
|
+
#include "git2/version.h"
|
11
|
+
#include "diff_generate.h"
|
12
|
+
#include "patch.h"
|
13
|
+
#include "commit.h"
|
14
|
+
#include "index.h"
|
229
15
|
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
}
|
16
|
+
struct patch_id_args {
|
17
|
+
git_hash_ctx ctx;
|
18
|
+
git_oid result;
|
19
|
+
int first_file;
|
20
|
+
};
|
236
21
|
|
237
22
|
GIT_INLINE(const char *) diff_delta__path(const git_diff_delta *delta)
|
238
23
|
{
|
@@ -247,6 +32,11 @@ GIT_INLINE(const char *) diff_delta__path(const git_diff_delta *delta)
|
|
247
32
|
return str;
|
248
33
|
}
|
249
34
|
|
35
|
+
const char *git_diff_delta__path(const git_diff_delta *delta)
|
36
|
+
{
|
37
|
+
return diff_delta__path(delta);
|
38
|
+
}
|
39
|
+
|
250
40
|
int git_diff_delta__cmp(const void *a, const void *b)
|
251
41
|
{
|
252
42
|
const git_diff_delta *da = a, *db = b;
|
@@ -261,1053 +51,465 @@ int git_diff_delta__casecmp(const void *a, const void *b)
|
|
261
51
|
return val ? val : ((int)da->status - (int)db->status);
|
262
52
|
}
|
263
53
|
|
264
|
-
|
265
|
-
const git_diff_options *opts, const git_diff_delta *delta)
|
54
|
+
int git_diff__entry_cmp(const void *a, const void *b)
|
266
55
|
{
|
267
|
-
|
268
|
-
|
269
|
-
if (delta->status == GIT_DELTA_UNMODIFIED &&
|
270
|
-
(flags & GIT_DIFF_INCLUDE_UNMODIFIED) == 0)
|
271
|
-
return true;
|
272
|
-
|
273
|
-
if (delta->status == GIT_DELTA_IGNORED &&
|
274
|
-
(flags & GIT_DIFF_INCLUDE_IGNORED) == 0)
|
275
|
-
return true;
|
56
|
+
const git_index_entry *entry_a = a;
|
57
|
+
const git_index_entry *entry_b = b;
|
276
58
|
|
277
|
-
|
278
|
-
(flags & GIT_DIFF_INCLUDE_UNTRACKED) == 0)
|
279
|
-
return true;
|
280
|
-
|
281
|
-
return false;
|
59
|
+
return strcmp(entry_a->path, entry_b->path);
|
282
60
|
}
|
283
61
|
|
284
|
-
|
285
|
-
static int config_bool(git_config *cfg, const char *name, int defvalue)
|
62
|
+
int git_diff__entry_icmp(const void *a, const void *b)
|
286
63
|
{
|
287
|
-
|
64
|
+
const git_index_entry *entry_a = a;
|
65
|
+
const git_index_entry *entry_b = b;
|
288
66
|
|
289
|
-
|
290
|
-
giterr_clear();
|
291
|
-
|
292
|
-
return val;
|
67
|
+
return strcasecmp(entry_a->path, entry_b->path);
|
293
68
|
}
|
294
69
|
|
295
|
-
|
70
|
+
void git_diff_free(git_diff *diff)
|
296
71
|
{
|
297
|
-
|
298
|
-
|
299
|
-
if (git_config_get_int32(&val, cfg, name) < 0)
|
300
|
-
giterr_clear();
|
72
|
+
if (!diff)
|
73
|
+
return;
|
301
74
|
|
302
|
-
|
75
|
+
GIT_REFCOUNT_DEC(diff, diff->free_fn);
|
303
76
|
}
|
304
77
|
|
305
|
-
|
306
|
-
git_iterator_type_t type, bool left_side)
|
78
|
+
void git_diff_addref(git_diff *diff)
|
307
79
|
{
|
308
|
-
|
309
|
-
|
310
|
-
switch (type) {
|
311
|
-
case GIT_ITERATOR_TYPE_EMPTY: pfx = "c"; break;
|
312
|
-
case GIT_ITERATOR_TYPE_TREE: pfx = "c"; break;
|
313
|
-
case GIT_ITERATOR_TYPE_INDEX: pfx = "i"; break;
|
314
|
-
case GIT_ITERATOR_TYPE_WORKDIR: pfx = "w"; break;
|
315
|
-
case GIT_ITERATOR_TYPE_FS: pfx = left_side ? "1" : "2"; break;
|
316
|
-
default: break;
|
317
|
-
}
|
318
|
-
|
319
|
-
/* note: without a deeper look at pathspecs, there is no easy way
|
320
|
-
* to get the (o)bject / (w)ork tree mnemonics working...
|
321
|
-
*/
|
322
|
-
|
323
|
-
return pfx;
|
80
|
+
GIT_REFCOUNT_INC(diff);
|
324
81
|
}
|
325
82
|
|
326
|
-
|
327
|
-
git_repository *repo,
|
328
|
-
git_iterator *old_iter,
|
329
|
-
git_iterator *new_iter)
|
83
|
+
size_t git_diff_num_deltas(const git_diff *diff)
|
330
84
|
{
|
331
|
-
|
332
|
-
|
333
|
-
if (!diff)
|
334
|
-
return NULL;
|
335
|
-
|
336
|
-
assert(repo && old_iter && new_iter);
|
337
|
-
|
338
|
-
GIT_REFCOUNT_INC(diff);
|
339
|
-
diff->repo = repo;
|
340
|
-
diff->old_src = old_iter->type;
|
341
|
-
diff->new_src = new_iter->type;
|
342
|
-
memcpy(&diff->opts, &dflt, sizeof(diff->opts));
|
343
|
-
|
344
|
-
if (git_vector_init(&diff->deltas, 0, git_diff_delta__cmp) < 0 ||
|
345
|
-
git_pool_init(&diff->pool, 1, 0) < 0) {
|
346
|
-
git_diff_list_free(diff);
|
347
|
-
return NULL;
|
348
|
-
}
|
349
|
-
|
350
|
-
/* Use case-insensitive compare if either iterator has
|
351
|
-
* the ignore_case bit set */
|
352
|
-
if (!git_iterator_ignore_case(old_iter) &&
|
353
|
-
!git_iterator_ignore_case(new_iter)) {
|
354
|
-
diff->opts.flags &= ~GIT_DIFF_DELTAS_ARE_ICASE;
|
355
|
-
|
356
|
-
diff->strcomp = git__strcmp;
|
357
|
-
diff->strncomp = git__strncmp;
|
358
|
-
diff->pfxcomp = git__prefixcmp;
|
359
|
-
diff->entrycomp = git_index_entry__cmp;
|
360
|
-
} else {
|
361
|
-
diff->opts.flags |= GIT_DIFF_DELTAS_ARE_ICASE;
|
362
|
-
|
363
|
-
diff->strcomp = git__strcasecmp;
|
364
|
-
diff->strncomp = git__strncasecmp;
|
365
|
-
diff->pfxcomp = git__prefixcmp_icase;
|
366
|
-
diff->entrycomp = git_index_entry__cmp_icase;
|
367
|
-
|
368
|
-
git_vector_set_cmp(&diff->deltas, git_diff_delta__casecmp);
|
369
|
-
}
|
370
|
-
|
371
|
-
return diff;
|
85
|
+
assert(diff);
|
86
|
+
return diff->deltas.length;
|
372
87
|
}
|
373
88
|
|
374
|
-
|
375
|
-
git_diff_list *diff,
|
376
|
-
const git_diff_options *opts)
|
89
|
+
size_t git_diff_num_deltas_of_type(const git_diff *diff, git_delta_t type)
|
377
90
|
{
|
378
|
-
|
379
|
-
|
380
|
-
git_pool *pool = &diff->pool;
|
381
|
-
int val;
|
382
|
-
|
383
|
-
if (opts) {
|
384
|
-
/* copy user options (except case sensitivity info from iterators) */
|
385
|
-
bool icase = DIFF_FLAG_IS_SET(diff, GIT_DIFF_DELTAS_ARE_ICASE);
|
386
|
-
memcpy(&diff->opts, opts, sizeof(diff->opts));
|
387
|
-
DIFF_FLAG_SET(diff, GIT_DIFF_DELTAS_ARE_ICASE, icase);
|
388
|
-
|
389
|
-
/* initialize pathspec from options */
|
390
|
-
if (git_pathspec_init(&diff->pathspec, &opts->pathspec, pool) < 0)
|
391
|
-
return -1;
|
392
|
-
}
|
393
|
-
|
394
|
-
/* flag INCLUDE_TYPECHANGE_TREES implies INCLUDE_TYPECHANGE */
|
395
|
-
if (DIFF_FLAG_IS_SET(diff, GIT_DIFF_INCLUDE_TYPECHANGE_TREES))
|
396
|
-
diff->opts.flags |= GIT_DIFF_INCLUDE_TYPECHANGE;
|
397
|
-
|
398
|
-
/* flag INCLUDE_UNTRACKED_CONTENT implies INCLUDE_UNTRACKED */
|
399
|
-
if (DIFF_FLAG_IS_SET(diff, GIT_DIFF_INCLUDE_UNTRACKED_CONTENT))
|
400
|
-
diff->opts.flags |= GIT_DIFF_INCLUDE_UNTRACKED;
|
401
|
-
|
402
|
-
/* load config values that affect diff behavior */
|
403
|
-
if (git_repository_config__weakptr(&cfg, repo) < 0)
|
404
|
-
return -1;
|
405
|
-
|
406
|
-
if (!git_repository__cvar(&val, repo, GIT_CVAR_SYMLINKS) && val)
|
407
|
-
diff->diffcaps = diff->diffcaps | GIT_DIFFCAPS_HAS_SYMLINKS;
|
408
|
-
|
409
|
-
if (!git_repository__cvar(&val, repo, GIT_CVAR_IGNORESTAT) && val)
|
410
|
-
diff->diffcaps = diff->diffcaps | GIT_DIFFCAPS_ASSUME_UNCHANGED;
|
411
|
-
|
412
|
-
if ((diff->opts.flags & GIT_DIFF_IGNORE_FILEMODE) == 0 &&
|
413
|
-
!git_repository__cvar(&val, repo, GIT_CVAR_FILEMODE) && val)
|
414
|
-
diff->diffcaps = diff->diffcaps | GIT_DIFFCAPS_TRUST_MODE_BITS;
|
415
|
-
|
416
|
-
if (!git_repository__cvar(&val, repo, GIT_CVAR_TRUSTCTIME) && val)
|
417
|
-
diff->diffcaps = diff->diffcaps | GIT_DIFFCAPS_TRUST_CTIME;
|
418
|
-
|
419
|
-
/* Don't set GIT_DIFFCAPS_USE_DEV - compile time option in core git */
|
420
|
-
|
421
|
-
/* Set GIT_DIFFCAPS_TRUST_NANOSECS on a platform basis */
|
422
|
-
diff->diffcaps = diff->diffcaps | GIT_DIFFCAPS_TRUST_NANOSECS;
|
423
|
-
|
424
|
-
/* If not given explicit `opts`, check `diff.xyz` configs */
|
425
|
-
if (!opts) {
|
426
|
-
diff->opts.context_lines = config_int(cfg, "diff.context", 3);
|
427
|
-
|
428
|
-
if (config_bool(cfg, "diff.ignoreSubmodules", 0))
|
429
|
-
diff->opts.flags |= GIT_DIFF_IGNORE_SUBMODULES;
|
430
|
-
}
|
431
|
-
|
432
|
-
/* if either prefix is not set, figure out appropriate value */
|
433
|
-
if (!diff->opts.old_prefix || !diff->opts.new_prefix) {
|
434
|
-
const char *use_old = DIFF_OLD_PREFIX_DEFAULT;
|
435
|
-
const char *use_new = DIFF_NEW_PREFIX_DEFAULT;
|
436
|
-
|
437
|
-
if (config_bool(cfg, "diff.noprefix", 0)) {
|
438
|
-
use_old = use_new = "";
|
439
|
-
} else if (config_bool(cfg, "diff.mnemonicprefix", 0)) {
|
440
|
-
use_old = diff_mnemonic_prefix(diff->old_src, true);
|
441
|
-
use_new = diff_mnemonic_prefix(diff->new_src, false);
|
442
|
-
}
|
443
|
-
|
444
|
-
if (!diff->opts.old_prefix)
|
445
|
-
diff->opts.old_prefix = use_old;
|
446
|
-
if (!diff->opts.new_prefix)
|
447
|
-
diff->opts.new_prefix = use_new;
|
448
|
-
}
|
91
|
+
size_t i, count = 0;
|
92
|
+
const git_diff_delta *delta;
|
449
93
|
|
450
|
-
|
451
|
-
diff->opts.old_prefix = diff_strdup_prefix(pool, diff->opts.old_prefix);
|
452
|
-
diff->opts.new_prefix = diff_strdup_prefix(pool, diff->opts.new_prefix);
|
453
|
-
if (!diff->opts.old_prefix || !diff->opts.new_prefix)
|
454
|
-
return -1;
|
94
|
+
assert(diff);
|
455
95
|
|
456
|
-
|
457
|
-
|
458
|
-
diff->opts.old_prefix = diff->opts.new_prefix;
|
459
|
-
diff->opts.new_prefix = swap;
|
96
|
+
git_vector_foreach(&diff->deltas, i, delta) {
|
97
|
+
count += (delta->status == type);
|
460
98
|
}
|
461
99
|
|
462
|
-
return
|
100
|
+
return count;
|
463
101
|
}
|
464
102
|
|
465
|
-
|
103
|
+
const git_diff_delta *git_diff_get_delta(const git_diff *diff, size_t idx)
|
466
104
|
{
|
467
|
-
|
468
|
-
|
469
|
-
|
470
|
-
git_vector_foreach(&diff->deltas, i, delta) {
|
471
|
-
git__free(delta);
|
472
|
-
diff->deltas.contents[i] = NULL;
|
473
|
-
}
|
474
|
-
git_vector_free(&diff->deltas);
|
475
|
-
|
476
|
-
git_pathspec_free(&diff->pathspec);
|
477
|
-
git_pool_clear(&diff->pool);
|
478
|
-
|
479
|
-
git__memzero(diff, sizeof(*diff));
|
480
|
-
git__free(diff);
|
105
|
+
assert(diff);
|
106
|
+
return git_vector_get(&diff->deltas, idx);
|
481
107
|
}
|
482
108
|
|
483
|
-
|
109
|
+
int git_diff_is_sorted_icase(const git_diff *diff)
|
484
110
|
{
|
485
|
-
|
486
|
-
return;
|
487
|
-
|
488
|
-
GIT_REFCOUNT_DEC(diff, diff_list_free);
|
111
|
+
return (diff->opts.flags & GIT_DIFF_IGNORE_CASE) != 0;
|
489
112
|
}
|
490
113
|
|
491
|
-
|
114
|
+
int git_diff_get_perfdata(git_diff_perfdata *out, const git_diff *diff)
|
492
115
|
{
|
493
|
-
|
116
|
+
assert(out);
|
117
|
+
GIT_ERROR_CHECK_VERSION(out, GIT_DIFF_PERFDATA_VERSION, "git_diff_perfdata");
|
118
|
+
out->stat_calls = diff->perf.stat_calls;
|
119
|
+
out->oid_calculations = diff->perf.oid_calculations;
|
120
|
+
return 0;
|
494
121
|
}
|
495
122
|
|
496
|
-
int
|
497
|
-
|
498
|
-
|
499
|
-
|
500
|
-
|
501
|
-
|
123
|
+
int git_diff_foreach(
|
124
|
+
git_diff *diff,
|
125
|
+
git_diff_file_cb file_cb,
|
126
|
+
git_diff_binary_cb binary_cb,
|
127
|
+
git_diff_hunk_cb hunk_cb,
|
128
|
+
git_diff_line_cb data_cb,
|
129
|
+
void *payload)
|
502
130
|
{
|
503
|
-
int
|
504
|
-
|
505
|
-
|
506
|
-
if (git_buf_joinpath(
|
507
|
-
&full_path, git_repository_workdir(repo), path) < 0)
|
508
|
-
return -1;
|
509
|
-
|
510
|
-
if (!mode) {
|
511
|
-
struct stat st;
|
512
|
-
|
513
|
-
if (p_stat(path, &st) < 0) {
|
514
|
-
giterr_set(GITERR_OS, "Could not stat '%s'", path);
|
515
|
-
result = -1;
|
516
|
-
goto cleanup;
|
517
|
-
}
|
518
|
-
|
519
|
-
mode = st.st_mode;
|
520
|
-
size = st.st_size;
|
521
|
-
}
|
131
|
+
int error = 0;
|
132
|
+
git_diff_delta *delta;
|
133
|
+
size_t idx;
|
522
134
|
|
523
|
-
|
524
|
-
if (S_ISGITLINK(mode)) {
|
525
|
-
git_submodule *sm;
|
526
|
-
const git_oid *sm_oid;
|
527
|
-
|
528
|
-
if (!git_submodule_lookup(&sm, repo, path) &&
|
529
|
-
(sm_oid = git_submodule_wd_id(sm)) != NULL)
|
530
|
-
git_oid_cpy(oid, sm_oid);
|
531
|
-
else {
|
532
|
-
/* if submodule lookup failed probably just in an intermediate
|
533
|
-
* state where some init hasn't happened, so ignore the error
|
534
|
-
*/
|
535
|
-
giterr_clear();
|
536
|
-
memset(oid, 0, sizeof(*oid));
|
537
|
-
}
|
538
|
-
} else if (S_ISLNK(mode)) {
|
539
|
-
result = git_odb__hashlink(oid, full_path.ptr);
|
540
|
-
} else if (!git__is_sizet(size)) {
|
541
|
-
giterr_set(GITERR_OS, "File size overflow (for 32-bits) on '%s'", path);
|
542
|
-
result = -1;
|
543
|
-
} else {
|
544
|
-
git_vector filters = GIT_VECTOR_INIT;
|
545
|
-
|
546
|
-
result = git_filters_load(&filters, repo, path, GIT_FILTER_TO_ODB);
|
547
|
-
if (result >= 0) {
|
548
|
-
int fd = git_futils_open_ro(full_path.ptr);
|
549
|
-
if (fd < 0)
|
550
|
-
result = fd;
|
551
|
-
else {
|
552
|
-
result = git_odb__hashfd_filtered(
|
553
|
-
oid, fd, (size_t)size, GIT_OBJ_BLOB, &filters);
|
554
|
-
p_close(fd);
|
555
|
-
}
|
556
|
-
}
|
135
|
+
assert(diff);
|
557
136
|
|
558
|
-
|
559
|
-
|
137
|
+
git_vector_foreach(&diff->deltas, idx, delta) {
|
138
|
+
git_patch *patch;
|
560
139
|
|
561
|
-
|
562
|
-
|
563
|
-
|
564
|
-
}
|
140
|
+
/* check flags against patch status */
|
141
|
+
if (git_diff_delta__should_skip(&diff->opts, delta))
|
142
|
+
continue;
|
565
143
|
|
566
|
-
|
567
|
-
|
568
|
-
{
|
569
|
-
return a->seconds == b->seconds &&
|
570
|
-
(!use_nanos || a->nanoseconds == b->nanoseconds);
|
571
|
-
}
|
144
|
+
if ((error = git_patch_from_diff(&patch, diff, idx)) != 0)
|
145
|
+
break;
|
572
146
|
|
573
|
-
|
574
|
-
|
575
|
-
|
576
|
-
git_iterator *new_iter;
|
577
|
-
const git_index_entry *oitem;
|
578
|
-
const git_index_entry *nitem;
|
579
|
-
git_buf ignore_prefix;
|
580
|
-
} diff_in_progress;
|
581
|
-
|
582
|
-
#define MODE_BITS_MASK 0000777
|
583
|
-
|
584
|
-
static int maybe_modified_submodule(
|
585
|
-
git_delta_t *status,
|
586
|
-
git_oid *found_oid,
|
587
|
-
git_diff_list *diff,
|
588
|
-
diff_in_progress *info)
|
589
|
-
{
|
590
|
-
int error = 0;
|
591
|
-
git_submodule *sub;
|
592
|
-
unsigned int sm_status = 0;
|
593
|
-
const git_oid *sm_oid;
|
594
|
-
|
595
|
-
*status = GIT_DELTA_UNMODIFIED;
|
596
|
-
|
597
|
-
if (!DIFF_FLAG_IS_SET(diff, GIT_DIFF_IGNORE_SUBMODULES) &&
|
598
|
-
!(error = git_submodule_lookup(
|
599
|
-
&sub, diff->repo, info->nitem->path)) &&
|
600
|
-
git_submodule_ignore(sub) != GIT_SUBMODULE_IGNORE_ALL &&
|
601
|
-
!(error = git_submodule_status(&sm_status, sub)))
|
602
|
-
{
|
603
|
-
/* check IS_WD_UNMODIFIED because this case is only used
|
604
|
-
* when the new side of the diff is the working directory
|
605
|
-
*/
|
606
|
-
if (!GIT_SUBMODULE_STATUS_IS_WD_UNMODIFIED(sm_status))
|
607
|
-
*status = GIT_DELTA_MODIFIED;
|
608
|
-
|
609
|
-
/* grab OID while we are here */
|
610
|
-
if (git_oid_iszero(&info->nitem->oid) &&
|
611
|
-
(sm_oid = git_submodule_wd_id(sub)) != NULL)
|
612
|
-
git_oid_cpy(found_oid, sm_oid);
|
613
|
-
}
|
147
|
+
error = git_patch__invoke_callbacks(patch, file_cb, binary_cb,
|
148
|
+
hunk_cb, data_cb, payload);
|
149
|
+
git_patch_free(patch);
|
614
150
|
|
615
|
-
|
616
|
-
|
617
|
-
giterr_clear();
|
618
|
-
error = 0;
|
151
|
+
if (error)
|
152
|
+
break;
|
619
153
|
}
|
620
154
|
|
621
155
|
return error;
|
622
156
|
}
|
623
157
|
|
624
|
-
|
625
|
-
|
626
|
-
|
158
|
+
int git_diff_format_email__append_header_tobuf(
|
159
|
+
git_buf *out,
|
160
|
+
const git_oid *id,
|
161
|
+
const git_signature *author,
|
162
|
+
const char *summary,
|
163
|
+
const char *body,
|
164
|
+
size_t patch_no,
|
165
|
+
size_t total_patches,
|
166
|
+
bool exclude_patchno_marker)
|
627
167
|
{
|
628
|
-
|
629
|
-
|
630
|
-
|
631
|
-
const git_index_entry *nitem = info->nitem;
|
632
|
-
unsigned int omode = oitem->mode;
|
633
|
-
unsigned int nmode = nitem->mode;
|
634
|
-
bool new_is_workdir = (info->new_iter->type == GIT_ITERATOR_TYPE_WORKDIR);
|
635
|
-
const char *matched_pathspec;
|
636
|
-
|
637
|
-
if (!git_pathspec_match_path(
|
638
|
-
&diff->pathspec, oitem->path,
|
639
|
-
DIFF_FLAG_IS_SET(diff, GIT_DIFF_DISABLE_PATHSPEC_MATCH),
|
640
|
-
DIFF_FLAG_IS_SET(diff, GIT_DIFF_DELTAS_ARE_ICASE),
|
641
|
-
&matched_pathspec))
|
642
|
-
return 0;
|
643
|
-
|
644
|
-
memset(&noid, 0, sizeof(noid));
|
645
|
-
|
646
|
-
/* on platforms with no symlinks, preserve mode of existing symlinks */
|
647
|
-
if (S_ISLNK(omode) && S_ISREG(nmode) && new_is_workdir &&
|
648
|
-
!(diff->diffcaps & GIT_DIFFCAPS_HAS_SYMLINKS))
|
649
|
-
nmode = omode;
|
650
|
-
|
651
|
-
/* on platforms with no execmode, just preserve old mode */
|
652
|
-
if (!(diff->diffcaps & GIT_DIFFCAPS_TRUST_MODE_BITS) &&
|
653
|
-
(nmode & MODE_BITS_MASK) != (omode & MODE_BITS_MASK) &&
|
654
|
-
new_is_workdir)
|
655
|
-
nmode = (nmode & ~MODE_BITS_MASK) | (omode & MODE_BITS_MASK);
|
656
|
-
|
657
|
-
/* support "assume unchanged" (poorly, b/c we still stat everything) */
|
658
|
-
if ((diff->diffcaps & GIT_DIFFCAPS_ASSUME_UNCHANGED) != 0)
|
659
|
-
status = (oitem->flags_extended & GIT_IDXENTRY_INTENT_TO_ADD) ?
|
660
|
-
GIT_DELTA_MODIFIED : GIT_DELTA_UNMODIFIED;
|
661
|
-
|
662
|
-
/* support "skip worktree" index bit */
|
663
|
-
else if ((oitem->flags_extended & GIT_IDXENTRY_SKIP_WORKTREE) != 0)
|
664
|
-
status = GIT_DELTA_UNMODIFIED;
|
665
|
-
|
666
|
-
/* if basic type of file changed, then split into delete and add */
|
667
|
-
else if (GIT_MODE_TYPE(omode) != GIT_MODE_TYPE(nmode)) {
|
668
|
-
if (DIFF_FLAG_IS_SET(diff, GIT_DIFF_INCLUDE_TYPECHANGE))
|
669
|
-
status = GIT_DELTA_TYPECHANGE;
|
670
|
-
else {
|
671
|
-
if (diff_delta__from_one(diff, GIT_DELTA_DELETED, oitem) < 0 ||
|
672
|
-
diff_delta__from_one(diff, GIT_DELTA_ADDED, nitem) < 0)
|
673
|
-
return -1;
|
674
|
-
return 0;
|
675
|
-
}
|
676
|
-
}
|
677
|
-
|
678
|
-
/* if oids and modes match (and are valid), then file is unmodified */
|
679
|
-
else if (git_oid_equal(&oitem->oid, &nitem->oid) &&
|
680
|
-
omode == nmode &&
|
681
|
-
!git_oid_iszero(&oitem->oid))
|
682
|
-
status = GIT_DELTA_UNMODIFIED;
|
683
|
-
|
684
|
-
/* if we have an unknown OID and a workdir iterator, then check some
|
685
|
-
* circumstances that can accelerate things or need special handling
|
686
|
-
*/
|
687
|
-
else if (git_oid_iszero(&nitem->oid) && new_is_workdir) {
|
688
|
-
bool use_ctime = ((diff->diffcaps & GIT_DIFFCAPS_TRUST_CTIME) != 0);
|
689
|
-
bool use_nanos = ((diff->diffcaps & GIT_DIFFCAPS_TRUST_NANOSECS) != 0);
|
168
|
+
char idstr[GIT_OID_HEXSZ + 1];
|
169
|
+
char date_str[GIT_DATE_RFC2822_SZ];
|
170
|
+
int error = 0;
|
690
171
|
|
691
|
-
|
172
|
+
git_oid_fmt(idstr, id);
|
173
|
+
idstr[GIT_OID_HEXSZ] = '\0';
|
692
174
|
|
693
|
-
|
175
|
+
if ((error = git__date_rfc2822_fmt(date_str, sizeof(date_str),
|
176
|
+
&author->when)) < 0)
|
177
|
+
return error;
|
694
178
|
|
695
|
-
|
696
|
-
|
697
|
-
|
698
|
-
|
179
|
+
error = git_buf_printf(out,
|
180
|
+
"From %s Mon Sep 17 00:00:00 2001\n" \
|
181
|
+
"From: %s <%s>\n" \
|
182
|
+
"Date: %s\n" \
|
183
|
+
"Subject: ",
|
184
|
+
idstr,
|
185
|
+
author->name, author->email,
|
186
|
+
date_str);
|
699
187
|
|
700
|
-
|
701
|
-
|
702
|
-
*/
|
703
|
-
else if (omode != nmode ||
|
704
|
-
oitem->file_size != nitem->file_size ||
|
705
|
-
!diff_time_eq(&oitem->mtime, &nitem->mtime, use_nanos) ||
|
706
|
-
(use_ctime &&
|
707
|
-
!diff_time_eq(&oitem->ctime, &nitem->ctime, use_nanos)) ||
|
708
|
-
oitem->ino != nitem->ino ||
|
709
|
-
oitem->uid != nitem->uid ||
|
710
|
-
oitem->gid != nitem->gid)
|
711
|
-
status = GIT_DELTA_MODIFIED;
|
712
|
-
}
|
188
|
+
if (error < 0)
|
189
|
+
return error;
|
713
190
|
|
714
|
-
|
715
|
-
|
716
|
-
|
717
|
-
|
718
|
-
|
719
|
-
|
720
|
-
* haven't calculated the OID of the new item, then calculate it now
|
721
|
-
*/
|
722
|
-
if (status != GIT_DELTA_UNMODIFIED && git_oid_iszero(&nitem->oid)) {
|
723
|
-
if (git_oid_iszero(&noid)) {
|
724
|
-
if (git_diff__oid_for_file(diff->repo,
|
725
|
-
nitem->path, nitem->mode, nitem->file_size, &noid) < 0)
|
726
|
-
return -1;
|
191
|
+
if (!exclude_patchno_marker) {
|
192
|
+
if (total_patches == 1) {
|
193
|
+
error = git_buf_puts(out, "[PATCH] ");
|
194
|
+
} else {
|
195
|
+
error = git_buf_printf(out, "[PATCH %"PRIuZ"/%"PRIuZ"] ",
|
196
|
+
patch_no, total_patches);
|
727
197
|
}
|
728
198
|
|
729
|
-
|
730
|
-
|
731
|
-
* matches between the index and the workdir HEAD)
|
732
|
-
*/
|
733
|
-
if (omode == nmode && !S_ISGITLINK(omode) &&
|
734
|
-
git_oid_equal(&oitem->oid, &noid))
|
735
|
-
status = GIT_DELTA_UNMODIFIED;
|
199
|
+
if (error < 0)
|
200
|
+
return error;
|
736
201
|
}
|
737
202
|
|
738
|
-
|
739
|
-
diff, status, oitem, omode, nitem, nmode,
|
740
|
-
git_oid_iszero(&noid) ? NULL : &noid, matched_pathspec);
|
741
|
-
}
|
742
|
-
|
743
|
-
static bool entry_is_prefixed(
|
744
|
-
git_diff_list *diff,
|
745
|
-
const git_index_entry *item,
|
746
|
-
const git_index_entry *prefix_item)
|
747
|
-
{
|
748
|
-
size_t pathlen;
|
203
|
+
error = git_buf_printf(out, "%s\n\n", summary);
|
749
204
|
|
750
|
-
if (
|
751
|
-
|
205
|
+
if (body) {
|
206
|
+
git_buf_puts(out, body);
|
752
207
|
|
753
|
-
|
208
|
+
if (out->ptr[out->size - 1] != '\n')
|
209
|
+
git_buf_putc(out, '\n');
|
210
|
+
}
|
754
211
|
|
755
|
-
return
|
756
|
-
item->path[pathlen] == '\0' ||
|
757
|
-
item->path[pathlen] == '/');
|
212
|
+
return error;
|
758
213
|
}
|
759
214
|
|
760
|
-
|
761
|
-
|
215
|
+
int git_diff_format_email__append_patches_tobuf(
|
216
|
+
git_buf *out,
|
217
|
+
git_diff *diff)
|
762
218
|
{
|
219
|
+
size_t i, deltas;
|
763
220
|
int error = 0;
|
764
|
-
git_buf base = GIT_BUF_INIT;
|
765
|
-
bool is_ignored;
|
766
|
-
|
767
|
-
*delta_type = GIT_DELTA_IGNORED;
|
768
|
-
git_buf_sets(&base, info->nitem->path);
|
769
221
|
|
770
|
-
|
771
|
-
if ((error = git_iterator_advance_into(&info->nitem, info->new_iter)) < 0) {
|
772
|
-
|
773
|
-
/* skip ahead if empty */
|
774
|
-
if (error == GIT_ENOTFOUND) {
|
775
|
-
giterr_clear();
|
776
|
-
error = git_iterator_advance(&info->nitem, info->new_iter);
|
777
|
-
}
|
222
|
+
deltas = git_diff_num_deltas(diff);
|
778
223
|
|
779
|
-
|
780
|
-
|
224
|
+
for (i = 0; i < deltas; ++i) {
|
225
|
+
git_patch *patch = NULL;
|
781
226
|
|
782
|
-
|
783
|
-
|
784
|
-
!diff->pfxcomp(info->nitem->path, git_buf_cstr(&base))) {
|
785
|
-
is_ignored = git_iterator_current_is_ignored(info->new_iter);
|
786
|
-
|
787
|
-
/* need to recurse into non-ignored directories */
|
788
|
-
if (!is_ignored && S_ISDIR(info->nitem->mode)) {
|
789
|
-
error = git_iterator_advance_into(&info->nitem, info->new_iter);
|
790
|
-
|
791
|
-
if (!error)
|
792
|
-
continue;
|
793
|
-
else if (error == GIT_ENOTFOUND) {
|
794
|
-
error = 0;
|
795
|
-
is_ignored = true; /* treat empty as ignored */
|
796
|
-
} else
|
797
|
-
break; /* real error, must stop */
|
798
|
-
}
|
227
|
+
if ((error = git_patch_from_diff(&patch, diff, i)) >= 0)
|
228
|
+
error = git_patch_to_buf(out, patch);
|
799
229
|
|
800
|
-
|
801
|
-
if (!is_ignored) {
|
802
|
-
*delta_type = GIT_DELTA_UNTRACKED;
|
803
|
-
break;
|
804
|
-
}
|
230
|
+
git_patch_free(patch);
|
805
231
|
|
806
|
-
if (
|
232
|
+
if (error < 0)
|
807
233
|
break;
|
808
234
|
}
|
809
235
|
|
810
|
-
/* finish off scan */
|
811
|
-
while (info->nitem != NULL &&
|
812
|
-
!diff->pfxcomp(info->nitem->path, git_buf_cstr(&base))) {
|
813
|
-
if ((error = git_iterator_advance(&info->nitem, info->new_iter)) < 0)
|
814
|
-
break;
|
815
|
-
}
|
816
|
-
|
817
|
-
done:
|
818
|
-
git_buf_free(&base);
|
819
|
-
|
820
|
-
if (error == GIT_ITEROVER)
|
821
|
-
error = 0;
|
822
|
-
|
823
236
|
return error;
|
824
237
|
}
|
825
238
|
|
826
|
-
|
827
|
-
|
239
|
+
int git_diff_format_email(
|
240
|
+
git_buf *out,
|
241
|
+
git_diff *diff,
|
242
|
+
const git_diff_format_email_options *opts)
|
828
243
|
{
|
829
|
-
|
830
|
-
|
831
|
-
|
832
|
-
|
833
|
-
|
834
|
-
|
835
|
-
contains_oitem = entry_is_prefixed(diff, info->oitem, nitem);
|
836
|
-
|
837
|
-
/* check if this is contained in an ignored parent directory */
|
838
|
-
if (git_buf_len(&info->ignore_prefix)) {
|
839
|
-
if (diff->pfxcomp(nitem->path, git_buf_cstr(&info->ignore_prefix)) == 0)
|
840
|
-
delta_type = GIT_DELTA_IGNORED;
|
841
|
-
else
|
842
|
-
git_buf_clear(&info->ignore_prefix);
|
843
|
-
}
|
244
|
+
git_diff_stats *stats = NULL;
|
245
|
+
char *summary = NULL, *loc = NULL;
|
246
|
+
bool ignore_marker;
|
247
|
+
unsigned int format_flags = 0;
|
248
|
+
size_t allocsize;
|
249
|
+
int error;
|
844
250
|
|
845
|
-
|
846
|
-
|
251
|
+
assert(out && diff && opts);
|
252
|
+
assert(opts->summary && opts->id && opts->author);
|
847
253
|
|
848
|
-
|
849
|
-
|
850
|
-
|
851
|
-
delta_type = GIT_DELTA_IGNORED;
|
852
|
-
git_buf_sets(&info->ignore_prefix, nitem->path);
|
853
|
-
}
|
254
|
+
GIT_ERROR_CHECK_VERSION(opts,
|
255
|
+
GIT_DIFF_FORMAT_EMAIL_OPTIONS_VERSION,
|
256
|
+
"git_format_email_options");
|
854
257
|
|
855
|
-
|
856
|
-
|
857
|
-
(delta_type == GIT_DELTA_UNTRACKED &&
|
858
|
-
DIFF_FLAG_IS_SET(diff, GIT_DIFF_RECURSE_UNTRACKED_DIRS)) ||
|
859
|
-
(delta_type == GIT_DELTA_IGNORED &&
|
860
|
-
DIFF_FLAG_IS_SET(diff, GIT_DIFF_RECURSE_IGNORED_DIRS));
|
861
|
-
|
862
|
-
/* do not advance into directories that contain a .git file */
|
863
|
-
if (recurse_into_dir) {
|
864
|
-
git_buf *full = NULL;
|
865
|
-
if (git_iterator_current_workdir_path(&full, info->new_iter) < 0)
|
866
|
-
return -1;
|
867
|
-
if (full && git_path_contains_dir(full, DOT_GIT))
|
868
|
-
recurse_into_dir = false;
|
869
|
-
}
|
258
|
+
ignore_marker = (opts->flags &
|
259
|
+
GIT_DIFF_FORMAT_EMAIL_EXCLUDE_SUBJECT_PATCH_MARKER) != 0;
|
870
260
|
|
871
|
-
|
872
|
-
|
873
|
-
|
874
|
-
|
875
|
-
|
876
|
-
|
877
|
-
{
|
878
|
-
git_diff_delta *last;
|
879
|
-
|
880
|
-
/* attempt to insert record for this directory */
|
881
|
-
if ((error = diff_delta__from_one(diff, delta_type, nitem)) < 0)
|
882
|
-
return error;
|
883
|
-
|
884
|
-
/* if delta wasn't created (because of rules), just skip ahead */
|
885
|
-
last = diff_delta__last_for_item(diff, nitem);
|
886
|
-
if (!last)
|
887
|
-
return git_iterator_advance(&info->nitem, info->new_iter);
|
888
|
-
|
889
|
-
/* iterate into dir looking for an actual untracked file */
|
890
|
-
if (diff_scan_inside_untracked_dir(diff, info, &delta_type) < 0)
|
891
|
-
return -1;
|
892
|
-
|
893
|
-
/* it iteration changed delta type, the update the record */
|
894
|
-
if (delta_type == GIT_DELTA_IGNORED) {
|
895
|
-
last->status = GIT_DELTA_IGNORED;
|
896
|
-
|
897
|
-
/* remove the record if we don't want ignored records */
|
898
|
-
if (DIFF_FLAG_ISNT_SET(diff, GIT_DIFF_INCLUDE_IGNORED)) {
|
899
|
-
git_vector_pop(&diff->deltas);
|
900
|
-
git__free(last);
|
901
|
-
}
|
902
|
-
}
|
903
|
-
|
904
|
-
return 0;
|
261
|
+
if (!ignore_marker) {
|
262
|
+
if (opts->patch_no > opts->total_patches) {
|
263
|
+
git_error_set(GIT_ERROR_INVALID,
|
264
|
+
"patch %"PRIuZ" out of range. max %"PRIuZ,
|
265
|
+
opts->patch_no, opts->total_patches);
|
266
|
+
return -1;
|
905
267
|
}
|
906
268
|
|
907
|
-
|
908
|
-
|
909
|
-
|
910
|
-
|
911
|
-
/* if real error or no error, proceed with iteration */
|
912
|
-
if (error != GIT_ENOTFOUND)
|
913
|
-
return error;
|
914
|
-
giterr_clear();
|
915
|
-
|
916
|
-
/* if directory is empty, can't advance into it, so either skip
|
917
|
-
* it or ignore it
|
918
|
-
*/
|
919
|
-
if (contains_oitem)
|
920
|
-
return git_iterator_advance(&info->nitem, info->new_iter);
|
921
|
-
delta_type = GIT_DELTA_IGNORED;
|
269
|
+
if (opts->patch_no == 0) {
|
270
|
+
git_error_set(GIT_ERROR_INVALID,
|
271
|
+
"invalid patch no %"PRIuZ". should be >0", opts->patch_no);
|
272
|
+
return -1;
|
922
273
|
}
|
923
274
|
}
|
924
275
|
|
925
|
-
/*
|
926
|
-
*
|
927
|
-
*
|
928
|
-
|
929
|
-
|
930
|
-
* To me, this seems odd. If the directory is ignored and the file is
|
931
|
-
* untracked, we should skip it consistently, regardless of whether it
|
932
|
-
* happens to match a pattern in the ignore file.
|
933
|
-
*
|
934
|
-
* To match the core git behavior, reverse the following two if checks
|
935
|
-
* so that individual file ignores are checked before container
|
936
|
-
* directory exclusions are used to skip the file.
|
937
|
-
*/
|
938
|
-
else if (delta_type == GIT_DELTA_IGNORED &&
|
939
|
-
DIFF_FLAG_ISNT_SET(diff, GIT_DIFF_RECURSE_IGNORED_DIRS))
|
940
|
-
/* item contained in ignored directory, so skip over it */
|
941
|
-
return git_iterator_advance(&info->nitem, info->new_iter);
|
942
|
-
|
943
|
-
else if (git_iterator_current_is_ignored(info->new_iter))
|
944
|
-
delta_type = GIT_DELTA_IGNORED;
|
945
|
-
|
946
|
-
else if (info->new_iter->type != GIT_ITERATOR_TYPE_WORKDIR)
|
947
|
-
delta_type = GIT_DELTA_ADDED;
|
948
|
-
|
949
|
-
/* Actually create the record for this item if necessary */
|
950
|
-
if ((error = diff_delta__from_one(diff, delta_type, nitem)) < 0)
|
951
|
-
return error;
|
276
|
+
/* the summary we receive may not be clean.
|
277
|
+
* it could potentially contain new line characters
|
278
|
+
* or not be set, sanitize, */
|
279
|
+
if ((loc = strpbrk(opts->summary, "\r\n")) != NULL) {
|
280
|
+
size_t offset = 0;
|
952
281
|
|
953
|
-
|
954
|
-
|
955
|
-
|
956
|
-
|
957
|
-
DIFF_FLAG_IS_SET(diff, GIT_DIFF_INCLUDE_TYPECHANGE_TREES) &&
|
958
|
-
contains_oitem)
|
959
|
-
{
|
960
|
-
/* this entry was prefixed with a tree - make TYPECHANGE */
|
961
|
-
git_diff_delta *last = diff_delta__last_for_item(diff, nitem);
|
962
|
-
if (last) {
|
963
|
-
last->status = GIT_DELTA_TYPECHANGE;
|
964
|
-
last->old_file.mode = GIT_FILEMODE_TREE;
|
282
|
+
if ((offset = (loc - opts->summary)) == 0) {
|
283
|
+
git_error_set(GIT_ERROR_INVALID, "summary is empty");
|
284
|
+
error = -1;
|
285
|
+
goto on_error;
|
965
286
|
}
|
966
|
-
}
|
967
287
|
|
968
|
-
|
969
|
-
|
288
|
+
GIT_ERROR_CHECK_ALLOC_ADD(&allocsize, offset, 1);
|
289
|
+
summary = git__calloc(allocsize, sizeof(char));
|
290
|
+
GIT_ERROR_CHECK_ALLOC(summary);
|
970
291
|
|
971
|
-
|
972
|
-
|
973
|
-
{
|
974
|
-
int error = diff_delta__from_one(diff, GIT_DELTA_DELETED, info->oitem);
|
975
|
-
if (error < 0)
|
976
|
-
return error;
|
292
|
+
strncpy(summary, opts->summary, offset);
|
293
|
+
}
|
977
294
|
|
978
|
-
|
979
|
-
|
980
|
-
|
981
|
-
if (DIFF_FLAG_IS_SET(diff, GIT_DIFF_INCLUDE_TYPECHANGE_TREES) &&
|
982
|
-
entry_is_prefixed(diff, info->nitem, info->oitem))
|
983
|
-
{
|
984
|
-
/* this entry has become a tree! convert to TYPECHANGE */
|
985
|
-
git_diff_delta *last = diff_delta__last_for_item(diff, info->oitem);
|
986
|
-
if (last) {
|
987
|
-
last->status = GIT_DELTA_TYPECHANGE;
|
988
|
-
last->new_file.mode = GIT_FILEMODE_TREE;
|
989
|
-
}
|
295
|
+
error = git_diff_format_email__append_header_tobuf(out,
|
296
|
+
opts->id, opts->author, summary == NULL ? opts->summary : summary,
|
297
|
+
opts->body, opts->patch_no, opts->total_patches, ignore_marker);
|
990
298
|
|
991
|
-
|
992
|
-
|
993
|
-
* Unless RECURSE_UNTRACKED_DIRS is set, skip over them...
|
994
|
-
*/
|
995
|
-
if (S_ISDIR(info->nitem->mode) &&
|
996
|
-
DIFF_FLAG_ISNT_SET(diff, GIT_DIFF_RECURSE_UNTRACKED_DIRS))
|
997
|
-
return git_iterator_advance(&info->nitem, info->new_iter);
|
998
|
-
}
|
299
|
+
if (error < 0)
|
300
|
+
goto on_error;
|
999
301
|
|
1000
|
-
|
1001
|
-
}
|
302
|
+
format_flags = GIT_DIFF_STATS_FULL | GIT_DIFF_STATS_INCLUDE_SUMMARY;
|
1002
303
|
|
1003
|
-
|
1004
|
-
|
1005
|
-
|
1006
|
-
|
304
|
+
if ((error = git_buf_puts(out, "---\n")) < 0 ||
|
305
|
+
(error = git_diff_get_stats(&stats, diff)) < 0 ||
|
306
|
+
(error = git_diff_stats_to_buf(out, stats, format_flags, 0)) < 0 ||
|
307
|
+
(error = git_buf_putc(out, '\n')) < 0 ||
|
308
|
+
(error = git_diff_format_email__append_patches_tobuf(out, diff)) < 0)
|
309
|
+
goto on_error;
|
1007
310
|
|
1008
|
-
|
1009
|
-
return error;
|
311
|
+
error = git_buf_puts(out, "--\nlibgit2 " LIBGIT2_VERSION "\n\n");
|
1010
312
|
|
1011
|
-
|
1012
|
-
|
1013
|
-
|
313
|
+
on_error:
|
314
|
+
git__free(summary);
|
315
|
+
git_diff_stats_free(stats);
|
1014
316
|
|
1015
317
|
return error;
|
1016
318
|
}
|
1017
319
|
|
1018
|
-
int
|
1019
|
-
|
320
|
+
int git_diff_commit_as_email(
|
321
|
+
git_buf *out,
|
1020
322
|
git_repository *repo,
|
1021
|
-
|
1022
|
-
|
1023
|
-
|
1024
|
-
|
1025
|
-
|
1026
|
-
|
1027
|
-
|
1028
|
-
|
1029
|
-
|
1030
|
-
|
1031
|
-
|
1032
|
-
|
1033
|
-
|
1034
|
-
|
1035
|
-
|
1036
|
-
|
1037
|
-
|
1038
|
-
|
1039
|
-
|
1040
|
-
|
1041
|
-
|
1042
|
-
|
1043
|
-
|
1044
|
-
}
|
1045
|
-
|
1046
|
-
/* finish initialization */
|
1047
|
-
if ((error = diff_list_apply_options(diff, opts)) < 0)
|
1048
|
-
goto cleanup;
|
1049
|
-
|
1050
|
-
if ((error = git_iterator_current(&info.oitem, old_iter)) < 0 &&
|
1051
|
-
error != GIT_ITEROVER)
|
1052
|
-
goto cleanup;
|
1053
|
-
if ((error = git_iterator_current(&info.nitem, new_iter)) < 0 &&
|
1054
|
-
error != GIT_ITEROVER)
|
1055
|
-
goto cleanup;
|
1056
|
-
error = 0;
|
1057
|
-
|
1058
|
-
/* run iterators building diffs */
|
1059
|
-
while (!error && (info.oitem || info.nitem)) {
|
1060
|
-
int cmp = info.oitem ?
|
1061
|
-
(info.nitem ? diff->entrycomp(info.oitem, info.nitem) : -1) : 1;
|
1062
|
-
|
1063
|
-
/* create DELETED records for old items not matched in new */
|
1064
|
-
if (cmp < 0)
|
1065
|
-
error = handle_unmatched_old_item(diff, &info);
|
1066
|
-
|
1067
|
-
/* create ADDED, TRACKED, or IGNORED records for new items not
|
1068
|
-
* matched in old (and/or descend into directories as needed)
|
1069
|
-
*/
|
1070
|
-
else if (cmp > 0)
|
1071
|
-
error = handle_unmatched_new_item(diff, &info);
|
1072
|
-
|
1073
|
-
/* otherwise item paths match, so create MODIFIED record
|
1074
|
-
* (or ADDED and DELETED pair if type changed)
|
1075
|
-
*/
|
1076
|
-
else
|
1077
|
-
error = handle_matched_item(diff, &info);
|
1078
|
-
|
1079
|
-
/* because we are iterating over two lists, ignore ITEROVER */
|
1080
|
-
if (error == GIT_ITEROVER)
|
1081
|
-
error = 0;
|
1082
|
-
}
|
1083
|
-
|
1084
|
-
cleanup:
|
1085
|
-
if (!error)
|
1086
|
-
*diff_ptr = diff;
|
1087
|
-
else
|
1088
|
-
git_diff_list_free(diff);
|
323
|
+
git_commit *commit,
|
324
|
+
size_t patch_no,
|
325
|
+
size_t total_patches,
|
326
|
+
git_diff_format_email_flags_t flags,
|
327
|
+
const git_diff_options *diff_opts)
|
328
|
+
{
|
329
|
+
git_diff *diff = NULL;
|
330
|
+
git_diff_format_email_options opts =
|
331
|
+
GIT_DIFF_FORMAT_EMAIL_OPTIONS_INIT;
|
332
|
+
int error;
|
333
|
+
|
334
|
+
assert (out && repo && commit);
|
335
|
+
|
336
|
+
opts.flags = flags;
|
337
|
+
opts.patch_no = patch_no;
|
338
|
+
opts.total_patches = total_patches;
|
339
|
+
opts.id = git_commit_id(commit);
|
340
|
+
opts.summary = git_commit_summary(commit);
|
341
|
+
opts.body = git_commit_body(commit);
|
342
|
+
opts.author = git_commit_author(commit);
|
343
|
+
|
344
|
+
if ((error = git_diff__commit(&diff, repo, commit, diff_opts)) < 0)
|
345
|
+
return error;
|
1089
346
|
|
1090
|
-
|
347
|
+
error = git_diff_format_email(out, diff, &opts);
|
1091
348
|
|
349
|
+
git_diff_free(diff);
|
1092
350
|
return error;
|
1093
351
|
}
|
1094
352
|
|
1095
|
-
|
1096
|
-
git_iterator *a = NULL, *b = NULL; \
|
1097
|
-
char *pfx = opts ? git_pathspec_prefix(&opts->pathspec) : NULL; \
|
1098
|
-
GITERR_CHECK_VERSION(opts, GIT_DIFF_OPTIONS_VERSION, "git_diff_options"); \
|
1099
|
-
if (!(error = MAKE_FIRST) && !(error = MAKE_SECOND)) \
|
1100
|
-
error = git_diff__from_iterators(diff, repo, a, b, opts); \
|
1101
|
-
git__free(pfx); git_iterator_free(a); git_iterator_free(b); \
|
1102
|
-
} while (0)
|
1103
|
-
|
1104
|
-
int git_diff_tree_to_tree(
|
1105
|
-
git_diff_list **diff,
|
1106
|
-
git_repository *repo,
|
1107
|
-
git_tree *old_tree,
|
1108
|
-
git_tree *new_tree,
|
1109
|
-
const git_diff_options *opts)
|
353
|
+
int git_diff_init_options(git_diff_options *opts, unsigned int version)
|
1110
354
|
{
|
1111
|
-
|
1112
|
-
|
1113
|
-
|
1114
|
-
|
1115
|
-
|
1116
|
-
/* for tree to tree diff, be case sensitive even if the index is
|
1117
|
-
* currently case insensitive, unless the user explicitly asked
|
1118
|
-
* for case insensitivity
|
1119
|
-
*/
|
1120
|
-
if (opts && (opts->flags & GIT_DIFF_DELTAS_ARE_ICASE) != 0)
|
1121
|
-
iflag = GIT_ITERATOR_IGNORE_CASE;
|
1122
|
-
|
1123
|
-
DIFF_FROM_ITERATORS(
|
1124
|
-
git_iterator_for_tree(&a, old_tree, iflag, pfx, pfx),
|
1125
|
-
git_iterator_for_tree(&b, new_tree, iflag, pfx, pfx)
|
1126
|
-
);
|
355
|
+
GIT_INIT_STRUCTURE_FROM_TEMPLATE(
|
356
|
+
opts, version, git_diff_options, GIT_DIFF_OPTIONS_INIT);
|
357
|
+
return 0;
|
358
|
+
}
|
1127
359
|
|
1128
|
-
|
360
|
+
int git_diff_find_init_options(
|
361
|
+
git_diff_find_options *opts, unsigned int version)
|
362
|
+
{
|
363
|
+
GIT_INIT_STRUCTURE_FROM_TEMPLATE(
|
364
|
+
opts, version, git_diff_find_options, GIT_DIFF_FIND_OPTIONS_INIT);
|
365
|
+
return 0;
|
1129
366
|
}
|
1130
367
|
|
1131
|
-
int
|
1132
|
-
|
1133
|
-
git_repository *repo,
|
1134
|
-
git_tree *old_tree,
|
1135
|
-
git_index *index,
|
1136
|
-
const git_diff_options *opts)
|
368
|
+
int git_diff_format_email_init_options(
|
369
|
+
git_diff_format_email_options *opts, unsigned int version)
|
1137
370
|
{
|
1138
|
-
|
1139
|
-
|
371
|
+
GIT_INIT_STRUCTURE_FROM_TEMPLATE(
|
372
|
+
opts, version, git_diff_format_email_options,
|
373
|
+
GIT_DIFF_FORMAT_EMAIL_OPTIONS_INIT);
|
374
|
+
return 0;
|
375
|
+
}
|
1140
376
|
|
1141
|
-
|
377
|
+
static int flush_hunk(git_oid *result, git_hash_ctx *ctx)
|
378
|
+
{
|
379
|
+
git_oid hash;
|
380
|
+
unsigned short carry = 0;
|
381
|
+
int error, i;
|
1142
382
|
|
1143
|
-
if (
|
383
|
+
if ((error = git_hash_final(&hash, ctx)) < 0 ||
|
384
|
+
(error = git_hash_init(ctx)) < 0)
|
1144
385
|
return error;
|
1145
386
|
|
1146
|
-
|
1147
|
-
|
1148
|
-
|
387
|
+
for (i = 0; i < GIT_OID_RAWSZ; i++) {
|
388
|
+
carry += result->id[i] + hash.id[i];
|
389
|
+
result->id[i] = (unsigned char)carry;
|
390
|
+
carry >>= 8;
|
1149
391
|
}
|
1150
392
|
|
1151
|
-
|
1152
|
-
|
1153
|
-
git_iterator_for_index(&b, index, 0, pfx, pfx)
|
1154
|
-
);
|
1155
|
-
|
1156
|
-
if (reset_index_ignore_case) {
|
1157
|
-
git_index__set_ignore_case(index, true);
|
1158
|
-
|
1159
|
-
if (!error) {
|
1160
|
-
git_diff_list *d = *diff;
|
393
|
+
return 0;
|
394
|
+
}
|
1161
395
|
|
1162
|
-
|
1163
|
-
|
1164
|
-
|
1165
|
-
|
1166
|
-
|
396
|
+
static void strip_spaces(git_buf *buf)
|
397
|
+
{
|
398
|
+
char *src = buf->ptr, *dst = buf->ptr;
|
399
|
+
char c;
|
400
|
+
size_t len = 0;
|
1167
401
|
|
1168
|
-
|
1169
|
-
|
402
|
+
while ((c = *src++) != '\0') {
|
403
|
+
if (!git__isspace(c)) {
|
404
|
+
*dst++ = c;
|
405
|
+
len++;
|
1170
406
|
}
|
1171
407
|
}
|
1172
408
|
|
1173
|
-
|
409
|
+
git_buf_truncate(buf, len);
|
1174
410
|
}
|
1175
411
|
|
1176
|
-
int
|
1177
|
-
|
1178
|
-
|
1179
|
-
|
1180
|
-
const git_diff_options *opts)
|
412
|
+
static int file_cb(
|
413
|
+
const git_diff_delta *delta,
|
414
|
+
float progress,
|
415
|
+
void *payload)
|
1181
416
|
{
|
1182
|
-
|
417
|
+
struct patch_id_args *args = (struct patch_id_args *) payload;
|
418
|
+
git_buf buf = GIT_BUF_INIT;
|
419
|
+
int error;
|
1183
420
|
|
1184
|
-
|
421
|
+
GIT_UNUSED(progress);
|
1185
422
|
|
1186
|
-
if (!
|
1187
|
-
|
423
|
+
if (!args->first_file &&
|
424
|
+
(error = flush_hunk(&args->result, &args->ctx)) < 0)
|
425
|
+
goto out;
|
426
|
+
args->first_file = 0;
|
1188
427
|
|
1189
|
-
|
1190
|
-
|
1191
|
-
|
1192
|
-
|
1193
|
-
|
428
|
+
if ((error = git_buf_printf(&buf,
|
429
|
+
"diff--gita/%sb/%s---a/%s+++b/%s",
|
430
|
+
delta->old_file.path,
|
431
|
+
delta->new_file.path,
|
432
|
+
delta->old_file.path,
|
433
|
+
delta->new_file.path)) < 0)
|
434
|
+
goto out;
|
1194
435
|
|
436
|
+
strip_spaces(&buf);
|
437
|
+
|
438
|
+
if ((error = git_hash_update(&args->ctx, buf.ptr, buf.size)) < 0)
|
439
|
+
goto out;
|
440
|
+
|
441
|
+
out:
|
442
|
+
git_buf_dispose(&buf);
|
1195
443
|
return error;
|
1196
444
|
}
|
1197
445
|
|
1198
|
-
|
1199
|
-
|
1200
|
-
|
1201
|
-
|
1202
|
-
|
1203
|
-
const git_diff_options *opts)
|
446
|
+
static int line_cb(
|
447
|
+
const git_diff_delta *delta,
|
448
|
+
const git_diff_hunk *hunk,
|
449
|
+
const git_diff_line *line,
|
450
|
+
void *payload)
|
1204
451
|
{
|
1205
|
-
|
452
|
+
struct patch_id_args *args = (struct patch_id_args *) payload;
|
453
|
+
git_buf buf = GIT_BUF_INIT;
|
454
|
+
int error;
|
1206
455
|
|
1207
|
-
|
456
|
+
GIT_UNUSED(delta);
|
457
|
+
GIT_UNUSED(hunk);
|
458
|
+
|
459
|
+
switch (line->origin) {
|
460
|
+
case GIT_DIFF_LINE_ADDITION:
|
461
|
+
git_buf_putc(&buf, '+');
|
462
|
+
break;
|
463
|
+
case GIT_DIFF_LINE_DELETION:
|
464
|
+
git_buf_putc(&buf, '-');
|
465
|
+
break;
|
466
|
+
case GIT_DIFF_LINE_CONTEXT:
|
467
|
+
break;
|
468
|
+
default:
|
469
|
+
git_error_set(GIT_ERROR_PATCH, "invalid line origin for patch");
|
470
|
+
return -1;
|
471
|
+
}
|
1208
472
|
|
1209
|
-
|
1210
|
-
|
1211
|
-
git_iterator_for_workdir(
|
1212
|
-
&b, repo, GIT_ITERATOR_DONT_AUTOEXPAND, pfx, pfx)
|
1213
|
-
);
|
473
|
+
git_buf_put(&buf, line->content, line->content_len);
|
474
|
+
strip_spaces(&buf);
|
1214
475
|
|
476
|
+
if ((error = git_hash_update(&args->ctx, buf.ptr, buf.size)) < 0)
|
477
|
+
goto out;
|
478
|
+
|
479
|
+
out:
|
480
|
+
git_buf_dispose(&buf);
|
1215
481
|
return error;
|
1216
482
|
}
|
1217
483
|
|
1218
|
-
|
484
|
+
int git_diff_patchid_init_options(git_diff_patchid_options *opts, unsigned int version)
|
1219
485
|
{
|
1220
|
-
|
1221
|
-
|
486
|
+
GIT_INIT_STRUCTURE_FROM_TEMPLATE(
|
487
|
+
opts, version, git_diff_patchid_options, GIT_DIFF_PATCHID_OPTIONS_INIT);
|
488
|
+
return 0;
|
1222
489
|
}
|
1223
490
|
|
1224
|
-
|
491
|
+
int git_diff_patchid(git_oid *out, git_diff *diff, git_diff_patchid_options *opts)
|
1225
492
|
{
|
1226
|
-
|
1227
|
-
|
493
|
+
struct patch_id_args args;
|
494
|
+
int error;
|
1228
495
|
|
1229
|
-
|
496
|
+
GIT_ERROR_CHECK_VERSION(
|
497
|
+
opts, GIT_DIFF_PATCHID_OPTIONS_VERSION, "git_diff_patchid_options");
|
1230
498
|
|
1231
|
-
|
1232
|
-
|
1233
|
-
|
499
|
+
memset(&args, 0, sizeof(args));
|
500
|
+
args.first_file = 1;
|
501
|
+
if ((error = git_hash_ctx_init(&args.ctx)) < 0)
|
502
|
+
goto out;
|
1234
503
|
|
1235
|
-
|
1236
|
-
|
504
|
+
if ((error = git_diff_foreach(diff, file_cb, NULL, NULL, line_cb, &args)) < 0)
|
505
|
+
goto out;
|
1237
506
|
|
1238
|
-
|
1239
|
-
|
1240
|
-
git_diff_list *idx2wd,
|
1241
|
-
int (*cb)(git_diff_delta *h2i, git_diff_delta *i2w, void *payload),
|
1242
|
-
void *payload)
|
1243
|
-
{
|
1244
|
-
int cmp;
|
1245
|
-
git_diff_delta *h2i, *i2w;
|
1246
|
-
size_t i, j, i_max, j_max;
|
1247
|
-
int (*strcomp)(const char *, const char *) = git__strcmp;
|
1248
|
-
bool icase_mismatch;
|
1249
|
-
|
1250
|
-
i_max = head2idx ? head2idx->deltas.length : 0;
|
1251
|
-
j_max = idx2wd ? idx2wd->deltas.length : 0;
|
1252
|
-
|
1253
|
-
/* At some point, tree-to-index diffs will probably never ignore case,
|
1254
|
-
* even if that isn't true now. Index-to-workdir diffs may or may not
|
1255
|
-
* ignore case, but the index filename for the idx2wd diff should
|
1256
|
-
* still be using the canonical case-preserving name.
|
1257
|
-
*
|
1258
|
-
* Therefore the main thing we need to do here is make sure the diffs
|
1259
|
-
* are traversed in a compatible order. To do this, we temporarily
|
1260
|
-
* resort a mismatched diff to get the order correct.
|
1261
|
-
*/
|
1262
|
-
icase_mismatch =
|
1263
|
-
(head2idx != NULL && idx2wd != NULL &&
|
1264
|
-
((head2idx->opts.flags ^ idx2wd->opts.flags) & GIT_DIFF_DELTAS_ARE_ICASE));
|
1265
|
-
|
1266
|
-
/* force case-sensitive delta sort */
|
1267
|
-
if (icase_mismatch) {
|
1268
|
-
if (head2idx->opts.flags & GIT_DIFF_DELTAS_ARE_ICASE) {
|
1269
|
-
git_vector_set_cmp(&head2idx->deltas, git_diff_delta__cmp);
|
1270
|
-
git_vector_sort(&head2idx->deltas);
|
1271
|
-
} else {
|
1272
|
-
git_vector_set_cmp(&idx2wd->deltas, git_diff_delta__cmp);
|
1273
|
-
git_vector_sort(&idx2wd->deltas);
|
1274
|
-
}
|
1275
|
-
}
|
1276
|
-
else if (head2idx->opts.flags & GIT_DIFF_DELTAS_ARE_ICASE)
|
1277
|
-
strcomp = git__strcasecmp;
|
1278
|
-
|
1279
|
-
for (i = 0, j = 0; i < i_max || j < j_max; ) {
|
1280
|
-
h2i = head2idx ? GIT_VECTOR_GET(&head2idx->deltas, i) : NULL;
|
1281
|
-
i2w = idx2wd ? GIT_VECTOR_GET(&idx2wd->deltas, j) : NULL;
|
1282
|
-
|
1283
|
-
cmp = !i2w ? -1 : !h2i ? 1 :
|
1284
|
-
strcomp(h2i->new_file.path, i2w->old_file.path);
|
1285
|
-
|
1286
|
-
if (cmp < 0) {
|
1287
|
-
if (cb(h2i, NULL, payload))
|
1288
|
-
return GIT_EUSER;
|
1289
|
-
i++;
|
1290
|
-
} else if (cmp > 0) {
|
1291
|
-
if (cb(NULL, i2w, payload))
|
1292
|
-
return GIT_EUSER;
|
1293
|
-
j++;
|
1294
|
-
} else {
|
1295
|
-
if (cb(h2i, i2w, payload))
|
1296
|
-
return GIT_EUSER;
|
1297
|
-
i++; j++;
|
1298
|
-
}
|
1299
|
-
}
|
507
|
+
if ((error = (flush_hunk(&args.result, &args.ctx))) < 0)
|
508
|
+
goto out;
|
1300
509
|
|
1301
|
-
|
1302
|
-
if (icase_mismatch) {
|
1303
|
-
if (head2idx->opts.flags & GIT_DIFF_DELTAS_ARE_ICASE) {
|
1304
|
-
git_vector_set_cmp(&head2idx->deltas, git_diff_delta__casecmp);
|
1305
|
-
git_vector_sort(&head2idx->deltas);
|
1306
|
-
} else {
|
1307
|
-
git_vector_set_cmp(&idx2wd->deltas, git_diff_delta__casecmp);
|
1308
|
-
git_vector_sort(&idx2wd->deltas);
|
1309
|
-
}
|
1310
|
-
}
|
510
|
+
git_oid_cpy(out, &args.result);
|
1311
511
|
|
1312
|
-
|
512
|
+
out:
|
513
|
+
git_hash_ctx_cleanup(&args.ctx);
|
514
|
+
return error;
|
1313
515
|
}
|