rugged 0.17.0.b7 → 0.18.0.b1
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +1 -1
- data/README.md +88 -32
- data/ext/rugged/extconf.rb +4 -2
- data/ext/rugged/rugged.c +72 -10
- data/ext/rugged/rugged.h +14 -10
- data/ext/rugged/rugged_blob.c +8 -10
- data/ext/rugged/rugged_branch.c +11 -14
- data/ext/rugged/rugged_commit.c +31 -24
- data/ext/rugged/rugged_config.c +2 -2
- data/ext/rugged/rugged_index.c +133 -198
- data/ext/rugged/rugged_note.c +372 -0
- data/ext/rugged/rugged_object.c +50 -22
- data/ext/rugged/rugged_reference.c +122 -130
- data/ext/rugged/rugged_remote.c +72 -29
- data/ext/rugged/rugged_repo.c +402 -20
- data/ext/rugged/rugged_revwalk.c +7 -3
- data/ext/rugged/rugged_settings.c +110 -0
- data/ext/rugged/rugged_signature.c +23 -7
- data/ext/rugged/rugged_tag.c +32 -16
- data/ext/rugged/rugged_tree.c +44 -15
- data/lib/rugged.rb +1 -0
- data/lib/rugged/index.rb +8 -0
- data/lib/rugged/remote.rb +13 -0
- data/lib/rugged/repository.rb +3 -3
- data/lib/rugged/version.rb +1 -1
- data/test/blob_test.rb +13 -15
- data/test/branch_test.rb +32 -67
- data/test/commit_test.rb +50 -12
- data/test/config_test.rb +12 -11
- data/test/coverage/HEAD.json +1 -1
- data/test/coverage/cover.rb +40 -21
- data/test/errors_test.rb +34 -0
- 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/testrepo.git/logs/refs/notes/commits +1 -0
- data/test/fixtures/testrepo.git/objects/44/1034f860c1d5d90e4188d11ae0d325176869a8 +1 -0
- data/test/fixtures/testrepo.git/objects/60/d415052a33de2150bf68757f6461df4f563ae4 +0 -0
- data/test/fixtures/testrepo.git/objects/68/8a8f4ef7496901d15322972f96e212a9e466cc +1 -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/b7/4713326bc972cc15751ed504dca6f6f3b91f7a +3 -0
- data/test/fixtures/testrepo.git/refs/notes/commits +1 -0
- data/test/index_test.rb +65 -69
- data/test/lib_test.rb +76 -11
- data/test/note_test.rb +158 -0
- data/test/object_test.rb +8 -11
- data/test/reference_test.rb +77 -85
- data/test/remote_test.rb +86 -8
- data/test/repo_pack_test.rb +9 -7
- data/test/repo_reset_test.rb +80 -0
- data/test/repo_test.rb +176 -53
- data/test/tag_test.rb +44 -7
- data/test/test_helper.rb +63 -35
- data/test/tree_test.rb +34 -13
- data/test/walker_test.rb +14 -14
- data/vendor/libgit2/Makefile.embed +1 -1
- data/vendor/libgit2/deps/http-parser/http_parser.c +974 -578
- data/vendor/libgit2/deps/http-parser/http_parser.h +106 -70
- data/vendor/libgit2/deps/regex/regcomp.c +7 -6
- data/vendor/libgit2/deps/regex/regex_internal.c +1 -1
- data/vendor/libgit2/deps/regex/regex_internal.h +12 -3
- data/vendor/libgit2/deps/regex/regexec.c +5 -5
- data/vendor/libgit2/include/git2.h +5 -1
- data/vendor/libgit2/include/git2/attr.h +4 -2
- data/vendor/libgit2/include/git2/blob.h +39 -12
- data/vendor/libgit2/include/git2/branch.h +123 -35
- data/vendor/libgit2/include/git2/checkout.h +206 -48
- data/vendor/libgit2/include/git2/clone.h +72 -27
- data/vendor/libgit2/include/git2/commit.h +20 -17
- data/vendor/libgit2/include/git2/common.h +67 -1
- data/vendor/libgit2/include/git2/config.h +81 -60
- data/vendor/libgit2/include/git2/cred_helpers.h +53 -0
- data/vendor/libgit2/include/git2/diff.h +459 -150
- data/vendor/libgit2/include/git2/errors.h +9 -1
- data/vendor/libgit2/include/git2/graph.h +41 -0
- data/vendor/libgit2/include/git2/ignore.h +7 -6
- data/vendor/libgit2/include/git2/index.h +323 -97
- data/vendor/libgit2/include/git2/indexer.h +27 -59
- data/vendor/libgit2/include/git2/inttypes.h +4 -0
- data/vendor/libgit2/include/git2/merge.h +13 -3
- data/vendor/libgit2/include/git2/message.h +14 -8
- data/vendor/libgit2/include/git2/net.h +9 -7
- data/vendor/libgit2/include/git2/notes.h +88 -29
- data/vendor/libgit2/include/git2/object.h +16 -6
- data/vendor/libgit2/include/git2/odb.h +80 -17
- data/vendor/libgit2/include/git2/odb_backend.h +47 -11
- data/vendor/libgit2/include/git2/oid.h +26 -17
- data/vendor/libgit2/include/git2/pack.h +62 -8
- data/vendor/libgit2/include/git2/push.h +131 -0
- data/vendor/libgit2/include/git2/refdb.h +103 -0
- data/vendor/libgit2/include/git2/refdb_backend.h +109 -0
- data/vendor/libgit2/include/git2/reflog.h +30 -21
- data/vendor/libgit2/include/git2/refs.h +215 -193
- data/vendor/libgit2/include/git2/refspec.h +22 -2
- data/vendor/libgit2/include/git2/remote.h +158 -37
- data/vendor/libgit2/include/git2/repository.h +150 -31
- data/vendor/libgit2/include/git2/reset.h +43 -9
- data/vendor/libgit2/include/git2/revparse.h +48 -4
- data/vendor/libgit2/include/git2/revwalk.h +25 -10
- data/vendor/libgit2/include/git2/signature.h +20 -12
- data/vendor/libgit2/include/git2/stash.h +121 -0
- data/vendor/libgit2/include/git2/status.h +122 -53
- data/vendor/libgit2/include/git2/strarray.h +17 -11
- data/vendor/libgit2/include/git2/submodule.h +42 -7
- data/vendor/libgit2/include/git2/tag.h +72 -59
- data/vendor/libgit2/include/git2/threads.h +4 -2
- data/vendor/libgit2/include/git2/trace.h +68 -0
- data/vendor/libgit2/include/git2/transport.h +328 -0
- data/vendor/libgit2/include/git2/tree.h +149 -120
- data/vendor/libgit2/include/git2/types.h +13 -12
- data/vendor/libgit2/include/git2/version.h +3 -3
- data/vendor/libgit2/src/amiga/map.c +2 -2
- data/vendor/libgit2/src/attr.c +58 -48
- data/vendor/libgit2/src/attr.h +4 -18
- data/vendor/libgit2/src/attr_file.c +30 -6
- data/vendor/libgit2/src/attr_file.h +6 -8
- data/vendor/libgit2/src/attrcache.h +24 -0
- data/vendor/libgit2/src/blob.c +30 -7
- data/vendor/libgit2/src/blob.h +1 -1
- data/vendor/libgit2/src/branch.c +361 -68
- data/vendor/libgit2/src/branch.h +17 -0
- data/vendor/libgit2/src/bswap.h +1 -1
- data/vendor/libgit2/src/buf_text.c +291 -0
- data/vendor/libgit2/src/buf_text.h +122 -0
- data/vendor/libgit2/src/buffer.c +27 -101
- data/vendor/libgit2/src/buffer.h +54 -39
- data/vendor/libgit2/src/cache.c +15 -6
- data/vendor/libgit2/src/cache.h +1 -1
- data/vendor/libgit2/src/cc-compat.h +3 -1
- data/vendor/libgit2/src/checkout.c +1165 -222
- data/vendor/libgit2/src/checkout.h +24 -0
- data/vendor/libgit2/src/clone.c +171 -86
- data/vendor/libgit2/src/commit.c +44 -45
- data/vendor/libgit2/src/commit.h +3 -3
- data/vendor/libgit2/src/commit_list.c +194 -0
- data/vendor/libgit2/src/commit_list.h +49 -0
- data/vendor/libgit2/src/common.h +44 -10
- data/vendor/libgit2/src/compress.c +1 -1
- data/vendor/libgit2/src/compress.h +1 -1
- data/vendor/libgit2/src/config.c +211 -124
- data/vendor/libgit2/src/config.h +23 -4
- data/vendor/libgit2/src/config_cache.c +2 -2
- data/vendor/libgit2/src/config_file.c +129 -53
- data/vendor/libgit2/src/config_file.h +10 -8
- data/vendor/libgit2/src/crlf.c +66 -67
- data/vendor/libgit2/src/date.c +12 -12
- data/vendor/libgit2/src/delta-apply.c +14 -1
- data/vendor/libgit2/src/delta-apply.h +18 -1
- data/vendor/libgit2/src/delta.c +40 -107
- data/vendor/libgit2/src/delta.h +19 -17
- data/vendor/libgit2/src/diff.c +347 -496
- data/vendor/libgit2/src/diff.h +27 -1
- data/vendor/libgit2/src/diff_output.c +564 -249
- data/vendor/libgit2/src/diff_output.h +15 -8
- data/vendor/libgit2/src/diff_tform.c +687 -0
- data/vendor/libgit2/src/errors.c +27 -36
- data/vendor/libgit2/src/fetch.c +13 -351
- data/vendor/libgit2/src/fetch.h +13 -3
- data/vendor/libgit2/src/fetchhead.c +295 -0
- data/vendor/libgit2/src/fetchhead.h +34 -0
- data/vendor/libgit2/src/filebuf.c +42 -15
- data/vendor/libgit2/src/filebuf.h +4 -2
- data/vendor/libgit2/src/fileops.c +466 -113
- data/vendor/libgit2/src/fileops.h +154 -28
- data/vendor/libgit2/src/filter.c +3 -75
- data/vendor/libgit2/src/filter.h +1 -29
- data/vendor/libgit2/src/fnmatch.c +1 -1
- data/vendor/libgit2/src/fnmatch.h +1 -1
- data/vendor/libgit2/src/global.c +54 -10
- data/vendor/libgit2/src/global.h +10 -1
- data/vendor/libgit2/src/graph.c +178 -0
- data/vendor/libgit2/src/hash.c +25 -52
- data/vendor/libgit2/src/hash.h +21 -9
- data/vendor/libgit2/src/{sha1/sha1.c → hash/hash_generic.c} +20 -12
- data/vendor/libgit2/src/hash/hash_generic.h +24 -0
- data/vendor/libgit2/src/hash/hash_openssl.h +45 -0
- data/vendor/libgit2/src/hash/hash_win32.c +291 -0
- data/vendor/libgit2/src/hash/hash_win32.h +140 -0
- data/vendor/libgit2/src/hashsig.c +368 -0
- data/vendor/libgit2/src/hashsig.h +72 -0
- data/vendor/libgit2/src/ignore.c +22 -15
- data/vendor/libgit2/src/ignore.h +6 -1
- data/vendor/libgit2/src/index.c +770 -171
- data/vendor/libgit2/src/index.h +13 -5
- data/vendor/libgit2/src/indexer.c +286 -431
- data/vendor/libgit2/src/iterator.c +854 -466
- data/vendor/libgit2/src/iterator.h +134 -109
- data/vendor/libgit2/src/map.h +1 -1
- data/vendor/libgit2/src/merge.c +296 -0
- data/vendor/libgit2/src/merge.h +22 -0
- data/vendor/libgit2/src/message.c +1 -1
- data/vendor/libgit2/src/message.h +1 -1
- data/vendor/libgit2/src/mwindow.c +35 -30
- data/vendor/libgit2/src/mwindow.h +2 -2
- data/vendor/libgit2/src/netops.c +162 -98
- data/vendor/libgit2/src/netops.h +50 -15
- data/vendor/libgit2/src/notes.c +109 -58
- data/vendor/libgit2/src/notes.h +2 -1
- data/vendor/libgit2/src/object.c +46 -57
- data/vendor/libgit2/src/object.h +1 -8
- data/vendor/libgit2/src/odb.c +151 -40
- data/vendor/libgit2/src/odb.h +5 -1
- data/vendor/libgit2/src/odb_loose.c +4 -5
- data/vendor/libgit2/src/odb_pack.c +122 -80
- data/vendor/libgit2/src/offmap.h +65 -0
- data/vendor/libgit2/src/oid.c +12 -4
- data/vendor/libgit2/src/oidmap.h +1 -1
- data/vendor/libgit2/src/pack-objects.c +88 -61
- data/vendor/libgit2/src/pack-objects.h +8 -8
- data/vendor/libgit2/src/pack.c +293 -28
- data/vendor/libgit2/src/pack.h +49 -4
- data/vendor/libgit2/src/path.c +103 -14
- data/vendor/libgit2/src/path.h +23 -7
- data/vendor/libgit2/src/pathspec.c +168 -0
- data/vendor/libgit2/src/pathspec.h +40 -0
- data/vendor/libgit2/src/pool.c +29 -4
- data/vendor/libgit2/src/pool.h +8 -1
- data/vendor/libgit2/src/posix.c +26 -27
- data/vendor/libgit2/src/posix.h +2 -3
- data/vendor/libgit2/src/pqueue.c +23 -1
- data/vendor/libgit2/src/pqueue.h +23 -1
- data/vendor/libgit2/src/push.c +653 -0
- data/vendor/libgit2/src/push.h +51 -0
- data/vendor/libgit2/src/refdb.c +185 -0
- data/vendor/libgit2/src/refdb.h +46 -0
- data/vendor/libgit2/src/refdb_fs.c +1024 -0
- data/vendor/libgit2/src/refdb_fs.h +15 -0
- data/vendor/libgit2/src/reflog.c +77 -45
- data/vendor/libgit2/src/reflog.h +1 -3
- data/vendor/libgit2/src/refs.c +366 -1326
- data/vendor/libgit2/src/refs.h +22 -13
- data/vendor/libgit2/src/refspec.c +46 -7
- data/vendor/libgit2/src/refspec.h +11 -1
- data/vendor/libgit2/src/remote.c +758 -120
- data/vendor/libgit2/src/remote.h +10 -5
- data/vendor/libgit2/src/repo_template.h +6 -6
- data/vendor/libgit2/src/repository.c +315 -96
- data/vendor/libgit2/src/repository.h +5 -3
- data/vendor/libgit2/src/reset.c +99 -81
- data/vendor/libgit2/src/revparse.c +157 -84
- data/vendor/libgit2/src/revwalk.c +68 -470
- data/vendor/libgit2/src/revwalk.h +44 -0
- data/vendor/libgit2/src/sha1_lookup.c +1 -1
- data/vendor/libgit2/src/sha1_lookup.h +1 -1
- data/vendor/libgit2/src/signature.c +68 -200
- data/vendor/libgit2/src/signature.h +1 -1
- data/vendor/libgit2/src/stash.c +663 -0
- data/vendor/libgit2/src/status.c +101 -79
- data/vendor/libgit2/src/strmap.h +1 -1
- data/vendor/libgit2/src/submodule.c +67 -51
- data/vendor/libgit2/src/submodule.h +1 -1
- data/vendor/libgit2/src/tag.c +35 -29
- data/vendor/libgit2/src/tag.h +1 -1
- data/vendor/libgit2/src/thread-utils.c +1 -1
- data/vendor/libgit2/src/thread-utils.h +2 -2
- data/vendor/libgit2/src/trace.c +39 -0
- data/vendor/libgit2/src/trace.h +56 -0
- data/vendor/libgit2/src/transport.c +81 -34
- data/vendor/libgit2/src/transports/cred.c +60 -0
- data/vendor/libgit2/src/transports/cred_helpers.c +49 -0
- data/vendor/libgit2/src/transports/git.c +234 -127
- data/vendor/libgit2/src/transports/http.c +761 -433
- data/vendor/libgit2/src/transports/local.c +460 -64
- data/vendor/libgit2/src/transports/smart.c +345 -0
- data/vendor/libgit2/src/transports/smart.h +179 -0
- data/vendor/libgit2/src/{pkt.c → transports/smart_pkt.c} +131 -12
- data/vendor/libgit2/src/transports/smart_protocol.c +856 -0
- data/vendor/libgit2/src/transports/winhttp.c +1136 -0
- data/vendor/libgit2/src/tree-cache.c +2 -2
- data/vendor/libgit2/src/tree-cache.h +1 -1
- data/vendor/libgit2/src/tree.c +239 -166
- data/vendor/libgit2/src/tree.h +11 -2
- data/vendor/libgit2/src/tsort.c +39 -23
- data/vendor/libgit2/src/unix/map.c +1 -1
- data/vendor/libgit2/src/unix/posix.h +12 -2
- data/vendor/libgit2/src/unix/realpath.c +30 -0
- data/vendor/libgit2/src/util.c +250 -13
- data/vendor/libgit2/src/util.h +71 -14
- data/vendor/libgit2/src/vector.c +123 -60
- data/vendor/libgit2/src/vector.h +24 -22
- data/vendor/libgit2/src/win32/dir.c +1 -1
- data/vendor/libgit2/src/win32/dir.h +1 -1
- data/vendor/libgit2/src/win32/error.c +77 -0
- data/vendor/libgit2/src/win32/error.h +13 -0
- data/vendor/libgit2/src/win32/findfile.c +143 -54
- data/vendor/libgit2/src/win32/findfile.h +10 -6
- data/vendor/libgit2/src/win32/map.c +1 -1
- data/vendor/libgit2/src/win32/mingw-compat.h +1 -1
- data/vendor/libgit2/src/win32/msvc-compat.h +10 -1
- data/vendor/libgit2/src/win32/posix.h +10 -1
- data/vendor/libgit2/src/win32/posix_w32.c +132 -63
- data/vendor/libgit2/src/win32/precompiled.c +1 -1
- data/vendor/libgit2/src/win32/pthread.c +1 -1
- data/vendor/libgit2/src/win32/pthread.h +1 -1
- data/vendor/libgit2/src/win32/utf-conv.c +5 -5
- data/vendor/libgit2/src/win32/utf-conv.h +3 -3
- data/vendor/libgit2/src/win32/version.h +20 -0
- metadata +308 -252
- data/test/fixtures/testrepo.git/objects/4b/825dc642cb6eb9a060e54bf8d69288fbee4904 +0 -0
- data/test/fixtures/testrepo.git/objects/7f/043268ea43ce18e3540acaabf9e090c91965b0 +0 -0
- data/test/fixtures/testrepo.git/objects/a3/e05719b428a2d0ed7a55c4ce53dcc5768c6d5e +0 -0
- data/test/index_test.rb~ +0 -218
- data/vendor/libgit2/src/pkt.h +0 -91
- data/vendor/libgit2/src/ppc/sha1.c +0 -70
- data/vendor/libgit2/src/ppc/sha1.h +0 -26
- data/vendor/libgit2/src/protocol.c +0 -110
- data/vendor/libgit2/src/protocol.h +0 -21
- data/vendor/libgit2/src/sha1.h +0 -33
- data/vendor/libgit2/src/transport.h +0 -148
@@ -1,5 +1,5 @@
|
|
1
1
|
/*
|
2
|
-
* Copyright (C)
|
2
|
+
* Copyright (C) the libgit2 contributors. All rights reserved.
|
3
3
|
*
|
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.
|
@@ -12,169 +12,194 @@
|
|
12
12
|
#include "vector.h"
|
13
13
|
#include "buffer.h"
|
14
14
|
|
15
|
-
#define ITERATOR_PREFIXCMP(ITER, STR, PREFIX) (((ITER).ignore_case) ? \
|
16
|
-
git__prefixcmp_icase((STR), (PREFIX)) : \
|
17
|
-
git__prefixcmp((STR), (PREFIX)))
|
18
|
-
|
19
15
|
typedef struct git_iterator git_iterator;
|
20
16
|
|
21
17
|
typedef enum {
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
GIT_ITERATOR_SPOOLANDSORT = 4
|
18
|
+
GIT_ITERATOR_TYPE_EMPTY = 0,
|
19
|
+
GIT_ITERATOR_TYPE_TREE = 1,
|
20
|
+
GIT_ITERATOR_TYPE_INDEX = 2,
|
21
|
+
GIT_ITERATOR_TYPE_WORKDIR = 3,
|
27
22
|
} git_iterator_type_t;
|
28
23
|
|
24
|
+
typedef enum {
|
25
|
+
/** ignore case for entry sort order */
|
26
|
+
GIT_ITERATOR_IGNORE_CASE = (1 << 0),
|
27
|
+
/** force case sensitivity for entry sort order */
|
28
|
+
GIT_ITERATOR_DONT_IGNORE_CASE = (1 << 1),
|
29
|
+
/** return tree items in addition to blob items */
|
30
|
+
GIT_ITERATOR_INCLUDE_TREES = (1 << 2),
|
31
|
+
/** don't flatten trees, requiring advance_into (implies INCLUDE_TREES) */
|
32
|
+
GIT_ITERATOR_DONT_AUTOEXPAND = (1 << 3),
|
33
|
+
} git_iterator_flag_t;
|
34
|
+
|
35
|
+
typedef struct {
|
36
|
+
int (*current)(const git_index_entry **, git_iterator *);
|
37
|
+
int (*advance)(const git_index_entry **, git_iterator *);
|
38
|
+
int (*advance_into)(const git_index_entry **, git_iterator *);
|
39
|
+
int (*seek)(git_iterator *, const char *prefix);
|
40
|
+
int (*reset)(git_iterator *, const char *start, const char *end);
|
41
|
+
int (*at_end)(git_iterator *);
|
42
|
+
void (*free)(git_iterator *);
|
43
|
+
} git_iterator_callbacks;
|
44
|
+
|
29
45
|
struct git_iterator {
|
30
46
|
git_iterator_type_t type;
|
47
|
+
git_iterator_callbacks *cb;
|
48
|
+
git_repository *repo;
|
31
49
|
char *start;
|
32
50
|
char *end;
|
33
|
-
int (*
|
34
|
-
int
|
35
|
-
int (*advance)(git_iterator *, const git_index_entry **);
|
36
|
-
int (*seek)(git_iterator *, const char *prefix);
|
37
|
-
int (*reset)(git_iterator *);
|
38
|
-
void (*free)(git_iterator *);
|
39
|
-
unsigned int ignore_case:1;
|
51
|
+
int (*prefixcomp)(const char *str, const char *prefix);
|
52
|
+
unsigned int flags;
|
40
53
|
};
|
41
54
|
|
42
|
-
extern int git_iterator_for_nothing(
|
55
|
+
extern int git_iterator_for_nothing(
|
56
|
+
git_iterator **out,
|
57
|
+
git_iterator_flag_t flags,
|
58
|
+
const char *start,
|
59
|
+
const char *end);
|
43
60
|
|
44
|
-
|
45
|
-
|
46
|
-
|
61
|
+
/* tree iterators will match the ignore_case value from the index of the
|
62
|
+
* repository, unless you override with a non-zero flag value
|
63
|
+
*/
|
64
|
+
extern int git_iterator_for_tree(
|
65
|
+
git_iterator **out,
|
66
|
+
git_tree *tree,
|
67
|
+
git_iterator_flag_t flags,
|
68
|
+
const char *start,
|
69
|
+
const char *end);
|
70
|
+
|
71
|
+
/* index iterators will take the ignore_case value from the index; the
|
72
|
+
* ignore_case flags are not used
|
73
|
+
*/
|
74
|
+
extern int git_iterator_for_index(
|
75
|
+
git_iterator **out,
|
76
|
+
git_index *index,
|
77
|
+
git_iterator_flag_t flags,
|
78
|
+
const char *start,
|
79
|
+
const char *end);
|
80
|
+
|
81
|
+
/* workdir iterators will match the ignore_case value from the index of the
|
82
|
+
* repository, unless you override with a non-zero flag value
|
83
|
+
*/
|
84
|
+
extern int git_iterator_for_workdir(
|
85
|
+
git_iterator **out,
|
86
|
+
git_repository *repo,
|
87
|
+
git_iterator_flag_t flags,
|
88
|
+
const char *start,
|
89
|
+
const char *end);
|
90
|
+
|
91
|
+
extern void git_iterator_free(git_iterator *iter);
|
47
92
|
|
48
|
-
|
49
|
-
|
93
|
+
/* Return a git_index_entry structure for the current value the iterator
|
94
|
+
* is looking at or NULL if the iterator is at the end.
|
95
|
+
*
|
96
|
+
* The entry may noy be fully populated. Tree iterators will only have a
|
97
|
+
* value mode, OID, and path. Workdir iterators will not have an OID (but
|
98
|
+
* you can use `git_iterator_current_oid()` to calculate it on demand).
|
99
|
+
*
|
100
|
+
* You do not need to free the entry. It is still "owned" by the iterator.
|
101
|
+
* Once you call `git_iterator_advance()` then the old entry is no longer
|
102
|
+
* guaranteed to be valid - it may be freed or just overwritten in place.
|
103
|
+
*/
|
104
|
+
GIT_INLINE(int) git_iterator_current(
|
105
|
+
const git_index_entry **entry, git_iterator *iter)
|
50
106
|
{
|
51
|
-
return
|
107
|
+
return iter->cb->current(entry, iter);
|
52
108
|
}
|
53
109
|
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
110
|
+
/**
|
111
|
+
* Advance to the next item for the iterator.
|
112
|
+
*
|
113
|
+
* If GIT_ITERATOR_INCLUDE_TREES is set, this may be a tree item. If
|
114
|
+
* GIT_ITERATOR_DONT_AUTOEXPAND is set, calling this again when on a tree
|
115
|
+
* item will skip over all the items under that tree.
|
116
|
+
*/
|
117
|
+
GIT_INLINE(int) git_iterator_advance(
|
118
|
+
const git_index_entry **entry, git_iterator *iter)
|
60
119
|
{
|
61
|
-
return
|
120
|
+
return iter->cb->advance(entry, iter);
|
62
121
|
}
|
63
122
|
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
123
|
+
/**
|
124
|
+
* Iterate into a tree item (when GIT_ITERATOR_DONT_AUTOEXPAND is set).
|
125
|
+
*
|
126
|
+
* git_iterator_advance() steps through all items being iterated over
|
127
|
+
* (either with or without trees, depending on GIT_ITERATOR_INCLUDE_TREES),
|
128
|
+
* but if GIT_ITERATOR_DONT_AUTOEXPAND is set, it will skip to the next
|
129
|
+
* sibling of a tree instead of going to the first child of the tree. In
|
130
|
+
* that case, use this function to advance to the first child of the tree.
|
131
|
+
*
|
132
|
+
* If the current item is not a tree, this is a no-op.
|
133
|
+
*
|
134
|
+
* For working directory iterators only, a tree (i.e. directory) can be
|
135
|
+
* empty. In that case, this function returns GIT_ENOTFOUND and does not
|
136
|
+
* advance. That can't happen for tree and index iterators.
|
137
|
+
*/
|
138
|
+
GIT_INLINE(int) git_iterator_advance_into(
|
139
|
+
const git_index_entry **entry, git_iterator *iter)
|
70
140
|
{
|
71
|
-
return
|
141
|
+
return iter->cb->advance_into(entry, iter);
|
72
142
|
}
|
73
143
|
|
74
|
-
|
75
|
-
git_iterator
|
76
|
-
git_vector_cmp comparer, bool ignore_case,
|
77
|
-
const char *start, const char *end);
|
78
|
-
|
79
|
-
GIT_INLINE(int) git_iterator_spoolandsort(
|
80
|
-
git_iterator **iter, git_iterator *towrap,
|
81
|
-
git_vector_cmp comparer, bool ignore_case)
|
144
|
+
GIT_INLINE(int) git_iterator_seek(
|
145
|
+
git_iterator *iter, const char *prefix)
|
82
146
|
{
|
83
|
-
return
|
147
|
+
return iter->cb->seek(iter, prefix);
|
84
148
|
}
|
85
149
|
|
86
|
-
|
87
|
-
*
|
88
|
-
* iterator, we will not populate the oid.
|
89
|
-
*
|
90
|
-
* You do not need to free the entry. It is still "owned" by the iterator.
|
91
|
-
* Once you call `git_iterator_advance`, then content of the old entry is
|
92
|
-
* no longer guaranteed to be valid.
|
93
|
-
*/
|
94
|
-
GIT_INLINE(int) git_iterator_current(
|
95
|
-
git_iterator *iter, const git_index_entry **entry)
|
150
|
+
GIT_INLINE(int) git_iterator_reset(
|
151
|
+
git_iterator *iter, const char *start, const char *end)
|
96
152
|
{
|
97
|
-
return iter->
|
153
|
+
return iter->cb->reset(iter, start, end);
|
98
154
|
}
|
99
155
|
|
100
156
|
GIT_INLINE(int) git_iterator_at_end(git_iterator *iter)
|
101
157
|
{
|
102
|
-
return iter->at_end(iter);
|
158
|
+
return iter->cb->at_end(iter);
|
103
159
|
}
|
104
160
|
|
105
|
-
GIT_INLINE(
|
106
|
-
git_iterator *iter, const git_index_entry **entry)
|
161
|
+
GIT_INLINE(git_iterator_type_t) git_iterator_type(git_iterator *iter)
|
107
162
|
{
|
108
|
-
return iter->
|
163
|
+
return iter->type;
|
109
164
|
}
|
110
165
|
|
111
|
-
GIT_INLINE(
|
112
|
-
git_iterator *iter, const char *prefix)
|
166
|
+
GIT_INLINE(git_repository *) git_iterator_owner(git_iterator *iter)
|
113
167
|
{
|
114
|
-
return iter->
|
168
|
+
return iter->repo;
|
115
169
|
}
|
116
170
|
|
117
|
-
GIT_INLINE(
|
171
|
+
GIT_INLINE(git_iterator_flag_t) git_iterator_flags(git_iterator *iter)
|
118
172
|
{
|
119
|
-
return iter->
|
173
|
+
return iter->flags;
|
120
174
|
}
|
121
175
|
|
122
|
-
GIT_INLINE(
|
176
|
+
GIT_INLINE(bool) git_iterator_ignore_case(git_iterator *iter)
|
123
177
|
{
|
124
|
-
|
125
|
-
return;
|
126
|
-
|
127
|
-
iter->free(iter);
|
128
|
-
|
129
|
-
git__free(iter->start);
|
130
|
-
git__free(iter->end);
|
131
|
-
|
132
|
-
memset(iter, 0, sizeof(*iter));
|
133
|
-
|
134
|
-
git__free(iter);
|
178
|
+
return ((iter->flags & GIT_ITERATOR_IGNORE_CASE) != 0);
|
135
179
|
}
|
136
180
|
|
137
|
-
|
138
|
-
{
|
139
|
-
return iter->type;
|
140
|
-
}
|
181
|
+
extern int git_iterator_set_ignore_case(git_iterator *iter, bool ignore_case);
|
141
182
|
|
142
183
|
extern int git_iterator_current_tree_entry(
|
143
|
-
|
184
|
+
const git_tree_entry **entry_out, git_iterator *iter);
|
144
185
|
|
145
186
|
extern int git_iterator_current_parent_tree(
|
146
|
-
git_iterator *iter, const char *parent_path
|
187
|
+
const git_tree **tree_out, git_iterator *iter, const char *parent_path);
|
147
188
|
|
148
|
-
extern
|
149
|
-
|
150
|
-
/**
|
151
|
-
* Iterate into a workdir directory.
|
152
|
-
*
|
153
|
-
* Workdir iterators do not automatically descend into directories (so that
|
154
|
-
* when comparing two iterator entries you can detect a newly created
|
155
|
-
* directory in the workdir). As a result, you may get S_ISDIR items from
|
156
|
-
* a workdir iterator. If you wish to iterate over the contents of the
|
157
|
-
* directories you encounter, then call this function when you encounter
|
158
|
-
* a directory.
|
159
|
-
*
|
160
|
-
* If there are no files in the directory, this will end up acting like a
|
161
|
-
* regular advance and will skip past the directory, so you should be
|
162
|
-
* prepared for that case.
|
163
|
-
*
|
164
|
-
* On non-workdir iterators or if not pointing at a directory, this is a
|
165
|
-
* no-op and will not advance the iterator.
|
166
|
-
*/
|
167
|
-
extern int git_iterator_advance_into_directory(
|
168
|
-
git_iterator *iter, const git_index_entry **entry);
|
189
|
+
extern bool git_iterator_current_is_ignored(git_iterator *iter);
|
169
190
|
|
170
191
|
extern int git_iterator_cmp(
|
171
192
|
git_iterator *iter, const char *path_prefix);
|
172
193
|
|
173
194
|
/**
|
174
|
-
* Get
|
175
|
-
*
|
195
|
+
* Get full path of the current item from a workdir iterator. This will
|
196
|
+
* return NULL for a non-workdir iterator. The git_buf is still owned by
|
197
|
+
* the iterator; this is exposed just for efficiency.
|
176
198
|
*/
|
177
199
|
extern int git_iterator_current_workdir_path(
|
178
|
-
git_iterator *iter
|
200
|
+
git_buf **path, git_iterator *iter);
|
201
|
+
|
202
|
+
/* Return index pointer if index iterator, else NULL */
|
203
|
+
extern git_index *git_iterator_get_index(git_iterator *iter);
|
179
204
|
|
180
205
|
#endif
|
data/vendor/libgit2/src/map.h
CHANGED
@@ -0,0 +1,296 @@
|
|
1
|
+
/*
|
2
|
+
* Copyright (C) the libgit2 contributors. All rights reserved.
|
3
|
+
*
|
4
|
+
* This file is part of libgit2, distributed under the GNU GPL v2 with
|
5
|
+
* a Linking Exception. For full terms see the included COPYING file.
|
6
|
+
*/
|
7
|
+
|
8
|
+
#include "repository.h"
|
9
|
+
#include "revwalk.h"
|
10
|
+
#include "buffer.h"
|
11
|
+
#include "merge.h"
|
12
|
+
#include "refs.h"
|
13
|
+
#include "git2/repository.h"
|
14
|
+
#include "git2/merge.h"
|
15
|
+
#include "git2/reset.h"
|
16
|
+
#include "commit_list.h"
|
17
|
+
|
18
|
+
int git_repository_merge_cleanup(git_repository *repo)
|
19
|
+
{
|
20
|
+
int error = 0;
|
21
|
+
git_buf merge_head_path = GIT_BUF_INIT,
|
22
|
+
merge_mode_path = GIT_BUF_INIT,
|
23
|
+
merge_msg_path = GIT_BUF_INIT;
|
24
|
+
|
25
|
+
assert(repo);
|
26
|
+
|
27
|
+
if (git_buf_joinpath(&merge_head_path, repo->path_repository, GIT_MERGE_HEAD_FILE) < 0 ||
|
28
|
+
git_buf_joinpath(&merge_mode_path, repo->path_repository, GIT_MERGE_MODE_FILE) < 0 ||
|
29
|
+
git_buf_joinpath(&merge_msg_path, repo->path_repository, GIT_MERGE_MSG_FILE) < 0)
|
30
|
+
return -1;
|
31
|
+
|
32
|
+
if (git_path_isfile(merge_head_path.ptr)) {
|
33
|
+
if ((error = p_unlink(merge_head_path.ptr)) < 0)
|
34
|
+
goto cleanup;
|
35
|
+
}
|
36
|
+
|
37
|
+
if (git_path_isfile(merge_mode_path.ptr))
|
38
|
+
(void)p_unlink(merge_mode_path.ptr);
|
39
|
+
|
40
|
+
if (git_path_isfile(merge_msg_path.ptr))
|
41
|
+
(void)p_unlink(merge_msg_path.ptr);
|
42
|
+
|
43
|
+
cleanup:
|
44
|
+
git_buf_free(&merge_msg_path);
|
45
|
+
git_buf_free(&merge_mode_path);
|
46
|
+
git_buf_free(&merge_head_path);
|
47
|
+
|
48
|
+
return error;
|
49
|
+
}
|
50
|
+
|
51
|
+
int git_merge_base_many(git_oid *out, git_repository *repo, const git_oid input_array[], size_t length)
|
52
|
+
{
|
53
|
+
git_revwalk *walk;
|
54
|
+
git_vector list;
|
55
|
+
git_commit_list *result = NULL;
|
56
|
+
int error = -1;
|
57
|
+
unsigned int i;
|
58
|
+
git_commit_list_node *commit;
|
59
|
+
|
60
|
+
assert(out && repo && input_array);
|
61
|
+
|
62
|
+
if (length < 2) {
|
63
|
+
giterr_set(GITERR_INVALID, "At least two commits are required to find an ancestor. Provided 'length' was %u.", length);
|
64
|
+
return -1;
|
65
|
+
}
|
66
|
+
|
67
|
+
if (git_vector_init(&list, length - 1, NULL) < 0)
|
68
|
+
return -1;
|
69
|
+
|
70
|
+
if (git_revwalk_new(&walk, repo) < 0)
|
71
|
+
goto cleanup;
|
72
|
+
|
73
|
+
for (i = 1; i < length; i++) {
|
74
|
+
commit = git_revwalk__commit_lookup(walk, &input_array[i]);
|
75
|
+
if (commit == NULL)
|
76
|
+
goto cleanup;
|
77
|
+
|
78
|
+
git_vector_insert(&list, commit);
|
79
|
+
}
|
80
|
+
|
81
|
+
commit = git_revwalk__commit_lookup(walk, &input_array[0]);
|
82
|
+
if (commit == NULL)
|
83
|
+
goto cleanup;
|
84
|
+
|
85
|
+
if (git_merge__bases_many(&result, walk, commit, &list) < 0)
|
86
|
+
goto cleanup;
|
87
|
+
|
88
|
+
if (!result) {
|
89
|
+
error = GIT_ENOTFOUND;
|
90
|
+
goto cleanup;
|
91
|
+
}
|
92
|
+
|
93
|
+
git_oid_cpy(out, &result->item->oid);
|
94
|
+
|
95
|
+
error = 0;
|
96
|
+
|
97
|
+
cleanup:
|
98
|
+
git_commit_list_free(&result);
|
99
|
+
git_revwalk_free(walk);
|
100
|
+
git_vector_free(&list);
|
101
|
+
return error;
|
102
|
+
}
|
103
|
+
|
104
|
+
int git_merge_base(git_oid *out, git_repository *repo, const git_oid *one, const git_oid *two)
|
105
|
+
{
|
106
|
+
git_revwalk *walk;
|
107
|
+
git_vector list;
|
108
|
+
git_commit_list *result = NULL;
|
109
|
+
git_commit_list_node *commit;
|
110
|
+
void *contents[1];
|
111
|
+
|
112
|
+
if (git_revwalk_new(&walk, repo) < 0)
|
113
|
+
return -1;
|
114
|
+
|
115
|
+
commit = git_revwalk__commit_lookup(walk, two);
|
116
|
+
if (commit == NULL)
|
117
|
+
goto on_error;
|
118
|
+
|
119
|
+
/* This is just one value, so we can do it on the stack */
|
120
|
+
memset(&list, 0x0, sizeof(git_vector));
|
121
|
+
contents[0] = commit;
|
122
|
+
list.length = 1;
|
123
|
+
list.contents = contents;
|
124
|
+
|
125
|
+
commit = git_revwalk__commit_lookup(walk, one);
|
126
|
+
if (commit == NULL)
|
127
|
+
goto on_error;
|
128
|
+
|
129
|
+
if (git_merge__bases_many(&result, walk, commit, &list) < 0)
|
130
|
+
goto on_error;
|
131
|
+
|
132
|
+
if (!result) {
|
133
|
+
git_revwalk_free(walk);
|
134
|
+
giterr_clear();
|
135
|
+
return GIT_ENOTFOUND;
|
136
|
+
}
|
137
|
+
|
138
|
+
git_oid_cpy(out, &result->item->oid);
|
139
|
+
git_commit_list_free(&result);
|
140
|
+
git_revwalk_free(walk);
|
141
|
+
|
142
|
+
return 0;
|
143
|
+
|
144
|
+
on_error:
|
145
|
+
git_revwalk_free(walk);
|
146
|
+
return -1;
|
147
|
+
}
|
148
|
+
|
149
|
+
static int interesting(git_pqueue *list)
|
150
|
+
{
|
151
|
+
unsigned int i;
|
152
|
+
/* element 0 isn't used - we need to start at 1 */
|
153
|
+
for (i = 1; i < list->size; i++) {
|
154
|
+
git_commit_list_node *commit = list->d[i];
|
155
|
+
if ((commit->flags & STALE) == 0)
|
156
|
+
return 1;
|
157
|
+
}
|
158
|
+
|
159
|
+
return 0;
|
160
|
+
}
|
161
|
+
|
162
|
+
int git_merge__bases_many(git_commit_list **out, git_revwalk *walk, git_commit_list_node *one, git_vector *twos)
|
163
|
+
{
|
164
|
+
int error;
|
165
|
+
unsigned int i;
|
166
|
+
git_commit_list_node *two;
|
167
|
+
git_commit_list *result = NULL, *tmp = NULL;
|
168
|
+
git_pqueue list;
|
169
|
+
|
170
|
+
/* if the commit is repeated, we have a our merge base already */
|
171
|
+
git_vector_foreach(twos, i, two) {
|
172
|
+
if (one == two)
|
173
|
+
return git_commit_list_insert(one, out) ? 0 : -1;
|
174
|
+
}
|
175
|
+
|
176
|
+
if (git_pqueue_init(&list, twos->length * 2, git_commit_list_time_cmp) < 0)
|
177
|
+
return -1;
|
178
|
+
|
179
|
+
if (git_commit_list_parse(walk, one) < 0)
|
180
|
+
return -1;
|
181
|
+
|
182
|
+
one->flags |= PARENT1;
|
183
|
+
if (git_pqueue_insert(&list, one) < 0)
|
184
|
+
return -1;
|
185
|
+
|
186
|
+
git_vector_foreach(twos, i, two) {
|
187
|
+
git_commit_list_parse(walk, two);
|
188
|
+
two->flags |= PARENT2;
|
189
|
+
if (git_pqueue_insert(&list, two) < 0)
|
190
|
+
return -1;
|
191
|
+
}
|
192
|
+
|
193
|
+
/* as long as there are non-STALE commits */
|
194
|
+
while (interesting(&list)) {
|
195
|
+
git_commit_list_node *commit;
|
196
|
+
int flags;
|
197
|
+
|
198
|
+
commit = git_pqueue_pop(&list);
|
199
|
+
|
200
|
+
flags = commit->flags & (PARENT1 | PARENT2 | STALE);
|
201
|
+
if (flags == (PARENT1 | PARENT2)) {
|
202
|
+
if (!(commit->flags & RESULT)) {
|
203
|
+
commit->flags |= RESULT;
|
204
|
+
if (git_commit_list_insert(commit, &result) == NULL)
|
205
|
+
return -1;
|
206
|
+
}
|
207
|
+
/* we mark the parents of a merge stale */
|
208
|
+
flags |= STALE;
|
209
|
+
}
|
210
|
+
|
211
|
+
for (i = 0; i < commit->out_degree; i++) {
|
212
|
+
git_commit_list_node *p = commit->parents[i];
|
213
|
+
if ((p->flags & flags) == flags)
|
214
|
+
continue;
|
215
|
+
|
216
|
+
if ((error = git_commit_list_parse(walk, p)) < 0)
|
217
|
+
return error;
|
218
|
+
|
219
|
+
p->flags |= flags;
|
220
|
+
if (git_pqueue_insert(&list, p) < 0)
|
221
|
+
return -1;
|
222
|
+
}
|
223
|
+
}
|
224
|
+
|
225
|
+
git_pqueue_free(&list);
|
226
|
+
|
227
|
+
/* filter out any stale commits in the results */
|
228
|
+
tmp = result;
|
229
|
+
result = NULL;
|
230
|
+
|
231
|
+
while (tmp) {
|
232
|
+
struct git_commit_list *next = tmp->next;
|
233
|
+
if (!(tmp->item->flags & STALE))
|
234
|
+
if (git_commit_list_insert_by_date(tmp->item, &result) == NULL)
|
235
|
+
return -1;
|
236
|
+
|
237
|
+
git__free(tmp);
|
238
|
+
tmp = next;
|
239
|
+
}
|
240
|
+
|
241
|
+
*out = result;
|
242
|
+
return 0;
|
243
|
+
}
|
244
|
+
|
245
|
+
int git_repository_mergehead_foreach(git_repository *repo,
|
246
|
+
git_repository_mergehead_foreach_cb cb,
|
247
|
+
void *payload)
|
248
|
+
{
|
249
|
+
git_buf merge_head_path = GIT_BUF_INIT, merge_head_file = GIT_BUF_INIT;
|
250
|
+
char *buffer, *line;
|
251
|
+
size_t line_num = 1;
|
252
|
+
git_oid oid;
|
253
|
+
int error = 0;
|
254
|
+
|
255
|
+
assert(repo && cb);
|
256
|
+
|
257
|
+
if ((error = git_buf_joinpath(&merge_head_path, repo->path_repository,
|
258
|
+
GIT_MERGE_HEAD_FILE)) < 0)
|
259
|
+
return error;
|
260
|
+
|
261
|
+
if ((error = git_futils_readbuffer(&merge_head_file,
|
262
|
+
git_buf_cstr(&merge_head_path))) < 0)
|
263
|
+
goto cleanup;
|
264
|
+
|
265
|
+
buffer = merge_head_file.ptr;
|
266
|
+
|
267
|
+
while ((line = git__strsep(&buffer, "\n")) != NULL) {
|
268
|
+
if (strlen(line) != GIT_OID_HEXSZ) {
|
269
|
+
giterr_set(GITERR_INVALID, "Unable to parse OID - invalid length");
|
270
|
+
error = -1;
|
271
|
+
goto cleanup;
|
272
|
+
}
|
273
|
+
|
274
|
+
if ((error = git_oid_fromstr(&oid, line)) < 0)
|
275
|
+
goto cleanup;
|
276
|
+
|
277
|
+
if (cb(&oid, payload) < 0) {
|
278
|
+
error = GIT_EUSER;
|
279
|
+
goto cleanup;
|
280
|
+
}
|
281
|
+
|
282
|
+
++line_num;
|
283
|
+
}
|
284
|
+
|
285
|
+
if (*buffer) {
|
286
|
+
giterr_set(GITERR_MERGE, "No EOL at line %d", line_num);
|
287
|
+
error = -1;
|
288
|
+
goto cleanup;
|
289
|
+
}
|
290
|
+
|
291
|
+
cleanup:
|
292
|
+
git_buf_free(&merge_head_path);
|
293
|
+
git_buf_free(&merge_head_file);
|
294
|
+
|
295
|
+
return error;
|
296
|
+
}
|