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_status module prints "Error finding stash reference" if there are no stashed changes #5432

Closed
gabebw opened this issue Sep 10, 2023 · 2 comments · Fixed by #5434
Closed
Labels
🐛 bug Something isn't working as expected.

Comments

@gabebw
Copy link

gabebw commented Sep 10, 2023

Current Behavior

When in a Git repo without any stashed changes, Starship prints this from the Git module:

[WARN] - (starship::modules::git_status): Error finding stash reference: The ref file "/Users/gabe/foo/.git/tags/refs/stash" could not be read in full

To reproduce:

mkdir foo
cd foo
git init
touch anything.txt
git commit -am "Initial commit"

Now, when the Starship prompt runs (though not every time, oddly - I think it's the first cd to that directory after shell startup), it prints that warning.

If I modify anything.txt then git stash the changes, the warning never appears.

Expected Behavior

I expect no warning to be printed if there is no stashed content.

Additional context/Screenshots

N/A

Possible Solution

N/A

Environment

  • Starship version: 1.16.0
  • fish version: fish, version 3.6.1
  • Operating system: Mac OS 12.6.8
  • Terminal emulator: tmux 3.3a
  • Git Commit Hash:
  • Branch/Tag:
  • Rust Version: rustc 1.71.0 (8ede3aae2 2023-07-12) (built from a source tarball)
  • Rust channel: release
  • Build Time: 2023-07-30 13:30:05 +00:00

Relevant Shell Configuration

My starship.toml:

# Don't print a new line at the start of the prompt
add_newline = false

format = """
$time\
$ruby\
$nodejs\
$directory\
$git_branch\
$git_state\
$git_status\
\\$ """

[time]
disabled = false
format = "[$time]($style) "
style = "#888888"
use_12hr = true

[ruby]
format = "[($version )]($style)"
style = "fg:218" # pink

[directory]
# Show 1 parent directory (setting to 0 means no truncation)
truncation_length = 2
# A lovely grayish-purple
style = "fg:146"
format = "[$path]($style) "
# When in a Git repo, keep showing parent directories
truncate_to_repo = false

[git_branch]
format = "[($branch )]($style)"
style = "fg:031" # dark blue

[git_state]
cherry_pick = "[🍒 PICKING](bold fg:197)" # red

[git_status]
format = """
($conflicted\
$stashed\
$deleted\
$renamed\
$modified\
$staged\
$untracked )\
($ahead_behind )""" # purple
stashed = "[stash](bold fg:222)" # yellow
staged = "[S](bold fg:222)" # yellow
conflicted = "[=](bold fg:197)" # red
untracked = "[?](bold fg:159)" # cyan
modified = "[!](bold fg:222)" # yellow
deleted = "[✘](bold fg:197)" # red
behind = "[↓](bold fg:159)" # cyan
ahead = "[↑](bold fg:159)" # cyan
diverged = "[⇔](bold fg:197)" # red

[nodejs]
# Don't show "v3", just "3"
version_format = "${raw}"
detect_files = ["package.json", ".node-version", "yarn.lock"]
detect_folders = ["node_modules"]
# Unlike the standard nodejs module, it intentionally does not check for
# *.js or *.ts since that triggers too often
detect_extensions = []
format = "[($version )]($style)"
style = "fg:031" # dark blue
@gabebw gabebw added the 🐛 bug Something isn't working as expected. label Sep 10, 2023
@davidkna
Copy link
Member

I can't reproduce the issue, but I have create a PR to decrease the log level of that warning to hide it by default.

@jasperges
Copy link

I have the same issue, but was able to track it down to using vim-gutentags which uses exuberant tags (ctags). In my .vimrc I have set the tags filepath to be .git/tags. Changing this to another path resolved the issue for me.

Steps to reproduce:

  • Start a fresh shell (with starship of course) and go to a git repository.
  • Do touch .git/tags and you should get the error message.

I haven't looked at the source code of the git_status module, but I don't know why it would look in .git/tags/refs/stash instead of .git/refs/stash if there is a .git/tags file or directory.

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

Successfully merging a pull request may close this issue.

3 participants