Let's say the user downloads the git repository revision with a particular hash. For example with this command: git clone --depth 1 --branch mybranch https://mygitserver.com/x.git && cd x && git checkout {hash}
.
Let's assume the git server isn't trustworthy, It might be compromised, hacked in some way. It might be attempting to alter the content in some malicious way.
Does the client actually recompute hashes of the whole content and fail in case of a wrong hash?
If the clone is shallow and only has depth=1 this means that the history is lost. Does each commit hash actually include the whole source hash, or only the delta hash? It appears that the latter is only reasonable, otherwise in case of deep histories it will have to recompute hash over and over again.
My suspicion is that it just takes the previous hash, adds the latest commit delta and metadata to it, and gets that latest hash. What about the parts of the code unchanged by the latest commit? Do they factor into the latest hash in question computed when the client downloads them this way?