Return-Path: X-Original-To: apmail-subversion-commits-archive@minotaur.apache.org Delivered-To: apmail-subversion-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id B236218139 for ; Fri, 11 Dec 2015 18:54:20 +0000 (UTC) Received: (qmail 52701 invoked by uid 500); 11 Dec 2015 18:54:20 -0000 Delivered-To: apmail-subversion-commits-archive@subversion.apache.org Received: (qmail 52667 invoked by uid 500); 11 Dec 2015 18:54:20 -0000 Mailing-List: contact commits-help@subversion.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@subversion.apache.org Delivered-To: mailing list commits@subversion.apache.org Received: (qmail 52657 invoked by uid 99); 11 Dec 2015 18:54:20 -0000 Received: from Unknown (HELO spamd3-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 11 Dec 2015 18:54:20 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd3-us-west.apache.org (ASF Mail Server at spamd3-us-west.apache.org) with ESMTP id 2E03C180A9A for ; Fri, 11 Dec 2015 18:54:20 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 1.246 X-Spam-Level: * X-Spam-Status: No, score=1.246 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, KAM_LAZY_DOMAIN_SECURITY=1, RP_MATCHES_RCVD=-0.554] autolearn=disabled Received: from mx1-eu-west.apache.org ([10.40.0.8]) by localhost (spamd3-us-west.apache.org [10.40.0.10]) (amavisd-new, port 10024) with ESMTP id SpL6MMqDJMc7 for ; Fri, 11 Dec 2015 18:54:18 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-eu-west.apache.org (ASF Mail Server at mx1-eu-west.apache.org) with ESMTP id E69EF23047 for ; Fri, 11 Dec 2015 18:54:17 +0000 (UTC) Received: from svn01-us-west.apache.org (svn.apache.org [10.41.0.6]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id D4DC3E0044 for ; Fri, 11 Dec 2015 18:54:16 +0000 (UTC) Received: from svn01-us-west.apache.org (localhost [127.0.0.1]) by svn01-us-west.apache.org (ASF Mail Server at svn01-us-west.apache.org) with ESMTP id D643A3A01DC for ; Fri, 11 Dec 2015 18:54:16 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1719496 - in /subversion/branches/ra-git/subversion: libsvn_ra_git/commit.c tests/libsvn_client/git-client-test.c Date: Fri, 11 Dec 2015 18:54:16 -0000 To: commits@subversion.apache.org From: rhuijben@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20151211185416.D643A3A01DC@svn01-us-west.apache.org> Author: rhuijben Date: Fri Dec 11 18:54:16 2015 New Revision: 1719496 URL: http://svn.apache.org/viewvc?rev=1719496&view=rev Log: On the ra-git branch: Fix verifications of base files by explicitly closing the source stream. * subversion/libsvn_ra_git/commit.c (git_commit_node_baton_t): Keep stream reference. (git_commit__apply_textdelta): Store reference if there is a base checksum. (git_commit__close_file): Verify checksums. * subversion/tests/libsvn_client/git-client-test.c (test_git_add_nodes): Extend test a tiny bit. Modified: subversion/branches/ra-git/subversion/libsvn_ra_git/commit.c subversion/branches/ra-git/subversion/tests/libsvn_client/git-client-test.c Modified: subversion/branches/ra-git/subversion/libsvn_ra_git/commit.c URL: http://svn.apache.org/viewvc/subversion/branches/ra-git/subversion/libsvn_ra_git/commit.c?rev=1719496&r1=1719495&r2=1719496&view=diff ============================================================================== --- subversion/branches/ra-git/subversion/libsvn_ra_git/commit.c (original) +++ subversion/branches/ra-git/subversion/libsvn_ra_git/commit.c Fri Dec 11 18:54:16 2015 @@ -88,7 +88,8 @@ typedef struct git_commit_node_baton_t const char *tmp_abspath; svn_checksum_t *result_checksum; svn_checksum_t *base_checksum; - svn_checksum_t *expected_base_checks; + svn_stream_t *base_stream; + svn_checksum_t *expected_base_checksum; } git_commit_node_baton_t; @@ -660,7 +661,8 @@ git_commit__apply_textdelta(void *file_b svn_stream_t *base_stream; if (base_checksum) - SVN_ERR(svn_checksum_parse_hex(&fb->expected_base_checks, svn_checksum_md5, + SVN_ERR(svn_checksum_parse_hex(&fb->expected_base_checksum, + svn_checksum_md5, base_checksum, fb->pool)); SVN_ERR(svn_io_open_unique_file3(&fnew, &fb->tmp_abspath, NULL, @@ -673,10 +675,15 @@ git_commit__apply_textdelta(void *file_b SVN_ERR(svn_fs_file_contents(&base_stream, fb->root, fb->root_path, result_pool)); - svn_txdelta_apply(svn_stream_checksummed2( - base_stream, - &fb->base_checksum, NULL, svn_checksum_md5, TRUE, - result_pool), + if (base_checksum) + { + base_stream = fb->base_stream = + svn_stream_checksummed2(base_stream, &fb->base_checksum, + NULL, svn_checksum_md5, TRUE, + result_pool); + } + + svn_txdelta_apply(base_stream, svn_stream_checksummed2( svn_stream_from_aprfile2(fnew, FALSE, result_pool), NULL, &fb->result_checksum, svn_checksum_md5, FALSE, @@ -702,8 +709,40 @@ git_commit__close_file(void *file_baton, apr_pool_t *scratch_pool) { git_commit_node_baton_t *fb = file_baton; + svn_checksum_t *final_checksum; /* TODO: Verify checksums! */ + if (text_checksum) + SVN_ERR(svn_checksum_parse_hex(&final_checksum, svn_checksum_md5, + text_checksum, scratch_pool)); + else + final_checksum = NULL; + + if (final_checksum && fb->result_checksum + && !svn_checksum_match(final_checksum, fb->result_checksum)) + { + return svn_error_trace( + svn_checksum_mismatch_err(final_checksum, fb->result_checksum, + scratch_pool, + _("Result checksum error on '%s'"), + fb->node_path)); + } + + if (fb->base_stream) + { + /* This explicit close sets fb->base_checksum */ + SVN_ERR(svn_stream_close(fb->base_stream)); + + if (!svn_checksum_match(fb->expected_base_checksum, fb->base_checksum)) + { + return svn_error_trace( + svn_checksum_mismatch_err(fb->expected_base_checksum, + fb->base_checksum, + scratch_pool, + _("Base checksum mismatch on '%s'"), + fb->node_path)); + } + } if (fb->pb->dir_builder && fb->tmp_abspath) { Modified: subversion/branches/ra-git/subversion/tests/libsvn_client/git-client-test.c URL: http://svn.apache.org/viewvc/subversion/branches/ra-git/subversion/tests/libsvn_client/git-client-test.c?rev=1719496&r1=1719495&r2=1719496&view=diff ============================================================================== --- subversion/branches/ra-git/subversion/tests/libsvn_client/git-client-test.c (original) +++ subversion/branches/ra-git/subversion/tests/libsvn_client/git-client-test.c Fri Dec 11 18:54:16 2015 @@ -324,7 +324,12 @@ test_git_add_nodes(const svn_test_opts_t subpool), subpool), NULL, - NULL, NULL, + svn_stream_from_string( + svn_string_create( + "This is the file 'pi'.\n", + subpool), + subpool), + NULL, mtcc, subpool)); SVN_ERR(svn_client__mtcc_commit(apr_hash_make(subpool),