From f1f9b45dd20b408953eac2d515e8dfa0264aa631 Mon Sep 17 00:00:00 2001 From: Yuang Li Date: Wed, 31 Aug 2022 15:34:06 +0100 Subject: fix test failures --- src/libgit2/fetch.c | 6 ++++-- src/libgit2/grafts.c | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) (limited to 'src') 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 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; } -- cgit v1.2.1