romkatv / gitstatus

Git status for Bash and Zsh prompt
GNU General Public License v3.0
1.65k stars 101 forks source link

Support SHA-256 repos #411

Open InSuperposition opened 8 months ago

InSuperposition commented 8 months ago

I have 2 repos initialized, the repo using SHA-256 for a hashing algorithm is not recognized by the vcs prompt.

test_repo - SHA-1 test_repo_256 - SHA-256

image

https://git-scm.com/docs/git-init#Documentation/git-init.txt---object-formatltformatgt

Vinfall commented 2 months ago

Any plan to support this?

Forgejo released v7.0 to add SHA256 hash support and I tried to setup repos using such feature which eventually led me to the issue.

In the past sha-256 support in git is considered experimental and not recommended by many due to possible future incompatible update but that does not seem to be the case anymore. It's at least not too early for gitstatus to support this now.

Quoted from git-init documentation in git 2.44.0:

[!note] --object-format=

Specify the given object format (hash algorithm) for the repository. The valid values are sha1 and (if enabled) sha256. sha1 is the default.

Note: At present, there is no interoperability between SHA-256 repositories and SHA-1 repositories.

Historically, we warned that SHA-256 repositories may later need backward incompatible changes when we introduce such interoperability features. Today, we only expect compatible changes. Furthermore, if such changes prove to be necessary, it can be expected that SHA-256 repositories created with today’s Git will be usable by future versions of Git without data loss.

romkatv commented 2 months ago

It's getting unlikely that I'll be working on this. If I get a decent chunk of free time, I'd like to remove the dependency on gitstatusd from powerlevel10k and mothball gitstatus after that.

Vinfall commented 2 months ago

Sorry to hear that but still thank you for the hard work!

Git 2.45 released with experimental SHA1/SHA256 interoperability. You can read a brief introduction on Highlights from Git 2.45.

So instead of supporting SHA-256 repos, is it possible to add support for repos with SHA1/SHA256 interoperability by parsing only SHA1 hashes? They are still considered experimental but should be backward-compatible at least.

Random example:

# This is supposed to work since git 2.45
$ git version
git version 2.45.0
# Create a repo using SHA256 hash
$ git init --object-format=sha256
# Check using different hash algo
$ git rev-parse --output-object-format=sha1 HEAD
f54f533028849a980fd290275629e66022f3a5c7
$ git rev-parse HEAD
c265ed589a863fcb8408aca716bdfb875ba62caa2b1ca27fb1608f93250c565a
romkatv commented 2 months ago

It's unlikely I'll be doing anything w.r.t. gitstatusd. I need to find time and motivation to make powerlevel10k work without it. There is also a possibility that I archive both repos but I hope it won't come to that.

Vinfall commented 2 months ago

I see, thank you for making it clear.❤️