rugged 0.17.0.b6 → 0.17.0.b7
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +3 -3
- data/Rakefile +3 -1
- data/ext/rugged/rugged.c +30 -0
- data/ext/rugged/rugged.h +9 -0
- data/ext/rugged/rugged_branch.c +306 -0
- data/ext/rugged/rugged_config.c +16 -13
- data/ext/rugged/rugged_index.c +25 -0
- data/ext/rugged/rugged_object.c +6 -2
- data/ext/rugged/rugged_reference.c +11 -18
- data/ext/rugged/rugged_revwalk.c +1 -1
- data/lib/rugged.rb +1 -0
- data/lib/rugged/branch.rb +28 -0
- data/lib/rugged/commit.rb +5 -5
- data/lib/rugged/repository.rb +32 -7
- data/lib/rugged/tag.rb +5 -1
- data/lib/rugged/version.rb +1 -1
- data/test/branch_test.rb +227 -0
- data/test/config_test.rb +1 -1
- data/test/fixtures/testrepo.git/objects/4b/825dc642cb6eb9a060e54bf8d69288fbee4904 +0 -0
- data/test/fixtures/testrepo.git/objects/a3/e05719b428a2d0ed7a55c4ce53dcc5768c6d5e +0 -0
- data/test/index_test.rb +31 -0
- data/test/index_test.rb~ +218 -0
- data/test/lib_test.rb +22 -0
- data/test/reference_test.rb +5 -3
- data/vendor/libgit2/Makefile.embed +1 -1
- data/vendor/libgit2/include/git2.h +1 -0
- data/vendor/libgit2/include/git2/branch.h +17 -13
- data/vendor/libgit2/include/git2/checkout.h +83 -22
- data/vendor/libgit2/include/git2/clone.h +6 -3
- data/vendor/libgit2/include/git2/common.h +1 -8
- data/vendor/libgit2/include/git2/config.h +185 -26
- data/vendor/libgit2/include/git2/diff.h +229 -17
- data/vendor/libgit2/include/git2/errors.h +39 -1
- data/vendor/libgit2/include/git2/ignore.h +6 -3
- data/vendor/libgit2/include/git2/indexer.h +1 -0
- data/vendor/libgit2/include/git2/merge.h +1 -1
- data/vendor/libgit2/include/git2/object.h +7 -4
- data/vendor/libgit2/include/git2/odb.h +4 -2
- data/vendor/libgit2/include/git2/odb_backend.h +6 -0
- data/vendor/libgit2/include/git2/oid.h +2 -0
- data/vendor/libgit2/include/git2/pack.h +89 -0
- data/vendor/libgit2/include/git2/refs.h +88 -0
- data/vendor/libgit2/include/git2/refspec.h +0 -8
- data/vendor/libgit2/include/git2/remote.h +34 -1
- data/vendor/libgit2/include/git2/repository.h +238 -6
- data/vendor/libgit2/include/git2/reset.h +4 -1
- data/vendor/libgit2/include/git2/revwalk.h +1 -1
- data/vendor/libgit2/include/git2/status.h +19 -14
- data/vendor/libgit2/include/git2/strarray.h +54 -0
- data/vendor/libgit2/include/git2/submodule.h +451 -45
- data/vendor/libgit2/include/git2/tag.h +16 -0
- data/vendor/libgit2/include/git2/tree.h +2 -2
- data/vendor/libgit2/include/git2/types.h +4 -0
- data/vendor/libgit2/src/amiga/map.c +4 -7
- data/vendor/libgit2/src/attr.c +21 -13
- data/vendor/libgit2/src/attr.h +3 -1
- data/vendor/libgit2/src/attr_file.c +14 -14
- data/vendor/libgit2/src/attr_file.h +6 -5
- data/vendor/libgit2/src/blob.c +22 -12
- data/vendor/libgit2/src/branch.c +62 -66
- data/vendor/libgit2/src/buffer.c +63 -14
- data/vendor/libgit2/src/buffer.h +4 -0
- data/vendor/libgit2/src/cache.c +5 -4
- data/vendor/libgit2/src/checkout.c +381 -159
- data/vendor/libgit2/src/clone.c +221 -94
- data/vendor/libgit2/src/common.h +13 -3
- data/vendor/libgit2/src/compress.c +53 -0
- data/vendor/libgit2/src/compress.h +16 -0
- data/vendor/libgit2/src/config.c +380 -175
- data/vendor/libgit2/src/config.h +2 -5
- data/vendor/libgit2/src/config_file.c +63 -46
- data/vendor/libgit2/src/config_file.h +16 -4
- data/vendor/libgit2/src/crlf.c +4 -3
- data/vendor/libgit2/src/delta.c +491 -0
- data/vendor/libgit2/src/delta.h +112 -0
- data/vendor/libgit2/src/diff.c +310 -67
- data/vendor/libgit2/src/diff.h +10 -1
- data/vendor/libgit2/src/diff_output.c +1030 -337
- data/vendor/libgit2/src/diff_output.h +86 -0
- data/vendor/libgit2/src/errors.c +10 -1
- data/vendor/libgit2/src/fetch.c +108 -24
- data/vendor/libgit2/src/filebuf.c +8 -2
- data/vendor/libgit2/src/fileops.c +342 -177
- data/vendor/libgit2/src/fileops.h +84 -7
- data/vendor/libgit2/src/filter.c +0 -35
- data/vendor/libgit2/src/filter.h +0 -12
- data/vendor/libgit2/src/{compat/fnmatch.c → fnmatch.c} +16 -4
- data/vendor/libgit2/src/{compat/fnmatch.h → fnmatch.h} +4 -3
- data/vendor/libgit2/src/global.c +4 -0
- data/vendor/libgit2/src/ignore.c +122 -23
- data/vendor/libgit2/src/ignore.h +1 -0
- data/vendor/libgit2/src/index.c +56 -10
- data/vendor/libgit2/src/index.h +2 -0
- data/vendor/libgit2/src/indexer.c +8 -9
- data/vendor/libgit2/src/iterator.c +244 -31
- data/vendor/libgit2/src/iterator.h +30 -1
- data/vendor/libgit2/src/message.c +1 -1
- data/vendor/libgit2/src/netops.c +44 -4
- data/vendor/libgit2/src/object.c +80 -69
- data/vendor/libgit2/src/object.h +39 -0
- data/vendor/libgit2/src/odb.c +79 -15
- data/vendor/libgit2/src/odb.h +20 -5
- data/vendor/libgit2/src/odb_pack.c +65 -33
- data/vendor/libgit2/src/oid.c +0 -3
- data/vendor/libgit2/src/pack-objects.c +1315 -0
- data/vendor/libgit2/src/pack-objects.h +87 -0
- data/vendor/libgit2/src/pack.c +36 -12
- data/vendor/libgit2/src/pack.h +1 -0
- data/vendor/libgit2/src/path.c +42 -9
- data/vendor/libgit2/src/path.h +14 -0
- data/vendor/libgit2/src/pkt.c +52 -2
- data/vendor/libgit2/src/pkt.h +10 -0
- data/vendor/libgit2/src/pool.h +11 -0
- data/vendor/libgit2/src/posix.h +8 -0
- data/vendor/libgit2/src/protocol.c +24 -2
- data/vendor/libgit2/src/protocol.h +4 -0
- data/vendor/libgit2/src/reflog.c +1 -1
- data/vendor/libgit2/src/refs.c +292 -124
- data/vendor/libgit2/src/refs.h +4 -2
- data/vendor/libgit2/src/refspec.c +117 -19
- data/vendor/libgit2/src/refspec.h +19 -0
- data/vendor/libgit2/src/remote.c +152 -48
- data/vendor/libgit2/src/remote.h +4 -1
- data/vendor/libgit2/src/repo_template.h +58 -0
- data/vendor/libgit2/src/repository.c +594 -179
- data/vendor/libgit2/src/repository.h +23 -22
- data/vendor/libgit2/src/reset.c +71 -29
- data/vendor/libgit2/src/revparse.c +26 -17
- data/vendor/libgit2/src/revwalk.c +36 -19
- data/vendor/libgit2/src/sha1.h +7 -0
- data/vendor/libgit2/src/{sha1.c → sha1/sha1.c} +0 -0
- data/vendor/libgit2/src/signature.c +12 -10
- data/vendor/libgit2/src/status.c +52 -6
- data/vendor/libgit2/src/submodule.c +1363 -255
- data/vendor/libgit2/src/submodule.h +102 -0
- data/vendor/libgit2/src/tag.c +42 -26
- data/vendor/libgit2/src/thread-utils.h +7 -7
- data/vendor/libgit2/src/transport.h +15 -1
- data/vendor/libgit2/src/transports/git.c +1 -1
- data/vendor/libgit2/src/transports/http.c +197 -36
- data/vendor/libgit2/src/tree.c +3 -3
- data/vendor/libgit2/src/unix/map.c +2 -0
- data/vendor/libgit2/src/unix/posix.h +1 -8
- data/vendor/libgit2/src/util.c +6 -1
- data/vendor/libgit2/src/util.h +7 -0
- data/vendor/libgit2/src/vector.c +16 -0
- data/vendor/libgit2/src/vector.h +1 -0
- data/vendor/libgit2/src/win32/dir.c +8 -21
- data/vendor/libgit2/src/win32/findfile.c +149 -0
- data/vendor/libgit2/src/win32/findfile.h +23 -0
- data/vendor/libgit2/src/win32/posix.h +3 -7
- data/vendor/libgit2/src/win32/posix_w32.c +44 -102
- data/vendor/libgit2/src/win32/pthread.c +68 -0
- data/vendor/libgit2/src/win32/pthread.h +7 -0
- data/vendor/libgit2/src/win32/utf-conv.c +60 -71
- data/vendor/libgit2/src/win32/utf-conv.h +4 -3
- metadata +70 -71
- data/vendor/libgit2/include/git2/windows.h +0 -59
@@ -18,6 +18,7 @@
|
|
18
18
|
#include "refs.h"
|
19
19
|
#include "buffer.h"
|
20
20
|
#include "odb.h"
|
21
|
+
#include "object.h"
|
21
22
|
#include "attr.h"
|
22
23
|
#include "strmap.h"
|
23
24
|
|
@@ -68,13 +69,14 @@ typedef enum {
|
|
68
69
|
GIT_EOL_DEFAULT = GIT_EOL_NATIVE
|
69
70
|
} git_cvar_value;
|
70
71
|
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
72
|
+
/* internal repository init flags */
|
73
|
+
enum {
|
74
|
+
GIT_REPOSITORY_INIT__HAS_DOTGIT = (1u << 16),
|
75
|
+
GIT_REPOSITORY_INIT__NATURAL_WD = (1u << 17),
|
76
|
+
GIT_REPOSITORY_INIT__IS_REINIT = (1u << 18),
|
76
77
|
};
|
77
78
|
|
79
|
+
/** Internal structure for repository object */
|
78
80
|
struct git_repository {
|
79
81
|
git_odb *_odb;
|
80
82
|
git_config *_config;
|
@@ -94,22 +96,6 @@ struct git_repository {
|
|
94
96
|
git_cvar_value cvar_cache[GIT_CVAR_CACHE_MAX];
|
95
97
|
};
|
96
98
|
|
97
|
-
/* fully free the object; internal method, do not
|
98
|
-
* export */
|
99
|
-
void git_object__free(void *object);
|
100
|
-
|
101
|
-
GIT_INLINE(int) git_object__dup(git_object **dest, git_object *source)
|
102
|
-
{
|
103
|
-
git_cached_obj_incref(source);
|
104
|
-
*dest = source;
|
105
|
-
return 0;
|
106
|
-
}
|
107
|
-
|
108
|
-
int git_object__resolve_to_type(git_object **obj, git_otype type);
|
109
|
-
|
110
|
-
int git_oid__parse(git_oid *oid, const char **buffer_out, const char *buffer_end, const char *header);
|
111
|
-
void git_oid__writebuf(git_buf *buf, const char *header, const git_oid *oid);
|
112
|
-
|
113
99
|
GIT_INLINE(git_attr_cache *) git_repository_attr_cache(git_repository *repo)
|
114
100
|
{
|
115
101
|
return &repo->attrcache;
|
@@ -129,7 +115,7 @@ int git_repository_odb__weakptr(git_odb **out, git_repository *repo);
|
|
129
115
|
int git_repository_index__weakptr(git_index **out, git_repository *repo);
|
130
116
|
|
131
117
|
/*
|
132
|
-
* CVAR cache
|
118
|
+
* CVAR cache
|
133
119
|
*
|
134
120
|
* Efficient access to the most used config variables of a repository.
|
135
121
|
* The cache is cleared everytime the config backend is replaced.
|
@@ -142,4 +128,19 @@ void git_repository__cvar_cache_clear(git_repository *repo);
|
|
142
128
|
*/
|
143
129
|
extern void git_submodule_config_free(git_repository *repo);
|
144
130
|
|
131
|
+
GIT_INLINE(int) git_repository__ensure_not_bare(
|
132
|
+
git_repository *repo,
|
133
|
+
const char *operation_name)
|
134
|
+
{
|
135
|
+
if (!git_repository_is_bare(repo))
|
136
|
+
return 0;
|
137
|
+
|
138
|
+
giterr_set(
|
139
|
+
GITERR_REPOSITORY,
|
140
|
+
"Cannot %s. This operation is not allowed against bare repositories.",
|
141
|
+
operation_name);
|
142
|
+
|
143
|
+
return GIT_EBAREREPO;
|
144
|
+
}
|
145
|
+
|
145
146
|
#endif
|
data/vendor/libgit2/src/reset.c
CHANGED
@@ -9,6 +9,7 @@
|
|
9
9
|
#include "commit.h"
|
10
10
|
#include "tag.h"
|
11
11
|
#include "git2/reset.h"
|
12
|
+
#include "git2/checkout.h"
|
12
13
|
|
13
14
|
#define ERROR_MSG "Cannot perform reset"
|
14
15
|
|
@@ -18,51 +19,78 @@ static int reset_error_invalid(const char *msg)
|
|
18
19
|
return -1;
|
19
20
|
}
|
20
21
|
|
22
|
+
static int update_head(git_repository *repo, git_object *commit)
|
23
|
+
{
|
24
|
+
int error;
|
25
|
+
git_reference *head = NULL, *target = NULL;
|
26
|
+
|
27
|
+
error = git_repository_head(&head, repo);
|
28
|
+
|
29
|
+
if (error < 0 && error != GIT_EORPHANEDHEAD)
|
30
|
+
return error;
|
31
|
+
|
32
|
+
if (error == GIT_EORPHANEDHEAD) {
|
33
|
+
giterr_clear();
|
34
|
+
|
35
|
+
/*
|
36
|
+
* TODO: This is a bit weak as this doesn't support chained
|
37
|
+
* symbolic references. yet.
|
38
|
+
*/
|
39
|
+
if ((error = git_reference_lookup(&head, repo, GIT_HEAD_FILE)) < 0)
|
40
|
+
goto cleanup;
|
41
|
+
|
42
|
+
if ((error = git_reference_create_oid(
|
43
|
+
&target,
|
44
|
+
repo,
|
45
|
+
git_reference_target(head),
|
46
|
+
git_object_id(commit), 0)) < 0)
|
47
|
+
goto cleanup;
|
48
|
+
} else {
|
49
|
+
if ((error = git_reference_set_oid(head, git_object_id(commit))) < 0)
|
50
|
+
goto cleanup;
|
51
|
+
}
|
52
|
+
|
53
|
+
error = 0;
|
54
|
+
|
55
|
+
cleanup:
|
56
|
+
git_reference_free(head);
|
57
|
+
git_reference_free(target);
|
58
|
+
return error;
|
59
|
+
}
|
60
|
+
|
21
61
|
int git_reset(
|
22
62
|
git_repository *repo,
|
23
|
-
|
63
|
+
git_object *target,
|
24
64
|
git_reset_type reset_type)
|
25
65
|
{
|
26
|
-
git_otype target_type = GIT_OBJ_BAD;
|
27
66
|
git_object *commit = NULL;
|
28
67
|
git_index *index = NULL;
|
29
68
|
git_tree *tree = NULL;
|
30
69
|
int error = -1;
|
70
|
+
git_checkout_opts opts;
|
31
71
|
|
32
72
|
assert(repo && target);
|
33
|
-
assert(reset_type == GIT_RESET_SOFT
|
73
|
+
assert(reset_type == GIT_RESET_SOFT
|
74
|
+
|| reset_type == GIT_RESET_MIXED
|
75
|
+
|| reset_type == GIT_RESET_HARD);
|
34
76
|
|
35
77
|
if (git_object_owner(target) != repo)
|
36
78
|
return reset_error_invalid("The given target does not belong to this repository.");
|
37
79
|
|
38
|
-
if (reset_type
|
39
|
-
|
80
|
+
if (reset_type != GIT_RESET_SOFT
|
81
|
+
&& git_repository__ensure_not_bare(
|
82
|
+
repo,
|
83
|
+
reset_type == GIT_RESET_MIXED ? "reset mixed" : "reset hard") < 0)
|
84
|
+
return GIT_EBAREREPO;
|
40
85
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
{
|
45
|
-
case GIT_OBJ_TAG:
|
46
|
-
if (git_tag_peel(&commit, (git_tag *)target) < 0)
|
47
|
-
goto cleanup;
|
48
|
-
|
49
|
-
if (git_object_type(commit) != GIT_OBJ_COMMIT) {
|
50
|
-
reset_error_invalid("The given target does not resolve to a commit.");
|
51
|
-
goto cleanup;
|
52
|
-
}
|
53
|
-
break;
|
54
|
-
|
55
|
-
case GIT_OBJ_COMMIT:
|
56
|
-
commit = (git_object *)target;
|
57
|
-
break;
|
58
|
-
|
59
|
-
default:
|
60
|
-
return reset_error_invalid("Only git_tag and git_commit objects are valid targets.");
|
86
|
+
if (git_object_peel(&commit, target, GIT_OBJ_COMMIT) < 0) {
|
87
|
+
reset_error_invalid("The given target does not resolve to a commit");
|
88
|
+
goto cleanup;
|
61
89
|
}
|
62
90
|
|
63
91
|
//TODO: Check for unmerged entries
|
64
92
|
|
65
|
-
if (
|
93
|
+
if (update_head(repo, commit) < 0)
|
66
94
|
goto cleanup;
|
67
95
|
|
68
96
|
if (reset_type == GIT_RESET_SOFT) {
|
@@ -90,12 +118,26 @@ int git_reset(
|
|
90
118
|
goto cleanup;
|
91
119
|
}
|
92
120
|
|
121
|
+
if (reset_type == GIT_RESET_MIXED) {
|
122
|
+
error = 0;
|
123
|
+
goto cleanup;
|
124
|
+
}
|
125
|
+
|
126
|
+
memset(&opts, 0, sizeof(opts));
|
127
|
+
opts.checkout_strategy =
|
128
|
+
GIT_CHECKOUT_CREATE_MISSING
|
129
|
+
| GIT_CHECKOUT_OVERWRITE_MODIFIED
|
130
|
+
| GIT_CHECKOUT_REMOVE_UNTRACKED;
|
131
|
+
|
132
|
+
if (git_checkout_index(repo, &opts, NULL) < 0) {
|
133
|
+
giterr_set(GITERR_INDEX, "%s - Failed to checkout the index.", ERROR_MSG);
|
134
|
+
goto cleanup;
|
135
|
+
}
|
136
|
+
|
93
137
|
error = 0;
|
94
138
|
|
95
139
|
cleanup:
|
96
|
-
|
97
|
-
git_object_free(commit);
|
98
|
-
|
140
|
+
git_object_free(commit);
|
99
141
|
git_index_free(index);
|
100
142
|
git_tree_free(tree);
|
101
143
|
|
@@ -28,11 +28,11 @@ static int disambiguate_refname(git_reference **out, git_repository *repo, const
|
|
28
28
|
|
29
29
|
static const char* formatters[] = {
|
30
30
|
"%s",
|
31
|
-
"
|
32
|
-
"
|
33
|
-
"
|
34
|
-
"
|
35
|
-
"
|
31
|
+
GIT_REFS_DIR "%s",
|
32
|
+
GIT_REFS_TAGS_DIR "%s",
|
33
|
+
GIT_REFS_HEADS_DIR "%s",
|
34
|
+
GIT_REFS_REMOTES_DIR "%s",
|
35
|
+
GIT_REFS_REMOTES_DIR "%s/" GIT_HEAD_FILE,
|
36
36
|
NULL
|
37
37
|
};
|
38
38
|
|
@@ -50,6 +50,11 @@ static int disambiguate_refname(git_reference **out, git_repository *repo, const
|
|
50
50
|
if ((error = git_buf_printf(&refnamebuf, formatters[i], git_buf_cstr(&name))) < 0)
|
51
51
|
goto cleanup;
|
52
52
|
|
53
|
+
if (!git_reference_is_valid_name(git_buf_cstr(&refnamebuf))) {
|
54
|
+
error = GIT_ENOTFOUND;
|
55
|
+
continue;
|
56
|
+
}
|
57
|
+
|
53
58
|
error = git_reference_lookup_resolved(&ref, repo, git_buf_cstr(&refnamebuf), -1);
|
54
59
|
|
55
60
|
if (!error) {
|
@@ -493,7 +498,7 @@ static int walk_and_search(git_object **out, git_revwalk *walk, regex_t *regex)
|
|
493
498
|
git_object_free(obj);
|
494
499
|
}
|
495
500
|
|
496
|
-
if (error < 0 && error ==
|
501
|
+
if (error < 0 && error == GIT_ITEROVER)
|
497
502
|
error = GIT_ENOTFOUND;
|
498
503
|
|
499
504
|
return error;
|
@@ -515,7 +520,7 @@ static int handle_grep_syntax(git_object **out, git_repository *repo, const git_
|
|
515
520
|
|
516
521
|
if (spec_oid == NULL) {
|
517
522
|
// TODO: @carlosmn: The glob should be refs/* but this makes git_revwalk_next() fails
|
518
|
-
if (git_revwalk_push_glob(walk, "
|
523
|
+
if (git_revwalk_push_glob(walk, GIT_REFS_HEADS_DIR "*") < 0)
|
519
524
|
goto cleanup;
|
520
525
|
} else if (git_revwalk_push(walk, spec_oid) < 0)
|
521
526
|
goto cleanup;
|
@@ -790,20 +795,24 @@ int git_revparse_single(git_object **out, git_repository *repo, const char *spec
|
|
790
795
|
|
791
796
|
case '@':
|
792
797
|
{
|
793
|
-
|
798
|
+
if (spec[pos+1] == '{') {
|
799
|
+
git_object *temp_object = NULL;
|
794
800
|
|
795
|
-
|
796
|
-
|
801
|
+
if ((error = extract_curly_braces_content(&buf, spec, &pos)) < 0)
|
802
|
+
goto cleanup;
|
797
803
|
|
798
|
-
|
799
|
-
|
804
|
+
if ((error = ensure_base_rev_is_not_known_yet(base_rev, spec)) < 0)
|
805
|
+
goto cleanup;
|
800
806
|
|
801
|
-
|
802
|
-
|
807
|
+
if ((error = handle_at_syntax(&temp_object, &reference, spec, identifier_len, repo, git_buf_cstr(&buf))) < 0)
|
808
|
+
goto cleanup;
|
803
809
|
|
804
|
-
|
805
|
-
|
806
|
-
|
810
|
+
if (temp_object != NULL)
|
811
|
+
base_rev = temp_object;
|
812
|
+
break;
|
813
|
+
} else {
|
814
|
+
/* Fall through */
|
815
|
+
}
|
807
816
|
}
|
808
817
|
|
809
818
|
default:
|
@@ -264,12 +264,7 @@ static int commit_parse(git_revwalk *walk, commit_object *commit)
|
|
264
264
|
|
265
265
|
if ((error = git_odb_read(&obj, walk->odb, &commit->oid)) < 0)
|
266
266
|
return error;
|
267
|
-
|
268
|
-
if (obj->raw.type != GIT_OBJ_COMMIT) {
|
269
|
-
git_odb_object_free(obj);
|
270
|
-
giterr_set(GITERR_INVALID, "Failed to parse commit. Object is no commit object");
|
271
|
-
return -1;
|
272
|
-
}
|
267
|
+
assert(obj->raw.type == GIT_OBJ_COMMIT);
|
273
268
|
|
274
269
|
error = commit_quick_parse(walk, commit, &obj->raw);
|
275
270
|
git_odb_object_free(obj);
|
@@ -279,7 +274,8 @@ static int commit_parse(git_revwalk *walk, commit_object *commit)
|
|
279
274
|
static int interesting(git_pqueue *list)
|
280
275
|
{
|
281
276
|
unsigned int i;
|
282
|
-
|
277
|
+
/* element 0 isn't used - we need to start at 1 */
|
278
|
+
for (i = 1; i < list->size; i++) {
|
283
279
|
commit_object *commit = list->d[i];
|
284
280
|
if ((commit->flags & STALE) == 0)
|
285
281
|
return 1;
|
@@ -424,7 +420,7 @@ cleanup:
|
|
424
420
|
return error;
|
425
421
|
}
|
426
422
|
|
427
|
-
int git_merge_base(git_oid *out, git_repository *repo, git_oid *one, git_oid *two)
|
423
|
+
int git_merge_base(git_oid *out, git_repository *repo, const git_oid *one, const git_oid *two)
|
428
424
|
{
|
429
425
|
git_revwalk *walk;
|
430
426
|
git_vector list;
|
@@ -454,6 +450,7 @@ int git_merge_base(git_oid *out, git_repository *repo, git_oid *one, git_oid *tw
|
|
454
450
|
|
455
451
|
if (!result) {
|
456
452
|
git_revwalk_free(walk);
|
453
|
+
giterr_clear();
|
457
454
|
return GIT_ENOTFOUND;
|
458
455
|
}
|
459
456
|
|
@@ -515,8 +512,21 @@ static int process_commit_parents(git_revwalk *walk, commit_object *commit)
|
|
515
512
|
|
516
513
|
static int push_commit(git_revwalk *walk, const git_oid *oid, int uninteresting)
|
517
514
|
{
|
515
|
+
git_object *obj;
|
516
|
+
git_otype type;
|
518
517
|
commit_object *commit;
|
519
518
|
|
519
|
+
if (git_object_lookup(&obj, walk->repo, oid, GIT_OBJ_ANY) < 0)
|
520
|
+
return -1;
|
521
|
+
|
522
|
+
type = git_object_type(obj);
|
523
|
+
git_object_free(obj);
|
524
|
+
|
525
|
+
if (type != GIT_OBJ_COMMIT) {
|
526
|
+
giterr_set(GITERR_INVALID, "Object is no commit object");
|
527
|
+
return -1;
|
528
|
+
}
|
529
|
+
|
520
530
|
commit = commit_lookup(walk, oid);
|
521
531
|
if (commit == NULL)
|
522
532
|
return -1; /* error already reported by failed lookup */
|
@@ -674,7 +684,8 @@ static int revwalk_next_timesort(commit_object **object_out, git_revwalk *walk)
|
|
674
684
|
}
|
675
685
|
}
|
676
686
|
|
677
|
-
|
687
|
+
giterr_clear();
|
688
|
+
return GIT_ITEROVER;
|
678
689
|
}
|
679
690
|
|
680
691
|
static int revwalk_next_unsorted(commit_object **object_out, git_revwalk *walk)
|
@@ -692,7 +703,8 @@ static int revwalk_next_unsorted(commit_object **object_out, git_revwalk *walk)
|
|
692
703
|
}
|
693
704
|
}
|
694
705
|
|
695
|
-
|
706
|
+
giterr_clear();
|
707
|
+
return GIT_ITEROVER;
|
696
708
|
}
|
697
709
|
|
698
710
|
static int revwalk_next_toposort(commit_object **object_out, git_revwalk *walk)
|
@@ -702,8 +714,10 @@ static int revwalk_next_toposort(commit_object **object_out, git_revwalk *walk)
|
|
702
714
|
|
703
715
|
for (;;) {
|
704
716
|
next = commit_list_pop(&walk->iterator_topo);
|
705
|
-
if (next == NULL)
|
706
|
-
|
717
|
+
if (next == NULL) {
|
718
|
+
giterr_clear();
|
719
|
+
return GIT_ITEROVER;
|
720
|
+
}
|
707
721
|
|
708
722
|
if (next->in_degree > 0) {
|
709
723
|
next->topo_delay = 1;
|
@@ -728,7 +742,7 @@ static int revwalk_next_toposort(commit_object **object_out, git_revwalk *walk)
|
|
728
742
|
static int revwalk_next_reverse(commit_object **object_out, git_revwalk *walk)
|
729
743
|
{
|
730
744
|
*object_out = commit_list_pop(&walk->iterator_reverse);
|
731
|
-
return *object_out ? 0 :
|
745
|
+
return *object_out ? 0 : GIT_ITEROVER;
|
732
746
|
}
|
733
747
|
|
734
748
|
|
@@ -743,8 +757,10 @@ static int prepare_walk(git_revwalk *walk)
|
|
743
757
|
* If walk->one is NULL, there were no positive references,
|
744
758
|
* so we know that the walk is already over.
|
745
759
|
*/
|
746
|
-
if (walk->one == NULL)
|
747
|
-
|
760
|
+
if (walk->one == NULL) {
|
761
|
+
giterr_clear();
|
762
|
+
return GIT_ITEROVER;
|
763
|
+
}
|
748
764
|
|
749
765
|
/* first figure out what the merge bases are */
|
750
766
|
if (merge_bases_many(&bases, walk, walk->one, &walk->twos) < 0)
|
@@ -772,7 +788,7 @@ static int prepare_walk(git_revwalk *walk)
|
|
772
788
|
return -1;
|
773
789
|
}
|
774
790
|
|
775
|
-
if (error !=
|
791
|
+
if (error != GIT_ITEROVER)
|
776
792
|
return error;
|
777
793
|
|
778
794
|
walk->get_next = &revwalk_next_toposort;
|
@@ -784,7 +800,7 @@ static int prepare_walk(git_revwalk *walk)
|
|
784
800
|
if (commit_list_insert(next, &walk->iterator_reverse) == NULL)
|
785
801
|
return -1;
|
786
802
|
|
787
|
-
if (error !=
|
803
|
+
if (error != GIT_ITEROVER)
|
788
804
|
return error;
|
789
805
|
|
790
806
|
walk->get_next = &revwalk_next_reverse;
|
@@ -883,9 +899,10 @@ int git_revwalk_next(git_oid *oid, git_revwalk *walk)
|
|
883
899
|
|
884
900
|
error = walk->get_next(&next, walk);
|
885
901
|
|
886
|
-
if (error ==
|
902
|
+
if (error == GIT_ITEROVER) {
|
887
903
|
git_revwalk_reset(walk);
|
888
|
-
|
904
|
+
giterr_clear();
|
905
|
+
return GIT_ITEROVER;
|
889
906
|
}
|
890
907
|
|
891
908
|
if (!error)
|
data/vendor/libgit2/src/sha1.h
CHANGED
@@ -8,12 +8,17 @@
|
|
8
8
|
#ifndef INCLUDE_sha1_h__
|
9
9
|
#define INCLUDE_sha1_h__
|
10
10
|
|
11
|
+
#ifdef OPENSSL_SHA
|
12
|
+
# include <openssl/sha.h>
|
13
|
+
|
14
|
+
#else
|
11
15
|
typedef struct {
|
12
16
|
unsigned long long size;
|
13
17
|
unsigned int H[5];
|
14
18
|
unsigned int W[16];
|
15
19
|
} blk_SHA_CTX;
|
16
20
|
|
21
|
+
|
17
22
|
void git__blk_SHA1_Init(blk_SHA_CTX *ctx);
|
18
23
|
void git__blk_SHA1_Update(blk_SHA_CTX *ctx, const void *dataIn, size_t len);
|
19
24
|
void git__blk_SHA1_Final(unsigned char hashout[20], blk_SHA_CTX *ctx);
|
@@ -23,4 +28,6 @@ void git__blk_SHA1_Final(unsigned char hashout[20], blk_SHA_CTX *ctx);
|
|
23
28
|
#define SHA1_Update git__blk_SHA1_Update
|
24
29
|
#define SHA1_Final git__blk_SHA1_Final
|
25
30
|
|
31
|
+
#endif // OPENSSL_SHA
|
32
|
+
|
26
33
|
#endif
|