onefetch
onefetch copied to clipboard
Support SHA256 git object format
Summary 💡
When trying to run Onefetch inside a git repo which uses the SHA256 object format, instead of the default SHA1, it immediately errors out:
Error: Failed to load the git configuration
Caused by:
The key "extensions.objectFormat=sha256" was invalid
Motivation 🔦
While the SHA256 object format is not yet used by default, it will eventually be set as the default by upstream git.
cc @Byron, is this related to gix?
Indeed, gitoxide doesn't currently support SHA256, even though all the groundwork is laid. This means that for the purpose of reading repository data, such support could be added quite swiftly I think.
I think here we'd have to watch out for when SHA256 is going to be the set as default so gitoxide can get its support added and enabled as well.
@AtmosphericIgnition Just curious about git's current behavior: is that config option needed for git to be able to read commits with SHA256 hashes, or just to write commits with SHA256 hashes?
I'm not sure I understand your question.
The way I understand the git documentation, the when running git init, all git versions so far will use the SHA1 object format. Newer versions of git support using SHA256 as the object format, if the repo was created with git init --object-format=sha256. After the repo is created, the object format cannot be changed without loosing commit history. No extra configuration is necessary after the repo's creation.
:thinking: Can you report on the output of cat .git/config? Based on your error report, I'm assuming that --object-format=sha256 instructs git to set a certain configuration value on init (extensions.objectFormat to be precise). And I'm assuming that config value is what actually instructs git to use sha256 when creating commits. And, if it's controlled by a config value, that implies that sha256 and sha1 hashes could possibly be mixed together in a repository by adjusting the configuration.
So, essentially, my question is that, if extension.objectFormat is set to sha256, does that mean it can be assumed that all commits in the repo use that format, or should a mix of sha1 and sha256 object formats be supported? This is, IMO, dependent on what git itself does. Would git break or succeed if it encountered a sha1 object format in a repo where extensions.objectFormat = sha256?
.git/config:
[core]
repositoryformatversion = 1
filemode = true
bare = false
logallrefupdates = true
[remote "origin"]
url = myrepo
fetch = +refs/heads/*:refs/remotes/origin/*
[extensions]
objectformat = sha256
[branch "main"]
remote = origin
merge = refs/heads/main
From everything I've read about this change, it seems the upstream git developers have no intention (point 3 of "Non-Goals") of making SHA1 and SHA256 object formats compatible in the same repository.
Thanks for the research!