‹ BackHN Continuity

Thread

Git 3.0's upcoming SHA-256 default will be a costly mistake

570 points · 536 comments · chmaynard

  1. purpleidea · · focus · HN ↗
    This means, if you migrate your repo, every single commit message that contains text like: "please see commit <sha1>" will now be broken.

    This will be a train wreck. I hope they don't release before adding compatibility modes to keep the existing sha1's around in the database.

    1. oasisaimlessly · · focus · HN ↗
      Tools like git-filter-repo[1] support rewriting commit hashes in commit messages. git-filter-repo actually does it by default; see `--preserve-commit-hashes` in the manual[2].

      [1]: <a href="https:&#x2F;&#x2F;github.com&#x2F;newren&#x2F;git-filter-repo" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;newren&#x2F;git-filter-repo

      [2]: <a href="https:&#x2F;&#x2F;htmlpreview.github.io&#x2F;?https:&#x2F;&#x2F;github.com&#x2F;newren&#x2F;git-filter-repo&#x2F;blob&#x2F;docs&#x2F;html&#x2F;git-filter-repo.html" rel="nofollow">https:&#x2F;&#x2F;htmlpreview.github.io&#x2F;?https:&#x2F;&#x2F;github.com&#x2F;newren&#x2F;git...

      1. donatj · · focus · HN ↗
        Sure, but that&#x27;s not going to rewrite Slack messages, emails, GitHub links, docs
        1. purpleidea · · focus · HN ↗
          Came to say something exactly like this... The old sha1 handle needs to be still available in the same way an HTTP 301 redirect would work.
          1. functional_dev · · focus · HN ↗

            [dead]

        2. diegocg · · focus · HN ↗
          ... do not migrate old repos? I&#x27;m not sure why people would do that. Or, if they do, why would they replace the current repo name instead of creating a different one and keeping the old one closed to make the references work.

          I don&#x27;t think this is going to be a problem at all.

          1. beart · · focus · HN ↗
            Hmm. If this is a security issue that matters, would you not be expected to migrate?

            Not talking about archived code, but active projects that pre-date git 3.0

            1. cylemons · · focus · HN ↗
              His point is keep an archived sha1 version of the repo and an active sha256 version.

              That way an old commit with a message having a sha1 can reference the archived version, and new commits reference the active version.

          2. krupan · · focus · HN ↗
            If we don&#x27;t need to migrate repos to sha256 them why do we need to change git to use sha256?
            1. samus · · focus · HN ↗
              You keep the old repo for archival purposes and work with the new one.
          3. hinkley · · focus · HN ↗
            Some companies survive longer than five years. So old repos are also active ones.
        3. samspot · · focus · HN ↗
          I run into broken documentation links all the time at work. A few more isn&#x27;t going to break us.
      2. okanat · · focus · HN ↗
        I need git-filter-repo to rewrite entire documentation and also resurrect and rehire earlier employees to repeat their GPG signatures.
    2. windsurfer · · focus · HN ↗
      Since SHA-1 is already broken (just expensive in terms of GPU-time), then the text &quot;please see commit &lt;sha1&gt;&quot; is also already broken.
      1. Dylan16807 · · focus · HN ↗
        You can&#x27;t attack an existing normal commit.

        But also collisions there aren&#x27;t a big deal. People will cite short hashes when referring to things and that&#x27;s not &quot;broken&quot;.

        1. windsurfer · · focus · HN ↗
          If it&#x27;s an existing commit and you&#x27;re already converting the repo, you can just convert the commit messages as well.
      2. schacon · · focus · HN ↗
        That is essentially only a second preimage problem, which is basically impossible.
        1. [deleted] · · focus · HN ↗

          [deleted]

    3. 112233 · · focus · HN ↗
      Once this starts being actual pain, we will each vibe the replacement index creator (git already supports replacement objects), for back-forth conversion, populated on pack and object indexing.

      For massive perf and mem use damage. But oh well. And then we will wait for official version

    4. schacon · · focus · HN ↗
      There are plans to keep sha1s around in a database, but as far as I know, no way to transmit those, so they seem specific to individual forges. They can be recomputed, sure, but again, any signatures break and it&#x27;s possible that in the case of an actual replacement, the recomputation is now wrong and not easily comparable. So what is the point?
      1. purpleidea · · focus · HN ↗
        This is not about forges, it is about the repo I have in a folder on my computer. The sha1 hashes shouldn&#x27;t go away. Yes the forges also need to support this.
    5. OneDeuxTriSeiGo · · focus · HN ↗
      Note that there exists multiple ways to continue to lookup SHA1s in a SHA256 repo.

      One example is to maintain git-replace refs for the rewritten SHAs but there also exist config flags to enable object format compatibility extensions that help translate the SHAs back and forth.

      <a href="https:&#x2F;&#x2F;git-scm.com&#x2F;docs&#x2F;git-replace" rel="nofollow">https:&#x2F;&#x2F;git-scm.com&#x2F;docs&#x2F;git-replace

Open on Hacker News to reply ↗

Unofficial Hacker News client; not affiliated with Y Combinator.