File tree Expand file tree Collapse file tree 1 file changed +24
-2
lines changed Expand file tree Collapse file tree 1 file changed +24
-2
lines changed Original file line number Diff line number Diff line change @@ -865,8 +865,30 @@ static int load_grafts(git_repository *repo)
865
865
git_str path = GIT_STR_INIT ;
866
866
int error ;
867
867
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 ||
870
892
(error = git_grafts_open_or_refresh (& repo -> grafts , path .ptr , repo -> oid_type )) < 0 )
871
893
goto error ;
872
894
You can’t perform that action at this time.
0 commit comments