[BUG]No data for SHA256-based git repos
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:
- Use
zshwith p10k (obvi) - Make sure you are using
git > v2.42 - Enable the
gitplugin in zsh - Create a new folder for testing
cdinto the new folder- Run
git init - Ensure that your prompt now displays the
mainormasterbranch (this is expected behaviour) - Now delete the git folder with:
rm -Rf .git - Reinitialize with SHA256 using:
git init --object-format=sha256 - The prompt will not have the
mainormasterbranch in the prompt like previously (<-- this is the bug) - As a sanity check, in the same folder, run
vcs_infothen; - 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.
My guess is that the work would need to be done in https://github.com/romkatv/gitstatus
Related: https://github.com/romkatv/libgit2/issues/6