rugged 0.27.10.1 → 0.28.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ext/rugged/extconf.rb +23 -2
- data/ext/rugged/rugged.c +48 -2
- data/ext/rugged/rugged.h +5 -0
- data/ext/rugged/rugged_allocator.c +89 -0
- data/ext/rugged/rugged_blob.c +3 -3
- data/ext/rugged/rugged_branch.c +1 -1
- data/ext/rugged/rugged_commit.c +8 -8
- data/ext/rugged/rugged_config.c +1 -1
- data/ext/rugged/rugged_diff.c +24 -4
- data/ext/rugged/rugged_note.c +1 -1
- data/ext/rugged/rugged_repo.c +10 -10
- data/ext/rugged/rugged_settings.c +1 -1
- data/lib/rugged/version.rb +1 -1
- data/vendor/libgit2/CMakeLists.txt +69 -47
- data/vendor/libgit2/cmake/Modules/AddCFlagIfSupported.cmake +15 -1
- data/vendor/libgit2/cmake/Modules/EnableWarnings.cmake +5 -8
- data/vendor/libgit2/cmake/Modules/FindmbedTLS.cmake +93 -0
- data/vendor/libgit2/deps/http-parser/CMakeLists.txt +2 -0
- data/vendor/libgit2/deps/http-parser/{LICENSE-MIT → COPYING} +0 -0
- data/vendor/libgit2/deps/regex/COPYING +502 -0
- data/vendor/libgit2/deps/winhttp/COPYING.GPL +993 -0
- data/vendor/libgit2/deps/winhttp/COPYING.LGPL +502 -0
- data/vendor/libgit2/deps/zlib/CMakeLists.txt +1 -0
- data/vendor/libgit2/deps/zlib/COPYING +27 -0
- data/vendor/libgit2/include/git2.h +3 -0
- data/vendor/libgit2/include/git2/annotated_commit.h +9 -0
- data/vendor/libgit2/include/git2/apply.h +129 -0
- data/vendor/libgit2/include/git2/attr.h +19 -8
- data/vendor/libgit2/include/git2/blame.h +41 -24
- data/vendor/libgit2/include/git2/blob.h +1 -1
- data/vendor/libgit2/include/git2/branch.h +1 -1
- data/vendor/libgit2/include/git2/buffer.h +2 -2
- data/vendor/libgit2/include/git2/checkout.h +20 -19
- data/vendor/libgit2/include/git2/cherrypick.h +6 -4
- data/vendor/libgit2/include/git2/clone.h +11 -9
- data/vendor/libgit2/include/git2/commit.h +30 -2
- data/vendor/libgit2/include/git2/common.h +54 -4
- data/vendor/libgit2/include/git2/config.h +18 -7
- data/vendor/libgit2/include/git2/deprecated.h +253 -0
- data/vendor/libgit2/include/git2/describe.h +30 -7
- data/vendor/libgit2/include/git2/diff.h +193 -143
- data/vendor/libgit2/include/git2/errors.h +54 -46
- data/vendor/libgit2/include/git2/ignore.h +2 -2
- data/vendor/libgit2/include/git2/index.h +72 -51
- data/vendor/libgit2/include/git2/indexer.h +30 -4
- data/vendor/libgit2/include/git2/mailmap.h +115 -0
- data/vendor/libgit2/include/git2/merge.h +29 -8
- data/vendor/libgit2/include/git2/net.h +1 -1
- data/vendor/libgit2/include/git2/notes.h +1 -1
- data/vendor/libgit2/include/git2/object.h +16 -16
- data/vendor/libgit2/include/git2/odb.h +10 -10
- data/vendor/libgit2/include/git2/odb_backend.h +7 -7
- data/vendor/libgit2/include/git2/oid.h +1 -1
- data/vendor/libgit2/include/git2/pack.h +2 -2
- data/vendor/libgit2/include/git2/proxy.h +9 -5
- data/vendor/libgit2/include/git2/rebase.h +7 -4
- data/vendor/libgit2/include/git2/refs.h +14 -15
- data/vendor/libgit2/include/git2/refspec.h +17 -0
- data/vendor/libgit2/include/git2/remote.h +92 -16
- data/vendor/libgit2/include/git2/repository.h +52 -37
- data/vendor/libgit2/include/git2/revert.h +5 -3
- data/vendor/libgit2/include/git2/revwalk.h +7 -7
- data/vendor/libgit2/include/git2/signature.h +2 -2
- data/vendor/libgit2/include/git2/stash.h +13 -10
- data/vendor/libgit2/include/git2/status.h +8 -4
- data/vendor/libgit2/include/git2/submodule.h +11 -10
- data/vendor/libgit2/include/git2/sys/alloc.h +101 -0
- data/vendor/libgit2/include/git2/sys/commit.h +1 -1
- data/vendor/libgit2/include/git2/sys/config.h +13 -13
- data/vendor/libgit2/include/git2/sys/filter.h +6 -6
- data/vendor/libgit2/include/git2/sys/index.h +3 -0
- data/vendor/libgit2/include/git2/sys/mempack.h +35 -35
- data/vendor/libgit2/include/git2/sys/merge.h +9 -4
- data/vendor/libgit2/include/git2/sys/odb_backend.h +19 -19
- data/vendor/libgit2/include/git2/sys/path.h +64 -0
- data/vendor/libgit2/include/git2/sys/refdb_backend.h +19 -19
- data/vendor/libgit2/include/git2/sys/stream.h +92 -12
- data/vendor/libgit2/include/git2/sys/transport.h +127 -81
- data/vendor/libgit2/include/git2/tag.h +2 -2
- data/vendor/libgit2/include/git2/trace.h +1 -1
- data/vendor/libgit2/include/git2/transaction.h +1 -0
- data/vendor/libgit2/include/git2/transport.h +47 -18
- data/vendor/libgit2/include/git2/tree.h +3 -3
- data/vendor/libgit2/include/git2/types.h +35 -28
- data/vendor/libgit2/include/git2/version.h +4 -4
- data/vendor/libgit2/include/git2/worktree.h +47 -12
- data/vendor/libgit2/src/CMakeLists.txt +87 -26
- data/vendor/libgit2/src/alloc.c +55 -0
- data/vendor/libgit2/src/alloc.h +40 -0
- data/vendor/libgit2/src/annotated_commit.c +15 -8
- data/vendor/libgit2/src/apply.c +490 -14
- data/vendor/libgit2/src/apply.h +3 -1
- data/vendor/libgit2/src/array.h +2 -2
- data/vendor/libgit2/src/attr.c +11 -11
- data/vendor/libgit2/src/attr_file.c +20 -15
- data/vendor/libgit2/src/attrcache.c +11 -11
- data/vendor/libgit2/src/blame.c +30 -15
- data/vendor/libgit2/src/blame.h +1 -0
- data/vendor/libgit2/src/blame_git.c +16 -13
- data/vendor/libgit2/src/blob.c +50 -28
- data/vendor/libgit2/src/blob.h +18 -1
- data/vendor/libgit2/src/branch.c +38 -38
- data/vendor/libgit2/src/buf_text.c +7 -6
- data/vendor/libgit2/src/buffer.c +55 -50
- data/vendor/libgit2/src/buffer.h +1 -1
- data/vendor/libgit2/src/cache.c +16 -16
- data/vendor/libgit2/src/cache.h +2 -2
- data/vendor/libgit2/src/cc-compat.h +15 -3
- data/vendor/libgit2/src/checkout.c +83 -74
- data/vendor/libgit2/src/cherrypick.c +6 -6
- data/vendor/libgit2/src/clone.c +20 -20
- data/vendor/libgit2/src/commit.c +53 -33
- data/vendor/libgit2/src/commit.h +1 -0
- data/vendor/libgit2/src/commit_list.c +6 -10
- data/vendor/libgit2/src/common.h +32 -30
- data/vendor/libgit2/src/config.c +167 -147
- data/vendor/libgit2/src/config.h +1 -14
- data/vendor/libgit2/src/config_backend.h +84 -0
- data/vendor/libgit2/src/config_cache.c +7 -1
- 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 +167 -439
- data/vendor/libgit2/src/config_mem.c +224 -0
- data/vendor/libgit2/src/config_parse.c +69 -38
- data/vendor/libgit2/src/config_parse.h +4 -4
- data/vendor/libgit2/src/crlf.c +215 -186
- data/vendor/libgit2/src/delta.c +25 -18
- data/vendor/libgit2/src/describe.c +23 -23
- data/vendor/libgit2/src/diff.c +12 -12
- data/vendor/libgit2/src/diff_driver.c +14 -15
- data/vendor/libgit2/src/diff_file.c +10 -10
- data/vendor/libgit2/src/diff_generate.c +29 -23
- data/vendor/libgit2/src/diff_generate.h +1 -1
- data/vendor/libgit2/src/diff_parse.c +3 -3
- data/vendor/libgit2/src/diff_print.c +17 -17
- data/vendor/libgit2/src/diff_stats.c +22 -7
- data/vendor/libgit2/src/diff_tform.c +12 -12
- data/vendor/libgit2/src/diff_xdiff.c +15 -3
- data/vendor/libgit2/src/errors.c +42 -20
- data/vendor/libgit2/src/features.h.in +2 -1
- data/vendor/libgit2/src/fetch.c +3 -3
- data/vendor/libgit2/src/fetchhead.c +16 -16
- data/vendor/libgit2/src/filebuf.c +28 -28
- data/vendor/libgit2/src/fileops.c +54 -54
- data/vendor/libgit2/src/fileops.h +1 -1
- data/vendor/libgit2/src/filter.c +30 -30
- data/vendor/libgit2/src/filter.h +0 -10
- data/vendor/libgit2/src/global.c +36 -23
- data/vendor/libgit2/src/hash.h +4 -1
- data/vendor/libgit2/src/hash/hash_collisiondetect.h +6 -2
- data/vendor/libgit2/src/hash/hash_common_crypto.h +5 -1
- data/vendor/libgit2/src/hash/hash_generic.h +5 -1
- 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 +8 -4
- data/vendor/libgit2/src/hash/hash_win32.c +13 -13
- data/vendor/libgit2/src/hashsig.c +4 -4
- data/vendor/libgit2/src/idxmap.c +25 -5
- data/vendor/libgit2/src/idxmap.h +4 -18
- data/vendor/libgit2/src/ignore.c +9 -9
- data/vendor/libgit2/src/index.c +280 -198
- data/vendor/libgit2/src/index.h +16 -0
- data/vendor/libgit2/src/indexer.c +311 -139
- data/vendor/libgit2/src/integer.h +32 -22
- data/vendor/libgit2/src/iterator.c +116 -49
- data/vendor/libgit2/src/iterator.h +15 -0
- data/vendor/libgit2/src/khash.h +3 -1
- data/vendor/libgit2/src/mailmap.c +485 -0
- data/vendor/libgit2/src/mailmap.h +35 -0
- data/vendor/libgit2/src/merge.c +89 -59
- data/vendor/libgit2/src/merge_driver.c +7 -7
- data/vendor/libgit2/src/merge_file.c +1 -1
- data/vendor/libgit2/src/mwindow.c +8 -8
- data/vendor/libgit2/src/netops.c +22 -13
- data/vendor/libgit2/src/netops.h +2 -0
- data/vendor/libgit2/src/notes.c +15 -10
- data/vendor/libgit2/src/object.c +118 -67
- data/vendor/libgit2/src/object.h +20 -9
- data/vendor/libgit2/src/object_api.c +8 -8
- data/vendor/libgit2/src/odb.c +72 -72
- data/vendor/libgit2/src/odb.h +7 -7
- data/vendor/libgit2/src/odb_loose.c +46 -46
- data/vendor/libgit2/src/odb_mempack.c +14 -14
- data/vendor/libgit2/src/odb_pack.c +14 -10
- data/vendor/libgit2/src/offmap.c +30 -0
- data/vendor/libgit2/src/offmap.h +20 -11
- data/vendor/libgit2/src/oid.c +6 -6
- data/vendor/libgit2/src/oidmap.c +20 -0
- data/vendor/libgit2/src/oidmap.h +9 -12
- data/vendor/libgit2/src/pack-objects.c +71 -63
- data/vendor/libgit2/src/pack-objects.h +1 -7
- data/vendor/libgit2/src/pack.c +58 -58
- data/vendor/libgit2/src/pack.h +6 -6
- data/vendor/libgit2/src/parse.h +1 -1
- data/vendor/libgit2/src/patch.c +3 -3
- data/vendor/libgit2/src/patch_generate.c +18 -18
- data/vendor/libgit2/src/patch_parse.c +13 -13
- data/vendor/libgit2/src/path.c +93 -225
- data/vendor/libgit2/src/path.h +2 -84
- data/vendor/libgit2/src/pathspec.c +6 -6
- data/vendor/libgit2/src/posix.c +3 -3
- data/vendor/libgit2/src/proxy.c +1 -1
- data/vendor/libgit2/src/push.c +27 -26
- data/vendor/libgit2/src/push.h +2 -1
- data/vendor/libgit2/src/reader.c +265 -0
- data/vendor/libgit2/src/reader.h +107 -0
- data/vendor/libgit2/src/rebase.c +49 -52
- data/vendor/libgit2/src/refdb.c +3 -3
- data/vendor/libgit2/src/refdb_fs.c +181 -103
- data/vendor/libgit2/src/reflog.c +3 -3
- data/vendor/libgit2/src/refs.c +98 -74
- data/vendor/libgit2/src/refs.h +5 -3
- data/vendor/libgit2/src/refspec.c +47 -21
- data/vendor/libgit2/src/refspec.h +1 -1
- data/vendor/libgit2/src/remote.c +219 -166
- data/vendor/libgit2/src/remote.h +9 -0
- data/vendor/libgit2/src/repository.c +173 -133
- data/vendor/libgit2/src/repository.h +6 -3
- data/vendor/libgit2/src/reset.c +8 -8
- data/vendor/libgit2/src/revert.c +6 -6
- data/vendor/libgit2/src/revparse.c +30 -30
- data/vendor/libgit2/src/revwalk.c +60 -30
- data/vendor/libgit2/src/revwalk.h +2 -1
- data/vendor/libgit2/src/settings.c +42 -10
- data/vendor/libgit2/src/signature.c +11 -11
- data/vendor/libgit2/src/sortedcache.c +13 -13
- data/vendor/libgit2/src/stash.c +91 -45
- data/vendor/libgit2/src/status.c +13 -13
- data/vendor/libgit2/src/stdalloc.c +120 -0
- data/vendor/libgit2/src/{streams/curl.h → stdalloc.h} +6 -6
- data/vendor/libgit2/src/stream.h +17 -2
- 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 +204 -114
- data/vendor/libgit2/src/streams/openssl.h +4 -108
- 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 +54 -29
- data/vendor/libgit2/src/streams/stransport.c +57 -32
- data/vendor/libgit2/src/streams/stransport.h +5 -0
- data/vendor/libgit2/src/streams/tls.c +50 -19
- data/vendor/libgit2/src/streams/tls.h +12 -4
- data/vendor/libgit2/src/strmap.c +22 -2
- data/vendor/libgit2/src/strmap.h +18 -15
- data/vendor/libgit2/src/submodule.c +179 -155
- data/vendor/libgit2/src/sysdir.c +18 -18
- data/vendor/libgit2/src/tag.c +31 -26
- data/vendor/libgit2/src/tag.h +2 -1
- data/vendor/libgit2/src/trace.c +1 -1
- data/vendor/libgit2/src/trace.h +1 -1
- data/vendor/libgit2/src/trailer.c +6 -6
- data/vendor/libgit2/src/transaction.c +23 -23
- data/vendor/libgit2/src/transport.c +5 -5
- data/vendor/libgit2/src/transports/auth.c +7 -4
- data/vendor/libgit2/src/transports/auth.h +1 -1
- data/vendor/libgit2/src/transports/auth_negotiate.c +12 -11
- data/vendor/libgit2/src/transports/cred.c +18 -18
- data/vendor/libgit2/src/transports/git.c +15 -15
- data/vendor/libgit2/src/transports/http.c +606 -216
- data/vendor/libgit2/src/transports/http.h +2 -0
- data/vendor/libgit2/src/transports/local.c +26 -26
- data/vendor/libgit2/src/transports/smart.c +54 -31
- data/vendor/libgit2/src/transports/smart.h +1 -2
- data/vendor/libgit2/src/transports/smart_pkt.c +43 -40
- data/vendor/libgit2/src/transports/smart_protocol.c +61 -57
- data/vendor/libgit2/src/transports/ssh.c +34 -33
- data/vendor/libgit2/src/transports/winhttp.c +99 -119
- data/vendor/libgit2/src/tree-cache.c +5 -5
- data/vendor/libgit2/src/tree.c +96 -121
- data/vendor/libgit2/src/tree.h +1 -12
- data/vendor/libgit2/src/unix/map.c +2 -2
- data/vendor/libgit2/src/util.c +22 -6
- data/vendor/libgit2/src/util.h +12 -135
- data/vendor/libgit2/src/vector.c +4 -4
- data/vendor/libgit2/src/win32/dir.c +3 -3
- data/vendor/libgit2/src/win32/findfile.c +3 -3
- data/vendor/libgit2/src/win32/map.c +6 -6
- data/vendor/libgit2/src/win32/msvc-compat.h +6 -0
- data/vendor/libgit2/src/win32/path_w32.c +101 -7
- data/vendor/libgit2/src/win32/path_w32.h +18 -0
- data/vendor/libgit2/src/win32/posix_w32.c +24 -43
- data/vendor/libgit2/src/win32/w32_buffer.c +2 -2
- data/vendor/libgit2/src/win32/w32_crtdbg_stacktrace.c +96 -2
- data/vendor/libgit2/src/win32/w32_crtdbg_stacktrace.h +28 -75
- data/vendor/libgit2/src/win32/w32_stack.c +2 -2
- data/vendor/libgit2/src/win32/w32_util.c +1 -69
- data/vendor/libgit2/src/win32/w32_util.h +1 -19
- data/vendor/libgit2/src/worktree.c +75 -54
- data/vendor/libgit2/src/worktree.h +2 -0
- data/vendor/libgit2/src/xdiff/xdiffi.c +7 -5
- data/vendor/libgit2/src/xdiff/xhistogram.c +1 -1
- data/vendor/libgit2/src/xdiff/xmerge.c +15 -15
- data/vendor/libgit2/src/zstream.c +4 -4
- metadata +33 -7
- data/vendor/libgit2/src/config_file.h +0 -73
- data/vendor/libgit2/src/streams/curl.c +0 -385
@@ -83,7 +83,7 @@ static int add_ref(transport_local *t, const char *name)
|
|
83
83
|
if (!strcmp(name, GIT_HEAD_FILE) && error == GIT_ENOTFOUND) {
|
84
84
|
/* This is actually okay. Empty repos often have a HEAD that
|
85
85
|
* points to a nonexistent "refs/heads/master". */
|
86
|
-
|
86
|
+
git_error_clear();
|
87
87
|
return 0;
|
88
88
|
}
|
89
89
|
return error;
|
@@ -93,16 +93,16 @@ static int add_ref(transport_local *t, const char *name)
|
|
93
93
|
git_reference_free(resolved);
|
94
94
|
|
95
95
|
head = git__calloc(1, sizeof(git_remote_head));
|
96
|
-
|
96
|
+
GIT_ERROR_CHECK_ALLOC(head);
|
97
97
|
|
98
98
|
head->name = git__strdup(name);
|
99
|
-
|
99
|
+
GIT_ERROR_CHECK_ALLOC(head->name);
|
100
100
|
|
101
101
|
git_oid_cpy(&head->oid, &obj_id);
|
102
102
|
|
103
|
-
if (git_reference_type(ref) ==
|
103
|
+
if (git_reference_type(ref) == GIT_REFERENCE_SYMBOLIC) {
|
104
104
|
head->symref_target = git__strdup(git_reference_symbolic_target(ref));
|
105
|
-
|
105
|
+
GIT_ERROR_CHECK_ALLOC(head->symref_target);
|
106
106
|
}
|
107
107
|
git_reference_free(ref);
|
108
108
|
|
@@ -115,14 +115,14 @@ static int add_ref(transport_local *t, const char *name)
|
|
115
115
|
if (git__prefixcmp(name, GIT_REFS_TAGS_DIR))
|
116
116
|
return 0;
|
117
117
|
|
118
|
-
if ((error = git_object_lookup(&obj, t->repo, &head->oid,
|
118
|
+
if ((error = git_object_lookup(&obj, t->repo, &head->oid, GIT_OBJECT_ANY)) < 0)
|
119
119
|
return error;
|
120
120
|
|
121
121
|
head = NULL;
|
122
122
|
|
123
123
|
/* If it's not an annotated tag, or if we're mocking
|
124
124
|
* git-receive-pack, just get out */
|
125
|
-
if (git_object_type(obj) !=
|
125
|
+
if (git_object_type(obj) != GIT_OBJECT_TAG ||
|
126
126
|
t->direction != GIT_DIRECTION_FETCH) {
|
127
127
|
git_object_free(obj);
|
128
128
|
return 0;
|
@@ -130,7 +130,7 @@ static int add_ref(transport_local *t, const char *name)
|
|
130
130
|
|
131
131
|
/* And if it's a tag, peel it, and add it to the list */
|
132
132
|
head = git__calloc(1, sizeof(git_remote_head));
|
133
|
-
|
133
|
+
GIT_ERROR_CHECK_ALLOC(head);
|
134
134
|
|
135
135
|
if (git_buf_join(&buf, 0, name, peeled) < 0) {
|
136
136
|
free_head(head);
|
@@ -222,20 +222,20 @@ static int local_connect(
|
|
222
222
|
free_heads(&t->refs);
|
223
223
|
|
224
224
|
t->url = git__strdup(url);
|
225
|
-
|
225
|
+
GIT_ERROR_CHECK_ALLOC(t->url);
|
226
226
|
t->direction = direction;
|
227
227
|
t->flags = flags;
|
228
228
|
|
229
229
|
/* 'url' may be a url or path; convert to a path */
|
230
230
|
if ((error = git_path_from_url_or_path(&buf, url)) < 0) {
|
231
|
-
|
231
|
+
git_buf_dispose(&buf);
|
232
232
|
return error;
|
233
233
|
}
|
234
234
|
path = git_buf_cstr(&buf);
|
235
235
|
|
236
236
|
error = git_repository_open(&repo, path);
|
237
237
|
|
238
|
-
|
238
|
+
git_buf_dispose(&buf);
|
239
239
|
|
240
240
|
if (error < 0)
|
241
241
|
return -1;
|
@@ -255,7 +255,7 @@ static int local_ls(const git_remote_head ***out, size_t *size, git_transport *t
|
|
255
255
|
transport_local *t = (transport_local *)transport;
|
256
256
|
|
257
257
|
if (!t->have_refs) {
|
258
|
-
|
258
|
+
git_error_set(GIT_ERROR_NET, "the transport has not yet loaded the refs");
|
259
259
|
return -1;
|
260
260
|
}
|
261
261
|
|
@@ -288,7 +288,7 @@ static int local_negotiate_fetch(
|
|
288
288
|
else if (error != GIT_ENOTFOUND)
|
289
289
|
return error;
|
290
290
|
else
|
291
|
-
|
291
|
+
git_error_clear();
|
292
292
|
git_object_free(obj);
|
293
293
|
}
|
294
294
|
|
@@ -354,14 +354,14 @@ static int local_push(
|
|
354
354
|
|
355
355
|
/* 'push->remote->url' may be a url or path; convert to a path */
|
356
356
|
if ((error = git_path_from_url_or_path(&buf, push->remote->url)) < 0) {
|
357
|
-
|
357
|
+
git_buf_dispose(&buf);
|
358
358
|
return error;
|
359
359
|
}
|
360
360
|
path = git_buf_cstr(&buf);
|
361
361
|
|
362
362
|
error = git_repository_open(&remote_repo, path);
|
363
363
|
|
364
|
-
|
364
|
+
git_buf_dispose(&buf);
|
365
365
|
|
366
366
|
if (error < 0)
|
367
367
|
return error;
|
@@ -374,7 +374,7 @@ static int local_push(
|
|
374
374
|
but we forbid all pushes just in case */
|
375
375
|
if (!remote_repo->is_bare) {
|
376
376
|
error = GIT_EBAREREPO;
|
377
|
-
|
377
|
+
git_error_set(GIT_ERROR_INVALID, "local push doesn't (yet) support pushing to non-bare repos.");
|
378
378
|
goto on_error;
|
379
379
|
}
|
380
380
|
|
@@ -383,7 +383,7 @@ static int local_push(
|
|
383
383
|
goto on_error;
|
384
384
|
|
385
385
|
error = git_packbuilder_write(push->pb, odb_path.ptr, 0, transfer_to_push_transfer, (void *) cbs);
|
386
|
-
|
386
|
+
git_buf_dispose(&odb_path);
|
387
387
|
|
388
388
|
if (error < 0)
|
389
389
|
goto on_error;
|
@@ -418,7 +418,7 @@ static int local_push(
|
|
418
418
|
status->msg = git__strdup("Remote branch not found to delete");
|
419
419
|
break;
|
420
420
|
default:
|
421
|
-
last =
|
421
|
+
last = git_error_last();
|
422
422
|
|
423
423
|
if (last && last->message)
|
424
424
|
status->msg = git__strdup(last->message);
|
@@ -502,7 +502,7 @@ static int local_counting(int stage, unsigned int current, unsigned int total, v
|
|
502
502
|
return -1;
|
503
503
|
|
504
504
|
error = t->progress_cb(git_buf_cstr(&progress_info), git_buf_len(&progress_info), t->message_cb_payload);
|
505
|
-
|
505
|
+
git_buf_dispose(&progress_info);
|
506
506
|
|
507
507
|
return error;
|
508
508
|
}
|
@@ -512,7 +512,7 @@ static int foreach_reference_cb(git_reference *reference, void *payload)
|
|
512
512
|
git_revwalk *walk = (git_revwalk *)payload;
|
513
513
|
int error;
|
514
514
|
|
515
|
-
if (git_reference_type(reference) !=
|
515
|
+
if (git_reference_type(reference) != GIT_REFERENCE_DIRECT) {
|
516
516
|
git_reference_free(reference);
|
517
517
|
return 0;
|
518
518
|
}
|
@@ -520,8 +520,8 @@ static int foreach_reference_cb(git_reference *reference, void *payload)
|
|
520
520
|
error = git_revwalk_hide(walk, git_reference_target(reference));
|
521
521
|
/* The reference is in the local repository, so the target may not
|
522
522
|
* exist on the remote. It also may not be a commit. */
|
523
|
-
if (error == GIT_ENOTFOUND || error ==
|
524
|
-
|
523
|
+
if (error == GIT_ENOTFOUND || error == GIT_ERROR_INVALID) {
|
524
|
+
git_error_clear();
|
525
525
|
error = 0;
|
526
526
|
}
|
527
527
|
|
@@ -563,10 +563,10 @@ static int local_download_pack(
|
|
563
563
|
|
564
564
|
git_vector_foreach(&t->refs, i, rhead) {
|
565
565
|
git_object *obj;
|
566
|
-
if ((error = git_object_lookup(&obj, t->repo, &rhead->oid,
|
566
|
+
if ((error = git_object_lookup(&obj, t->repo, &rhead->oid, GIT_OBJECT_ANY)) < 0)
|
567
567
|
goto cleanup;
|
568
568
|
|
569
|
-
if (git_object_type(obj) ==
|
569
|
+
if (git_object_type(obj) == GIT_OBJECT_COMMIT) {
|
570
570
|
/* Revwalker includes only wanted commits */
|
571
571
|
error = git_revwalk_push(walk, &rhead->oid);
|
572
572
|
} else {
|
@@ -627,7 +627,7 @@ static int local_download_pack(
|
|
627
627
|
|
628
628
|
cleanup:
|
629
629
|
if (writepack) writepack->free(writepack);
|
630
|
-
|
630
|
+
git_buf_dispose(&progress_info);
|
631
631
|
git_packbuilder_free(pack);
|
632
632
|
git_revwalk_free(walk);
|
633
633
|
return error;
|
@@ -718,7 +718,7 @@ int git_transport_local(git_transport **out, git_remote *owner, void *param)
|
|
718
718
|
GIT_UNUSED(param);
|
719
719
|
|
720
720
|
t = git__calloc(1, sizeof(transport_local));
|
721
|
-
|
721
|
+
GIT_ERROR_CHECK_ALLOC(t);
|
722
722
|
|
723
723
|
t->parent.version = GIT_TRANSPORT_VERSION;
|
724
724
|
t->parent.set_callbacks = local_set_callbacks;
|
@@ -86,7 +86,7 @@ static bool is_malformed_http_header(const char *http_header)
|
|
86
86
|
const char *c;
|
87
87
|
int name_len;
|
88
88
|
|
89
|
-
|
89
|
+
/* Disallow \r and \n */
|
90
90
|
c = strchr(http_header, '\r');
|
91
91
|
if (c)
|
92
92
|
return true;
|
@@ -94,7 +94,7 @@ static bool is_malformed_http_header(const char *http_header)
|
|
94
94
|
if (c)
|
95
95
|
return true;
|
96
96
|
|
97
|
-
|
97
|
+
/* Require a header name followed by : */
|
98
98
|
name_len = http_header_name_length(http_header);
|
99
99
|
if (name_len < 1)
|
100
100
|
return true;
|
@@ -116,7 +116,7 @@ static bool is_forbidden_custom_header(const char *custom_header)
|
|
116
116
|
unsigned long i;
|
117
117
|
int name_len = http_header_name_length(custom_header);
|
118
118
|
|
119
|
-
|
119
|
+
/* Disallow headers that we set */
|
120
120
|
for (i = 0; i < ARRAY_SIZE(forbidden_custom_headers); i++)
|
121
121
|
if (strncmp(forbidden_custom_headers[i], custom_header, name_len) == 0)
|
122
122
|
return true;
|
@@ -139,11 +139,11 @@ static int git_smart__set_custom_headers(
|
|
139
139
|
|
140
140
|
for (i = 0; i < custom_headers->count; i++) {
|
141
141
|
if (is_malformed_http_header(custom_headers->strings[i])) {
|
142
|
-
|
142
|
+
git_error_set(GIT_ERROR_INVALID, "custom HTTP header '%s' is malformed", custom_headers->strings[i]);
|
143
143
|
return -1;
|
144
144
|
}
|
145
145
|
if (is_forbidden_custom_header(custom_headers->strings[i])) {
|
146
|
-
|
146
|
+
git_error_set(GIT_ERROR_INVALID, "custom HTTP header '%s' is already set by libgit2", custom_headers->strings[i]);
|
147
147
|
return -1;
|
148
148
|
}
|
149
149
|
}
|
@@ -171,11 +171,13 @@ int git_smart__update_heads(transport_smart *t, git_vector *symrefs)
|
|
171
171
|
git_vector_foreach(symrefs, j, spec) {
|
172
172
|
git_buf_clear(&buf);
|
173
173
|
if (git_refspec_src_matches(spec, ref->head.name) &&
|
174
|
-
!(error = git_refspec_transform(&buf, spec, ref->head.name)))
|
174
|
+
!(error = git_refspec_transform(&buf, spec, ref->head.name))) {
|
175
|
+
git__free(ref->head.symref_target);
|
175
176
|
ref->head.symref_target = git_buf_detach(&buf);
|
177
|
+
}
|
176
178
|
}
|
177
179
|
|
178
|
-
|
180
|
+
git_buf_dispose(&buf);
|
179
181
|
|
180
182
|
if (error < 0)
|
181
183
|
return error;
|
@@ -194,7 +196,7 @@ static void free_symrefs(git_vector *symrefs)
|
|
194
196
|
size_t i;
|
195
197
|
|
196
198
|
git_vector_foreach(symrefs, i, spec) {
|
197
|
-
|
199
|
+
git_refspec__dispose(spec);
|
198
200
|
git__free(spec);
|
199
201
|
}
|
200
202
|
|
@@ -222,7 +224,7 @@ static int git_smart__connect(
|
|
222
224
|
return -1;
|
223
225
|
|
224
226
|
t->url = git__strdup(url);
|
225
|
-
|
227
|
+
GIT_ERROR_CHECK_ALLOC(t->url);
|
226
228
|
|
227
229
|
if (git_proxy_options_dup(&t->proxy, proxy) < 0)
|
228
230
|
return -1;
|
@@ -237,7 +239,7 @@ static int git_smart__connect(
|
|
237
239
|
else if (GIT_DIRECTION_PUSH == t->direction)
|
238
240
|
service = GIT_SERVICE_RECEIVEPACK_LS;
|
239
241
|
else {
|
240
|
-
|
242
|
+
git_error_set(GIT_ERROR_NET, "invalid direction");
|
241
243
|
return -1;
|
242
244
|
}
|
243
245
|
|
@@ -258,7 +260,7 @@ static int git_smart__connect(
|
|
258
260
|
pkt = (git_pkt *)git_vector_get(&t->refs, 0);
|
259
261
|
|
260
262
|
if (!pkt || GIT_PKT_COMMENT != pkt->type) {
|
261
|
-
|
263
|
+
git_error_set(GIT_ERROR_NET, "invalid response");
|
262
264
|
return -1;
|
263
265
|
} else {
|
264
266
|
/* Remove the comment pkt from the list */
|
@@ -270,34 +272,45 @@ static int git_smart__connect(
|
|
270
272
|
/* We now have loaded the refs. */
|
271
273
|
t->have_refs = 1;
|
272
274
|
|
273
|
-
|
275
|
+
pkt = (git_pkt *)git_vector_get(&t->refs, 0);
|
276
|
+
if (pkt && GIT_PKT_REF != pkt->type) {
|
277
|
+
git_error_set(GIT_ERROR_NET, "invalid response");
|
278
|
+
return -1;
|
279
|
+
}
|
280
|
+
first = (git_pkt_ref *)pkt;
|
274
281
|
|
275
282
|
if ((error = git_vector_init(&symrefs, 1, NULL)) < 0)
|
276
283
|
return error;
|
277
284
|
|
278
285
|
/* Detect capabilities */
|
279
|
-
if (git_smart__detect_caps(first, &t->caps, &symrefs)
|
280
|
-
|
286
|
+
if ((error = git_smart__detect_caps(first, &t->caps, &symrefs)) == 0) {
|
287
|
+
/* If the only ref in the list is capabilities^{} with OID_ZERO, remove it */
|
288
|
+
if (1 == t->refs.length && !strcmp(first->head.name, "capabilities^{}") &&
|
289
|
+
git_oid_iszero(&first->head.oid)) {
|
290
|
+
git_vector_clear(&t->refs);
|
291
|
+
git_pkt_free((git_pkt *)first);
|
292
|
+
}
|
281
293
|
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
294
|
+
/* Keep a list of heads for _ls */
|
295
|
+
git_smart__update_heads(t, &symrefs);
|
296
|
+
} else if (error == GIT_ENOTFOUND) {
|
297
|
+
/* There was no ref packet received, or the cap list was empty */
|
298
|
+
error = 0;
|
299
|
+
} else {
|
300
|
+
git_error_set(GIT_ERROR_NET, "invalid response");
|
301
|
+
goto cleanup;
|
287
302
|
}
|
288
303
|
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
free_symrefs(&symrefs);
|
293
|
-
|
294
|
-
if (t->rpc && git_smart__reset_stream(t, false) < 0)
|
295
|
-
return -1;
|
304
|
+
if (t->rpc && (error = git_smart__reset_stream(t, false)) < 0)
|
305
|
+
goto cleanup;
|
296
306
|
|
297
307
|
/* We're now logically connected. */
|
298
308
|
t->connected = 1;
|
299
309
|
|
300
|
-
|
310
|
+
cleanup:
|
311
|
+
free_symrefs(&symrefs);
|
312
|
+
|
313
|
+
return error;
|
301
314
|
}
|
302
315
|
|
303
316
|
static int git_smart__ls(const git_remote_head ***out, size_t *size, git_transport *transport)
|
@@ -305,7 +318,7 @@ static int git_smart__ls(const git_remote_head ***out, size_t *size, git_transpo
|
|
305
318
|
transport_smart *t = (transport_smart *)transport;
|
306
319
|
|
307
320
|
if (!t->have_refs) {
|
308
|
-
|
321
|
+
git_error_set(GIT_ERROR_NET, "the transport has not yet loaded the refs");
|
309
322
|
return -1;
|
310
323
|
}
|
311
324
|
|
@@ -325,7 +338,7 @@ int git_smart__negotiation_step(git_transport *transport, void *data, size_t len
|
|
325
338
|
return -1;
|
326
339
|
|
327
340
|
if (GIT_DIRECTION_FETCH != t->direction) {
|
328
|
-
|
341
|
+
git_error_set(GIT_ERROR_NET, "this operation is only valid for fetch");
|
329
342
|
return -1;
|
330
343
|
}
|
331
344
|
|
@@ -354,7 +367,7 @@ int git_smart__get_push_stream(transport_smart *t, git_smart_subtransport_stream
|
|
354
367
|
return -1;
|
355
368
|
|
356
369
|
if (GIT_DIRECTION_PUSH != t->direction) {
|
357
|
-
|
370
|
+
git_error_set(GIT_ERROR_NET, "this operation is only valid for push");
|
358
371
|
return -1;
|
359
372
|
}
|
360
373
|
|
@@ -468,6 +481,11 @@ int git_transport_smart_certificate_check(git_transport *transport, git_cert *ce
|
|
468
481
|
{
|
469
482
|
transport_smart *t = (transport_smart *)transport;
|
470
483
|
|
484
|
+
assert(transport && cert && hostname);
|
485
|
+
|
486
|
+
if (!t->certificate_check_cb)
|
487
|
+
return GIT_PASSTHROUGH;
|
488
|
+
|
471
489
|
return t->certificate_check_cb(cert, valid, hostname, t->message_cb_payload);
|
472
490
|
}
|
473
491
|
|
@@ -475,6 +493,11 @@ int git_transport_smart_credentials(git_cred **out, git_transport *transport, co
|
|
475
493
|
{
|
476
494
|
transport_smart *t = (transport_smart *)transport;
|
477
495
|
|
496
|
+
assert(out && transport);
|
497
|
+
|
498
|
+
if (!t->cred_acquire_cb)
|
499
|
+
return GIT_PASSTHROUGH;
|
500
|
+
|
478
501
|
return t->cred_acquire_cb(out, t->url, user, methods, t->cred_acquire_payload);
|
479
502
|
}
|
480
503
|
|
@@ -493,7 +516,7 @@ int git_transport_smart(git_transport **out, git_remote *owner, void *param)
|
|
493
516
|
return -1;
|
494
517
|
|
495
518
|
t = git__calloc(1, sizeof(transport_smart));
|
496
|
-
|
519
|
+
GIT_ERROR_CHECK_ALLOC(t);
|
497
520
|
|
498
521
|
t->parent.version = GIT_TRANSPORT_VERSION;
|
499
522
|
t->parent.set_callbacks = git_smart__set_callbacks;
|
@@ -40,7 +40,6 @@ typedef enum {
|
|
40
40
|
GIT_PKT_HAVE,
|
41
41
|
GIT_PKT_ACK,
|
42
42
|
GIT_PKT_NAK,
|
43
|
-
GIT_PKT_PACK__UNUSED,
|
44
43
|
GIT_PKT_COMMENT,
|
45
44
|
GIT_PKT_ERR,
|
46
45
|
GIT_PKT_DATA,
|
@@ -50,7 +49,7 @@ typedef enum {
|
|
50
49
|
GIT_PKT_UNPACK,
|
51
50
|
} git_pkt_type;
|
52
51
|
|
53
|
-
/* Used for multi_ack and
|
52
|
+
/* Used for multi_ack and multi_ack_detailed */
|
54
53
|
enum git_ack_status {
|
55
54
|
GIT_ACK_NONE,
|
56
55
|
GIT_ACK_CONTINUE,
|
@@ -31,7 +31,7 @@ static int flush_pkt(git_pkt **out)
|
|
31
31
|
git_pkt *pkt;
|
32
32
|
|
33
33
|
pkt = git__malloc(sizeof(git_pkt));
|
34
|
-
|
34
|
+
GIT_ERROR_CHECK_ALLOC(pkt);
|
35
35
|
|
36
36
|
pkt->type = GIT_PKT_FLUSH;
|
37
37
|
*out = pkt;
|
@@ -45,7 +45,7 @@ static int ack_pkt(git_pkt **out, const char *line, size_t len)
|
|
45
45
|
git_pkt_ack *pkt;
|
46
46
|
|
47
47
|
pkt = git__calloc(1, sizeof(git_pkt_ack));
|
48
|
-
|
48
|
+
GIT_ERROR_CHECK_ALLOC(pkt);
|
49
49
|
pkt->type = GIT_PKT_ACK;
|
50
50
|
|
51
51
|
if (git__prefixncmp(line, len, "ACK "))
|
@@ -77,7 +77,7 @@ static int ack_pkt(git_pkt **out, const char *line, size_t len)
|
|
77
77
|
return 0;
|
78
78
|
|
79
79
|
out_err:
|
80
|
-
|
80
|
+
git_error_set(GIT_ERROR_NET, "error parsing ACK pkt-line");
|
81
81
|
git__free(pkt);
|
82
82
|
return -1;
|
83
83
|
}
|
@@ -87,7 +87,7 @@ static int nak_pkt(git_pkt **out)
|
|
87
87
|
git_pkt *pkt;
|
88
88
|
|
89
89
|
pkt = git__malloc(sizeof(git_pkt));
|
90
|
-
|
90
|
+
GIT_ERROR_CHECK_ALLOC(pkt);
|
91
91
|
|
92
92
|
pkt->type = GIT_PKT_NAK;
|
93
93
|
*out = pkt;
|
@@ -100,10 +100,10 @@ static int comment_pkt(git_pkt **out, const char *line, size_t len)
|
|
100
100
|
git_pkt_comment *pkt;
|
101
101
|
size_t alloclen;
|
102
102
|
|
103
|
-
|
104
|
-
|
103
|
+
GIT_ERROR_CHECK_ALLOC_ADD(&alloclen, sizeof(git_pkt_comment), len);
|
104
|
+
GIT_ERROR_CHECK_ALLOC_ADD(&alloclen, alloclen, 1);
|
105
105
|
pkt = git__malloc(alloclen);
|
106
|
-
|
106
|
+
GIT_ERROR_CHECK_ALLOC(pkt);
|
107
107
|
|
108
108
|
pkt->type = GIT_PKT_COMMENT;
|
109
109
|
memcpy(pkt->comment, line, len);
|
@@ -125,10 +125,10 @@ static int err_pkt(git_pkt **out, const char *line, size_t len)
|
|
125
125
|
line += 4;
|
126
126
|
len -= 4;
|
127
127
|
|
128
|
-
|
129
|
-
|
128
|
+
GIT_ERROR_CHECK_ALLOC_ADD(&alloclen, sizeof(git_pkt_progress), len);
|
129
|
+
GIT_ERROR_CHECK_ALLOC_ADD(&alloclen, alloclen, 1);
|
130
130
|
pkt = git__malloc(alloclen);
|
131
|
-
|
131
|
+
GIT_ERROR_CHECK_ALLOC(pkt);
|
132
132
|
pkt->type = GIT_PKT_ERR;
|
133
133
|
pkt->len = len;
|
134
134
|
|
@@ -140,7 +140,7 @@ static int err_pkt(git_pkt **out, const char *line, size_t len)
|
|
140
140
|
return 0;
|
141
141
|
|
142
142
|
out_err:
|
143
|
-
|
143
|
+
git_error_set(GIT_ERROR_NET, "error parsing ERR pkt-line");
|
144
144
|
git__free(pkt);
|
145
145
|
return -1;
|
146
146
|
}
|
@@ -153,9 +153,9 @@ static int data_pkt(git_pkt **out, const char *line, size_t len)
|
|
153
153
|
line++;
|
154
154
|
len--;
|
155
155
|
|
156
|
-
|
156
|
+
GIT_ERROR_CHECK_ALLOC_ADD(&alloclen, sizeof(git_pkt_progress), len);
|
157
157
|
pkt = git__malloc(alloclen);
|
158
|
-
|
158
|
+
GIT_ERROR_CHECK_ALLOC(pkt);
|
159
159
|
|
160
160
|
pkt->type = GIT_PKT_DATA;
|
161
161
|
pkt->len = len;
|
@@ -174,9 +174,9 @@ static int sideband_progress_pkt(git_pkt **out, const char *line, size_t len)
|
|
174
174
|
line++;
|
175
175
|
len--;
|
176
176
|
|
177
|
-
|
177
|
+
GIT_ERROR_CHECK_ALLOC_ADD(&alloclen, sizeof(git_pkt_progress), len);
|
178
178
|
pkt = git__malloc(alloclen);
|
179
|
-
|
179
|
+
GIT_ERROR_CHECK_ALLOC(pkt);
|
180
180
|
|
181
181
|
pkt->type = GIT_PKT_PROGRESS;
|
182
182
|
pkt->len = len;
|
@@ -195,10 +195,10 @@ static int sideband_error_pkt(git_pkt **out, const char *line, size_t len)
|
|
195
195
|
line++;
|
196
196
|
len--;
|
197
197
|
|
198
|
-
|
199
|
-
|
198
|
+
GIT_ERROR_CHECK_ALLOC_ADD(&alloc_len, sizeof(git_pkt_err), len);
|
199
|
+
GIT_ERROR_CHECK_ALLOC_ADD(&alloc_len, alloc_len, 1);
|
200
200
|
pkt = git__malloc(alloc_len);
|
201
|
-
|
201
|
+
GIT_ERROR_CHECK_ALLOC(pkt);
|
202
202
|
|
203
203
|
pkt->type = GIT_PKT_ERR;
|
204
204
|
pkt->len = (int)len;
|
@@ -219,7 +219,7 @@ static int ref_pkt(git_pkt **out, const char *line, size_t len)
|
|
219
219
|
size_t alloclen;
|
220
220
|
|
221
221
|
pkt = git__calloc(1, sizeof(git_pkt_ref));
|
222
|
-
|
222
|
+
GIT_ERROR_CHECK_ALLOC(pkt);
|
223
223
|
pkt->type = GIT_PKT_REF;
|
224
224
|
|
225
225
|
if (len < GIT_OID_HEXSZ || git_oid_fromstr(&pkt->head.oid, line) < 0)
|
@@ -238,9 +238,9 @@ static int ref_pkt(git_pkt **out, const char *line, size_t len)
|
|
238
238
|
if (line[len - 1] == '\n')
|
239
239
|
--len;
|
240
240
|
|
241
|
-
|
241
|
+
GIT_ERROR_CHECK_ALLOC_ADD(&alloclen, len, 1);
|
242
242
|
pkt->head.name = git__malloc(alloclen);
|
243
|
-
|
243
|
+
GIT_ERROR_CHECK_ALLOC(pkt->head.name);
|
244
244
|
|
245
245
|
memcpy(pkt->head.name, line, len);
|
246
246
|
pkt->head.name[len] = '\0';
|
@@ -252,7 +252,7 @@ static int ref_pkt(git_pkt **out, const char *line, size_t len)
|
|
252
252
|
return 0;
|
253
253
|
|
254
254
|
out_err:
|
255
|
-
|
255
|
+
git_error_set(GIT_ERROR_NET, "error parsing REF pkt-line");
|
256
256
|
if (pkt)
|
257
257
|
git__free(pkt->head.name);
|
258
258
|
git__free(pkt);
|
@@ -265,7 +265,7 @@ static int ok_pkt(git_pkt **out, const char *line, size_t len)
|
|
265
265
|
size_t alloc_len;
|
266
266
|
|
267
267
|
pkt = git__malloc(sizeof(*pkt));
|
268
|
-
|
268
|
+
GIT_ERROR_CHECK_ALLOC(pkt);
|
269
269
|
pkt->type = GIT_PKT_OK;
|
270
270
|
|
271
271
|
if (git__prefixncmp(line, len, "ok "))
|
@@ -276,9 +276,9 @@ static int ok_pkt(git_pkt **out, const char *line, size_t len)
|
|
276
276
|
if (line[len - 1] == '\n')
|
277
277
|
--len;
|
278
278
|
|
279
|
-
|
279
|
+
GIT_ERROR_CHECK_ALLOC_ADD(&alloc_len, len, 1);
|
280
280
|
pkt->ref = git__malloc(alloc_len);
|
281
|
-
|
281
|
+
GIT_ERROR_CHECK_ALLOC(pkt->ref);
|
282
282
|
|
283
283
|
memcpy(pkt->ref, line, len);
|
284
284
|
pkt->ref[len] = '\0';
|
@@ -287,7 +287,7 @@ static int ok_pkt(git_pkt **out, const char *line, size_t len)
|
|
287
287
|
return 0;
|
288
288
|
|
289
289
|
out_err:
|
290
|
-
|
290
|
+
git_error_set(GIT_ERROR_NET, "error parsing OK pkt-line");
|
291
291
|
git__free(pkt);
|
292
292
|
return -1;
|
293
293
|
}
|
@@ -299,7 +299,7 @@ static int ng_pkt(git_pkt **out, const char *line, size_t len)
|
|
299
299
|
size_t alloclen;
|
300
300
|
|
301
301
|
pkt = git__malloc(sizeof(*pkt));
|
302
|
-
|
302
|
+
GIT_ERROR_CHECK_ALLOC(pkt);
|
303
303
|
|
304
304
|
pkt->ref = NULL;
|
305
305
|
pkt->type = GIT_PKT_NG;
|
@@ -314,9 +314,9 @@ static int ng_pkt(git_pkt **out, const char *line, size_t len)
|
|
314
314
|
goto out_err;
|
315
315
|
len = ptr - line;
|
316
316
|
|
317
|
-
|
317
|
+
GIT_ERROR_CHECK_ALLOC_ADD(&alloclen, len, 1);
|
318
318
|
pkt->ref = git__malloc(alloclen);
|
319
|
-
|
319
|
+
GIT_ERROR_CHECK_ALLOC(pkt->ref);
|
320
320
|
|
321
321
|
memcpy(pkt->ref, line, len);
|
322
322
|
pkt->ref[len] = '\0';
|
@@ -329,9 +329,9 @@ static int ng_pkt(git_pkt **out, const char *line, size_t len)
|
|
329
329
|
goto out_err;
|
330
330
|
len = ptr - line;
|
331
331
|
|
332
|
-
|
332
|
+
GIT_ERROR_CHECK_ALLOC_ADD(&alloclen, len, 1);
|
333
333
|
pkt->msg = git__malloc(alloclen);
|
334
|
-
|
334
|
+
GIT_ERROR_CHECK_ALLOC(pkt->msg);
|
335
335
|
|
336
336
|
memcpy(pkt->msg, line, len);
|
337
337
|
pkt->msg[len] = '\0';
|
@@ -340,7 +340,7 @@ static int ng_pkt(git_pkt **out, const char *line, size_t len)
|
|
340
340
|
return 0;
|
341
341
|
|
342
342
|
out_err:
|
343
|
-
|
343
|
+
git_error_set(GIT_ERROR_NET, "invalid packet line");
|
344
344
|
git__free(pkt->ref);
|
345
345
|
git__free(pkt);
|
346
346
|
return -1;
|
@@ -351,7 +351,7 @@ static int unpack_pkt(git_pkt **out, const char *line, size_t len)
|
|
351
351
|
git_pkt_unpack *pkt;
|
352
352
|
|
353
353
|
pkt = git__malloc(sizeof(*pkt));
|
354
|
-
|
354
|
+
GIT_ERROR_CHECK_ALLOC(pkt);
|
355
355
|
pkt->type = GIT_PKT_UNPACK;
|
356
356
|
|
357
357
|
if (!git__prefixncmp(line, len, "unpack ok"))
|
@@ -386,7 +386,7 @@ static int parse_len(size_t *out, const char *line, size_t linelen)
|
|
386
386
|
}
|
387
387
|
}
|
388
388
|
|
389
|
-
|
389
|
+
git_error_set(GIT_ERROR_NET, "invalid hex digit in length: '%s'", num);
|
390
390
|
return -1;
|
391
391
|
}
|
392
392
|
}
|
@@ -430,9 +430,9 @@ int git_pkt_parse_line(
|
|
430
430
|
if (error == GIT_EBUFS)
|
431
431
|
;
|
432
432
|
else if (!git__prefixncmp(line, linelen, "PACK"))
|
433
|
-
|
433
|
+
git_error_set(GIT_ERROR_NET, "unexpected pack file");
|
434
434
|
else
|
435
|
-
|
435
|
+
git_error_set(GIT_ERROR_NET, "bad packet length");
|
436
436
|
return error;
|
437
437
|
}
|
438
438
|
|
@@ -458,7 +458,7 @@ int git_pkt_parse_line(
|
|
458
458
|
* line, we should return an error upon hitting one.
|
459
459
|
*/
|
460
460
|
if (len == PKT_LEN_SIZE) {
|
461
|
-
|
461
|
+
git_error_set_str(GIT_ERROR_NET, "Invalid empty packet");
|
462
462
|
return GIT_ERROR;
|
463
463
|
}
|
464
464
|
|
@@ -499,6 +499,9 @@ int git_pkt_parse_line(
|
|
499
499
|
|
500
500
|
void git_pkt_free(git_pkt *pkt)
|
501
501
|
{
|
502
|
+
if (pkt == NULL) {
|
503
|
+
return;
|
504
|
+
}
|
502
505
|
if (pkt->type == GIT_PKT_REF) {
|
503
506
|
git_pkt_ref *p = (git_pkt_ref *) pkt;
|
504
507
|
git__free(p->head.name);
|
@@ -558,7 +561,7 @@ static int buffer_want_with_caps(const git_remote_head *head, transport_smart_ca
|
|
558
561
|
git_buf_len(&str) + 1 /* LF */;
|
559
562
|
|
560
563
|
if (len > 0xffff) {
|
561
|
-
|
564
|
+
git_error_set(GIT_ERROR_NET,
|
562
565
|
"tried to produce packet with invalid length %" PRIuZ, len);
|
563
566
|
return -1;
|
564
567
|
}
|
@@ -567,9 +570,9 @@ static int buffer_want_with_caps(const git_remote_head *head, transport_smart_ca
|
|
567
570
|
git_oid_fmt(oid, &head->oid);
|
568
571
|
git_buf_printf(buf,
|
569
572
|
"%04xwant %s %s\n", (unsigned int)len, oid, git_buf_cstr(&str));
|
570
|
-
|
573
|
+
git_buf_dispose(&str);
|
571
574
|
|
572
|
-
|
575
|
+
GIT_ERROR_CHECK_ALLOC_BUF(buf);
|
573
576
|
|
574
577
|
return 0;
|
575
578
|
}
|