mirror of
https://github.com/facebook/sapling.git
synced 2024-10-11 17:27:53 +03:00
a72478f016
Summary: This patch removes all `#include "../` lines and use the shortest possible include path. Test Plan: `make clean build` Reviewers: durham, #mercurial, rmcelroy Reviewed By: rmcelroy Subscribers: mjpieters Differential Revision: https://phabricator.intern.facebook.com/D5113672 Signature: t1:5113672:1495565454:961fb6f2f57a81a95013e0b8f67b2917c2e4523e
37 lines
963 B
C
37 lines
963 B
C
// Copyright 2016-present Facebook. All Rights Reserved.
|
|
//
|
|
// checksum.c: implementation for recalculating the checksums for
|
|
// intermediate nodes in a tree.
|
|
//
|
|
// no-check-code
|
|
|
|
#include "sha1/sha1.h"
|
|
|
|
#include "node.h"
|
|
#include "tree.h"
|
|
|
|
static void update_checksum(node_t *node) {
|
|
SHA1_CTX ctx;
|
|
SHA1DCInit(&ctx);
|
|
|
|
// find all the children and make sure their checksums are up-to-date.
|
|
for (child_num_t ix = 0; ix < node->num_children; ix++) {
|
|
node_t* child = get_child_by_index(node, ix);
|
|
if (child->checksum_valid == false) {
|
|
update_checksum(child);
|
|
}
|
|
|
|
SHA1DCUpdate(&ctx, (const unsigned char*) child->name, child->name_sz);
|
|
SHA1DCUpdate(&ctx, child->checksum, child->checksum_sz);
|
|
SHA1DCUpdate(&ctx, &child->flags, 1);
|
|
}
|
|
|
|
SHA1DCFinal(node->checksum, &ctx);
|
|
node->checksum_sz = SHA1_BYTES;
|
|
node->checksum_valid = true;
|
|
}
|
|
|
|
void update_checksums(tree_t *tree) {
|
|
update_checksum(tree->shadow_root);
|
|
}
|