File tree Expand file tree Collapse file tree 1 file changed +18
-1
lines changed
Expand file tree Collapse file tree 1 file changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -1674,6 +1674,12 @@ int git_repository__set_objectformat(
16741674 if (oid_type == GIT_OID_DEFAULT )
16751675 return 0 ;
16761676
1677+ if (!git_repository_is_empty (repo ) && repo -> oid_type != oid_type ) {
1678+ git_error_set (GIT_ERROR_REPOSITORY ,
1679+ "cannot change object id type of existing repository" );
1680+ return -1 ;
1681+ }
1682+
16771683 if (git_repository_config__weakptr (& cfg , repo ) < 0 )
16781684 return -1 ;
16791685
@@ -1683,7 +1689,18 @@ int git_repository__set_objectformat(
16831689 git_oid_type_name (oid_type )) < 0 )
16841690 return -1 ;
16851691
1686- repo -> oid_type = oid_type ;
1692+ /*
1693+ * During repo init, we may create some backends with the
1694+ * default oid type. Clear them so that we create them with
1695+ * the proper oid type.
1696+ */
1697+ if (repo -> oid_type != oid_type ) {
1698+ set_index (repo , NULL );
1699+ set_odb (repo , NULL );
1700+ set_refdb (repo , NULL );
1701+
1702+ repo -> oid_type = oid_type ;
1703+ }
16871704
16881705 return 0 ;
16891706}
You can’t perform that action at this time.
0 commit comments