File tree 1 file changed +20
-2
lines changed 1 file changed +20
-2
lines changed Original file line number Diff line number Diff line change @@ -1032,7 +1032,8 @@ int git_repository_open_ext(
1032
1032
goto cleanup ;
1033
1033
}
1034
1034
1035
- if ((error = load_objectformat (repo , config )) < 0 )
1035
+ if (version > 0 &&
1036
+ (error = load_objectformat (repo , config )) < 0 )
1036
1037
goto cleanup ;
1037
1038
1038
1039
/*
@@ -1670,6 +1671,12 @@ int git_repository__set_objectformat(
1670
1671
if (oid_type == GIT_OID_DEFAULT )
1671
1672
return 0 ;
1672
1673
1674
+ if (!git_repository_is_empty (repo ) && repo -> oid_type != oid_type ) {
1675
+ git_error_set (GIT_ERROR_REPOSITORY ,
1676
+ "cannot change object id type of existing repository" );
1677
+ return -1 ;
1678
+ }
1679
+
1673
1680
if (git_repository_config__weakptr (& cfg , repo ) < 0 )
1674
1681
return -1 ;
1675
1682
@@ -1679,7 +1686,18 @@ int git_repository__set_objectformat(
1679
1686
git_oid_type_name (oid_type )) < 0 )
1680
1687
return -1 ;
1681
1688
1682
- repo -> oid_type = oid_type ;
1689
+ /*
1690
+ * During repo init, we may create some backends with the
1691
+ * default oid type. Clear them so that we create them with
1692
+ * the proper oid type.
1693
+ */
1694
+ if (repo -> oid_type != oid_type ) {
1695
+ set_index (repo , NULL );
1696
+ set_odb (repo , NULL );
1697
+ set_refdb (repo , NULL );
1698
+
1699
+ repo -> oid_type = oid_type ;
1700
+ }
1683
1701
1684
1702
return 0 ;<
3D68
/div>
1685
1703
}
You can’t perform that action at this time.
0 commit comments