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]No data for SHA256-based git repos #2703

Open
bryanvaz opened this issue Jun 9, 2024 · 2 comments · May be fixed by romkatv/libgit2#7
Open

[BUG]No data for SHA256-based git repos #2703

bryanvaz opened this issue Jun 9, 2024 · 2 comments · May be fixed by romkatv/libgit2#7

Comments

@bryanvaz
Copy link

bryanvaz commented Jun 9, 2024

TLDR; git repos that use the new SHA256-based object hashing do not show any data in the terminal prompt including branch, dirty status, etc... this can be replicated by creating a new git repo using git init --object-format=sha256

Background
This is more of a note-to-file as SHA256-based hashing is currently not the default for the git init command and the transition will probable take 7-10 years. The goal of the transition by the git team is to avoid SHA1 collisions and attacks. This will likely only become a "noticeable bug" in about 3 years and "breaking bug" in about 7 years.

While Git repos that use SHA256-based object hashing are no longer considered experimental, there is no backward interop between older SHA1 repos and newer SHA256 repos. git v2.45 is the first version to attempt forward interop between the two formats (see Github update on git v2.45.)

Issue
While zsh + p10k can read git data (i.e. branch/commit/etc..) for a legacy SHA1 based repo and display it in the prompt, when the prompt is in a git repo using SHA256-based object hashing p10k does not display any git info in the prompt.

Steps to replicate:

  1. Use zsh with p10k (obvi)
  2. Make sure you are using git > v2.42
  3. Enable the git plugin in zsh
  4. Create a new folder for testing
  5. cd into the new folder
  6. Run git init
  7. Ensure that your prompt now displays the main or master branch (this is expected behaviour)
  8. Now delete the git folder with: rm -Rf .git
  9. Reinitialize with SHA256 using: git init --object-format=sha256
  10. The prompt will not have the main or master branch in the prompt like previously (<-- this is the bug)
  11. As a sanity check, in the same folder, run vcs_info then;
  12. Run echo "${vcs_info_msg_0_}"; this should output the git portion of the terminal prompt you expect to see, but don't (i.e. the branch name)

Environment:

  • OS: macOS Sonoma 14.4.1 arm64
  • zsh verison: zsh 5.9 (x86_64-apple-darwin23.0)
  • powerlevel10k: bde5ca4
  • git version: 2.45.2

Note: I've tried to trace the bug, however changes I make to my local powerlevel10k does not reflect in the prompt. I suspect the issue is somewhere in gitstatus, but without a way to push debug statements through to the terminal, I can't trace the issue.

@grimm26
Copy link

grimm26 commented Jun 12, 2024

My guess is that the work would need to be done in https://github.com/romkatv/gitstatus

@romkatv
Copy link
Owner

romkatv commented Jun 13, 2024

Related: romkatv/libgit2#6

@orgads orgads linked a pull request Aug 16, 2024 that will close this issue
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

Successfully merging a pull request may close this issue.

3 participants