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

[BUG][git_status][git_metrics] With Worktree. Status displays as if all files are gone #6417

Open
alexrecuenco opened this issue Nov 27, 2024 · 2 comments
Labels
🐛 bug Something isn't working as expected.

Comments

@alexrecuenco
Copy link

alexrecuenco commented Nov 27, 2024

Current Behavior

First of all, I love starship

Steps to reproduce

  1. I have a project new-workspace that contains some submodules
  2. I created from one of these submodules called code a new worktree
  3. For example git worktree add ../../corp/worktree/deleteme temp
  4. I change directory to this worktree
  5. All the git status shows as if every file was deleted

In my terminal, git status works fine! (And vscode also reports this with no issues)

However starship reports like this:

..../worktree/code on  main -664219 [$8✘2839?17] via  v23.2.0 via 🐍 v3.11.10 via 💎 v2.7.5

Again, git status reports empty (See below, I tried a few times)

Expected Behavior

code on  main [$8] via  v23.2.0 via 🐍 v3.11.10 via 💎 v2.7.5

Additional context/Screenshots

Screenshot 2024-11-27 at 8 56 33 PM Screenshot 2024-11-27 at 8 56 23 PM
Logs
esave/worktree/code on  main -664219 [$8✘2839?17] via  v23.2.0 via 🐍 v3.11.10 via 💎 v2.7.5 
❯ cat .git
gitdir: /Volumes/Workspace/new-workspace/.git/modules/code/worktrees/code

corp/worktree/code on  main -664219 [$8✘2839?17] via  v23.2.0 via 🐍 v3.11.10 via 💎 v2.7.5 
❯ git status
On branch main
Your branch is up to date with 'origin/main'.

nothing to commit, working tree clean

corp/worktree/code on  main -664219 [$8✘2839?17] via  v23.2.0 via 🐍 v3.11.10 via 💎 v2.7.5 
❯ starship bug-report
pkg_version:1.21.1
branch:
...
corp/worktree/code on  main -664219 [$8✘2839?17] via  v23.2.0 via 🐍 v3.11.10 via 💎 v2.7.5 
❯ open ../..

corp/worktree/code on  main -664219 [$8✘2839?17] via  v23.2.0 via 🐍 v3.11.10 via 💎 v2.7.5 
❯ cd ..

Workspace/corp/worktree 
❯ cd ..

/Volumes/Workspace/corp 
❯ cd ..

/Volumes/Workspace 
❯ cd ..

/Volumes🔒 
❯ cd ..

Possible Solution

I have no idea

Environment

  • Starship version: 1.21.1
  • zsh version: zsh 5.9 (arm64-apple-darwin24.0)
  • Operating system: Mac OS 15.1.0
  • Terminal emulator: vscode 1.95.3
  • Git Commit Hash:
  • Branch/Tag:
  • Rust Version: rustc 1.81.0 (eeb90cda1 2024-09-04) (Homebrew)
  • Rust channel: release
  • Build Time: 2024-10-18 16:27:23 +00:00

I minimized my configurations to the minimum reproducible set

Relevant Shell Configuration

if type brew &>/dev/null
then
  FPATH="$(brew --prefix)/share/zsh/site-functions:${FPATH}"

  # HOMEBREW ENVIRONMENT

  HOMEBREW_NO_INSECURE_REDIRECT=1
  HOMEBREW_NO_ANALYTICS=1
  # For WORK computers otherwise it can screw you
  HOMEBREW_NO_AUTO_UPDATE=1

  # If completions stopped working properly rm -f ~/.zcompdump; compinit
fi

export VIRTUAL_ENV_DISABLE_PROMPT=1
if type starship &>/dev/null
then
  eval "$(starship init zsh)"
fi

Starship Configuration

[git_metrics]
disabled = false
ignore_submodules = true
[git_status]
conflicted = "=${count}"
untracked = "?${count}"
stashed = "\\$${count}"
modified = "!${count}"
staged = "+${count}"
renamed = "»${count}"
deleted = "✘${count}"
ahead = '⇡${count}'
behind = '⇣${count}'
diverged = '⇕⇡${ahead_count}⇣${behind_count}'
@alexrecuenco alexrecuenco added the 🐛 bug Something isn't working as expected. label Nov 27, 2024
@davidkna
Copy link
Member

Please post the output of STARSHIP_LOG=trace starship module git_metrics

@alexrecuenco
Copy link
Author

Here are the results.

I navigated a bit the folders that starship provided hoping that would help as well debug it.

Logs running `STARSHIP_LOG=trace starship module git_metrics`
esave/worktree/code on  pin-image-sha -665292 [$9✘2850?18] via  v23.2.0 via 🐍 v3.13.0 via 💎 v2.7.5 
❯ STARSHIP_LOG=trace starship module git_metrics
[TRACE] - (starship): Parsed arguments: Cli {
    command: Module {
        name: Some(
            "git_metrics",
        ),
        list: false,
        properties: Properties {
            status_code: None,
            pipestatus: None,
            terminal_width: 80,
            path: None,
            logical_path: None,
            cmd_duration: None,
            keymap: "viins",
            jobs: 0,
        },
    },
}
[TRACE] - (starship::utils): Trying to read from "/Users/alexrecuenco/.config/starship-debug.toml"
[TRACE] - (starship::utils): File read successfully
[TRACE] - (starship::config): Config file content: "
[git_metrics]
disabled = false
ignore_submodules = true
[git_status]
conflicted = "=${count}"
untracked = "?${count}"
stashed = "\\$${count}"
modified = "!${count}"
staged = "+${count}"
renamed = "»${count}"
deleted = "${count}"
ahead = '⇡${count}'
behind = '⇣${count}'
diverged = '⇕⇡${ahead_count}${behind_count}'
"
[DEBUG] - (starship::config): Config parsed: {"git_metrics": Table({"disabled": Boolean(false), "ignore_submodules": Boolean(true)}), "git_status": Table({"conflicted": String("=${count}"), "untracked": String("?${count}"), "stashed": String("\\$${count}"), "modified": String("!${count}"), "staged": String("+${count}"), "renamed": String("»${count}"), "deleted": String("${count}"), "ahead": String("${count}"), "behind": String("${count}"), "diverged": String("⇕⇡${ahead_count}${behind_count}")})}
[TRACE] - (starship::context): Received completed pipestatus of None
[DEBUG] - (starship::config): Config found for "git_metrics": Some(Table({"disabled": Boolean(false), "ignore_submodules": Boolean(true)}))
[TRACE] - (starship::context): Found git repo: Repository { kind: Submodule, git_dir: "/Volumes/Workspace/new-workspace/.git/modules/code/worktrees/code", work_dir: Some("/Volumes/Workspace/new-workspace/.git/modules/code") }, (trust: Full)
[TRACE] - (starship::utils): Creating Command for binary "git"
[TRACE] - (starship::utils): Using "/opt/homebrew/bin/git" as "git"
[TRACE] - (starship::context): Executing git command: GIT_OPTIONAL_LOCKS="0" "/opt/homebrew/bin/git" "-C" "/Volumes/Workspace/esave/worktree/code" "--git-dir" "/Volumes/Workspace/new-workspace/.git/modules/code/worktrees/code" "-c" "core.fsmonitor=" "--work-tree" "/Volumes/Workspace/new-workspace/.git/modules/code" "diff" "--shortstat" "--ignore-submodules"
[TRACE] - (starship::utils): stdout: " 2850 files changed, 665292 deletions(-)\n", stderr: "", exit code: "Some(0)", took 261.455916ms
[TRACE] - (starship::config): No color palette specified, using defaults
[TRACE] - (starship::config): Parsing color_string: red
[TRACE] - (starship::config): Read predefined color: red

esave/worktree/code on  pin-image-sha -665292 [$9✘2850?18] via  v23.2.0 via 🐍 v3.13.0 via 💎 v2.7.5 
❯ GIT_OPTIONAL_LOCKS="0" "/opt/homebrew/bin/git" "-C" "/Volumes/Workspace/esave/worktree/code" "--git-dir" "/Volumes/Workspace/new-workspace/.git/modules/code/worktrees/code" "-c" "core.fsmonitor=" "--work-tree" "/Volumes/Workspace/new-workspace/.git/modules/code" "diff" "--shortstat" "--ignore-submodules"
 2850 files changed, 665292 deletions(-)

esave/worktree/code on  pin-image-sha -665292 [$9✘2850?18] via  v23.2.0 via 🐍 v3.13.0 via 💎 v2.7.5 
❯ cd /Volumes/Workspace/new-workspace/.git/modules/code/worktrees/code

code/worktrees/code on  pin-image-sha -665292 [$9✘2850?18] 
❯ ls
COMMIT_EDITMSG	FETCH_HEAD	HEAD		MERGE_RR	ORIG_HEAD	commondir	gitdir		index		logs		refs

code/worktrees/code on  pin-image-sha -665292 [$9✘2850?18] 
❯ git status
fatal: this operation must be run in a work tree

code/worktrees/code on  pin-image-sha -665292 [$9✘2850?18] 
❯ cd ..

modules/code/worktrees on  reduce-number-of-jobs [$9] 
❯ git status
On branch reduce-number-of-jobs
Your branch is up to date with 'origin/reduce-number-of-jobs'.

nothing to commit, working tree clean

modules/code/worktrees on  reduce-number-of-jobs [$9] 
❯ cd ..

.git/modules/code on  reduce-number-of-jobs [$9] 
❯ cd ..

new-workspace/.git/modules on  debug-attach +4 -3 [!6] 
❯ git status
fatal: this operation must be run in a work tree

new-workspace/.git/modules on  debug-attach +4 -3 [!6] 
❯ cd ..

new-workspace/.git on  debug-attach +4 -3 [!6] 
❯ git status
fatal: this operation must be run in a work tree

new-workspace/.git on  debug-attach +4 -3 [!6] 
❯ cd ..

new-workspace on  debug-attach +4 -3 [!6] 
❯ git status
On branch debug-attach
Your branch is based on 'origin/debug-attach', but the upstream is gone.
  (use "git branch --unset-upstream" to fixup)

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
	modified:   api-contract (new commits)
	modified:   code (new commits)
	modified:   frontend (new commits)
	modified:   global-view/esave.code-workspace
	modified:   iframe (new commits)
	modified:   landing-page (new commits)

no changes added to commit (use "git add" and/or "git commit -a")

new-workspace on  debug-attach +4 -3 [!6] 
❯ ls
README.md		code			docs			iframe			ingress.files.dev	reports
api-contract		compose.debug.yml	frontend		images			landing-page
certs			compose.yml		global-view		ingress			rails.files.dev

new-workspace on  debug-attach +4 -3 [!6] 
❯ cd  code

code on  reduce-number-of-jobs [$9] via  v23.2.0 via 🐍 v3.13.0 via 💎 v2.7.5 
❯ git status
On branch reduce-number-of-jobs
Your branch is up to date with 'origin/reduce-number-of-jobs'.

nothing to commit, working tree clean

code on  reduce-number-of-jobs [$9] via  v23.2.0 via 🐍 v3.13.0 via 💎 v2.7.5 
❯ cd /Volumes/Workspace/esave/worktree/code

esave/worktree/code on  pin-image-sha -665292 [$9✘2850?18] via  v23.2.0 via 🐍 v3.13.0 via 💎 v2.7.5 
❯ git status
On branch pin-image-sha
Your branch is up to date with 'origin/pin-image-sha'.

nothing to commit, working tree clean

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 bug Something isn't working as expected.
Projects
None yet
Development

No branches or pull requests

2 participants