Calculate the default for index relative to git_dir instead of work_tree #499
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.
Your checklist for this pull request
🚨Please review the guidelines for contributing to this repository.
Description
index
when not given, defaults to"#{work_tree}/.git/index"
. This only works as long asgit_dir
is"#{work_tree}/.git"
. In the general case, theindex
default should be#{git_dir}/index
.This PR adds two tests:
TestGitDir#test_index_calculated_from_git_dir
which tests thatindex
is calculated correctly whengit_dir
is not"#{work_tree}/.git/index"
TestGitDir#test_git_dir_outside_work_tree
which tests that whengit_dir
is in a non-standard location, Git.open and option functions work.Fix the case in
Base#open
where the--git-dir
is a file as is the case with Submodules and (non-main) Worktrees. This case was handled forBase.init
but notBase.open
.tests/test_helper.rb
was changed so that MiniTest classes that do not callset_file_paths
do not output a warning because@tmp_path
is referenced without being defined.