summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYuang Li <yuangli88@hotmail.com>2022-08-31 15:34:06 +0100
committerYuang Li <yuangli88@hotmail.com>2022-08-31 15:34:06 +0100
commitf1f9b45dd20b408953eac2d515e8dfa0264aa631 (patch)
treedbdc3192bc484de37599d656702868684aeebb12
parentb20f013c129a27a86b5207a2f6ad1d858113f46c (diff)
downloadlibgit2-f1f9b45dd20b408953eac2d515e8dfa0264aa631.tar.gz
fix test failures
-rw-r--r--src/libgit2/fetch.c6
-rw-r--r--src/libgit2/grafts.c4
2 files changed, 6 insertions, 4 deletions
diff --git a/src/libgit2/fetch.c b/src/libgit2/fetch.c
index 3216b261c..69794ed1f 100644
--- a/src/libgit2/fetch.c
+++ b/src/libgit2/fetch.c
@@ -21,6 +21,7 @@
#include "repository.h"
#include "refs.h"
#include "transports/smart.h"
+#include <limits.h>
static int maybe_want(git_remote *remote, git_remote_head *head, git_refspec *tagspec, git_remote_autotag_option_t tagopt)
{
@@ -175,7 +176,8 @@ int git_fetch_negotiate(git_remote *remote, const git_fetch_options *opts)
git_transport *t = remote->transport;
remote->need_pack = 0;
- remote->nego.depth = opts->unshallow ? INT_MAX : opts->depth;
+
+ remote->nego.depth = (opts && !opts->unshallow) ? opts->depth : INT_MAX;
if (filter_wants(remote, opts) < 0)
return -1;
@@ -184,7 +186,7 @@ int git_fetch_negotiate(git_remote *remote, const git_fetch_options *opts)
if (!remote->need_pack)
return 0;
- if (opts->unshallow && opts->depth > 0) {
+ if (opts && opts->unshallow && opts->depth > 0) {
git_error_set(GIT_ERROR_INVALID, "options '--depth' and '--unshallow' cannot be used together");
return -1;
}
diff --git a/src/libgit2/grafts.c b/src/libgit2/grafts.c
index 5b078b01d..6662f5009 100644
--- a/src/libgit2/grafts.c
+++ b/src/libgit2/grafts.c
@@ -133,7 +133,7 @@ int git_grafts_parse(git_grafts *grafts, const char *content, size_t contentlen)
const char *line_start = parser.line, *line_end = parser.line + parser.line_len;
git_oid graft_oid;
- if ((error = git_oid_fromstrn(&graft_oid, line_start, GIT_OID_SHA1_HEXSIZE)) < 0) {
+ if ((error = git_oid__fromstrn(&graft_oid, line_start, GIT_OID_SHA1_HEXSIZE, GIT_OID_SHA1)) < 0) {
git_error_set(GIT_ERROR_GRAFTS, "invalid graft OID at line %" PRIuZ, parser.line_num);
goto error;
}
@@ -143,7 +143,7 @@ int git_grafts_parse(git_grafts *grafts, const char *content, size_t contentlen)
git_oid *id = git_array_alloc(parents);
GIT_ERROR_CHECK_ALLOC(id);
- if ((error = git_oid_fromstrn(id, ++line_start, GIT_OID_SHA1_HEXSIZE)) < 0) {
+ if ((error = git_oid__fromstrn(id, ++line_start, GIT_OID_SHA1_HEXSIZE, GIT_OID_SHA1)) < 0) {
git_error_set(GIT_ERROR_GRAFTS, "invalid parent OID at line %" PRIuZ, parser.line_num);
goto error;
}