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

Linked gitdirs without commondir file (submodules) don't resolve git dir #482

Closed
1 task done
davidkna opened this issue Aug 16, 2022 · 1 comment · Fixed by #484
Closed
1 task done

Linked gitdirs without commondir file (submodules) don't resolve git dir #482

davidkna opened this issue Aug 16, 2022 · 1 comment · Fixed by #484

Comments

@davidkna
Copy link
Contributor

Duplicates

  • I have searched the existing issues

Current behavior 😯

This causes starship/starship#4266

If a linked git dir does not contain a commondir file, it will be ignored:

let common_dir = private_git_dir.join("commondir");
let common_dir = crate::path::from_plain_file(&common_dir)
.ok_or_else(|| crate::is_git::Error::MissingCommonDir {
missing: common_dir.clone(),
})?
.map_err(|_| crate::is_git::Error::MissingCommonDir { missing: common_dir })?;

I tried replacing it with this, but that caused some test failures I wasn't sure how to best resolve:

            let common_dir = private_git_dir.join(common_dir);
                .and_then(Result::ok)
                .map(|cd| private_git_dir.join(cd))
                .unwrap_or_else(|| private_git_dir.clone());

This means that for git submodules, the git dir ends up resolving to mysubmodule/.git instead of .git/modules/mysubmodule.

Expected behavior 🤔

Git submodule .git-files resolve to the referenced location.

Steps to reproduce 🕹

  1. Attempt to open a submodule directory
  2. Inspect .git_dir()
@Byron
Copy link
Owner

Byron commented Aug 16, 2022

Thanks a lot! It would have been lucky if this would have worked out of the box, as it was never tested.

This should change though, and I plan to remedy this soon, hoping that a test or two with submodules can help making the necessary adjustments without having to support submodules fully. Let's see :D.

Byron added a commit that referenced this issue Aug 17, 2022
…ough. (#482)

We currently detect them as possibly bare, which could be improved if we
allow ourselves to see `.git/modules` as `submodule` always.
Byron added a commit that referenced this issue Aug 17, 2022
Byron added a commit that referenced this issue Aug 17, 2022
Byron added a commit that referenced this issue Aug 17, 2022
Byron added a commit that referenced this issue Aug 17, 2022
Byron added a commit that referenced this issue Aug 17, 2022
…#482)

That way we can avoid feeding `.git` files to `git-repository::open()`
and avoid work duplication, which ultimately allows to open submodules
directories of all kinds.
Byron added a commit that referenced this issue Aug 17, 2022
Byron added a commit that referenced this issue Aug 17, 2022
This includes submodule checkouts as well as their original module git
directories.
Byron added a commit that referenced this issue Aug 17, 2022
Byron added a commit that referenced this issue Aug 17, 2022
This should complete the list of git repository types and flavors.
Byron added a commit that referenced this issue Aug 17, 2022
…482)

It's actually used by `ein t organize` so we should keep it, and it's
probably useful
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants