Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 7ebd8a1

Browse files
authored
Merge pull request #6684 from kcsaul/ignore_missing_grafts
Bypass shallow clone support for in-memory repositories
2 parents bd85506 + 6855502 commit 7ebd8a1

File tree

1 file changed

+24
-2
lines changed

1 file changed

+24
-2
lines changed

src/libgit2/repository.c

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -865,8 +865,30 @@ static int load_grafts(git_repository *repo)
865865
git_str path = GIT_STR_INIT;
866866
int error;
867867

868-
if ((error = git_repository__item_path(&path, repo, GIT_REPOSITORY_ITEM_INFO)) < 0 ||
869-
(error = git_str_joinpath(&path, path.ptr, "grafts")) < 0 ||
868+
/* refresh if they've both been opened previously */
869+
if (repo->grafts && repo->shallow_grafts) {
870+
if ((error = git_grafts_refresh(repo->grafts)) < 0 ||
871+
(error = git_grafts_refresh(repo->shallow_grafts)) < 0)
872+
return error;
873+
}
874+
875+
/* resolve info path, which may not be found for inmemory repository */
876+
if ((error = git_repository__item_path(&path, repo, GIT_REPOSITORY_ITEM_INFO)) < 0) {
877+
if (error != GIT_ENOTFOUND)
878+
return error;
879+
880+
/* create empty/inmemory grafts for inmemory repository */
881+
if (!repo->grafts && (error = git_grafts_new(&repo->grafts, repo->oid_type)) < 0)
882+
return error;
883+
884+
if (!repo->shallow_grafts && (error = git_grafts_new(&repo->shallow_grafts, repo->oid_type)) < 0)
885+
return error;
886+
887+
return 0;
888+
}
889+
890+
/* load grafts from disk */
891+
if ((error = git_str_joinpath(&path, path.ptr, "grafts")) < 0 ||
870892
(error = git_grafts_open_or_refresh(&repo->grafts, path.ptr, repo->oid_type)) < 0)
871893
goto error;
872894

0 commit comments

Comments
 (0)