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

VCS for git doesn't appear in worktree checkouts #816

Closed
cujomalainey opened this issue Jun 11, 2020 · 24 comments
Closed

VCS for git doesn't appear in worktree checkouts #816

cujomalainey opened this issue Jun 11, 2020 · 24 comments

Comments

@cujomalainey
Copy link

The git status does not show up if you are in a work tree checkout.

See documentation here https://git-scm.com/docs/git-worktree

My guess is the system is confused by the fact that .git is a file not a folder and just ignoring it.

@romkatv
Copy link
Owner

romkatv commented Jun 11, 2020

Could you list the exact commands necessary to reproduce this?

@cujomalainey
Copy link
Author

I am only able to reproduce this so far with a chromiumos checkout using worktrees.

https://chromium.googlesource.com/chromiumos/docs/+/master/developer_guide.md#Get-the-source-code

if you add --worktree to the repo init command then none of the repos will have their git status after a sync

@romkatv
Copy link
Owner

romkatv commented Jun 12, 2020

Here's what I've tried:

git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git ~/depot_tools
path=(~/depot_tools $path)
mkdir ~/chromiumos
cd ~/chromiumos
repo init -u https://chromium.googlesource.com/chromiumos/manifest.git --repo-url https://chromium.googlesource.com/external/repo.git --worktree
repo sync -j4
cd ~/chromiumos/src/chromium/src/tools/md_browser

This gave me @be8cf5a1 in prompt -- the same as git rev-parse HEAD.

Which commands do I need to run to reproduce this problem?

@cujomalainey
Copy link
Author

Hmm, that should have reproduced it. Is there any sort of debug I can dump to help identify the issue?

@romkatv
Copy link
Owner

romkatv commented Jun 12, 2020

I've reproduced it. I think on my previous attempt I've either forgot to pass --worktree or it didn't work somehow.

Powerlevel10k uses gitstatus, and gitstatus for historical reasons relies on libgit2 for non-performance-critical operations, and that includes opening repositories. libgit2 cannot open repositories with extensions.worktreeconfig extension.

Powerlevel10k will start supporting your use case when gitstatus start supporting it. The latter will happen either when libgit2 starts supporting extensions.worktreeconfig or when more users ask for this feature (in this case I'll implement it myself).

Edit: I won't be implementing this myself.

@romkatv romkatv closed this as completed Jun 12, 2020
@cujomalainey
Copy link
Author

Thanks for the detailed explanation.

@ericu65
Copy link

ericu65 commented Jan 13, 2021

+1 for this

Compiling and using the latest gitstatusd still shows:

[2021-01-13 12:23:42 0000000109791e00 INFO src/gitstatus.cc:192] Processing request: "1610533422.0786039829 _p9k_vcs_resume 0" for "/Users/eric/Code/cc_source" [no-diff]
[2021-01-13 12:23:42 0000000109791e00 ERROR src/repo_cache.cc:66] git_repository_open_ext: "/Users/eric/Code/cc_source/.git/": unsupported extension name extensions.worktreeconfig
[2021-01-13 12:23:42 0000000109791e00 INFO src/response.cc:69] Replying without git status
[2021-01-13 12:23:42 0000000109791e00 INFO src/timer.cc:64] Timing for: request: 0.624ms cpu
[2021-01-13 12:23:42 0000000109791e00 ERROR src/gitstatus.cc:197] Error processing request: "1610533422.0786039829 _p9k_vcs_resume 0" for "/Users/eric/Code/cc_source" [no-diff]

Strange thing is that I am not using worktrees but I am using sparse-checkout. I will open a case on gitstatusd for this.

@romkatv
Copy link
Owner

romkatv commented Jan 13, 2021

Strange thing is that I am not using worktrees but I am using sparse-checkout. I will open a case on gitstatusd for this.

No need. #816 (comment) still applies except that I won't be adding support for extensions.worktreeconfig in libgit2 myself.

@seanabraham
Copy link

Thanks for the detail on this. Is this the appropriate issue on the libgit2 side to track: libgit2/libgit2#6044

@romkatv
Copy link
Owner

romkatv commented Sep 20, 2021

@seanabraham I don’t know.

fei6409 added a commit to fei6409/dotfiles that referenced this issue Apr 1, 2022
Since the embedded vcs/gitstatus in p10k doesn't work for git worktree.
The custom prompt is ported from p10k.zsh my_git_formatter.

See romkatv/powerlevel10k#816 for detail.
@urwrstkn8mare
Copy link

Would it be very hard to add a fallback? i.e. If the extensions.worktreeconfig extension is found, use something else that does support it?

@romkatv
Copy link
Owner

romkatv commented Apr 24, 2023

Very hard? Probably not. For someone with the level of zsh experience similar to my own it would probably take no more than 40 hours.

@urwrstkn8mare
Copy link

Is that something that you would accept in your project? I could try and give it ago but my experience in zsh is close to nothing.

@romkatv
Copy link
Owner

romkatv commented Apr 24, 2023

Is that something that you would accept in your project?

If someone submits a clean PR (no bugs, good performance, matches the style and architecture of the existing code, etc.), I'll merge it.

@joaotavora
Copy link

or when more users ask for this feature (in this case I'll implement it myself).

Well, count me as one. ;-)

Curiously, I'm only having this problem for sparse repos, not for worktrees. That seems to be working fine

@urwrstkn8mare
Copy link

Yeah same here

@romkatv
Copy link
Owner

romkatv commented May 23, 2023

See #816 (comment) above. No need to post "me too" comments.

@urwrstkn8mare
Copy link

Oh sorry about that, I was aiming to just confirm that it is effecting only sparse repos but I see it was unnecessary.

@joepvl
Copy link

joepvl commented Aug 14, 2023

FWIW: I had this problem up to Git 2.39, but I recently started using microsoft/git with a large monorepo I'm working on, and now both the branch name and the status indicator shorthand (e.g. !1) are showing in all my worktrees. I'm not sure if it's because of the later Git version (2.40) or because of Microsoft's additions, but I'm not complaining.
EDIT it has since stopped working again unfortunately. My setup hasn't structurally changed but the repo has grown.

@art3xias23
Copy link

@joepvl

I'm on Windows with WSL2 with Debian and just updated git for windows to version 2.42.0

Unfortunately, still not seeing branch name and status indicator for worktrees.

@romkatv
Copy link
Owner

romkatv commented Oct 20, 2023

Please don't post "me too" comments here. They aren't helpful.

@joaotavora
Copy link

Please don't post "me too" comments here. They aren't helpful.

The clean reproducer that someone just added and someone just deleted was certainly helpful

@fei6409
Copy link

fei6409 commented Apr 3, 2024

It looks like the extensions.worktreeconfig support was added recently: libgit2/libgit2#6044

@joepvl
Copy link

joepvl commented May 29, 2024

FWIW: I had this problem up to Git 2.39, but I recently started using microsoft/git with a large monorepo I'm working on, and now both the branch name and the status indicator shorthand (e.g. !1) are showing in all my worktrees. I'm not sure if it's because of the later Git version (2.40) or because of Microsoft's additions, but I'm not complaining. EDIT it has since stopped working again unfortunately. My setup hasn't structurally changed but the repo has grown.

Update on this: it still doesn't work... in iTerm2. Even on a new machine with fresh installs of both iTerm2 and p10k, the repo I work on has this problem. It works fine in other terminal emulators I've tried on macOS — Terminal.app, WezTerm, Alacritty, even Warp. I've personally switched to WezTerm full time and am no longer experiencing issues. I don't know if the problem is with iTerm2 itself or the way p10k (internals and/or dependencies) acts when it detects it's being run in iTerm2. 🤷

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

No branches or pull requests

9 participants