Search code examples
gitsha1sha256

Will Git's hash length change with the SHA256 transition?


As stated in this commit from 2018, there have been plans to switch out Git's hash algorithm from SHA1 to SHA256.

Will that be a truncated SHA256, or are Git's hash lengths going to change?


Solution

  • it seems it does change…

    $ for a in sha1 sha256; do d=${a%56}; git init -q --object-format=$a $d; touch $d/x; git -C $d add x; done
    $ find sha?/.git/objects/ -type f
    sha1/.git/objects/e6/9de29bb2d1d6434b8b29ae775ad8c2e48c5391
    sha2/.git/objects/47/3a0f4c3be8a93681a267e3b1e9a7dcda1185436fe141f7749120a303721813