@@ -177,7 +177,7 @@ static int needs_work_tree_config(const char *git_dir, const char *work_tree)
177177}
178178
179179static int create_default_files (const char * template_path ,
180- const char * original_git_dir )
180+ const char * original_git_dir , int flags )
181181{
182182 struct stat st1 ;
183183 struct strbuf buf = STRBUF_INIT ;
@@ -226,8 +226,6 @@ static int create_default_files(const char *template_path,
226226 * We need to create a "refs" dir in any case so that older
227227 * versions of git can tell that this is a repository.
228228 */
229- safe_create_dir (git_path ("refs" ), 1 );
230- adjust_shared_perm (git_path ("refs" ));
231229
232230 if (refs_init_db (& err ))
233231 die ("failed to set up refs db: %s" , err .buf );
@@ -236,17 +234,24 @@ static int create_default_files(const char *template_path,
236234 * Create the default symlink from ".git/HEAD" to the "master"
237235 * branch, if it does not exist yet.
238236 */
239- path = git_path_buf (& buf , "HEAD" );
240- reinit = (!access (path , R_OK )
241- || readlink (path , junk , sizeof (junk )- 1 ) != -1 );
237+ if (flags & INIT_DB_REFTABLE ) {
238+ reinit = 0 ; /* XXX - how do we recognize a reinit,
239+ * and what should we do? */
240+ } else {
241+ path = git_path_buf (& buf , "HEAD" );
242+ reinit = (!access (path , R_OK ) ||
243+ readlink (path , junk , sizeof (junk ) - 1 ) != -1 );
244+ }
245+
242246 if (!reinit ) {
243247 if (create_symref ("HEAD" , "refs/heads/master" , NULL ) < 0 )
244248 exit (1 );
245249 }
246250
247251 /* This forces creation of new config file */
248- xsnprintf (repo_version_string , sizeof (repo_version_string ),
249- "%d" , GIT_REPO_VERSION );
252+ xsnprintf (repo_version_string , sizeof (repo_version_string ), "%d" ,
253+ flags & INIT_DB_REFTABLE ? GIT_REPO_VERSION_READ :
254+ GIT_REPO_VERSION );
250255 git_config_set ("core.repositoryformatversion" , repo_version_string );
251256
252257 /* Check filemode trustability */
@@ -380,7 +385,7 @@ int init_db(const char *git_dir, const char *real_git_dir,
380385 */
381386 check_repository_format ();
382387
383- reinit = create_default_files (template_dir , original_git_dir );
388+ reinit = create_default_files (template_dir , original_git_dir , flags );
384389
385390 create_object_directory ();
386391
@@ -405,6 +410,10 @@ int init_db(const char *git_dir, const char *real_git_dir,
405410 git_config_set ("receive.denyNonFastforwards" , "true" );
406411 }
407412
413+ if (flags & INIT_DB_REFTABLE ) {
414+ git_config_set ("extensions.refStorage" , "reftable" );
415+ }
416+
408417 if (!(flags & INIT_DB_QUIET )) {
409418 int len = strlen (git_dir );
410419
@@ -483,15 +492,18 @@ int cmd_init_db(int argc, const char **argv, const char *prefix)
483492 const char * template_dir = NULL ;
484493 unsigned int flags = 0 ;
485494 const struct option init_db_options [] = {
486- OPT_STRING (0 , "template" , & template_dir , N_ ("template-directory" ),
487- N_ ("directory from which templates will be used" )),
495+ OPT_STRING (0 , "template" , & template_dir ,
496+ N_ ("template-directory" ),
497+ N_ ("directory from which templates will be used" )),
488498 OPT_SET_INT (0 , "bare" , & is_bare_repository_cfg ,
489- N_ ("create a bare repository" ), 1 ),
499+ N_ ("create a bare repository" ), 1 ),
490500 { OPTION_CALLBACK , 0 , "shared" , & init_shared_repository ,
491- N_ ("permissions" ),
492- N_ ("specify that the git repository is to be shared amongst several users" ),
493- PARSE_OPT_OPTARG | PARSE_OPT_NONEG , shared_callback , 0 },
501+ N_ ("permissions" ),
502+ N_ ("specify that the git repository is to be shared amongst several users" ),
503+ PARSE_OPT_OPTARG | PARSE_OPT_NONEG , shared_callback , 0 },
494504 OPT_BIT ('q' , "quiet" , & flags , N_ ("be quiet" ), INIT_DB_QUIET ),
505+ OPT_BIT (0 , "reftable" , & flags , N_ ("use reftable" ),
506+ INIT_DB_REFTABLE ),
495507 OPT_STRING (0 , "separate-git-dir" , & real_git_dir , N_ ("gitdir" ),
496508 N_ ("separate git dir from working tree" )),
497509 OPT_END ()
0 commit comments