romkatv / powerlevel10k

A Zsh theme
MIT License
44.26k stars 2.12k forks source link

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

Open bryanvaz opened 3 weeks ago

bryanvaz commented 3 weeks ago

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:

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 commented 2 weeks ago

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

romkatv commented 2 weeks ago

Related: https://github.com/romkatv/libgit2/issues/6