8000 Bypass shallow clone support for in-memory repositories by kcsaul · Pull Request #6684 · libgit2/libgit2 · GitHub
[go: up one dir, main page]

Skip to content

Bypass shallow clone support for in-memory repositories #6684

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 20, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 24 additions & 2 deletions src/libgit2/repository.c
Original file line number Diff line number Diff line change
Expand Up @@ -865,8 +865,30 @@ static int load_grafts(git_repository *repo)
git_str path = GIT_STR_INIT;
int error;

if ((error = git_repository__item_path(&path, repo, GIT_REPOSITORY_ITEM_INFO)) < 0 ||
(error = git_str_joinpath(&path, path.ptr, "grafts")) < 0 ||
/* refresh if they've both been opened previously */
if (repo->grafts && repo->shallow_grafts) {
if ((error = git_grafts_refresh(repo->grafts)) < 0 ||
(error = git_grafts_refresh(repo->shallow_grafts)) < 0)
return error;
}

/* resolve info path, which may not be found for inmemory repository */
if ((error = git_repository__item_path(&path, repo, GIT_REPOSITORY_ITEM_INFO)) < 0) {
if (error != GIT_ENOTFOUND)
return error;

/* create empty/inmemory grafts for inmemory repository */
if (!repo->grafts && (error = git_grafts_new(&repo->grafts, repo->oid_type)) < 0)
return error;

if (!repo->shallow_grafts && (error = git_grafts_new(&repo->shallow_grafts, repo->oid_type)) < 0)
return error;

return 0;
}

/* load grafts from disk */
if ((error = git_str_joinpath(&path, path.ptr, "grafts")) < 0 ||
(error = git_grafts_open_or_refresh(&repo->grafts, path.ptr, repo->oid_type)) < 0)
goto error;

Expand Down
0