[go: up one dir, main page]

Skip to content
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

Gix incorrectly reports a core.bare=true repo has having a work dir #1683

Closed
cormacrelf opened this issue Nov 17, 2024 · 2 comments · Fixed by #1684
Closed

Gix incorrectly reports a core.bare=true repo has having a work dir #1683

cormacrelf opened this issue Nov 17, 2024 · 2 comments · Fixed by #1684
Labels
acknowledged an issue is accepted as shortcoming to be fixed

Comments

@cormacrelf
Copy link
cormacrelf commented Nov 17, 2024

Current behavior 😯

# /tmp
; git init repo
Initialized empty Git repository in /private/tmp/repo/.git/
# /tmp
; cd repo
# /tmp/repo
; git commit --allow-empty -m 'empty'
[master (root-commit) ca4f799] empty
# /tmp/repo
; git config core.bare true
# /tmp/repo
; git status
fatal: this operation must be run in a work tree
# /tmp/repo
; gix status
 23:58:05 status done 0.0 files in 0.00s (0.0 files/s)

head -> index isn't implemented yet

And

fn main() {
    let repo = gix::open("/tmp/repo").unwrap();
    dbg!(repo.work_dir());
}

should print None, but it's Some("/tmp/repo").

Expected behavior 🤔

Gix status should not succeed. Also, Repository::work_dir() should be None.

Git behavior

Refuses to do worktree-related things if core.bare=true. But please note that core.bare=true is generally not respected when opening the repo from a worktree: https://git-scm.com/docs/git-worktree#_configuration_file

By default, the repository config file is shared across all worktrees. If the config variables core.bare or core.worktree are present in the common config file and extensions.worktreeConfig is disabled, then they will be applied to the main worktree only.

In order to have worktree-specific configuration, you can turn on the worktreeConfig extension, [...]

I couldn't care less about the worktreeConfig extension, seems pretty niche. But "applied to the main worktree only" is the important part.

Steps to reproduce 🕹

See above

@Byron Byron mentioned this issue Nov 17, 2024
2 tasks
@Byron Byron added the acknowledged an issue is accepted as shortcoming to be fixed label Nov 17, 2024
@Byron
Copy link
Member
Byron commented Nov 17, 2024

Thanks a lot for letting me know. I do remember vaguely that I was quite 'flexible' when implementing this, but it felt like for good reason related to worktrees maybe.

Let me try once more, with some additional tests it should be possible to finally get the correct behaviour.

@cormacrelf
Copy link
Author

That was quick! Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
acknowledged an issue is accepted as shortcoming to be fixed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants