{"id":28044,"date":"2020-02-04T15:35:27","date_gmt":"2020-02-04T20:35:27","guid":{"rendered":"https:\/\/mjtsai.com\/blog\/?p=28044"},"modified":"2020-02-04T15:35:47","modified_gmt":"2020-02-04T20:35:47","slug":"a-new-hash-algorithm-for-git","status":"publish","type":"post","link":"https:\/\/mjtsai.com\/blog\/2020\/02\/04\/a-new-hash-algorithm-for-git\/","title":{"rendered":"A New Hash Algorithm for Git"},"content":{"rendered":"<p><a href=\"https:\/\/lwn.net\/SubscriberLink\/811068\/cfeb6a67b8dfbe47\/\">Jonathan Corbet<\/a> (via <a href=\"https:\/\/news.ycombinator.com\/item?id=22233295\">Hacker News<\/a>):<\/p>\n<blockquote cite=\"https:\/\/lwn.net\/SubscriberLink\/811068\/cfeb6a67b8dfbe47\/\">\n<p>\nWith the hash algorithm abstracted out of the core Git code, the transition\nis, on the surface, relatively easy.  A new version of Git can be made with\na different hash algorithm, along with a tool that will convert a\nrepository from the old hash to the new.  With a simple command like:\n<\/p><pre>git convert-repo --to-hash=sha-256 --frobnicate-blobs --climb-subtrees \\\n   \t--liability-waiver=none --use-shovels --carbon-offsets<\/pre>\n<p>\na user can leave SHA&#x2011;1 behind (note that the specific command-line options\nmay differ).  There is only one problem with this plan,\nthough: most Git repositories do not operate in a vacuum.  This sort of\nflag-day conversion might work for a tiny project, but it&rsquo;s not going to\nwork well for a project like the kernel.\nSo Git needs to be able to work with both SHA&#x2011;1 and SHA&#x2011;256 hashes for the\nforeseeable future.  There are a number of implications to this requirement\nthat make themselves felt throughout the system.\n<\/p>\n<p>One of the transition design goals is that SHA&#x2011;256 repositories should be able to interoperate with SHA&#x2011;1 repositories managed by older versions of Git. If kernel.org updates to the new format, developers running older versions should still be able to pull from (and push to) that site. That will only happen if Git continues to track the SHA&#x2011;1 hashes for each object indefinitely.<\/p>\n<\/blockquote>\n\n<p>Previously:<\/p>\n<ul>\n<li><a href=\"https:\/\/mjtsai.com\/blog\/2020\/01\/08\/chosen-prefix-collision-for-sha-1\/\">Chosen-Prefix Collision for SHA-1<\/a><\/li>\n<\/ul>","protected":false},"excerpt":{"rendered":"<p>Jonathan Corbet (via Hacker News): With the hash algorithm abstracted out of the core Git code, the transition is, on the surface, relatively easy. A new version of Git can be made with a different hash algorithm, along with a tool that will convert a repository from the old hash to the new. With a [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"apple_news_api_created_at":"2020-02-04T20:35:30Z","apple_news_api_id":"1365a656-b10b-4381-998c-eeb68332e5d1","apple_news_api_modified_at":"2020-02-04T20:35:50Z","apple_news_api_revision":"AAAAAAAAAAAAAAAAAAAAAA==","apple_news_api_share_url":"https:\/\/apple.news\/AE2WmVrELQ4GZjO62gzLl0Q","apple_news_coverimage":0,"apple_news_coverimage_caption":"","apple_news_is_hidden":false,"apple_news_is_paid":false,"apple_news_is_preview":false,"apple_news_is_sponsored":false,"apple_news_maturity_rating":"","apple_news_metadata":"\"\"","apple_news_pullquote":"","apple_news_pullquote_position":"","apple_news_slug":"","apple_news_sections":"\"\"","apple_news_suppress_video_url":false,"apple_news_use_image_component":false,"footnotes":""},"categories":[2],"tags":[377,31,30,71,1484],"class_list":["post-28044","post","type-post","status-publish","format-standard","hentry","category-technology","tag-git","tag-ios","tag-mac","tag-programming","tag-sha-1"],"apple_news_notices":[],"_links":{"self":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/28044","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/comments?post=28044"}],"version-history":[{"count":2,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/28044\/revisions"}],"predecessor-version":[{"id":28046,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/28044\/revisions\/28046"}],"wp:attachment":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/media?parent=28044"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/categories?post=28044"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/tags?post=28044"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}