Repository navigation
Conversation
git_repository_init_ext passed its GIT_REPOSITORY_INIT_* flags to is_valid_repository_path, which expects GIT_REPOSITORY_OPEN_* flags. GIT_REPOSITORY_INIT_MKPATH, which git_repository_init always sets, has the value of GIT_REPOSITORY_OPEN_FROM_ENV, so initializing a repository took the common directory from GIT_COMMON_DIR. With GIT_COMMON_DIR set, reinitializing an existing repository looked for it in the wrong place, and repo::init::reinit_nondefault_version and two more tests fail. Add a test that reinitializes a repository with GIT_COMMON_DIR pointing elsewhere.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
git_repository_init_extpassesopts->flags, which areGIT_REPOSITORY_INIT_*flags, tois_valid_repository_path, which expectsGIT_REPOSITORY_OPEN_*flags. The two enums share bit values:GIT_REPOSITORY_INIT_MKPATHandGIT_REPOSITORY_OPEN_FROM_ENVare both1 << 4.git_repository_initalways setsMKPATH, andgit_repository_init_extpasses it on whenever the caller sets it, so init takes the common directory fromGIT_COMMON_DIR. WithGIT_COMMON_DIRpointing elsewhere, an existing repository is not recognized, and reinitializing it resets its configuration:core.repositoryformatversiongoes back to 0, an unsupported version is not rejected, andcore.ignorecaseis removed.is_valid_repository_pathreads no other open flag, and no init flag asks for the environment, so the commit passes 0, asgit_repository_open_baredoes. This restores the behaviour before #6544, which added the flags argument.A question on the same mix-up, which I left alone:
repo_init_configalso tests the init flags forGIT_REPOSITORY_OPEN_FROM_ENVto getuse_env(also from #6544). Sogit_repository_initalways runs withuse_envset, andgit_repository_init_extdoes whenever the caller setsMKPATH. As far as I can see,use_envmatters there only on Windows:are_symlinks_supportedthen readscore.symlinksfrom the system and global config, anduse_envdecides whetherGIT_CONFIG_NOSYSTEM,GIT_CONFIG_SYSTEMandGIT_CONFIG_GLOBALchoose those files. Should init honor these variables always, never, or through an init flag of its own? I'm happy to change it either way.To reproduce (on
main, 42a89d7)GIT_COMMON_DIR=/tmp/x build/libgit2_tests -srepo::init # reinit_nondefault_version, reinit_unsupported_version, reinit_doesnot_overwrite_ignorecaseTesting
The commit adds
repo::init::reinit_ignores_common_dir_env: it setsGIT_COMMON_DIRto a directory that does not exist, reinitializes a repository with a non-default format version, checks that the version is kept, and restoresGIT_COMMON_DIRin the suite's cleanup. Without the fix it fails (1 != 0), whatever the environment.With the commit,
repo::initpasses withGIT_COMMON_DIRunset and set, and the command above passes. The offline suite (-xonline -xstress, Debug build, Linux) passes exceptcore::structinit::compare, which fails on my machine without the commit too.