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

Fix opening repos when .git is a soft link #21153

Conversation

can2049
Copy link
Contributor

@can2049 can2049 commented Nov 25, 2024

Closes #ISSUE

background

If a project is big, some times it will be splited into many small git repos.
google repo is a tool to manage a group of git repos.

But, any small git repo manged by this tool, have a difference with normal git repo.
That is , the path .git in the root of the git repo, is not a normal directory, but a soft link to real git bare dir.

zed can not recognize the git-repo managed git repos

you can use the procedure to genreate this problem

# tested on linux
mkdir -p bad_git_repo_project
cd bad_git_repo_project
git init
echo "hello" > hi.txt
git add .
git commit -m "init commit"
echo "hello world" >> hi.txt

# modify the repo
mv .git ../.real_git_repo
ln -sf ../.real_git_repo .git

with vscode, after opening this project, git works well.
but for Zed, git not work(not git status, no git blame)

how to fix

libgit2 can recognize git repo from the root of the project(dir that have .git).
so, we can recognize the git project by opening from the project root dir, but not the .git dir

This fix also works with normal git project.

before fix

image

after fix

image

Release Notes:

  • Fix opening repos when .git is a soft link

@maxdeviant maxdeviant changed the title fix: cannot recognize a project that .git is soft link Fix opening repos when .git is a soft link Nov 25, 2024
@can2049
Copy link
Contributor Author

can2049 commented Nov 25, 2024

@cla-bot check

@SomeoneToIgnore SomeoneToIgnore added the cla-signed The user has signed the Contributor License Agreement label Nov 25, 2024
@zed-industries-bot
Copy link

zed-industries-bot commented Nov 25, 2024

Warnings
⚠️

This PR is missing release notes.

Please add a "Release Notes" section that describes the change:

Release Notes:

- Added/Fixed/Improved ...

If your change is not user-facing, you can use "N/A" for the entry:

Release Notes:

- N/A

Generated by 🚫 dangerJS against fc22e7e

@can2049
Copy link
Contributor Author

can2049 commented Nov 25, 2024

@maxbrunsfeld can you help me review this change?

@can2049 can2049 force-pushed the can/fix_not_recognize_git_repo_that_dot_git_is_soft_link_1125 branch from 9ca1803 to 06dccc5 Compare November 27, 2024 11:17
Copy link

cla-bot bot commented Nov 27, 2024

Thank you for your pull request and welcome to our community. We could not parse the GitHub identity of the following contributors: CanWang.
This is most likely caused by a git client misconfiguration; please make sure to:

  1. check if your git client is configured with an email to sign commits git config --list | grep email
  2. If not, set it up using git config --global user.email [email protected]
  3. Make sure that the git commit email is configured in your GitHub account settings, see https://github.com/settings/emails

@cla-bot cla-bot bot removed the cla-signed The user has signed the Contributor License Agreement label Nov 27, 2024
@can2049 can2049 force-pushed the can/fix_not_recognize_git_repo_that_dot_git_is_soft_link_1125 branch from 06dccc5 to 0f1c680 Compare November 27, 2024 11:21
@cla-bot cla-bot bot added the cla-signed The user has signed the Contributor License Agreement label Nov 27, 2024
@can2049 can2049 force-pushed the can/fix_not_recognize_git_repo_that_dot_git_is_soft_link_1125 branch 2 times, most recently from edb9813 to 21bcfdc Compare December 4, 2024 02:29
@can2049 can2049 force-pushed the can/fix_not_recognize_git_repo_that_dot_git_is_soft_link_1125 branch from 21bcfdc to 0fdc8c0 Compare December 6, 2024 09:47
Copy link
Member

@mikayla-maki mikayla-maki left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's add a comment documenting why we use the parent directory here, including a link to the libgit2 documentation:

https://libgit2.org/docs/reference/main/repository/git_repository_open.html

@can2049
Copy link
Contributor Author

can2049 commented Dec 7, 2024

Let's add a comment documenting why we use the parent directory here, including a link to the libgit2 documentation:

https://libgit2.org/docs/reference/main/repository/git_repository_open.html

comment added

@can2049 can2049 requested a review from mikayla-maki December 7, 2024 12:32
@mikayla-maki
Copy link
Member

Thank you!

@mikayla-maki mikayla-maki merged commit e0cbbf8 into zed-industries:main Dec 13, 2024
13 checks passed
@can2049 can2049 deleted the can/fix_not_recognize_git_repo_that_dot_git_is_soft_link_1125 branch January 16, 2025 08:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla-signed The user has signed the Contributor License Agreement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants