File tree Expand file tree Collapse file tree 3 files changed +18
-8
lines changed
Expand file tree Collapse file tree 3 files changed +18
-8
lines changed Original file line number Diff line number Diff line change @@ -44,18 +44,15 @@ int git_grafts_new(git_grafts **out, git_oid_t oid_type)
4444 return 0 ;
4545}
4646
47- int git_grafts_from_file (
47+ int git_grafts_open (
4848 git_grafts * * out ,
4949 const char * path ,
5050 git_oid_t oid_type )
5151{
5252 git_grafts * grafts = NULL ;
5353 int error ;
5454
55- GIT_ASSERT_ARG (path && oid_type );
56-
57- if (* out )
58- return git_grafts_refresh (* out );
55+ GIT_ASSERT_ARG (out && path && oid_type );
5956
6057 if ((error = git_grafts_new (& grafts , oid_type )) < 0 )
6158 goto error ;
@@ -67,12 +64,24 @@ int git_grafts_from_file(
6764 goto error ;
6865
6966 * out = grafts ;
67+
7068error :
7169 if (error < 0 )
7270 git_grafts_free (grafts );
71+
7372 return error ;
7473}
7574
75+ int git_grafts_open_or_refresh (
76+ git_grafts * * out ,
77+ const char * path ,
78+ git_oid_t oid_type )
79+ {
80+ GIT_ASSERT_ARG (out && path && oid_type );
81+
82+ return * out ? git_grafts_refresh (* out ) : git_grafts_open (out , path , oid_type );
83+ }
84+
7685void git_grafts_free (git_grafts * grafts )
7786{
7887 if (!grafts )
Original file line number Diff line number Diff line change @@ -20,7 +20,8 @@ typedef struct {
2020typedef struct git_grafts git_grafts ;
2121
2222int git_grafts_new (git_grafts * * out , git_oid_t oid_type );
23- int git_grafts_from_file (git_grafts * * out , const char * path , git_oid_t oid_type );
23+ int git_grafts_open (git_grafts * * out , const char * path , git_oid_t oid_type );
24+ int git_grafts_open_or_refresh (git_grafts * * out , const char * path , git_oid_t oid_type );
2425void git_grafts_free (git_grafts * grafts );
2526void git_grafts_clear (git_grafts * grafts );
2627
Original file line number Diff line number Diff line change @@ -852,13 +852,13 @@ static int load_grafts(git_repository *repo)
852852
853853 if ((error = git_repository__item_path (& path , repo , GIT_REPOSITORY_ITEM_INFO )) < 0 ||
854854 (error = git_str_joinpath (& path , path .ptr , "grafts" )) < 0 ||
855- (error = git_grafts_from_file (& repo -> grafts , path .ptr , repo -> oid_type )) < 0 )
855+ (error = git_grafts_open_or_refresh (& repo -> grafts , path .ptr , repo -> oid_type )) < 0 )
856856 goto error ;
857857
858858 git_str_clear (& path );
859859
860860 if ((error = git_str_joinpath (& path , repo -> gitdir , "shallow" )) < 0 ||
861- (error = git_grafts_from_file (& repo -> shallow_grafts , path .ptr , repo -> oid_type )) < 0 )
861+ (error = git_grafts_open_or_refresh (& repo -> shallow_grafts , path .ptr , repo -> oid_type )) < 0 )
862862 goto error ;
863863
864864error :
You can’t perform that action at this time.
0 commit comments