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

Git blame fails when using git-repo for code management #20008

Closed
1 task done
zkun90 opened this issue Oct 31, 2024 · 5 comments
Closed
1 task done

Git blame fails when using git-repo for code management #20008

zkun90 opened this issue Oct 31, 2024 · 5 comments
Labels
bug [core label] git Git integration feedback stale Label used by `stale` action

Comments

@zkun90
Copy link

zkun90 commented Oct 31, 2024

Check for existing issues

  • Completed

Describe the bug / provide steps to reproduce it

I use git-repo to manage multiple git repositories, the .git in the source code is a soft link to the .repo/projects/xxx.git, Zed cannot handle this situation when I use git blame, it will show the error message "Failed to blame "xxx.cpp": git blame process failed: fatal: not a git repository (or any for the parent direcotries): .git".
2024-10-31 16 32 49

Environment

Zed: v0.159.5
OS: macOS 14.5
Memory: 18 GiB
Architecture: aarch64

If applicable, add mockups / screenshots to help explain present your vision of the feature

No response

If applicable, attach your Zed.log file to this issue.

Zed.log
@zkun90 zkun90 added admin read bug [core label] labels Oct 31, 2024
@notpeter
Copy link
Member

What happens when you run git blame src/ble_characteristic.cpp from the root of your project? Because under the hood we are just spawning git blame:

child
.current_dir(working_directory)
.arg("blame")
.arg("--incremental")
.arg("--contents")
.arg("-")

Here's where that is failing:

zed/crates/git/src/blame.rs

Lines 120 to 127 in 0cb056c

if !output.status.success() {
let stderr = String::from_utf8_lossy(&output.stderr);
let trimmed = stderr.trim();
if trimmed == GIT_BLAME_NO_COMMIT_ERROR || trimmed.contains(GIT_BLAME_NO_PATH) {
return Ok(String::new());
}
return Err(anyhow!("git blame process failed: {}", stderr));
}

Could you enumerate the steps necessary to go from a couple empty directories to having the symlinks to git repos necessary to trigger this bug so I can test/reproduce?

@notpeter notpeter added git Git integration feedback and removed triage labels Oct 31, 2024
@zkun90
Copy link
Author

zkun90 commented Nov 1, 2024

What happens when you run git blame src/ble_characteristic.cpp from the root of your project? Because under the hood we are just spawning git blame:

child
.current_dir(working_directory)
.arg("blame")
.arg("--incremental")
.arg("--contents")
.arg("-")

Here's where that is failing:

zed/crates/git/src/blame.rs

Lines 120 to 127 in 0cb056c

if !output.status.success() {
let stderr = String::from_utf8_lossy(&output.stderr);
let trimmed = stderr.trim();
if trimmed == GIT_BLAME_NO_COMMIT_ERROR || trimmed.contains(GIT_BLAME_NO_PATH) {
return Ok(String::new());
}
return Err(anyhow!("git blame process failed: {}", stderr));
}

Could you enumerate the steps necessary to go from a couple empty directories to having the symlinks to git repos necessary to trigger this bug so I can test/reproduce?

git blame works well when I run git blame xxx in the terminal.

Steps to reproduce this issue:

  1. mkdir test
  2. cd test
  3. curl https://raw.githubusercontent.com/zkun90/git-repo/refs/heads/main/repo -o repo
  4. chmod +x repo
  5. export REPO_URL=https://github.com/zkun90/git-repo.git
  6. export REPO_REV=main
  7. ./repo init -u https://github.com/zkun90/test.git -m test.xml -b main
  8. ./repo sync
  9. ./repo start main --all
  10. zed .
    Open workspace/test/test.xml in zed, run "toggle git blame" command.

@can2049
Copy link
Contributor

can2049 commented Nov 15, 2024

in this way, the .git in everyt sub-dir ,is a soft link to .repo inside

Copy link

Hi there! 👋
We're working to clean up our issue tracker by closing older issues that might not be relevant anymore. If you are able to reproduce this issue in the latest version of Zed, please let us know by commenting on this issue, and we will keep it open. If you can't reproduce it, feel free to close the issue yourself. Otherwise, we'll close it in 7 days.
Thanks for your help!

@github-actions github-actions bot added the stale Label used by `stale` action label Mar 18, 2025
Copy link

This issue was closed due to inactivity. If you're still experiencing this problem, please open a new issue with a link to this issue.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Mar 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug [core label] git Git integration feedback stale Label used by `stale` action
Projects
None yet
Development

No branches or pull requests

4 participants