-
Notifications
You must be signed in to change notification settings - Fork 533
Calculate the default for index relative to git_dir instead of work_tree #490
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
I want to thank you for taking the time and trying to resolve this, but with all due respect, your creating a synthetic test based on your thinking about the topic which might not correlate to a real world one, while also I provided for you 2 real world test cases of a submodule and a worktree. This code https://github.com/ruby-git/ruby-git/blob/master/lib/git/base.rb#L58-L65 was way closer to understanding the core issue, when these features are used, the Also unless adding these special parameters, under normal Is it reasonable for me to claim that for a solution to be correct it should pass both real examples for a submodule and a worktree? (I don't know how partial steps fwd look like, maybe at least one should work?) |
Well I guess if the whole context you had in mind is of manual usage of these switches you'd probably be right with this... Maybe that's step one 🤔 |
I agree. The tests in this PR were not meant to address the submodule / worktree issues you brought up in #488 and #489 . I was only trying to demonstrate that using I have really enjoyed interacting with you on these PRs. I will get to the submodule / worktree issues but I just haven't had enough time to get to it yet. I have confidence that we will make it work. I'd like to merge this PR to master because it tests the public interface as it currently exists and how it is currently documented. I think that is important. Would you 👍 this PR? |
I think I'm digesting in waves... |
As a type of documentation for what currently exists it's an ok patch. 👍 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tiny step fwd, document with tests what's there 🤷
It might make sense to also document this somehow in words... like the README as part of this patch.. |
I've been wanting to add comprehensive Yard documentation but it doesn't seem to be top priority. |
Ok, I think I see the issue with the I'll have to test some. It seems like a lot of code relies on this value being set to something non-nil. I think this will preserving existing functionality (allowing separate --work-tree and --git-dir settings) along with working trees and submodules. I plan on making those changes in this PR. |
One real world use I know of for having the Another real world example where this might prove useful is this: https://www.atlassian.com/git/tutorials/dotfiles |
OK, another layer of the git onion I guess... just when you think you half get it. So basically I should think of what I know as a "git directory" as 3 components
Does this kinda align to the git_dir, work_dir and index we try to manage in the Git object? (not sure about the 3rd part and what about other things that aren't the index, or what exactly is the index) So for the example you mention and if my understanding is correct, could I not just have one directory setup as bare git, Or the main difference is that we actually share that one transaction log, anything I'd do doesn't need a push, it's just changed for everyone basically if we use some share fs thingy. I think my main point for simplifying is not using these parameters if they weren't explicitly requested by the user, so if people don't use these advance setups of manually managing the special directories, the git shell command used shouldn't add them. So advance use cases should be the special use cases not the normal because they are versatile. I'm sure most users won't set these parameters. The common use of So basically the worktree feature extends the work directory feature which used to be 1:1, or allowed multiple with these advance parameter and just offers it in simpler commands? while adding central tracking I guess that didn't exist... |
Signed-off-by: James Couball <jcouball@yahoo.com>
@hatkyinc2 with these changes, I believe this gets past the problem in #489 of calling Git.open. I do still get an error:
|
I've had these errors as well plenty.. |
Here is how I think of it: working tree repository This is, for example, what GitHub stores on it's servers. When you Many companies use Git internally and serve the bare repositories via ssh. This is probably a big use case of using index |
is the index fully self contained file? or is index concept actually a directory that looks a bit like a repository? |
@hatkyinc2 do you Slack? I just created ruby-git.slack.com. Join if you want to chat. |
can't join that slack, can you invite me to my main email, without the |
Should the |
I lost my working copy of this change so I created PR #499 for this change. |
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.