Live data from Hacker News

Gitlab Gitaly project now supports the SHA-256 hashing algorithm

about.gitlab.com

1–10 of 15 posts

Re: Gitlab Gitaly project now supports the SHA-256 hashing algorithm

#2
Clicking through to https://gitlab.com/gitlab-org/gitaly yields

> Gitaly is a Git RPC service for handling all the git calls made by GitLab

So I think this means that a major piece of gitlab now supports sha256 git repos? But probably not everything and therefore we can't actually push sha256 git repos to gitlab yet?

Re: Gitlab Gitaly project now supports the SHA-256 hashing algorithm

#3
They have a common beginner's mistake in their example usage of sha256sum. Nothing that would affect the git usage, to be fair... unless they have related tooling that does this.

    > echo "please hash this data" | sha256sum
    f2ccc47bcb79799071eab33aa4311e6764769681bb9052ae444cb6e2d87427c8  -
This sum is not the sum of "please hash this data" but instead it is the sum of "please hash this data\n" where "\n" represents not a literal backslash and n, but a newline character. The unwanted newline is supplied by the echo command, obviously.

The proper way to have done this example (edit: on BSD, macOS, etc.) would be:

    > echo -n "please hash this data" | sha256sum
    62f73749b40cc70f453320e1ffc37e405ba50474b5db68ad436e64b61fbb8cf0  -
And then we would see the actual sha256sum for the example data used.

Edit: Forget this, an even better way is posted by others below! Thanks!

Re: Gitlab Gitaly project now supports the SHA-256 hashing algorithm

#4
post #3

They have a common beginner's mistake in their example usage of sha256sum. Nothing that would affect the git usage, to be fair... unless they have related tooling that does this. > echo "please hash this data" | sha256sum f2ccc47bcb79799071eab33aa4311e6764769681bb9052ae444cb6e2d87427c8 - This sum is not the sum of "please hash this data" but instead it is the sum of "please hash this data\n" where "\n" represents not…

best to avoid echo in the first place:

    printf '%s' "my string" | sha256sum

Re: Gitlab Gitaly project now supports the SHA-256 hashing algorithm

#5
post #4
post #3

They have a common beginner's mistake in their example usage of sha256sum. Nothing that would affect the git usage, to be fair... unless they have related tooling that does this. > echo "please hash this data" | sha256sum f2ccc47bcb79799071eab33aa4311e6764769681bb9052ae444cb6e2d87427c8 - This sum is not the sum of "please hash this data" but instead it is the sum of "please hash this data\n" where "\n" represents not…

best to avoid echo in the first place: printf '%s' "my string" | sha256sum

Can you expand on why?

Re: Gitlab Gitaly project now supports the SHA-256 hashing algorithm

#6
post #4

Earlier quoted context omitted.

best to avoid echo in the first place: printf '%s' "my string" | sha256sum

Can you expand on why?

With the formated parameters '%s' it's instantly visible that there is no new line.

Re: Gitlab Gitaly project now supports the SHA-256 hashing algorithm

#7
post #4

Earlier quoted context omitted.

best to avoid echo in the first place: printf '%s' "my string" | sha256sum

Can you expand on why?

Because if you get in the habit of using printf instead of echo you can avoid having to remember to strip the newline when it matters and only add it when you need it. Though obviously echo is simpler to use for 95% of situations.

Re: Gitlab Gitaly project now supports the SHA-256 hashing algorithm

#8

Clicking through to https://gitlab.com/gitlab-org/gitaly yields > Gitaly is a Git RPC service for handling all the git calls made by GitLab So I think this means that a major piece of gitlab now supports sha256 git repos? But probably not everything and therefore we can't actually push sha256 git repos to gitlab yet?

The answer to your question is in the first sentence of the article.

Re: Gitlab Gitaly project now supports the SHA-256 hashing algorithm

#9

Clicking through to https://gitlab.com/gitlab-org/gitaly yields > Gitaly is a Git RPC service for handling all the git calls made by GitLab So I think this means that a major piece of gitlab now supports sha256 git repos? But probably not everything and therefore we can't actually push sha256 git repos to gitlab yet?

Yeah, Gitaly is GitLab's approach to scaling up the actual Git operations. It's certainly a major part of the equation, but the article suggests the Rails app still has a bit of work to go before it's possible to use SHA256 repos.

Re: Gitlab Gitaly project now supports the SHA-256 hashing algorithm

#10
post #4

Earlier quoted context omitted.

best to avoid echo in the first place: printf '%s' "my string" | sha256sum

Can you expand on why?

Because `echo -n` is a BSD-ism that's not supported on System V derivatives¹. It's perfectly legitimate for:

    echo -n "please hash this data"
...to output the bytes "-n please hash this data\n", which is even more misleading than the extra newline echo outputs normally.

¹: https://pubs.opengroup.org/onlinepubs/9699919799/utilities/e...

Post reply on HN