MCPcopy Create free account
hub / github.com/ClickHouse/ClickHouse / diffHash

Function diffHash

programs/git-import/git-import.cpp:761–789  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

759using DiffHashes = std::unordered_set<UInt128>;
760
761static UInt128 diffHash(const CommitDiff & file_changes)
762{
763 SipHash hasher;
764
765 for (const auto & elem : file_changes)
766 {
767 hasher.update(elem.second.file_change.change_type);
768 hasher.update(elem.second.file_change.old_path.size());
769 hasher.update(elem.second.file_change.old_path);
770 hasher.update(elem.second.file_change.path.size());
771 hasher.update(elem.second.file_change.path);
772
773 hasher.update(elem.second.line_changes.size());
774 for (const auto & line_change : elem.second.line_changes)
775 {
776 hasher.update(line_change.sign);
777 hasher.update(line_change.line_number_old);
778 hasher.update(line_change.line_number_new);
779 hasher.update(line_change.indent);
780 hasher.update(line_change.line.size());
781 hasher.update(line_change.line);
782 }
783 }
784
785 UInt128 hash_of_diff;
786 hasher.get128(hash_of_diff.items[0], hash_of_diff.items[1]);
787
788 return hash_of_diff;
789}
790
791
792/** File changes in form

Callers 1

processCommitFunction · 0.85

Calls 3

updateMethod · 0.45
sizeMethod · 0.45
get128Method · 0.45

Tested by

no test coverage detected