From patchwork Sat Dec 15 00:09:20 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Beller X-Patchwork-Id: 10731869 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id F3F84746 for ; Sat, 15 Dec 2018 00:09:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8CA2F2D3F8 for ; Sat, 15 Dec 2018 00:09:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 80C3D2D404; Sat, 15 Dec 2018 00:09:50 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, USER_IN_DEF_DKIM_WL autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2BBF62D3F8 for ; Sat, 15 Dec 2018 00:09:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729200AbeLOAJt (ORCPT ); Fri, 14 Dec 2018 19:09:49 -0500 Received: from mail-pl1-f202.google.com ([209.85.214.202]:44239 "EHLO mail-pl1-f202.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726772AbeLOAJs (ORCPT ); Fri, 14 Dec 2018 19:09:48 -0500 Received: by mail-pl1-f202.google.com with SMTP id b24so4696512pls.11 for ; Fri, 14 Dec 2018 16:09:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=RnV5H1Ni8WnGohtGXcw8YDUBD8u8JlncOSimCee42yw=; b=wS2csN46jvHL1QqNMbZu+sItmM02pcHWMkVzjnmU8UQ45tKVX0SBNjy5uhiIslMfwF SPlGhW5Dc25znCyKN3xog6KoD6IXKwpzRjFL52/qcnd9Vs5HuK1wqBCPi2UXDBC00JKB OANieiQC2Na3Gu8I/DMZzjr3GzRmNZOOS2Iw/S2565J5p5budx7th4vE8QwHQJUvjws+ 3RTZlf59vPTP3ZCKpkJyTpIJ/AsQLzQWrqGRQ6sRYYLZ/xy/C3GfP6OP+El9frvvrjeS y0FDWaQ+aO6oJ6RcvjJ9bknDwCIdLaa8ExPl1V8zGYaqOo74lIuJs79awUkDs2FFzZLe yTRA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=RnV5H1Ni8WnGohtGXcw8YDUBD8u8JlncOSimCee42yw=; b=Zkv8lpM5K+20IZcrxGAthFQ/CSFHsw6t0vVCI6BoqfQAH4l1hg6SiJKAjCxBpSCzID KuJu2yNicwaQdkg6fRzkbG4hXs2p3qul/mBGdJhFvaNdHm50Podzi7D5s0A65e1/PtEi ue0ElDbpVhlMWavtvFMVfw9FKi/Uz2vxTZYMIqaSMCs3sINxzmeDSFCzvd7H7S7wHp0G 6TGbqRpd3PXvwUIGUWlScxNOJtckp8ITN7mcBG3T/9Z3lM1cYcyVp/CN4d18RpH9BQHV wDLy5uxCSAPP0SqM+jZDHW0miAHTDW4uKVdHHR2gwEyTngGpo/kRpsrC7KHplc8Q//85 lFVg== X-Gm-Message-State: AA+aEWZK04uYbaqYKPSsrx8lS7sH4a6d0p9+oufhjm606eK6ColHUVd1 iCjIBwpub7jcMKZMPcxcWrignn385TuhP+OY6aheuQAbRhrob/vexz0hF1ZpPrvKVsc7e2HC2N/ fsaMabU+e6fnf/totQY/pbTJ+YnGMSrXlVTYWRPhEs93V5ilnK7in2/A0h+dr X-Google-Smtp-Source: AFSGD/XZ5ZtqNpEtuETwFeZU1o0mRFlSnLQ7XJ6yjZLgofQu3Tke4oP0k0+OlCmjQP8KP/XzTQ+1SuplJbGw X-Received: by 2002:a62:d70e:: with SMTP id b14mr2792124pfh.86.1544832587718; Fri, 14 Dec 2018 16:09:47 -0800 (PST) Date: Fri, 14 Dec 2018 16:09:20 -0800 In-Reply-To: <20181215000942.46033-1-sbeller@google.com> Message-Id: <20181215000942.46033-2-sbeller@google.com> Mime-Version: 1.0 References: <20181215000942.46033-1-sbeller@google.com> X-Mailer: git-send-email 2.20.0.405.gbc1bbc6f85-goog Subject: [PATCH 01/23] sha1_file: allow read_object to read objects in arbitrary repositories From: Stefan Beller To: git@vger.kernel.org Cc: Stefan Beller , Junio C Hamano Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Allow read_object (a file local functon in sha1_file) to handle arbitrary repositories by passing the repository down to oid_object_info_extended. Signed-off-by: Stefan Beller Signed-off-by: Junio C Hamano --- sha1-file.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/sha1-file.c b/sha1-file.c index dd0b6aa873..b8ce21cbaf 100644 --- a/sha1-file.c +++ b/sha1-file.c @@ -1361,7 +1361,9 @@ int oid_object_info(struct repository *r, return type; } -static void *read_object(const unsigned char *sha1, enum object_type *type, +static void *read_object(struct repository *r, + const unsigned char *sha1, + enum object_type *type, unsigned long *size) { struct object_id oid; @@ -1373,7 +1375,7 @@ static void *read_object(const unsigned char *sha1, enum object_type *type, hashcpy(oid.hash, sha1); - if (oid_object_info_extended(the_repository, &oid, &oi, 0) < 0) + if (oid_object_info_extended(r, &oid, &oi, 0) < 0) return NULL; return content; } @@ -1414,7 +1416,7 @@ void *read_object_file_extended(const struct object_id *oid, lookup_replace_object(the_repository, oid) : oid; errno = 0; - data = read_object(repl->hash, type, size); + data = read_object(the_repository, repl->hash, type, size); if (data) return data; @@ -1755,7 +1757,7 @@ int force_object_loose(const struct object_id *oid, time_t mtime) if (has_loose_object(oid)) return 0; - buf = read_object(oid->hash, &type, &len); + buf = read_object(the_repository, oid->hash, &type, &len); if (!buf) return error(_("cannot read sha1_file for %s"), oid_to_hex(oid)); hdrlen = xsnprintf(hdr, sizeof(hdr), "%s %lu", type_name(type), len) + 1; From patchwork Sat Dec 15 00:09:21 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Beller X-Patchwork-Id: 10731871 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 64557746 for ; Sat, 15 Dec 2018 00:09:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F27132D3F8 for ; Sat, 15 Dec 2018 00:09:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E71202D404; Sat, 15 Dec 2018 00:09:52 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, USER_IN_DEF_DKIM_WL autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 919042D3F8 for ; Sat, 15 Dec 2018 00:09:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729441AbeLOAJv (ORCPT ); Fri, 14 Dec 2018 19:09:51 -0500 Received: from mail-io1-f73.google.com ([209.85.166.73]:46067 "EHLO mail-io1-f73.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726772AbeLOAJv (ORCPT ); Fri, 14 Dec 2018 19:09:51 -0500 Received: by mail-io1-f73.google.com with SMTP id r65so6078401iod.12 for ; Fri, 14 Dec 2018 16:09:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=ef6cfstK31cHUl53R4s1NhtgQjSryFwo/flJmAvUnnk=; b=aTPPzKT1InQradWsGi4DiNoYfpxUGeQvuQNi5ZXWZcvKCrVXG1/a2jLlzbFMU5x3Rl fxRg7JR4BVB3bS2OTze9xl0S08uRTBQlRe7GAJu1F2dYB932cbZN4eGM5hWS+QsjNH/M q+D9xIdLNjPGy2Qe7RSD1RFwZYEFF/Zhp9AW9A5+2eEbcWdD1wD4RYmMU/cWnzKIbP7R 5ga/Egn0WXLpOPOcj03EqY9x8uWMtsccW8X0rV/fAKFdgDoT/bbIWd8F2sxYP5BPimtM U/Lq7trvIkhTj48zRxZyvpo2milsgTg1d6RKyL2fTF3ePIIe/+VirjthYaAhTRkC3xru CNVg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=ef6cfstK31cHUl53R4s1NhtgQjSryFwo/flJmAvUnnk=; b=hfcXRR2iCqRzXq0f5bH8XbQ1axLixnyZ/WtrZ8T3Bttbr4DNZlIfYud4yKxNDyXcCY 7oh99RFtHxtxqXGVaKaP71olgkv3lo52crriw1drtglEUkJR2qevvJrVtmhgOU3jLMV3 L2pqPzignbNSlNeihJQ1SDpjad1XBbyyeWC/NjJ+jWCB+H/AwTwxgvYEbJRXPYzc7vYU liTqHsPYfqE6X2CnkusUaFJEcTa9B0iLgH3zSP8BLeZd04rGNXNYGL6Xcn2xsN/+09zW cIQngKn7qUDyjaubEiwJMtUQsIpu13IY32tPaxhT7sEqkf6JEIth2i60ZSAPXdVEjah8 5ZyA== X-Gm-Message-State: AA+aEWZYBt6TTQtn5jD4boNxXAGHd8hQpm1Sa9pduK/6wCaJ1BcbPi90 OpNHfCTpXg3uHhlE2wAQdQBDJ+PiGKah1gHbvz/PHhDeEBKW0aZPzoBQzWCpBApplaCGnUa/9NQ 5s/tnDKRMGh7USkDQ3SYnA9wwUfIutAyqq41g3EwtUC7hueXcNlQLOwBsGipI X-Google-Smtp-Source: AFSGD/VQjVKVpO83g9PsS/qNlUzZCe7WOPVkXszxR6tSbRKB/2WXga6Q/qhDwOD0nPtLNclMUgfsZ9GbJsUa X-Received: by 2002:a24:6852:: with SMTP id v79mr4485569itb.29.1544832590058; Fri, 14 Dec 2018 16:09:50 -0800 (PST) Date: Fri, 14 Dec 2018 16:09:21 -0800 In-Reply-To: <20181215000942.46033-1-sbeller@google.com> Message-Id: <20181215000942.46033-3-sbeller@google.com> Mime-Version: 1.0 References: <20181215000942.46033-1-sbeller@google.com> X-Mailer: git-send-email 2.20.0.405.gbc1bbc6f85-goog Subject: [PATCH 02/23] packfile: allow has_packed_and_bad to handle arbitrary repositories From: Stefan Beller To: git@vger.kernel.org Cc: Stefan Beller , Junio C Hamano Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP has_packed_and_bad is not widely used, so just migrate it all at once. Signed-off-by: Stefan Beller Signed-off-by: Junio C Hamano --- packfile.c | 5 +++-- packfile.h | 2 +- sha1-file.c | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/packfile.c b/packfile.c index 841b36182f..bc2e0f5043 100644 --- a/packfile.c +++ b/packfile.c @@ -1131,12 +1131,13 @@ void mark_bad_packed_object(struct packed_git *p, const unsigned char *sha1) p->num_bad_objects++; } -const struct packed_git *has_packed_and_bad(const unsigned char *sha1) +const struct packed_git *has_packed_and_bad(struct repository *r, + const unsigned char *sha1) { struct packed_git *p; unsigned i; - for (p = the_repository->objects->packed_git; p; p = p->next) + for (p = r->objects->packed_git; p; p = p->next) for (i = 0; i < p->num_bad_objects; i++) if (hasheq(sha1, p->bad_object_sha1 + the_hash_algo->rawsz * i)) diff --git a/packfile.h b/packfile.h index 442625723d..7a62d72231 100644 --- a/packfile.h +++ b/packfile.h @@ -146,7 +146,7 @@ extern int packed_object_info(struct repository *r, off_t offset, struct object_info *); extern void mark_bad_packed_object(struct packed_git *p, const unsigned char *sha1); -extern const struct packed_git *has_packed_and_bad(const unsigned char *sha1); +extern const struct packed_git *has_packed_and_bad(struct repository *r, const unsigned char *sha1); /* * Iff a pack file in the given repository contains the object named by sha1, diff --git a/sha1-file.c b/sha1-file.c index b8ce21cbaf..856e000ee1 100644 --- a/sha1-file.c +++ b/sha1-file.c @@ -1432,7 +1432,7 @@ void *read_object_file_extended(const struct object_id *oid, die(_("loose object %s (stored in %s) is corrupt"), oid_to_hex(repl), path); - if ((p = has_packed_and_bad(repl->hash)) != NULL) + if ((p = has_packed_and_bad(the_repository, repl->hash)) != NULL) die(_("packed object %s (stored in %s) is corrupt"), oid_to_hex(repl), p->pack_name); From patchwork Sat Dec 15 00:09:22 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Beller X-Patchwork-Id: 10731873 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 956611399 for ; Sat, 15 Dec 2018 00:09:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2EE512D3F8 for ; Sat, 15 Dec 2018 00:09:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 237AA2D404; Sat, 15 Dec 2018 00:09:55 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, USER_IN_DEF_DKIM_WL autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B3B702D3F8 for ; Sat, 15 Dec 2018 00:09:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729963AbeLOAJx (ORCPT ); Fri, 14 Dec 2018 19:09:53 -0500 Received: from mail-pf1-f201.google.com ([209.85.210.201]:36507 "EHLO mail-pf1-f201.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726772AbeLOAJx (ORCPT ); Fri, 14 Dec 2018 19:09:53 -0500 Received: by mail-pf1-f201.google.com with SMTP id p9so5734028pfj.3 for ; Fri, 14 Dec 2018 16:09:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=MVDX573Eb6d7l4R6Y1nGqeqlAFP9pdIUA95wEwEWBJI=; b=JWIz4Sit1eq4TYpx7xMWQIerQWPbb1G03cs+db7DG2oHac+EF5kY7vukIx9Pa/1Sr2 W+3y8PM/XhzSv0TYx+EzNGvYvcv9OuAOnAbSU4bj/+JCPT7v6diVkmFI5JGeDgNf2lv4 Q/UqOLVtlJrHqSUFg1mMAyr+wQKnYzDsY+00K7scR4G+yMg5od8dHtsZkeklJzs3k9Iv nfHEPbXaOLvFaeG9ULjGaMmTrzomhub1POJ+/HX+/Hzhq9mxvJkT4ktbv8bsJXkuKSgX rdWNvmUcbrecZu62rv0mymo5pgfHkUH/lpNgdyTlJ5s8G0Ds8220QMmTOYuFX0QqQn6D dyGw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=MVDX573Eb6d7l4R6Y1nGqeqlAFP9pdIUA95wEwEWBJI=; b=orYcux855dg5h5irtrnwsV/4M07EEpeJuzfOiLGrsE5ifBluaag5syhrr8FZznLk/W HiJ4SR2MEwpVxcGwxFAiP60SYu7rQXGVvxjUKEvm4O+wDkv2pr0X/6mcW/Xq1Qbploo0 PID8gEbN5LJDMVEpbFU9J2qfKLv6Kv4hEX0dQ39qAD3PgVxGcOd5hUdgk3BWnRoyhgBJ /9UAGQUJsUiGOc7ujsh56VyotW36CMHYmSrJ/pJsnTOeQZxzskBiaspLmLSd7TdeLrvu QghDrICkQM7CZLfPaUNdF4Jm6clG7Cdj9JoxDWyYdGeSGUNVIYO1JKfJ77Mr+99jwedc MvQQ== X-Gm-Message-State: AA+aEWYS+S2oWOUp5RT1FuMJ8nH+N/qwcMLG3AzzMEIBcvPd7ACGc33P Lsktv4iFNtBwClqrZeoKc3y8DR/df9rhEaR6RtxLNaD9nz2rmObBbUeAzWrY8HMsdezHrMPXLvw u+3XNAhKJqTYssYgjQBx5xiypfFiYpjUs+d9Mdd9ahENkqmtVyqhEDXP3nYgd X-Google-Smtp-Source: AFSGD/WnYFzS9JF4Q4OrlCgFcO7zKIbURcv8LHnMM4yiOjddQfM9DN/hqu+ZtrmovnWOJ1qDoMtLuiqdl59R X-Received: by 2002:a17:902:70c9:: with SMTP id l9mr2241527plt.86.1544832592417; Fri, 14 Dec 2018 16:09:52 -0800 (PST) Date: Fri, 14 Dec 2018 16:09:22 -0800 In-Reply-To: <20181215000942.46033-1-sbeller@google.com> Message-Id: <20181215000942.46033-4-sbeller@google.com> Mime-Version: 1.0 References: <20181215000942.46033-1-sbeller@google.com> X-Mailer: git-send-email 2.20.0.405.gbc1bbc6f85-goog Subject: [PATCH 03/23] object-store: allow read_object_file_extended to read from any repo From: Stefan Beller To: git@vger.kernel.org Cc: Stefan Beller , Junio C Hamano Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP read_object_file_extended is not widely used, so migrate it all at once. Signed-off-by: Stefan Beller Signed-off-by: Junio C Hamano --- object-store.h | 5 +++-- sha1-file.c | 11 ++++++----- streaming.c | 2 +- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/object-store.h b/object-store.h index 63b7605a3e..3d98a682b2 100644 --- a/object-store.h +++ b/object-store.h @@ -161,12 +161,13 @@ void sha1_file_name(struct repository *r, struct strbuf *buf, const unsigned cha void *map_sha1_file(struct repository *r, const unsigned char *sha1, unsigned long *size); -extern void *read_object_file_extended(const struct object_id *oid, +extern void *read_object_file_extended(struct repository *r, + const struct object_id *oid, enum object_type *type, unsigned long *size, int lookup_replace); static inline void *read_object_file(const struct object_id *oid, enum object_type *type, unsigned long *size) { - return read_object_file_extended(oid, type, size, 1); + return read_object_file_extended(the_repository, oid, type, size, 1); } /* Read and unpack an object file into memory, write memory to an object file */ diff --git a/sha1-file.c b/sha1-file.c index 856e000ee1..c5b704aec5 100644 --- a/sha1-file.c +++ b/sha1-file.c @@ -1403,7 +1403,8 @@ int pretend_object_file(void *buf, unsigned long len, enum object_type type, * deal with them should arrange to call read_object() and give error * messages themselves. */ -void *read_object_file_extended(const struct object_id *oid, +void *read_object_file_extended(struct repository *r, + const struct object_id *oid, enum object_type *type, unsigned long *size, int lookup_replace) @@ -1413,10 +1414,10 @@ void *read_object_file_extended(const struct object_id *oid, const char *path; struct stat st; const struct object_id *repl = lookup_replace ? - lookup_replace_object(the_repository, oid) : oid; + lookup_replace_object(r, oid) : oid; errno = 0; - data = read_object(the_repository, repl->hash, type, size); + data = read_object(r, repl->hash, type, size); if (data) return data; @@ -1428,11 +1429,11 @@ void *read_object_file_extended(const struct object_id *oid, die(_("replacement %s not found for %s"), oid_to_hex(repl), oid_to_hex(oid)); - if (!stat_sha1_file(the_repository, repl->hash, &st, &path)) + if (!stat_sha1_file(r, repl->hash, &st, &path)) die(_("loose object %s (stored in %s) is corrupt"), oid_to_hex(repl), path); - if ((p = has_packed_and_bad(the_repository, repl->hash)) != NULL) + if ((p = has_packed_and_bad(r, repl->hash)) != NULL) die(_("packed object %s (stored in %s) is corrupt"), oid_to_hex(repl), p->pack_name); diff --git a/streaming.c b/streaming.c index d1e6b2dce6..c843a1230f 100644 --- a/streaming.c +++ b/streaming.c @@ -490,7 +490,7 @@ static struct stream_vtbl incore_vtbl = { static open_method_decl(incore) { - st->u.incore.buf = read_object_file_extended(oid, type, &st->size, 0); + st->u.incore.buf = read_object_file_extended(the_repository, oid, type, &st->size, 0); st->u.incore.read_ptr = 0; st->vtbl = &incore_vtbl; From patchwork Sat Dec 15 00:09:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Beller X-Patchwork-Id: 10731875 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 950E51399 for ; Sat, 15 Dec 2018 00:09:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2E60E2D3F8 for ; Sat, 15 Dec 2018 00:09:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 219372D404; Sat, 15 Dec 2018 00:09:58 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, USER_IN_DEF_DKIM_WL autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B29012D3F8 for ; Sat, 15 Dec 2018 00:09:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729971AbeLOAJ4 (ORCPT ); Fri, 14 Dec 2018 19:09:56 -0500 Received: from mail-oi1-f201.google.com ([209.85.167.201]:35017 "EHLO mail-oi1-f201.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726772AbeLOAJ4 (ORCPT ); Fri, 14 Dec 2018 19:09:56 -0500 Received: by mail-oi1-f201.google.com with SMTP id p128so3508057oib.2 for ; Fri, 14 Dec 2018 16:09:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=DACWlUeY+RZA0wRcFkTx1UDCPhv018/kT5+4RWS8SlI=; b=iSeOf4GFvr7A/+3yaAJ6ZbqWQGNbrWSNVVUuMxdEAnwGiJtw/ovWQf2lywvWCBMbU5 +OZ2YDTJTJjswPh4PujQSgTMVS79xyszgFxXNnQdGtmge24YzRSRxIwnMGZ88CnbGq2n sKCPRYmw4RcP7X0P/JCK3BtHzPi1LMFiJohnYIjY8w3jmAfkSKre5hadG/DuVq5g6SC4 DAmgjyCaZWJ4Vg4wNonUfZt43UpnyK2ZGTXCLcSnXzK2pGe3nFrVSbxjoKDB5wICPF5r Jw6nuBmGBzFiY6hlzNcfUajJYKpmaYonvDHlTn2D87K44gPEsT/QcmFeOej+3rJ8rvY9 yFow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=DACWlUeY+RZA0wRcFkTx1UDCPhv018/kT5+4RWS8SlI=; b=VazPuo5+Ei1hnkraKJ3YmX7B66hcNHi7ttmLPIjho/4R5KGbQNPQeaulo/CI5+aOon GNR0imtJzozCryEV/c/2/vJBk6peX0bhV7DPBmD8evTgrD4QuRgIi+Euai82arf8fwXJ ZptqSBTsMhTbB2SSC0DB/glawEE9biDj8oNchHgis3tq+ZDVIHT59v+ZJ9vQdFkRnE9A MEZ2iRwxsB0Eqr1Fv/V4y8IZEQHxKzlE3eenxeYhsTsfWS3bT63+p4/PPo0OqGqg4vXR zjoCeCS2dchXgkPbs1yQ+UOB1pSSJZj6sZohgnahp1jCjKHHyHL4sQebpbJlhuvZA9zf bUkA== X-Gm-Message-State: AA+aEWZfT6V2dLce+QKqrXJKANpxyzo2SI2Z25o5NNlejy3tl/Et8tO1 IF+8/oTl/kiR62jnYSeQlBJ26L64LfBQdz4ix3n/GYIQ8v1oKK9aaGvDn2vEGRf5dcpmgAgrVIm BMLQOGOkxTzD7sqi2Jo+RC+cfAd9TQPGLHZDoqczJEatR+3rGOtAHyer3c/7x X-Google-Smtp-Source: AFSGD/Wlh/pOZK6fp0bxwveogV1kYkE8K23E7umT0Zk7EAlA9woeWRLto574aJH4d/vIrqoEoCZMNfvHNdP0 X-Received: by 2002:aca:3341:: with SMTP id z62mr4171825oiz.32.1544832594985; Fri, 14 Dec 2018 16:09:54 -0800 (PST) Date: Fri, 14 Dec 2018 16:09:23 -0800 In-Reply-To: <20181215000942.46033-1-sbeller@google.com> Message-Id: <20181215000942.46033-5-sbeller@google.com> Mime-Version: 1.0 References: <20181215000942.46033-1-sbeller@google.com> X-Mailer: git-send-email 2.20.0.405.gbc1bbc6f85-goog Subject: [PATCH 04/23] object-store: prepare read_object_file to deal with any repo From: Stefan Beller To: git@vger.kernel.org Cc: Stefan Beller , Junio C Hamano Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP As read_object_file is a widely used function (which is also regularly used in new code in flight between master..pu), changing its signature is painful is hard, as other series in flight rely on the original signature. It would burden the maintainer if we'd just change the signature. Introduce repo_read_object_file which takes the repository argument, and hide the original read_object_file as a macro behind NO_THE_REPOSITORY_COMPATIBILITY_MACROS, similar to e675765235 (diff.c: remove implicit dependency on the_index, 2018-09-21) Add a coccinelle patch to convert existing callers, but do not apply the resulting patch to keep the diff of this patch small. Signed-off-by: Stefan Beller Signed-off-by: Junio C Hamano --- contrib/coccinelle/the_repository.pending.cocci | 12 ++++++++++++ object-store.h | 10 ++++++++-- 2 files changed, 20 insertions(+), 2 deletions(-) create mode 100644 contrib/coccinelle/the_repository.pending.cocci diff --git a/contrib/coccinelle/the_repository.pending.cocci b/contrib/coccinelle/the_repository.pending.cocci new file mode 100644 index 0000000000..a7ac9e0c46 --- /dev/null +++ b/contrib/coccinelle/the_repository.pending.cocci @@ -0,0 +1,12 @@ +// This file is used for the ongoing refactoring of +// bringing the index or repository struct in all of +// our code base. + +@@ +expression E; +expression F; +expression G; +@@ +- read_object_file( ++ repo_read_object_file(the_repository, + E, F, G) diff --git a/object-store.h b/object-store.h index 3d98a682b2..00a64622e6 100644 --- a/object-store.h +++ b/object-store.h @@ -165,10 +165,16 @@ extern void *read_object_file_extended(struct repository *r, const struct object_id *oid, enum object_type *type, unsigned long *size, int lookup_replace); -static inline void *read_object_file(const struct object_id *oid, enum object_type *type, unsigned long *size) +static inline void *repo_read_object_file(struct repository *r, + const struct object_id *oid, + enum object_type *type, + unsigned long *size) { - return read_object_file_extended(the_repository, oid, type, size, 1); + return read_object_file_extended(r, oid, type, size, 1); } +#ifndef NO_THE_REPOSITORY_COMPATIBILITY_MACROS +#define read_object_file(oid, type, size) repo_read_object_file(the_repository, oid, type, size) +#endif /* Read and unpack an object file into memory, write memory to an object file */ int oid_object_info(struct repository *r, const struct object_id *, unsigned long *); From patchwork Sat Dec 15 00:09:24 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Beller X-Patchwork-Id: 10731877 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B4BB0746 for ; Sat, 15 Dec 2018 00:10:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4ED1A2D3F8 for ; Sat, 15 Dec 2018 00:10:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4335B2D404; Sat, 15 Dec 2018 00:10:00 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, USER_IN_DEF_DKIM_WL autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C4C8C2D3F8 for ; Sat, 15 Dec 2018 00:09:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729979AbeLOAJ6 (ORCPT ); Fri, 14 Dec 2018 19:09:58 -0500 Received: from mail-qk1-f202.google.com ([209.85.222.202]:53484 "EHLO mail-qk1-f202.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726772AbeLOAJ6 (ORCPT ); Fri, 14 Dec 2018 19:09:58 -0500 Received: by mail-qk1-f202.google.com with SMTP id s19so6717102qke.20 for ; Fri, 14 Dec 2018 16:09:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=CzvlT4WIhEJRVP8hCQ0KaOrI064jrf7Cp8CR30bm7jo=; b=TLJSCblKAR04X6ObJ27uBjaFz4a2y3oZdLfpHRIpC+1dEW8IdH0MKZiR3aLvREq9zb IDmzdYmZNl7NPCvC78bLuy6Ibq3E5gDHCQk5DqLQ/94YzrRYz695+oHQ1ySZJRK86va5 01RIigVWOHNwTg7yI7jeEfh0+kq02VPRGVAP8jR4wDuZ01IKwKy0R4ZlFA7vJ352pKn+ ENHtGfzfIFxYVmeVRBgaEFgzJmVuhU/e2kJZpvIPkNF1tdsYEZEPVsu2LnU6tjzjz0sC BhmIVFMBqm5WxIBVWpGk9M9p+qdvx7bJOuG+LAGEHsWJuGLcg6cZokQh/xmSfV3sOoqx 4tWA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=CzvlT4WIhEJRVP8hCQ0KaOrI064jrf7Cp8CR30bm7jo=; b=feN25+NjTC3IVi7BFfkG9Hj7gzHGlDvt/lH5nf5nwz99p6hNgpx88WgqRVtbYzKXsz nEHhiRMNLon1zQgW1NZzV6j6zpTWTKZOv0Y8IGpSWWC7AekBmAwWZqfkxO2j7NYIgyw4 /JyHwXgD7cpRtk4JkET/BpuTo3CYJlp0ar/4nehGHkckH7vIFUIS+btuImM3V1U0tsZd 5nsV2JvHXmv8rKwBi6AcqSu2dDtHtGXQ8aDXEYifMFjGhDy6t2I1u//mUz39ArvH23xz +FIHv2JIpDf2gooT4h4sEiJTXnc5oZEnKl9PNfpXMdLYMaKfkbl7yveFblJfTko8F8UB /kGw== X-Gm-Message-State: AA+aEWZ81CkHyYCzpUWhePjoqRyHRvXdrPWqvT9jrDHYQP52Nh0WbJSK /X+93iuyBpIPnd3FDc8FN8AM2Bt6s6BnsZSRpyyg71WtvrUUsWnN6VT1AZNEnlTapDcHjoDf82T 3GP4rrQa1epTYYxXFgnSnJ6q++FlNVaHF/rRDXVezdRER7tsdcbjYA0chLYVY X-Google-Smtp-Source: AFSGD/USM6LxI4vJWOA4o6VTuXzGXU5V3DbczwdxXjT73ZcVwv94tWv889Q/Hi+PzE9PCCecWjW8bPpETSbw X-Received: by 2002:a0c:9357:: with SMTP id e23mr4872800qve.55.1544832597277; Fri, 14 Dec 2018 16:09:57 -0800 (PST) Date: Fri, 14 Dec 2018 16:09:24 -0800 In-Reply-To: <20181215000942.46033-1-sbeller@google.com> Message-Id: <20181215000942.46033-6-sbeller@google.com> Mime-Version: 1.0 References: <20181215000942.46033-1-sbeller@google.com> X-Mailer: git-send-email 2.20.0.405.gbc1bbc6f85-goog Subject: [PATCH 05/23] object-store: prepare has_{sha1, object}_file to handle any repo From: Stefan Beller To: git@vger.kernel.org Cc: Stefan Beller , Junio C Hamano Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Stefan Beller Signed-off-by: Junio C Hamano --- .../coccinelle/the_repository.pending.cocci | 30 +++++++++++++++++++ object-store.h | 22 ++++++++++---- sha1-file.c | 15 ++++++---- 3 files changed, 56 insertions(+), 11 deletions(-) diff --git a/contrib/coccinelle/the_repository.pending.cocci b/contrib/coccinelle/the_repository.pending.cocci index a7ac9e0c46..46f3a1b23a 100644 --- a/contrib/coccinelle/the_repository.pending.cocci +++ b/contrib/coccinelle/the_repository.pending.cocci @@ -10,3 +10,33 @@ expression G; - read_object_file( + repo_read_object_file(the_repository, E, F, G) + +@@ +expression E; +@@ +- has_sha1_file( ++ repo_has_sha1_file(the_repository, + E) + +@@ +expression E; +expression F; +@@ +- has_sha1_file_with_flags( ++ repo_has_sha1_file_with_flags(the_repository, + E) + +@@ +expression E; +@@ +- has_object_file( ++ repo_has_object_file(the_repository, + E) + +@@ +expression E; +expression F; +@@ +- has_object_file_with_flags( ++ repo_has_object_file_with_flags(the_repository, + E) diff --git a/object-store.h b/object-store.h index 00a64622e6..2b5e6ff1ed 100644 --- a/object-store.h +++ b/object-store.h @@ -212,15 +212,27 @@ int read_loose_object(const char *path, * object_info. OBJECT_INFO_SKIP_CACHED is automatically set; pass * nonzero flags to also set other flags. */ -extern int has_sha1_file_with_flags(const unsigned char *sha1, int flags); -static inline int has_sha1_file(const unsigned char *sha1) +int repo_has_sha1_file_with_flags(struct repository *r, + const unsigned char *sha1, int flags); +static inline int repo_has_sha1_file(struct repository *r, + const unsigned char *sha1) { - return has_sha1_file_with_flags(sha1, 0); + return repo_has_sha1_file_with_flags(r, sha1, 0); } +#ifndef NO_THE_REPOSITORY_COMPATIBILITY_MACROS +#define has_sha1_file_with_flags(sha1, flags) repo_has_sha1_file_with_flags(the_repository, sha1, flags) +#define has_sha1_file(sha1) repo_has_sha1_file(the_repository, sha1) +#endif + /* Same as the above, except for struct object_id. */ -extern int has_object_file(const struct object_id *oid); -extern int has_object_file_with_flags(const struct object_id *oid, int flags); +int repo_has_object_file(struct repository *r, const struct object_id *oid); +int repo_has_object_file_with_flags(struct repository *r, + const struct object_id *oid, int flags); +#ifndef NO_THE_REPOSITORY_COMPATIBILITY_MACROS +#define has_object_file(oid) repo_has_object_file(the_repository, oid) +#define has_object_file_with_flags(oid, flags) repo_has_object_file_with_flags(the_repository, oid, flags) +#endif /* * Return true iff an alternate object database has a loose object diff --git a/sha1-file.c b/sha1-file.c index c5b704aec5..e77273ccfd 100644 --- a/sha1-file.c +++ b/sha1-file.c @@ -1768,24 +1768,27 @@ int force_object_loose(const struct object_id *oid, time_t mtime) return ret; } -int has_sha1_file_with_flags(const unsigned char *sha1, int flags) +int repo_has_sha1_file_with_flags(struct repository *r, + const unsigned char *sha1, int flags) { struct object_id oid; if (!startup_info->have_repository) return 0; hashcpy(oid.hash, sha1); - return oid_object_info_extended(the_repository, &oid, NULL, + return oid_object_info_extended(r, &oid, NULL, flags | OBJECT_INFO_SKIP_CACHED) >= 0; } -int has_object_file(const struct object_id *oid) +int repo_has_object_file(struct repository *r, + const struct object_id *oid) { - return has_sha1_file(oid->hash); + return repo_has_sha1_file(r, oid->hash); } -int has_object_file_with_flags(const struct object_id *oid, int flags) +int repo_has_object_file_with_flags(struct repository *r, + const struct object_id *oid, int flags) { - return has_sha1_file_with_flags(oid->hash, flags); + return repo_has_sha1_file_with_flags(r, oid->hash, flags); } static void check_tree(const void *buf, size_t size) From patchwork Sat Dec 15 00:09:25 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Beller X-Patchwork-Id: 10731879 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 84D9C1399 for ; Sat, 15 Dec 2018 00:10:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1A2382D3F8 for ; Sat, 15 Dec 2018 00:10:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0BF822D404; Sat, 15 Dec 2018 00:10:03 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, USER_IN_DEF_DKIM_WL autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F2C012D400 for ; Sat, 15 Dec 2018 00:10:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729993AbeLOAKB (ORCPT ); Fri, 14 Dec 2018 19:10:01 -0500 Received: from mail-it1-f202.google.com ([209.85.166.202]:43807 "EHLO mail-it1-f202.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726772AbeLOAKA (ORCPT ); Fri, 14 Dec 2018 19:10:00 -0500 Received: by mail-it1-f202.google.com with SMTP id 128so7659315itw.8 for ; Fri, 14 Dec 2018 16:10:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=sid1qn/jq/oUHvTRU2d5Rfs9v0w1WFTSzjuvcuydNW4=; b=TWQIhzojQlFZ+7Dyn6SdW+eefOT3+Grqp2JQoiYpGAzGjrzymfeDxy6iZ9/mklBIZr rKenTOs42zKWha2wGmpta5U/atfsrGS6VOL6KuiSh8YXAFZDjXyKqJLjCYhLj3TO2j6L KOSBfR4CVC7R/WBMVsIH/5urZMmfU6IwDiq6YQYy7N6pKj8zOPcLyjW7p8Yawjwp4+Rg 4vrGGtL64IoYEP2TjT8WKZagF3kIDNyorHlBnm/2+8dfs4QreqB9Y32B9exsEnrd5H8Y Lc9nbzJlel9aSfckXjNX0Zc+ojxcCMXWwnfAzpQWdyWSVdpU67ZaLGh/cyVDCl06GOUd Ua2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=sid1qn/jq/oUHvTRU2d5Rfs9v0w1WFTSzjuvcuydNW4=; b=ofifFCmNDcr9n/OuoP3HylL1FrO5XNVtVV2skM8y22Gkrfm42An8fc2/8GVewCSsvC 0k+qgaDb4kylHtPzxvboG/D6WCdiLsPYeaPAzVY38Hnr57IoNwVrSuid8AhmNajkCjnP qF4lPhme1DPu7x1AWGj2t4jGVFYeslFvcoogurkr3XygesKwrg8MBwUkW/19IZ4BmGSE yw6DqAQKHhgezAriqXDCG+HYI0htjjt12IL5LzNJY8+pS/kHeClzD8VFt2g7xYkRz80a nACOVdZoxaE+DaDXgBq5mj3PDvu/XAEQZCRBp4YS857bFul8nJKEWnVzO1CyE2kZTHeR JIzg== X-Gm-Message-State: AA+aEWZUAOYeFuGo5l+ZUHpt5CTO+hzNTClYonbrHj53NokvkgcXZDEx anj2H0TBC1VFZyIBMRcSKUbra8lHexnl4HlC+m6HrCTefynTOwWuzfYrPQjtg4G7MF+9JIaqCw0 XQYnfkq2FenAxM43nkvDC0BQJ4bju6kxfb36DZu5i2gQr0GHkKu9Xg6knEqaA X-Google-Smtp-Source: AFSGD/XYYNGPzLzZ8oqRZ6SEEZY8IJ2THif6LU/QofwD2OyuEVVHEhcYNdHTbHAjKQ26JNcsKK/RMkfwhqzM X-Received: by 2002:a24:42c3:: with SMTP id i186mr4662677itb.2.1544832599705; Fri, 14 Dec 2018 16:09:59 -0800 (PST) Date: Fri, 14 Dec 2018 16:09:25 -0800 In-Reply-To: <20181215000942.46033-1-sbeller@google.com> Message-Id: <20181215000942.46033-7-sbeller@google.com> Mime-Version: 1.0 References: <20181215000942.46033-1-sbeller@google.com> X-Mailer: git-send-email 2.20.0.405.gbc1bbc6f85-goog Subject: [PATCH 06/23] object: parse_object to honor its repository argument From: Stefan Beller To: git@vger.kernel.org Cc: Stefan Beller , Junio C Hamano Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP In 8e4b0b6047 (object.c: allow parse_object to handle arbitrary repositories, 2018-06-28), we forgot to pass the repository down to the read_object_file. Signed-off-by: Stefan Beller Signed-off-by: Junio C Hamano --- object.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/object.c b/object.c index e54160550c..003f870484 100644 --- a/object.c +++ b/object.c @@ -259,8 +259,8 @@ struct object *parse_object(struct repository *r, const struct object_id *oid) if (obj && obj->parsed) return obj; - if ((obj && obj->type == OBJ_BLOB && has_object_file(oid)) || - (!obj && has_object_file(oid) && + if ((obj && obj->type == OBJ_BLOB && repo_has_object_file(r, oid)) || + (!obj && repo_has_object_file(r, oid) && oid_object_info(r, oid, NULL) == OBJ_BLOB)) { if (check_object_signature(repl, NULL, 0, NULL) < 0) { error(_("sha1 mismatch %s"), oid_to_hex(oid)); @@ -270,7 +270,7 @@ struct object *parse_object(struct repository *r, const struct object_id *oid) return lookup_object(r, oid->hash); } - buffer = read_object_file(oid, &type, &size); + buffer = repo_read_object_file(r, oid, &type, &size); if (buffer) { if (check_object_signature(repl, buffer, size, type_name(type)) < 0) { free(buffer); From patchwork Sat Dec 15 00:09:26 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Beller X-Patchwork-Id: 10731881 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DA612746 for ; Sat, 15 Dec 2018 00:10:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 73FD02D3F8 for ; Sat, 15 Dec 2018 00:10:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 674E22D404; Sat, 15 Dec 2018 00:10:05 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, USER_IN_DEF_DKIM_WL autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E77852D3F8 for ; Sat, 15 Dec 2018 00:10:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730020AbeLOAKD (ORCPT ); Fri, 14 Dec 2018 19:10:03 -0500 Received: from mail-qk1-f201.google.com ([209.85.222.201]:39627 "EHLO mail-qk1-f201.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729995AbeLOAKD (ORCPT ); Fri, 14 Dec 2018 19:10:03 -0500 Received: by mail-qk1-f201.google.com with SMTP id d196so6698222qkb.6 for ; Fri, 14 Dec 2018 16:10:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=YeZ+zUv2zWfAv5Kp5HUo0hvcLk8SERNJaXR2VzZhsLQ=; b=TgjF4Er+AI9r8dXIKMVaTJx/LDQX0Y6XQDXPm50/xwhcScGbz4H+AWcR2H3eXQbNTN aXevPuQUU2sfNoGx/OSrubJpvVizPTxYjDlyddW4OuCcY1Ycx73NWxqaGabXf5Fq+xVW TTLDBLLGZ5i6fU14M/haHHfw070kByqcisNUd8VmBsKXmRxmFU+rAIzrIArlrClIewKi qJylVAzyV4VB0NvSg0hV4K3LCz7FP+IF4pX2Yfen9Cqp1bDoD/m6ecS2c9+Sxou4G51O JaKjIq5KqrDuBv7uNnTrleQarfRvxzpkcqjiM7MRfkbOXg0Bd06lkNLEfYAu2AyV3xS5 lhtw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=YeZ+zUv2zWfAv5Kp5HUo0hvcLk8SERNJaXR2VzZhsLQ=; b=DGAwU8mL6HmW4tJvQ3ZrgKaBNtRKQMZibr1g8yPv+odkI3dsBJqQSjhkyZyyR0RMi+ v/mExQ3sfA9Y9HA2UHuaCOELuCeWZ+OzwSrA4YwI4bWKiyZZPkhImqgqw8CjSWPOqPZ6 s75XBwtHluUWA2Ii6gN9KGD8KkgllwfQr+P5eULN9WUGJoDObTNmkTYSY8HCcBjOYmU0 qPmZivMuUUKrCSx9M2QIgLj8HnGizmIECIu2xM/+0SxwyrCWk1Au/hvnai+zsWlLrd22 tBXm2jgU6HpuVu0WJlQTUrmX9cotHVnuS/GMXkBg7B+2xDG9BcpelP/cadk3kbwNeg7t ByVA== X-Gm-Message-State: AA+aEWYIE2AVGu7Wbqg0TMSfu17DTl1IM4I5daDYUYCiAhxUv4jhqWWi hHEy7eaq7JT8xfz9LXiYQAtT4IVXrlNdLG5U/lRmd9sWiHaylE7AFQKHap7glpcjepzrglmdCyr x3+ghfSujwQnOOfTNDAcPWczMk/t75UIw+D+SvflYLnbOqQv5TYyVKw1KbY3B X-Google-Smtp-Source: AFSGD/UmgCoXABUW8tQt4PrxTjP+3jUH+twuAL9cQV2vUzBSMHRZJIIpPytsqmC9ztKABX9Kf1lhFxcC+zc4 X-Received: by 2002:ac8:43da:: with SMTP id w26mr4780593qtn.25.1544832602167; Fri, 14 Dec 2018 16:10:02 -0800 (PST) Date: Fri, 14 Dec 2018 16:09:26 -0800 In-Reply-To: <20181215000942.46033-1-sbeller@google.com> Message-Id: <20181215000942.46033-8-sbeller@google.com> Mime-Version: 1.0 References: <20181215000942.46033-1-sbeller@google.com> X-Mailer: git-send-email 2.20.0.405.gbc1bbc6f85-goog Subject: [PATCH 07/23] commit: allow parse_commit* to handle any repo From: Stefan Beller To: git@vger.kernel.org Cc: Stefan Beller , Junio C Hamano Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Just like the previous commit, parse_commit and friends are used a lot and are found in new patches, so we cannot change their signature easily. Re-introduce these function prefixed with 'repo_' that take a repository argument and keep the original as a shallow macro. Signed-off-by: Stefan Beller Signed-off-by: Junio C Hamano --- commit.c | 18 ++++++++------ commit.h | 17 +++++++++---- .../coccinelle/the_repository.pending.cocci | 24 +++++++++++++++++++ 3 files changed, 48 insertions(+), 11 deletions(-) diff --git a/commit.c b/commit.c index dc8a39d52a..7a931d7fd4 100644 --- a/commit.c +++ b/commit.c @@ -443,7 +443,10 @@ int parse_commit_buffer(struct repository *r, struct commit *item, const void *b return 0; } -int parse_commit_internal(struct commit *item, int quiet_on_missing, int use_commit_graph) +int repo_parse_commit_internal(struct repository *r, + struct commit *item, + int quiet_on_missing, + int use_commit_graph) { enum object_type type; void *buffer; @@ -454,9 +457,9 @@ int parse_commit_internal(struct commit *item, int quiet_on_missing, int use_com return -1; if (item->object.parsed) return 0; - if (use_commit_graph && parse_commit_in_graph(the_repository, item)) + if (use_commit_graph && parse_commit_in_graph(r, item)) return 0; - buffer = read_object_file(&item->object.oid, &type, &size); + buffer = repo_read_object_file(r, &item->object.oid, &type, &size); if (!buffer) return quiet_on_missing ? -1 : error("Could not read %s", @@ -467,18 +470,19 @@ int parse_commit_internal(struct commit *item, int quiet_on_missing, int use_com oid_to_hex(&item->object.oid)); } - ret = parse_commit_buffer(the_repository, item, buffer, size, 0); + ret = parse_commit_buffer(r, item, buffer, size, 0); if (save_commit_buffer && !ret) { - set_commit_buffer(the_repository, item, buffer, size); + set_commit_buffer(r, item, buffer, size); return 0; } free(buffer); return ret; } -int parse_commit_gently(struct commit *item, int quiet_on_missing) +int repo_parse_commit_gently(struct repository *r, + struct commit *item, int quiet_on_missing) { - return parse_commit_internal(item, quiet_on_missing, 1); + return repo_parse_commit_internal(r, item, quiet_on_missing, 1); } void parse_commit_or_die(struct commit *item) diff --git a/commit.h b/commit.h index 1d260d62f5..08935f9a19 100644 --- a/commit.h +++ b/commit.h @@ -79,12 +79,21 @@ struct commit *lookup_commit_reference_by_name(const char *name); struct commit *lookup_commit_or_die(const struct object_id *oid, const char *ref_name); int parse_commit_buffer(struct repository *r, struct commit *item, const void *buffer, unsigned long size, int check_graph); -int parse_commit_internal(struct commit *item, int quiet_on_missing, int use_commit_graph); -int parse_commit_gently(struct commit *item, int quiet_on_missing); -static inline int parse_commit(struct commit *item) +int repo_parse_commit_internal(struct repository *r, struct commit *item, + int quiet_on_missing, int use_commit_graph); +int repo_parse_commit_gently(struct repository *r, + struct commit *item, + int quiet_on_missing); +static inline int repo_parse_commit(struct repository *r, struct commit *item) { - return parse_commit_gently(item, 0); + return repo_parse_commit_gently(r, item, 0); } +#ifndef NO_THE_REPOSITORY_COMPATIBILITY_MACROS +#define parse_commit_internal(item, quiet, use) repo_parse_commit_internal(the_repository, item, quiet, use) +#define parse_commit_gently(item, quiet) repo_parse_commit_gently(the_repository, item, quiet) +#define parse_commit(item) repo_parse_commit(the_repository, item) +#endif + void parse_commit_or_die(struct commit *item); struct buffer_slab; diff --git a/contrib/coccinelle/the_repository.pending.cocci b/contrib/coccinelle/the_repository.pending.cocci index 46f3a1b23a..b185fe0a1d 100644 --- a/contrib/coccinelle/the_repository.pending.cocci +++ b/contrib/coccinelle/the_repository.pending.cocci @@ -40,3 +40,27 @@ expression F; - has_object_file_with_flags( + repo_has_object_file_with_flags(the_repository, E) + +@@ +expression E; +expression F; +expression G; +@@ +- parse_commit_internal( ++ repo_parse_commit_internal(the_repository, + E, F, G) + +@@ +expression E; +expression F; +@@ +- parse_commit_gently( ++ repo_parse_commit_gently(the_repository, + E, F) + +@@ +expression E; +@@ +- parse_commit( ++ repo_parse_commit(the_repository, + E) From patchwork Sat Dec 15 00:09:27 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Beller X-Patchwork-Id: 10731883 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8AA44746 for ; Sat, 15 Dec 2018 00:10:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 23E8A2D3F8 for ; Sat, 15 Dec 2018 00:10:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 186F12D404; Sat, 15 Dec 2018 00:10:08 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, USER_IN_DEF_DKIM_WL autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B44DE2D3F8 for ; Sat, 15 Dec 2018 00:10:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730023AbeLOAKG (ORCPT ); Fri, 14 Dec 2018 19:10:06 -0500 Received: from mail-yw1-f73.google.com ([209.85.161.73]:40114 "EHLO mail-yw1-f73.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729995AbeLOAKG (ORCPT ); Fri, 14 Dec 2018 19:10:06 -0500 Received: by mail-yw1-f73.google.com with SMTP id l69so4248340ywb.7 for ; Fri, 14 Dec 2018 16:10:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=Etx73kyqJPXbt8GvWfs4sqwAwR4Jh8mjtb5s5i9ZhcE=; b=RrmUl80krKFyswuw1T3B5v+IV67u0WOntMPMJ58cm6kSx44ve36vuxtEH5LEmCGBm9 Ds2CILJIrpUFDtvv/0NKG7SKD20XXGRABIjP8Dw22zEzsZxC4tsfapJO3IZINhyZGLhJ Cy/xKdKQC2DaXvbZ3czlQ6FJDprXrTKtZxsG+Pd92EEhpTBIoT48HCY2KvNgFG2vefjv clDq9pXuRZ5dtCDO30O9vB2x0VE8IhhTfSFziqBD9Lvd3NMxALZ3n9kzP5POscEwj0Jh 3QWStWXSl9UYaX7cEJ5aPdKBREKTX7gjW/ONuAorPktbGzCjCWfwgzRtw0hLv4mCPLel Bt5w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=Etx73kyqJPXbt8GvWfs4sqwAwR4Jh8mjtb5s5i9ZhcE=; b=dqZMKx1ZXYuH5oZeNfI4gJwe97dpRA/sR8sCoHDz7DzgQ2BKQND7k/C/FGwBkb/4UW gJ1ybfrxD0b+/JE69XuBgmvmtIfz0CX9uwhuhQz1PLJ242IqE2aQro6Bhp77LN15VXpm aKf5wEJppWgKcka5GVd1dZtD7BRhdbI0c3e5D4ksxIMgJ1S8vRVQXfXZAR8EWPGN0pyP X+tZ2+Ukk574sNGtXdCYghkJVFg5NOv9hhzaR8JqNReUg/QWtkLYkqphnc73tgWKsVSD flZAx6BhvCu+h8Tpp4iYmyi3JKo/BpyBXbb/UWlTyL6qoo20uvXrckRYWC+1rUmIaAjC 9wrQ== X-Gm-Message-State: AA+aEWZdlcbFnKta0XI9IPHSL39/4ZwKstkCwktA30y4AccobVhkS364 N19jBbBmO1J6wWoaTbKAEwgb8ky/XPK58mmA683G0//QbGMZ/U2ELFAKzafNQ9OOKSwduBUpnXr XwdHJ/Fcv7Rqd6fb4uxqCZznOIiEr4twdBTD2SISua5I61+wpN4Kc67CoX9Kl X-Google-Smtp-Source: AFSGD/W/dKe1Icb5cqqgl4m6VkrBF02kwpAulBnanFAmBLm79vIU7nkH++gU3LX+za8uo6enq1CfxT4xtSvP X-Received: by 2002:a25:ac90:: with SMTP id x16-v6mr3324140ybi.3.1544832604840; Fri, 14 Dec 2018 16:10:04 -0800 (PST) Date: Fri, 14 Dec 2018 16:09:27 -0800 In-Reply-To: <20181215000942.46033-1-sbeller@google.com> Message-Id: <20181215000942.46033-9-sbeller@google.com> Mime-Version: 1.0 References: <20181215000942.46033-1-sbeller@google.com> X-Mailer: git-send-email 2.20.0.405.gbc1bbc6f85-goog Subject: [PATCH 08/23] commit-reach.c: allow paint_down_to_common to handle any repo From: Stefan Beller To: git@vger.kernel.org Cc: Stefan Beller , Junio C Hamano Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP As the function is file local and not widely used, migrate it all at once. Signed-off-by: Stefan Beller Signed-off-by: Junio C Hamano --- commit-reach.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/commit-reach.c b/commit-reach.c index 9f79ce0a22..67c2e43d5e 100644 --- a/commit-reach.c +++ b/commit-reach.c @@ -30,7 +30,8 @@ static int queue_has_nonstale(struct prio_queue *queue) } /* all input commits in one and twos[] must have been parsed! */ -static struct commit_list *paint_down_to_common(struct commit *one, int n, +static struct commit_list *paint_down_to_common(struct repository *r, + struct commit *one, int n, struct commit **twos, int min_generation) { @@ -83,7 +84,7 @@ static struct commit_list *paint_down_to_common(struct commit *one, int n, parents = parents->next; if ((p->object.flags & flags) == flags) continue; - if (parse_commit(p)) + if (repo_parse_commit(r, p)) return NULL; p->object.flags |= flags; prio_queue_put(&queue, p); @@ -116,7 +117,7 @@ static struct commit_list *merge_bases_many(struct commit *one, int n, struct co return NULL; } - list = paint_down_to_common(one, n, twos, 0); + list = paint_down_to_common(the_repository, one, n, twos, 0); while (list) { struct commit *commit = pop_commit(&list); @@ -187,8 +188,8 @@ static int remove_redundant(struct commit **array, int cnt) if (array[j]->generation < min_generation) min_generation = array[j]->generation; } - common = paint_down_to_common(array[i], filled, work, - min_generation); + common = paint_down_to_common(the_repository, array[i], filled, + work, min_generation); if (array[i]->object.flags & PARENT2) redundant[i] = 1; for (j = 0; j < filled; j++) @@ -322,7 +323,9 @@ int in_merge_bases_many(struct commit *commit, int nr_reference, struct commit * if (commit->generation > min_generation) return ret; - bases = paint_down_to_common(commit, nr_reference, reference, commit->generation); + bases = paint_down_to_common(the_repository, commit, + nr_reference, reference, + commit->generation); if (commit->object.flags & PARENT2) ret = 1; clear_commit_marks(commit, all_flags); From patchwork Sat Dec 15 00:09:28 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Beller X-Patchwork-Id: 10731885 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 978CA1399 for ; Sat, 15 Dec 2018 00:10:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 315B42D3F8 for ; Sat, 15 Dec 2018 00:10:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 262472D404; Sat, 15 Dec 2018 00:10:10 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, USER_IN_DEF_DKIM_WL autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C9C232D3F8 for ; Sat, 15 Dec 2018 00:10:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730031AbeLOAKI (ORCPT ); Fri, 14 Dec 2018 19:10:08 -0500 Received: from mail-pg1-f201.google.com ([209.85.215.201]:38673 "EHLO mail-pg1-f201.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729995AbeLOAKI (ORCPT ); Fri, 14 Dec 2018 19:10:08 -0500 Received: by mail-pg1-f201.google.com with SMTP id x26so4978696pgc.5 for ; Fri, 14 Dec 2018 16:10:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=aVF32Ohub+dX3Ja3aLdphwGDaYF3GYle5PUNGGrttT8=; b=SBjwEVUww1F25FRwuLusU06ZAcXckCJsHdlsIDxdabHVWFaLEaIKomS8iU91Fv3p4H nsabsaduLVEkvnqtErhkfBeLR3WJ5DboWaMhDdK8v4bWXbtW3DBjoxE7QQZa4yCIT1oV JFvx2NiuQPPa5zeBImuM74NhLOPx4cZsa2ER714KmbSt4o5qP4f3Cstl0NJqBBP3xjAk M9BLX5EUwl7v8RvVEyDpXlrFXRMd/eZr8l1aazpwCe4d89mqUze0+c/sR/TPoc7C/BdF 4MU9ChrRi88WOjW5+L3bifKXmlzatwhCygDBlxyI2hfoUgadRov7eXSQ9KVFrigVTou8 kIkw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=aVF32Ohub+dX3Ja3aLdphwGDaYF3GYle5PUNGGrttT8=; b=jV9ImIRDp05+DWTdqUHwd3AXE7RAxSe7YsOmMOP2kW+ZXIyWp647SGQF7SkjkqErc/ 2jQ6WgnYjPC+dNcU3f5cCGAoYN7LLX421m9rNzCqBq0sUElOKnUT2XeIQQ03po0Tzlhu 4D/Y6kc7BVZnzSvjCzs4ZeETtuaywYUJtvFtINAL1wuM+mJWOXErD58ZgY0ffNeAEb/+ FVxptacp/fPePAWA9wgp4mQvL/gGIAvRJkLnlQzKaaG4dmUejNqTamiSRJuzgH3iS3Mm PUj3hlf1E48l1D0LWs7RFN3GaVBBQCN4Gk1jbLBsnM5Le/wRdoNv409nH9lW+pfF43BR 7FGA== X-Gm-Message-State: AA+aEWaaia0WEZhTVfH9EDs6HPH5Jd/ijG9PxF801Jr63fLXvPrznFaM OfORxZLfZhE2hAhF3kV3uXdO1b6BdI8wIMYFdPjXszA0CM90q38pEZkL8I6HQoxWmztBz9pOnxV pe3LUzhvIfMspL5oMobtIM4TPmImP6EUMpaEtWxIz5QuHwaetDhZwGcqAEbkT X-Google-Smtp-Source: AFSGD/UHCUcg2OanqzCZsp/JVEEOwKx9Fxha0n4niFGRD3bJFabh/PndaFRJ5wSRxTUFY1VSD7jhmIuFtFh4 X-Received: by 2002:a62:ae16:: with SMTP id q22mr2720398pff.1.1544832607019; Fri, 14 Dec 2018 16:10:07 -0800 (PST) Date: Fri, 14 Dec 2018 16:09:28 -0800 In-Reply-To: <20181215000942.46033-1-sbeller@google.com> Message-Id: <20181215000942.46033-10-sbeller@google.com> Mime-Version: 1.0 References: <20181215000942.46033-1-sbeller@google.com> X-Mailer: git-send-email 2.20.0.405.gbc1bbc6f85-goog Subject: [PATCH 09/23] commit-reach.c: allow merge_bases_many to handle any repo From: Stefan Beller To: git@vger.kernel.org Cc: Stefan Beller , Junio C Hamano Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Stefan Beller Signed-off-by: Junio C Hamano --- commit-reach.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/commit-reach.c b/commit-reach.c index 67c2e43d5e..a53b31e6a2 100644 --- a/commit-reach.c +++ b/commit-reach.c @@ -95,7 +95,9 @@ static struct commit_list *paint_down_to_common(struct repository *r, return result; } -static struct commit_list *merge_bases_many(struct commit *one, int n, struct commit **twos) +static struct commit_list *merge_bases_many(struct repository *r, + struct commit *one, int n, + struct commit **twos) { struct commit_list *list = NULL; struct commit_list *result = NULL; @@ -110,14 +112,14 @@ static struct commit_list *merge_bases_many(struct commit *one, int n, struct co return commit_list_insert(one, &result); } - if (parse_commit(one)) + if (repo_parse_commit(r, one)) return NULL; for (i = 0; i < n; i++) { - if (parse_commit(twos[i])) + if (repo_parse_commit(r, twos[i])) return NULL; } - list = paint_down_to_common(the_repository, one, n, twos, 0); + list = paint_down_to_common(r, one, n, twos, 0); while (list) { struct commit *commit = pop_commit(&list); @@ -224,7 +226,7 @@ static struct commit_list *get_merge_bases_many_0(struct commit *one, struct commit_list *result; int cnt, i; - result = merge_bases_many(one, n, twos); + result = merge_bases_many(the_repository, one, n, twos); for (i = 0; i < n; i++) { if (one == twos[i]) return result; From patchwork Sat Dec 15 00:09:29 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Beller X-Patchwork-Id: 10731887 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8AD721399 for ; Sat, 15 Dec 2018 00:10:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 249F32D3F8 for ; Sat, 15 Dec 2018 00:10:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 18FDE2D404; Sat, 15 Dec 2018 00:10:12 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, USER_IN_DEF_DKIM_WL autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B872C2D3F8 for ; Sat, 15 Dec 2018 00:10:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729670AbeLOAKK (ORCPT ); Fri, 14 Dec 2018 19:10:10 -0500 Received: from mail-qk1-f201.google.com ([209.85.222.201]:37735 "EHLO mail-qk1-f201.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726448AbeLOAKK (ORCPT ); Fri, 14 Dec 2018 19:10:10 -0500 Received: by mail-qk1-f201.google.com with SMTP id s70so6779074qks.4 for ; Fri, 14 Dec 2018 16:10:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=edud6D32Xl3o0Vv2Yxc7tIJStc03SwPsoabEfx6VPpg=; b=vUiRW8amEYRm15Qivet48OPKUMgjEVPVG9rXvDgifQTlOIZsjN5Tl65MyEkWntOF8O Pq8FczlvYxVraTQqOIiKprkcComxKxtoemorDHwoyutV2nLmRfnJrHZw9AiJwWjhN4FR dH8nlOCO4blR5ooneTdCXiuN5Vm6tbqjlOSxwHO1+ueZ88nXf7LULxSQG8xLKykAdx3w V4u1wILIVBP8Ys1EGqyYJ0DqfqcAWKM5n/RfcfdtTQ6A5hIkyEMsHanbhuAKxgKlGBLl AJ+svpgP/lEJ+EM53Sl8bjN4jQrEiegOoF3HHftOy9TwWqUeUhor/bbW6DZ+W5ZuI68R NV8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=edud6D32Xl3o0Vv2Yxc7tIJStc03SwPsoabEfx6VPpg=; b=pVQzwc9YHlR0fAeqnWnBhozjw95KFJsEK/d0aq0ZPkAJ+mrzPdd2+oA8C3NubFUxhJ ziLgocehMRgIVGB8iIxAF4vAzndO8MGyUsjQj6+F495Wpw3uyGt4lhGxnLOfH2LwIVJY 36Jx/uEKzqdbDZe3HmlWD3DSs75JoBCclBgMkJKAmxGzOirtZyqMPcRn81UC3er/n1bO rnn/JXCHmCcrFDoqNBWh7tchMLezl1cmH+C7ck7sXn1v/yhRvCwgtCjHnZa+Pd73OP+G gsp2dfF4SWC88FMhDhtqs4Pv4pkYagjERavbnMBj2Oq37Q9OJNY/VFxo+HEfMBfJrkeo LbFA== X-Gm-Message-State: AA+aEWbkUb6RKY6vr89rrRYJTUJwnV0Ptz2Hr8nCFJJhHmR9iFXIzA4a SeduP38ZAaDn90WbY3imOwU9MaSOG301uvi31k1Mf+hv3szjz2c6p3qy7J0g2Qx4xeBwfhR5+bs 5nbH+MiVva0P+F/OAXMgfk3xdBwuyDcAB0/BJXL5fmwu7W8IQgIbx5L2IIS+h X-Google-Smtp-Source: AFSGD/Ve/3Ats5HXNS7nUQr80baTG23lDv5C4EoWgnZIJlvkDEJm+iILunD6fYtQWf5ftMOy9M72svEsomWZ X-Received: by 2002:a0c:8709:: with SMTP id 9mr4814334qvh.6.1544832609493; Fri, 14 Dec 2018 16:10:09 -0800 (PST) Date: Fri, 14 Dec 2018 16:09:29 -0800 In-Reply-To: <20181215000942.46033-1-sbeller@google.com> Message-Id: <20181215000942.46033-11-sbeller@google.com> Mime-Version: 1.0 References: <20181215000942.46033-1-sbeller@google.com> X-Mailer: git-send-email 2.20.0.405.gbc1bbc6f85-goog Subject: [PATCH 10/23] commit-reach.c: allow remove_redundant to handle any repo From: Stefan Beller To: git@vger.kernel.org Cc: Stefan Beller , Junio C Hamano Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Stefan Beller Signed-off-by: Junio C Hamano --- commit-reach.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/commit-reach.c b/commit-reach.c index a53b31e6a2..81015830cb 100644 --- a/commit-reach.c +++ b/commit-reach.c @@ -156,7 +156,7 @@ struct commit_list *get_octopus_merge_bases(struct commit_list *in) return ret; } -static int remove_redundant(struct commit **array, int cnt) +static int remove_redundant(struct repository *r, struct commit **array, int cnt) { /* * Some commit in the array may be an ancestor of @@ -174,7 +174,7 @@ static int remove_redundant(struct commit **array, int cnt) ALLOC_ARRAY(filled_index, cnt - 1); for (i = 0; i < cnt; i++) - parse_commit(array[i]); + repo_parse_commit(r, array[i]); for (i = 0; i < cnt; i++) { struct commit_list *common; uint32_t min_generation = array[i]->generation; @@ -190,7 +190,7 @@ static int remove_redundant(struct commit **array, int cnt) if (array[j]->generation < min_generation) min_generation = array[j]->generation; } - common = paint_down_to_common(the_repository, array[i], filled, + common = paint_down_to_common(r, array[i], filled, work, min_generation); if (array[i]->object.flags & PARENT2) redundant[i] = 1; @@ -249,7 +249,7 @@ static struct commit_list *get_merge_bases_many_0(struct commit *one, clear_commit_marks(one, all_flags); clear_commit_marks_many(n, twos, all_flags); - cnt = remove_redundant(rslt, cnt); + cnt = remove_redundant(the_repository, rslt, cnt); result = NULL; for (i = 0; i < cnt; i++) commit_list_insert_by_date(rslt[i], &result); @@ -370,7 +370,7 @@ struct commit_list *reduce_heads(struct commit_list *heads) p->item->object.flags &= ~STALE; } } - num_head = remove_redundant(array, num_head); + num_head = remove_redundant(the_repository, array, num_head); for (i = 0; i < num_head; i++) tail = &commit_list_insert(array[i], tail)->next; free(array); From patchwork Sat Dec 15 00:09:30 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Beller X-Patchwork-Id: 10731889 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 72A02746 for ; Sat, 15 Dec 2018 00:10:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0C37F2D3F8 for ; Sat, 15 Dec 2018 00:10:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0090A2D404; Sat, 15 Dec 2018 00:10:13 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, USER_IN_DEF_DKIM_WL autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 99D532D3F8 for ; Sat, 15 Dec 2018 00:10:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730037AbeLOAKM (ORCPT ); Fri, 14 Dec 2018 19:10:12 -0500 Received: from mail-pl1-f202.google.com ([209.85.214.202]:54628 "EHLO mail-pl1-f202.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729985AbeLOAKM (ORCPT ); Fri, 14 Dec 2018 19:10:12 -0500 Received: by mail-pl1-f202.google.com with SMTP id c14so4686402pls.21 for ; Fri, 14 Dec 2018 16:10:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=Qq36AbhTu2/y1VVQ5FAITMobyo+rHzjZ8TZA73x4h6M=; b=qkOnJv2C4dGlbngqAROmUA9GCHDxnWNpxkGHwJ346uhifzzO7fKXTNqY6DIWfPHzCL 9XMO35W0uXtoitlW0sYvPa3bGC0c4tO+++IiHaDXWq/rxdFve2SNwUILUdCHcRP1X6cO TPULeGHb6VzJu+r3f7dusbUUotKMAkFcNI5siblFCsNzz7QyvPvE4bIubIfLJeO7GEaO EZpXonwj6QGA5sx9DgoqbI+k8dSpNaJ0dr+VWxD6+OpLvd+T3oNhqNqFPcdoWr13/pHp Rt7KQZipr5xCqtiYknlKGbEr7m8fpopIW+un+2FYqxIDckKyavGK1MiwR3TCNqgDkyBF HExQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=Qq36AbhTu2/y1VVQ5FAITMobyo+rHzjZ8TZA73x4h6M=; b=GHHaXpIVhthgIZw4kt150f2frGGek7eC8eqr8Aoj1oP/+KGUOY3U1q3eF5NZpAxZpY JVuW4nnhiQ6XNa00tv23Le41/Izd2Mj0EfFHQVnv01hrmVUGGyyS8X6Qc1ziRDHPAh2c aD3nh2lX0DIYo1rDeYKxuRg440rm/dgGWYDJnTgu82Fuz33S+wb+Mri/P4XV3zQ13NfN sbGB5sqjpeRqc0i8Wyvw5WZ+QcDyU0B1e0UOGdtzgHSLdkQ6YSzc4jeI1n8X0FFIaNOM hN6I6VkXBYUJAWNuk0YkcMi6cUJkhlX4PN12e+LIfNT9qKQ9+gIA37Tgj1h21fpSnrZ8 Hw1w== X-Gm-Message-State: AA+aEWbNaJabQxSe1m5+A+0gS3ASu/EAAv6MRlz3MaU49qqMVlBzqmvX kGFk69BFS8pTvdHue0AkWxn47kazSoloi8fzuA7oOWZnWI6BMmn1zwCeVNPiQ5QqzKN0AjzGcU5 CbCOo16izRj8kKsS5SL+Kl7kdOJH5MFrFXPPdJny8mQw52Ai6UY5vlSzGYBc6 X-Google-Smtp-Source: AFSGD/VNdON2BpF+pmMa+jadzie8v3bYa48zJDpBYDo3OYkexZ/Y3fwqbI7ALlPUmV512sv3XitGv34p4MgW X-Received: by 2002:a62:d5c2:: with SMTP id d185mr2782711pfg.123.1544832611777; Fri, 14 Dec 2018 16:10:11 -0800 (PST) Date: Fri, 14 Dec 2018 16:09:30 -0800 In-Reply-To: <20181215000942.46033-1-sbeller@google.com> Message-Id: <20181215000942.46033-12-sbeller@google.com> Mime-Version: 1.0 References: <20181215000942.46033-1-sbeller@google.com> X-Mailer: git-send-email 2.20.0.405.gbc1bbc6f85-goog Subject: [PATCH 11/23] commit-reach.c: allow get_merge_bases_many_0 to handle any repo From: Stefan Beller To: git@vger.kernel.org Cc: Stefan Beller , Junio C Hamano Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Stefan Beller Signed-off-by: Junio C Hamano --- commit-reach.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/commit-reach.c b/commit-reach.c index 81015830cb..b3b1f62aba 100644 --- a/commit-reach.c +++ b/commit-reach.c @@ -216,7 +216,8 @@ static int remove_redundant(struct repository *r, struct commit **array, int cnt return filled; } -static struct commit_list *get_merge_bases_many_0(struct commit *one, +static struct commit_list *get_merge_bases_many_0(struct repository *r, + struct commit *one, int n, struct commit **twos, int cleanup) @@ -226,7 +227,7 @@ static struct commit_list *get_merge_bases_many_0(struct commit *one, struct commit_list *result; int cnt, i; - result = merge_bases_many(the_repository, one, n, twos); + result = merge_bases_many(r, one, n, twos); for (i = 0; i < n; i++) { if (one == twos[i]) return result; @@ -249,7 +250,7 @@ static struct commit_list *get_merge_bases_many_0(struct commit *one, clear_commit_marks(one, all_flags); clear_commit_marks_many(n, twos, all_flags); - cnt = remove_redundant(the_repository, rslt, cnt); + cnt = remove_redundant(r, rslt, cnt); result = NULL; for (i = 0; i < cnt; i++) commit_list_insert_by_date(rslt[i], &result); @@ -261,19 +262,19 @@ struct commit_list *get_merge_bases_many(struct commit *one, int n, struct commit **twos) { - return get_merge_bases_many_0(one, n, twos, 1); + return get_merge_bases_many_0(the_repository, one, n, twos, 1); } struct commit_list *get_merge_bases_many_dirty(struct commit *one, int n, struct commit **twos) { - return get_merge_bases_many_0(one, n, twos, 0); + return get_merge_bases_many_0(the_repository, one, n, twos, 0); } struct commit_list *get_merge_bases(struct commit *one, struct commit *two) { - return get_merge_bases_many_0(one, 1, &two, 1); + return get_merge_bases_many_0(the_repository, one, 1, &two, 1); } /* From patchwork Sat Dec 15 00:09:31 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Beller X-Patchwork-Id: 10731891 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A77AD1399 for ; Sat, 15 Dec 2018 00:10:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 41AEF2D3F8 for ; Sat, 15 Dec 2018 00:10:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 35CCE2D404; Sat, 15 Dec 2018 00:10:17 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, USER_IN_DEF_DKIM_WL autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AF18E2D3F8 for ; Sat, 15 Dec 2018 00:10:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730056AbeLOAKP (ORCPT ); Fri, 14 Dec 2018 19:10:15 -0500 Received: from mail-oi1-f201.google.com ([209.85.167.201]:50379 "EHLO mail-oi1-f201.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729985AbeLOAKP (ORCPT ); Fri, 14 Dec 2018 19:10:15 -0500 Received: by mail-oi1-f201.google.com with SMTP id u63so3438961oie.17 for ; Fri, 14 Dec 2018 16:10:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=SNdzTqvEPRUuy2MlNDNeLQoA3wta3rvPiVpwNcE1FR0=; b=rALuuXdAIpxuYEAZ6bqxb2Uh16DF7qsgiyK2i4JcMwzKGWA3P37ok89+Zljd1Duay1 FjXlgTZo4vmiUQOYhH3rdyPQqaqcWjL6Tkt1NmqeWnlU8OVwu7Vrdx5AN5oLOX6uz1Gr XLuSpBAAb2QTjcr2AN804/87AuDHMqcG60RnUg6UA0O0e8RoPH1qc6eU+GA+Rcr2lCDT 2qS6/HQ0eJZ8sUh9VNdN4E3+YuwdLhDcPHGV7IbTHuXSESpwD1IUxz1DupBmXZWM0FM3 nHhT05hYjalp2hPNKBCRfqXIBbZi+Dd2Qk8UKmzZtq0ynAz627S2Kg4h/C1QmJVwYg02 PC8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=SNdzTqvEPRUuy2MlNDNeLQoA3wta3rvPiVpwNcE1FR0=; b=SOPiLdJh2zeZzmd8s0it5jzxW1CgxDZ/wMM3m8M8dNCd/HmQ1xZuo3bfWldLes8cWl Qsp6saEMtUIUYsSeCNb2pTU/h76UW3ETLPjTIKpL6mmHPMTwMHrSClvmCIqmNgJDyOkg p/GPu9XkGXz9tQLl9ZbsRvJYhSYpVl/NZpdnzQpYarkhFarK//Kmhv1kka772xi/G0wd xpoUaTRybK6OPqeVVmHrdZUxTz22yH0QDcVlPkG0Fbl8zy0ScoUG0cji+dJXFVP03YT2 +6PlWmA9kXFgh82AWRtXCUU3N+Da3OSUpoh7ztFDDS7NWyshru71WyKc0gtXRSXgx3hD NwWA== X-Gm-Message-State: AA+aEWZrEMbxhVqvh4MjhCUu3Np6gAVKcLhR6/sM2yAad67ybt2gaCRz SSx1AA6eXgQdt6J30c3ChW8r8HbjFq2QIhXJo2KZX0Lim/YK/OZyv+cFC3wnW7cuif6Tc0T3JvD VIykD2W1RmkagzGRLnkAAPM1tepy/cjwfGD9UsgfjwZg9/aBxsKK0uQTAj+S0 X-Google-Smtp-Source: AFSGD/Wm9o/vwbq05BpFYFEW+pZw/14+mjpA6gWIcFH6oI1RUIZVAMydqvpRmOazM4DsV+M+wzxoGZYUnboV X-Received: by 2002:aca:47c9:: with SMTP id u192mr4172131oia.14.1544832614438; Fri, 14 Dec 2018 16:10:14 -0800 (PST) Date: Fri, 14 Dec 2018 16:09:31 -0800 In-Reply-To: <20181215000942.46033-1-sbeller@google.com> Message-Id: <20181215000942.46033-13-sbeller@google.com> Mime-Version: 1.0 References: <20181215000942.46033-1-sbeller@google.com> X-Mailer: git-send-email 2.20.0.405.gbc1bbc6f85-goog Subject: [PATCH 12/23] commit-reach: prepare get_merge_bases to handle any repo From: Stefan Beller To: git@vger.kernel.org Cc: Stefan Beller , Junio C Hamano Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Similarly to previous patches, the get_merge_base functions are used often in the code base, which makes migrating them hard. Implement the new functions, prefixed with 'repo_' and hide the old functions behind a wrapper macro. Signed-off-by: Stefan Beller Signed-off-by: Junio C Hamano --- commit-reach.c | 24 ++++++++++------- commit-reach.h | 26 ++++++++++++------- .../coccinelle/the_repository.pending.cocci | 26 +++++++++++++++++++ 3 files changed, 56 insertions(+), 20 deletions(-) diff --git a/commit-reach.c b/commit-reach.c index b3b1f62aba..657a4e9b5a 100644 --- a/commit-reach.c +++ b/commit-reach.c @@ -258,23 +258,27 @@ static struct commit_list *get_merge_bases_many_0(struct repository *r, return result; } -struct commit_list *get_merge_bases_many(struct commit *one, - int n, - struct commit **twos) +struct commit_list *repo_get_merge_bases_many(struct repository *r, + struct commit *one, + int n, + struct commit **twos) { - return get_merge_bases_many_0(the_repository, one, n, twos, 1); + return get_merge_bases_many_0(r, one, n, twos, 1); } -struct commit_list *get_merge_bases_many_dirty(struct commit *one, - int n, - struct commit **twos) +struct commit_list *repo_get_merge_bases_many_dirty(struct repository *r, + struct commit *one, + int n, + struct commit **twos) { - return get_merge_bases_many_0(the_repository, one, n, twos, 0); + return get_merge_bases_many_0(r, one, n, twos, 0); } -struct commit_list *get_merge_bases(struct commit *one, struct commit *two) +struct commit_list *repo_get_merge_bases(struct repository *r, + struct commit *one, + struct commit *two) { - return get_merge_bases_many_0(the_repository, one, 1, &two, 1); + return get_merge_bases_many_0(r, one, 1, &two, 1); } /* diff --git a/commit-reach.h b/commit-reach.h index 7d313e2975..52667d64ac 100644 --- a/commit-reach.h +++ b/commit-reach.h @@ -8,17 +8,23 @@ struct commit_list; struct contains_cache; struct ref_filter; -struct commit_list *get_merge_bases_many(struct commit *one, - int n, - struct commit **twos); -struct commit_list *get_merge_bases_many_dirty(struct commit *one, - int n, - struct commit **twos); -struct commit_list *get_merge_bases(struct commit *one, struct commit *two); -struct commit_list *get_octopus_merge_bases(struct commit_list *in); - +struct commit_list *repo_get_merge_bases(struct repository *r, + struct commit *rev1, + struct commit *rev2); +struct commit_list *repo_get_merge_bases_many(struct repository *r, + struct commit *one, int n, + struct commit **twos); /* To be used only when object flags after this call no longer matter */ -struct commit_list *get_merge_bases_many_dirty(struct commit *one, int n, struct commit **twos); +struct commit_list *repo_get_merge_bases_many_dirty(struct repository *r, + struct commit *one, int n, + struct commit **twos); +#ifndef NO_THE_REPOSITORY_COMPATIBILITY_MACROS +#define get_merge_bases(r1, r2) repo_get_merge_bases(the_repository, r1, r2) +#define get_merge_bases_many(one, n, two) repo_get_merge_bases_many(the_repository, one, n, two) +#define get_merge_bases_many_dirty(one, n, twos) repo_get_merge_bases_many_dirty(the_repository, one, n, twos) +#endif + +struct commit_list *get_octopus_merge_bases(struct commit_list *in); int is_descendant_of(struct commit *commit, struct commit_list *with_commit); int in_merge_bases_many(struct commit *commit, int nr_reference, struct commit **reference); diff --git a/contrib/coccinelle/the_repository.pending.cocci b/contrib/coccinelle/the_repository.pending.cocci index b185fe0a1d..f6c2915a4e 100644 --- a/contrib/coccinelle/the_repository.pending.cocci +++ b/contrib/coccinelle/the_repository.pending.cocci @@ -64,3 +64,29 @@ expression E; - parse_commit( + repo_parse_commit(the_repository, E) + +@@ +expression E; +expression F; +@@ +- get_merge_bases( ++ repo_get_merge_bases(the_repository, + E, F); + +@@ +expression E; +expression F; +expression G; +@@ +- get_merge_bases_many( ++ repo_get_merge_bases_many(the_repository, + E, F, G); + +@@ +expression E; +expression F; +expression G; +@@ +- get_merge_bases_many_dirty( ++ repo_get_merge_bases_many_dirty(the_repository, + E, F, G); From patchwork Sat Dec 15 00:09:32 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Beller X-Patchwork-Id: 10731893 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 326761399 for ; Sat, 15 Dec 2018 00:10:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C02872D3F8 for ; Sat, 15 Dec 2018 00:10:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B43DE2D404; Sat, 15 Dec 2018 00:10:19 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, USER_IN_DEF_DKIM_WL autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 495E92D3F8 for ; Sat, 15 Dec 2018 00:10:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730061AbeLOAKS (ORCPT ); Fri, 14 Dec 2018 19:10:18 -0500 Received: from mail-yw1-f74.google.com ([209.85.161.74]:42320 "EHLO mail-yw1-f74.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729985AbeLOAKR (ORCPT ); Fri, 14 Dec 2018 19:10:17 -0500 Received: by mail-yw1-f74.google.com with SMTP id d72so4321831ywe.9 for ; Fri, 14 Dec 2018 16:10:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=IZAUkKssT2FykRphWLtNBX69xKlH92cRM0qWMPDdb8Q=; b=OQM5wgh/Kla5M40qj95yI/WT9THvb0D8R9EbUcfQ2WOvkO8MrqfBMn9iNKuX7codWp Gp75COICMt424JMbMimTiO9P2GrBz+pkBbYPrExA6Z04RkpXxhipUK12QrVn/D6t1z0X L4DMni6WdQCP1tiFym06cBigSYQdhS3HcuNcqoxK+rVGWQ2FZFE/nuKgPaD8bN8SqeBX cNoerDDfMQ9LJUoUdovtYxqMBhkpmY2e+yQ6fGSoLtQm/J4LT0E9gc/UjLbcWLZ7W6Y4 6EhwjtqtdeMykTsnxJ91hwJF9D8Uvx8NYUfIvwpAlw/fmelxR0XGNOGEyQTkqs5+T+Xd wClQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=IZAUkKssT2FykRphWLtNBX69xKlH92cRM0qWMPDdb8Q=; b=eMYBAZ1j3MB8TwPFW4NQhWnSOSTIsl6k2T/mIMF/0lKquNGvFfPhgk+9fMPQU9S2gc PXUf6hYki82KXzN31obL9utNkZPoHIJbdr1jZwwurXPbbfd2sP2vR2m3tVTJZe6Gxftc VaDHwYMERhZtaydQz+h9PGontrSOl91IUg/wnoxe9/zTCScU+pajbKFHqqOeZyj8QgGp oqJvFFm5W1N/Fw7Pj/EWBHJCJYMpxRetB0NWa8QZvJMAYljzI9dDT+F2U5MIXAEkgHEY n96wYTO5h01BgsAyRJ/ECM/sPRP2AMjwbIW5tahboEk7v7U1McEPDQCArlECjlRNRCc/ vzrA== X-Gm-Message-State: AA+aEWYNEB/IJSFVhQgnZ/0p9nStfAHNiAkEVagI/iST4rxOp+E55pTc B3w8kZ3rrKANCGy00OWjClBwwni7gX4X6ZbhLzQLm7eEQk/oGv/XndWDUSYflxWCeU/IMZGCMvu X3kehEKH77iaEhZJFtDFFzaEu3ruCFxaCGE3Pjn3OXFd0NA/E6yuVXeFuhuqR X-Google-Smtp-Source: AFSGD/WBEjqaeYB6GbGY0ltR0p06KHnYnob5OqrT4mSjlwN2qdJrBwMXoiQ3dBVN0o0mgPcHmvb4NPAX6M3q X-Received: by 2002:a5b:cca:: with SMTP id e10mr2875266ybr.91.1544832616756; Fri, 14 Dec 2018 16:10:16 -0800 (PST) Date: Fri, 14 Dec 2018 16:09:32 -0800 In-Reply-To: <20181215000942.46033-1-sbeller@google.com> Message-Id: <20181215000942.46033-14-sbeller@google.com> Mime-Version: 1.0 References: <20181215000942.46033-1-sbeller@google.com> X-Mailer: git-send-email 2.20.0.405.gbc1bbc6f85-goog Subject: [PATCH 13/23] commit-reach: prepare in_merge_bases[_many] to handle any repo From: Stefan Beller To: git@vger.kernel.org Cc: Stefan Beller , Junio C Hamano Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Stefan Beller Signed-off-by: Junio C Hamano --- commit-reach.c | 15 +++++++++------ commit-reach.h | 12 ++++++++++-- contrib/coccinelle/the_repository.pending.cocci | 17 +++++++++++++++++ 3 files changed, 36 insertions(+), 8 deletions(-) diff --git a/commit-reach.c b/commit-reach.c index 657a4e9b5a..8715008fef 100644 --- a/commit-reach.c +++ b/commit-reach.c @@ -312,16 +312,17 @@ int is_descendant_of(struct commit *commit, struct commit_list *with_commit) /* * Is "commit" an ancestor of one of the "references"? */ -int in_merge_bases_many(struct commit *commit, int nr_reference, struct commit **reference) +int repo_in_merge_bases_many(struct repository *r, struct commit *commit, + int nr_reference, struct commit **reference) { struct commit_list *bases; int ret = 0, i; uint32_t min_generation = GENERATION_NUMBER_INFINITY; - if (parse_commit(commit)) + if (repo_parse_commit(r, commit)) return ret; for (i = 0; i < nr_reference; i++) { - if (parse_commit(reference[i])) + if (repo_parse_commit(r, reference[i])) return ret; if (reference[i]->generation < min_generation) min_generation = reference[i]->generation; @@ -330,7 +331,7 @@ int in_merge_bases_many(struct commit *commit, int nr_reference, struct commit * if (commit->generation > min_generation) return ret; - bases = paint_down_to_common(the_repository, commit, + bases = paint_down_to_common(r, commit, nr_reference, reference, commit->generation); if (commit->object.flags & PARENT2) @@ -344,9 +345,11 @@ int in_merge_bases_many(struct commit *commit, int nr_reference, struct commit * /* * Is "commit" an ancestor of (i.e. reachable from) the "reference"? */ -int in_merge_bases(struct commit *commit, struct commit *reference) +int repo_in_merge_bases(struct repository *r, + struct commit *commit, + struct commit *reference) { - return in_merge_bases_many(commit, 1, &reference); + return repo_in_merge_bases_many(r, commit, 1, &reference); } struct commit_list *reduce_heads(struct commit_list *heads) diff --git a/commit-reach.h b/commit-reach.h index 52667d64ac..a0d4a29d25 100644 --- a/commit-reach.h +++ b/commit-reach.h @@ -27,8 +27,16 @@ struct commit_list *repo_get_merge_bases_many_dirty(struct repository *r, struct commit_list *get_octopus_merge_bases(struct commit_list *in); int is_descendant_of(struct commit *commit, struct commit_list *with_commit); -int in_merge_bases_many(struct commit *commit, int nr_reference, struct commit **reference); -int in_merge_bases(struct commit *commit, struct commit *reference); +int repo_in_merge_bases(struct repository *r, + struct commit *commit, + struct commit *reference); +int repo_in_merge_bases_many(struct repository *r, + struct commit *commit, + int nr_reference, struct commit **reference); +#ifndef NO_THE_REPOSITORY_COMPATIBILITY_MACROS +#define in_merge_bases(c1, c2) repo_in_merge_bases(the_repository, c1, c2) +#define in_merge_bases_many(c1, n, cs) repo_in_merge_bases_many(the_repository, c1, n, cs) +#endif /* * Takes a list of commits and returns a new list where those diff --git a/contrib/coccinelle/the_repository.pending.cocci b/contrib/coccinelle/the_repository.pending.cocci index f6c2915a4e..8c6a71bf64 100644 --- a/contrib/coccinelle/the_repository.pending.cocci +++ b/contrib/coccinelle/the_repository.pending.cocci @@ -90,3 +90,20 @@ expression G; - get_merge_bases_many_dirty( + repo_get_merge_bases_many_dirty(the_repository, E, F, G); + +@@ +expression E; +expression F; +@@ +- in_merge_bases( ++ repo_in_merge_bases(the_repository, + E, F); + +@@ +expression E; +expression F; +expression G; +@@ +- in_merge_bases_many( ++ repo_in_merge_bases_many(the_repository, + E, F, G); From patchwork Sat Dec 15 00:09:33 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Beller X-Patchwork-Id: 10731895 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 28351746 for ; Sat, 15 Dec 2018 00:10:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B6E822D3F8 for ; Sat, 15 Dec 2018 00:10:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AB6942D404; Sat, 15 Dec 2018 00:10:21 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, USER_IN_DEF_DKIM_WL autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4B7892D3F8 for ; Sat, 15 Dec 2018 00:10:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730072AbeLOAKU (ORCPT ); Fri, 14 Dec 2018 19:10:20 -0500 Received: from mail-qt1-f202.google.com ([209.85.160.202]:54799 "EHLO mail-qt1-f202.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729985AbeLOAKU (ORCPT ); Fri, 14 Dec 2018 19:10:20 -0500 Received: by mail-qt1-f202.google.com with SMTP id z6so7272641qtj.21 for ; Fri, 14 Dec 2018 16:10:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=J+42hj3ZmivEwJlhvnMqR7aqGjOf6M4lReIfT0AEgEM=; b=rw82E47ePV81aIdadnfb/jDy0y6iRJ2pBLkUEDAjc1rNhP5waopx5kJNMk20wlFNSv TK7XvG/AgKe1a/pd1LOWhqtorRUKG48cqthReehv24VWFy8glDKBiI3+su9MPlWeEdz9 2Dg5TwcRQP6BWUQJtzr+uHnOGJ3sQbF8dqSWGpB3cDHqGGE8Y/9E92GpvSzACDLoHmbz 2TgMDASUUioHhMM5ZqcO25PK5aZe197lZen7N6X2jaNgyr3TEUsCBaH+noBxao3njqL4 lKkvBTBvVF6IbGMEgdphbnS5nw/PWqPZsJOhOhSCK08y6ZylaAiN82ZsMCqkcsyLubnR Xgqg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=J+42hj3ZmivEwJlhvnMqR7aqGjOf6M4lReIfT0AEgEM=; b=Vo7H25Xeo7Mld08pjDkh4CqlpdGP3CUnrNBqfVo2BUSQdWq2ReW30i8nAGvAug8mcK uN4aQYxf4zSeCY04tu0RGzEY3R/LP1AuyHBriFFl5vB/4iG2IciE7X5bv+7xJhiO/Q2f LjPTspyZ1OFhk+op9bw0P0L3v0qvvHW5qv/z3TZ/0roqT0+It6EwUX2u6bi+RrizXdOJ SEU0vJZvsFIeTuQVodOfn7Z10+2LTNRpG5gN4KOtoNBuqYFbIKZPLfQT9Rt70NqPrCjH AzXoQ1tuAZ40kIttunpetLtfbMwr09U8bLB9DcSFtckng1hohqgGMGMzkprafy7s7Y7H kMtg== X-Gm-Message-State: AA+aEWZWwwmnp5e8CHbk6F/qlS+nZjRsus7oJgyWXqtKvdJKP+gJyu81 MnWAFWMnXQjsI2pfR5PEEQtW79jsRzxbz3cPjfxrV+ywwupCxoP4MN4HkPYsy2QMGe7tVWonbfr PHC1K6lPf3Vm9JG1PzBLHFW3h3pLlcvU7CBLCkdBsyEGOXXULw+0/asDla0lJ X-Google-Smtp-Source: AFSGD/Xh4PugkvWw9pwb5BZk5HZxM9L3MYqgbwmzXZS6KL0BMEYKhH4/sJ99Nt07PhNqLIfVcFw0ES+4usXE X-Received: by 2002:a0c:b58d:: with SMTP id g13mr4868620qve.1.1544832619185; Fri, 14 Dec 2018 16:10:19 -0800 (PST) Date: Fri, 14 Dec 2018 16:09:33 -0800 In-Reply-To: <20181215000942.46033-1-sbeller@google.com> Message-Id: <20181215000942.46033-15-sbeller@google.com> Mime-Version: 1.0 References: <20181215000942.46033-1-sbeller@google.com> X-Mailer: git-send-email 2.20.0.405.gbc1bbc6f85-goog Subject: [PATCH 14/23] commit: prepare get_commit_buffer to handle any repo From: Stefan Beller To: git@vger.kernel.org Cc: Stefan Beller , Junio C Hamano Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Stefan Beller Signed-off-by: Junio C Hamano --- commit.c | 8 +++++--- commit.h | 7 ++++++- contrib/coccinelle/the_repository.pending.cocci | 8 ++++++++ 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/commit.c b/commit.c index 7a931d7fd4..4034def16c 100644 --- a/commit.c +++ b/commit.c @@ -297,13 +297,15 @@ const void *get_cached_commit_buffer(struct repository *r, const struct commit * return v->buffer; } -const void *get_commit_buffer(const struct commit *commit, unsigned long *sizep) +const void *repo_get_commit_buffer(struct repository *r, + const struct commit *commit, + unsigned long *sizep) { - const void *ret = get_cached_commit_buffer(the_repository, commit, sizep); + const void *ret = get_cached_commit_buffer(r, commit, sizep); if (!ret) { enum object_type type; unsigned long size; - ret = read_object_file(&commit->object.oid, &type, &size); + ret = repo_read_object_file(r, &commit->object.oid, &type, &size); if (!ret) die("cannot read commit object %s", oid_to_hex(&commit->object.oid)); diff --git a/commit.h b/commit.h index 08935f9a19..591a77a5bb 100644 --- a/commit.h +++ b/commit.h @@ -117,7 +117,12 @@ const void *get_cached_commit_buffer(struct repository *, const struct commit *, * from disk. The resulting memory should not be modified, and must be given * to unuse_commit_buffer when the caller is done. */ -const void *get_commit_buffer(const struct commit *, unsigned long *size); +const void *repo_get_commit_buffer(struct repository *r, + const struct commit *, + unsigned long *size); +#ifndef NO_THE_REPOSITORY_COMPATIBILITY_MACROS +#define get_commit_buffer(c, s) repo_get_commit_buffer(the_repository, c, s) +#endif /* * Tell the commit subsytem that we are done with a particular commit buffer. diff --git a/contrib/coccinelle/the_repository.pending.cocci b/contrib/coccinelle/the_repository.pending.cocci index 8c6a71bf64..4018e6eaf7 100644 --- a/contrib/coccinelle/the_repository.pending.cocci +++ b/contrib/coccinelle/the_repository.pending.cocci @@ -107,3 +107,11 @@ expression G; - in_merge_bases_many( + repo_in_merge_bases_many(the_repository, E, F, G); + +@@ +expression E; +expression F; +@@ +- get_commit_buffer( ++ repo_get_commit_buffer(the_repository, + E, F); From patchwork Sat Dec 15 00:09:34 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Beller X-Patchwork-Id: 10731897 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 98E59746 for ; Sat, 15 Dec 2018 00:10:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 330B62D3F8 for ; Sat, 15 Dec 2018 00:10:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 274AA2D404; Sat, 15 Dec 2018 00:10:24 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, USER_IN_DEF_DKIM_WL autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C35A12D3F8 for ; Sat, 15 Dec 2018 00:10:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729906AbeLOAKX (ORCPT ); Fri, 14 Dec 2018 19:10:23 -0500 Received: from mail-yw1-f73.google.com ([209.85.161.73]:36035 "EHLO mail-yw1-f73.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729895AbeLOAKW (ORCPT ); Fri, 14 Dec 2018 19:10:22 -0500 Received: by mail-yw1-f73.google.com with SMTP id y65so4338356ywy.3 for ; Fri, 14 Dec 2018 16:10:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=b70SLontAiSQvlnWO/t3BXy3Zfptakm8RrjbpbOmtmE=; b=HzwI+pmIgDXev6D3Vak1rNBXa+eNYuDbNSGAkPDSoaKbk+T7IUtiUqupJzOmKk70Up Y5GxlCs9YnJGusGmnHSiAsof3lWPaOX1OOlR9s9oYxZv7wPtsBQIG58CwqUeZdeqtFL/ Zg5Zp6WvF4T2Xb7LrcwJsN4VqrMJlg++eIi1HmrfcooXeZbeFRTINDaM7ZFV+vaW9LLI uBOkWt/dZsQH/dhi0at0pgBikfL4ulK00dFcbCJg+hAlJ5anU3YNRK30dNZ2cP9VPsZa 4Ops20p1hDElHjVqs+dI2JPLQkoRU18d7aKbYfTdZ3IhPumVnh+NZX0qg6i5QL+IiUpy LlOw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=b70SLontAiSQvlnWO/t3BXy3Zfptakm8RrjbpbOmtmE=; b=WQ12Ay0xXkeNpWOJcaspNGDq+d80gCEG75crbF2hZoykvvPwlwobJt/uuc2vy930sE JmGSXJQuUUYU1GLSXTbAtySYTQmaWsOVqZVu1vhlCVwm9tgO/WXahZU5smhC1Y24rIo9 bH9BfZosUMIkD162p2o3eW9IZolztDdX75i088/ezobVEjwRJiHO+tL6uBBx9xlkHB/j GJXH/FbPaqOpniDwbo8u2eyo3o8dkygn1b2ZnXh18V/8GKrmeRpTseBCrBRcvz4PbnaH pCw3/PrS+WKq/LGJ6t3XacBYLplto8HsV2JCc1ltM6uG9SkJjedFoDjFxa5i+7edWl76 3ktQ== X-Gm-Message-State: AA+aEWbkSKHb35+Gy0IaDw8JbNvBZ9hK+nPQ/SC9/MI6G7A1JkTCdii4 SgcdvKxpNSkEiVOpmlQzVHffyAIoErkZdmZN7R7HqaupKoxJ0juH4eLG2NKePq28ZZbd6asFy1O 6E5c48ITdYjr0vG1abBb70CIj1P6rR2o83kVGbVdyFLB/HwjAQYtnb0z6G3Gx X-Google-Smtp-Source: AFSGD/VZuhTOS8nfa/dr5fsIB2MztEt2F+4IT9vhUPnMZsQZIfCc+pn0A071tzpKw+H8bYEfeioNSSt61x3o X-Received: by 2002:a25:8b81:: with SMTP id j1-v6mr3123962ybl.60.1544832621582; Fri, 14 Dec 2018 16:10:21 -0800 (PST) Date: Fri, 14 Dec 2018 16:09:34 -0800 In-Reply-To: <20181215000942.46033-1-sbeller@google.com> Message-Id: <20181215000942.46033-16-sbeller@google.com> Mime-Version: 1.0 References: <20181215000942.46033-1-sbeller@google.com> X-Mailer: git-send-email 2.20.0.405.gbc1bbc6f85-goog Subject: [PATCH 15/23] commit: prepare repo_unuse_commit_buffer to handle any repo From: Stefan Beller To: git@vger.kernel.org Cc: Stefan Beller , Junio C Hamano Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Stefan Beller Signed-off-by: Junio C Hamano --- commit.c | 6 ++++-- commit.h | 7 ++++++- contrib/coccinelle/the_repository.pending.cocci | 8 ++++++++ 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/commit.c b/commit.c index 4034def16c..7d2f3a9a93 100644 --- a/commit.c +++ b/commit.c @@ -318,10 +318,12 @@ const void *repo_get_commit_buffer(struct repository *r, return ret; } -void unuse_commit_buffer(const struct commit *commit, const void *buffer) +void repo_unuse_commit_buffer(struct repository *r, + const struct commit *commit, + const void *buffer) { struct commit_buffer *v = buffer_slab_peek( - the_repository->parsed_objects->buffer_slab, commit); + r->parsed_objects->buffer_slab, commit); if (!(v && v->buffer == buffer)) free((void *)buffer); } diff --git a/commit.h b/commit.h index 591a77a5bb..57375e3239 100644 --- a/commit.h +++ b/commit.h @@ -130,7 +130,12 @@ const void *repo_get_commit_buffer(struct repository *r, * from an earlier call to get_commit_buffer. The buffer may or may not be * freed by this call; callers should not access the memory afterwards. */ -void unuse_commit_buffer(const struct commit *, const void *buffer); +void repo_unuse_commit_buffer(struct repository *r, + const struct commit *, + const void *buffer); +#ifndef NO_THE_REPOSITORY_COMPATIBILITY_MACROS +#define unuse_commit_buffer(c, b) repo_unuse_commit_buffer(the_repository, c, b) +#endif /* * Free any cached object buffer associated with the commit. diff --git a/contrib/coccinelle/the_repository.pending.cocci b/contrib/coccinelle/the_repository.pending.cocci index 4018e6eaf7..516f19ffee 100644 --- a/contrib/coccinelle/the_repository.pending.cocci +++ b/contrib/coccinelle/the_repository.pending.cocci @@ -115,3 +115,11 @@ expression F; - get_commit_buffer( + repo_get_commit_buffer(the_repository, E, F); + +@@ +expression E; +expression F; +@@ +- unuse_commit_buffer( ++ repo_unuse_commit_buffer(the_repository, + E, F); From patchwork Sat Dec 15 00:09:35 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Beller X-Patchwork-Id: 10731899 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 217BC746 for ; Sat, 15 Dec 2018 00:10:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AF8D32D3F8 for ; Sat, 15 Dec 2018 00:10:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A41AC2D404; Sat, 15 Dec 2018 00:10:26 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, USER_IN_DEF_DKIM_WL autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 462042D3F8 for ; Sat, 15 Dec 2018 00:10:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730083AbeLOAKZ (ORCPT ); Fri, 14 Dec 2018 19:10:25 -0500 Received: from mail-pl1-f202.google.com ([209.85.214.202]:56428 "EHLO mail-pl1-f202.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730078AbeLOAKY (ORCPT ); Fri, 14 Dec 2018 19:10:24 -0500 Received: by mail-pl1-f202.google.com with SMTP id x7so4675688pll.23 for ; Fri, 14 Dec 2018 16:10:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=h4PuIsap4vNJg9HdWbZgjsl2Pvo6Cq3jLdfZG5g5qD4=; b=ik18bD3ZV4q3m7eeOenDPIVIvV+hq012yDJ5dI5P9/OeGZLkxIhVsSVN3ZDTcTIzdl 8O6iw3+9hrLetCFQ53YOwMYH9BirtRdrW0ikJy7WsC3Tq9XyRD/nOqyQu5WLRMduquLH jO4mUEknOGS6CK4Fep8baVlnN7EK3iBxwM7WzcJcat20ZUzWcsfd1yL2S5NzzTk5onOS aT9cjIkQBhvfY1CfU9O2OfGc+vDer/xmIRnydG7bPk4fpC6hV4AlXDVqohHYkevzThTb N3XZkgsrsHyzAnTwBzdtp9BF2XWoPa1/JCOC19pSy7/QHNqTXASvTq81sQCHWv9GmZWB T8tQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=h4PuIsap4vNJg9HdWbZgjsl2Pvo6Cq3jLdfZG5g5qD4=; b=NJ+eNIS7wMPqYbhX5vRQxSbMFm2NgYMZUeW41pW7NtnOO619dDKKeKsZWmL7Y/Z17O nBuLO6cKUSHm+6rbgOsrOgLdZtWngk0GrFTd4IedanfB/5vQSG0NJJp/WAbx6STaTW/K bV+W1RzeUrde6pGgNQojxePqvIx+2X4GJDJ5tRgXqKhxAPX2KBjGBdWtxTjRZ1ku0hrN iuXKCc+dWgoz+6+kFJbQvD2og26gqzESRxbyFeJOSKZLtixZjxECpVB12QEoH2/uyyeU 3xaNB/ODhup3T2ouMTvq9PQ7EWfrSLpYiJYKjoEShtjcqtCZU6b6VaV0kqNXRg7Ia2u2 nQMA== X-Gm-Message-State: AA+aEWb+E/EWT1B643hZH5Y2ZDHBt3yrfbuW10BZw+UaoS4+xQqRuBdR N8Y2u5+QCuKT/TkNg6hN2aXSVXNwn+jMqeW7rl3SoruGTXHnipRerVhZUwXd6lttD1bdf+28/4t /8Rq/Cj009DvBSm9EMucAivt4oiU3ouwVC/Z4Yd2+NuU7XQ6riD0lG616BDqt X-Google-Smtp-Source: AFSGD/VQZ2Hr9yf0xP6qhEhs2w4T03Ez3pEO8u9G4woAJ9pKZ9RSpYM3hMM/Bsct7+jiaXZ6gaSGarl8cocT X-Received: by 2002:a17:902:6103:: with SMTP id t3mr2242159plj.117.1544832623655; Fri, 14 Dec 2018 16:10:23 -0800 (PST) Date: Fri, 14 Dec 2018 16:09:35 -0800 In-Reply-To: <20181215000942.46033-1-sbeller@google.com> Message-Id: <20181215000942.46033-17-sbeller@google.com> Mime-Version: 1.0 References: <20181215000942.46033-1-sbeller@google.com> X-Mailer: git-send-email 2.20.0.405.gbc1bbc6f85-goog Subject: [PATCH 16/23] commit: prepare logmsg_reencode to handle arbitrary repositories From: Stefan Beller To: git@vger.kernel.org Cc: Stefan Beller , Junio C Hamano Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Stefan Beller Signed-off-by: Junio C Hamano --- commit.h | 8 ++++++++ contrib/coccinelle/the_repository.pending.cocci | 9 +++++++++ pretty.c | 13 +++++++------ 3 files changed, 24 insertions(+), 6 deletions(-) diff --git a/commit.h b/commit.h index 57375e3239..2e6b799b26 100644 --- a/commit.h +++ b/commit.h @@ -180,6 +180,14 @@ extern int has_non_ascii(const char *text); extern const char *logmsg_reencode(const struct commit *commit, char **commit_encoding, const char *output_encoding); +const char *repo_logmsg_reencode(struct repository *r, + const struct commit *commit, + char **commit_encoding, + const char *output_encoding); +#ifndef NO_THE_REPOSITORY_COMPATIBILITY_MACROS +#define logmsg_reencode(c, enc, out) repo_logmsg_reencode(the_repository, c, enc, out) +#endif + extern const char *skip_blank_lines(const char *msg); /** Removes the first commit from a list sorted by date, and adds all diff --git a/contrib/coccinelle/the_repository.pending.cocci b/contrib/coccinelle/the_repository.pending.cocci index 516f19ffee..f5b42cfc62 100644 --- a/contrib/coccinelle/the_repository.pending.cocci +++ b/contrib/coccinelle/the_repository.pending.cocci @@ -123,3 +123,12 @@ expression F; - unuse_commit_buffer( + repo_unuse_commit_buffer(the_repository, E, F); + +@@ +expression E; +expression F; +expression G; +@@ +- logmsg_reencode( ++ repo_logmsg_reencode(the_repository, + E, F, G); diff --git a/pretty.c b/pretty.c index 8ca29e9281..b359b68750 100644 --- a/pretty.c +++ b/pretty.c @@ -595,14 +595,15 @@ static char *replace_encoding_header(char *buf, const char *encoding) return strbuf_detach(&tmp, NULL); } -const char *logmsg_reencode(const struct commit *commit, - char **commit_encoding, - const char *output_encoding) +const char *repo_logmsg_reencode(struct repository *r, + const struct commit *commit, + char **commit_encoding, + const char *output_encoding) { static const char *utf8 = "UTF-8"; const char *use_encoding; char *encoding; - const char *msg = get_commit_buffer(commit, NULL); + const char *msg = repo_get_commit_buffer(r, commit, NULL); char *out; if (!output_encoding || !*output_encoding) { @@ -630,7 +631,7 @@ const char *logmsg_reencode(const struct commit *commit, * the cached copy from get_commit_buffer, we need to duplicate it * to avoid munging the cached copy. */ - if (msg == get_cached_commit_buffer(the_repository, commit, NULL)) + if (msg == get_cached_commit_buffer(r, commit, NULL)) out = xstrdup(msg); else out = (char *)msg; @@ -644,7 +645,7 @@ const char *logmsg_reencode(const struct commit *commit, */ out = reencode_string(msg, output_encoding, use_encoding); if (out) - unuse_commit_buffer(commit, msg); + repo_unuse_commit_buffer(r, commit, msg); } /* From patchwork Sat Dec 15 00:09:36 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Beller X-Patchwork-Id: 10731901 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 60825746 for ; Sat, 15 Dec 2018 00:10:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EF0B52D3F8 for ; Sat, 15 Dec 2018 00:10:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E39782D404; Sat, 15 Dec 2018 00:10:28 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, USER_IN_DEF_DKIM_WL autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 80A512D3F8 for ; Sat, 15 Dec 2018 00:10:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730091AbeLOAK1 (ORCPT ); Fri, 14 Dec 2018 19:10:27 -0500 Received: from mail-io1-f74.google.com ([209.85.166.74]:50534 "EHLO mail-io1-f74.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730078AbeLOAK0 (ORCPT ); Fri, 14 Dec 2018 19:10:26 -0500 Received: by mail-io1-f74.google.com with SMTP id p4so6090255iod.17 for ; Fri, 14 Dec 2018 16:10:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=L0KhuO4VvSFHDmNc68K7b4oXzaLRvmpO4XuJPz3NT0Y=; b=qj7nmDcIhUmYWuGuw42/XM8hvT2BA0DoDpY9CMFapHcTpJsMum9av9Wb9JGaf0FL4E SjbOHzM97RFC03DrDP6zJSiaDOyUC3/osst+PHHyxueX+cF6GvnUdmAQk7tIqcpVL9n9 GzHVYQFBADXGX9TC8WhcOG6kAYb9jpU/2D677t2OllZ6fXn9tF6H49rfvQXbz5AC5E5g 2Nuf90WoBFUEJeheCb+4wPkDbJuJbu2xQbkqPZtdhQPT0DaRFzrUAfvZI/LlMcwan/GW iAlsR+Xny8biIeflMpFlWfTggttZacSdo1CERPz5m/eU9gnJ8tXDBu1FFnwLBm7cEqhd MaRQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=L0KhuO4VvSFHDmNc68K7b4oXzaLRvmpO4XuJPz3NT0Y=; b=h4UwqReM8xAiBD7fU8HkHLx8A6FcRL1538xEev1frOR0nR1Oo4itObms9sUwQ+x5xp okGhSGYkPwoL1K0P897rDj7zIECRy2Ed7ygKabUKDgNIiMxkG2ui+F723ehPky27yTOQ CUc+E1WASMvXwhVylmv7JCMQUM4gnYmPTjax8dO3KSdSqXKjevS3RSH7JRQOaKuCqYFJ vQDTwZJc05bWeFLt6Eol1N+ix0A6Fo79XRie1iw84MXuUrq8kKpyJuhve+v09ZFoTnhT v8tpRcGnAZmwt3tJBvYXiH5JlGOWZSnN/pnta3q5IuzUE0r5VDq7L6W/P1H9Q0LTzSXI YF/g== X-Gm-Message-State: AA+aEWY6NnVAeXro6T0Uisvg5uMVUv0todoYDbSaqR27ikTeSbB0qP0y kzPsKuDsa7EupMjzW/NFn3NAGmfPUbmV7BqAGtfQLCFdAxjqmvVE1mvdU718sOGYIZ4+cJfKfwu aT4do5sFaltELRAGJs6FPkY9h7jZMUht6hFHifcHUfW6iX5cIi2NcY2yuxzxg X-Google-Smtp-Source: AFSGD/UdxDabIieItqJdjVDPQKZ1ihHDE95dbulBqB6EAHTUSLYMBl17zXCxQB2GjTj8q4o1e1nC0+gHeAym X-Received: by 2002:a24:5755:: with SMTP id u82mr4791315ita.16.1544832625784; Fri, 14 Dec 2018 16:10:25 -0800 (PST) Date: Fri, 14 Dec 2018 16:09:36 -0800 In-Reply-To: <20181215000942.46033-1-sbeller@google.com> Message-Id: <20181215000942.46033-18-sbeller@google.com> Mime-Version: 1.0 References: <20181215000942.46033-1-sbeller@google.com> X-Mailer: git-send-email 2.20.0.405.gbc1bbc6f85-goog Subject: [PATCH 17/23] pretty: prepare format_commit_message to handle arbitrary repositories From: Stefan Beller To: git@vger.kernel.org Cc: Stefan Beller , Junio C Hamano Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Stefan Beller Signed-off-by: Junio C Hamano --- contrib/coccinelle/the_repository.pending.cocci | 10 ++++++++++ pretty.c | 15 ++++++++------- pretty.h | 7 ++++++- 3 files changed, 24 insertions(+), 8 deletions(-) diff --git a/contrib/coccinelle/the_repository.pending.cocci b/contrib/coccinelle/the_repository.pending.cocci index f5b42cfc62..2ee702ecf7 100644 --- a/contrib/coccinelle/the_repository.pending.cocci +++ b/contrib/coccinelle/the_repository.pending.cocci @@ -132,3 +132,13 @@ expression G; - logmsg_reencode( + repo_logmsg_reencode(the_repository, E, F, G); + +@@ +expression E; +expression F; +expression G; +expression H; +@@ +- format_commit_message( ++ repo_format_commit_message(the_repository, + E, F, G, H); diff --git a/pretty.c b/pretty.c index b359b68750..3240495308 100644 --- a/pretty.c +++ b/pretty.c @@ -1508,9 +1508,10 @@ void userformat_find_requirements(const char *fmt, struct userformat_want *w) strbuf_release(&dummy); } -void format_commit_message(const struct commit *commit, - const char *format, struct strbuf *sb, - const struct pretty_print_context *pretty_ctx) +void repo_format_commit_message(struct repository *r, + const struct commit *commit, + const char *format, struct strbuf *sb, + const struct pretty_print_context *pretty_ctx) { struct format_commit_context context; const char *output_enc = pretty_ctx->output_encoding; @@ -1524,9 +1525,9 @@ void format_commit_message(const struct commit *commit, * convert a commit message to UTF-8 first * as far as 'format_commit_item' assumes it in UTF-8 */ - context.message = logmsg_reencode(commit, - &context.commit_encoding, - utf8); + context.message = repo_logmsg_reencode(r, commit, + &context.commit_encoding, + utf8); strbuf_expand(sb, format, format_commit_item, &context); rewrap_message_tail(sb, &context, 0, 0, 0); @@ -1550,7 +1551,7 @@ void format_commit_message(const struct commit *commit, } free(context.commit_encoding); - unuse_commit_buffer(commit, context.message); + repo_unuse_commit_buffer(r, commit, context.message); } static void pp_header(struct pretty_print_context *pp, diff --git a/pretty.h b/pretty.h index 7359d318a9..e6625269cf 100644 --- a/pretty.h +++ b/pretty.h @@ -103,9 +103,14 @@ void pp_remainder(struct pretty_print_context *pp, const char **msg_p, * Put the result to "sb". * Please use this function for custom formats. */ -void format_commit_message(const struct commit *commit, +void repo_format_commit_message(struct repository *r, + const struct commit *commit, const char *format, struct strbuf *sb, const struct pretty_print_context *context); +#ifndef NO_THE_REPOSITORY_COMPATIBILITY_MACROS +#define format_commit_message(c, f, s, con) \ + repo_format_commit_message(the_repository, c, f, s, con) +#endif /* * Parse given arguments from "arg", check it for correctness and From patchwork Sat Dec 15 00:09:37 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Beller X-Patchwork-Id: 10731903 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id EDDB7746 for ; Sat, 15 Dec 2018 00:10:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 873A42D3F8 for ; Sat, 15 Dec 2018 00:10:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7B1D52D404; Sat, 15 Dec 2018 00:10:31 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, USER_IN_DEF_DKIM_WL autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DEFC92D3F8 for ; Sat, 15 Dec 2018 00:10:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728799AbeLOAK3 (ORCPT ); Fri, 14 Dec 2018 19:10:29 -0500 Received: from mail-yw1-f74.google.com ([209.85.161.74]:46123 "EHLO mail-yw1-f74.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730078AbeLOAK3 (ORCPT ); Fri, 14 Dec 2018 19:10:29 -0500 Received: by mail-yw1-f74.google.com with SMTP id 201so4301656ywp.13 for ; Fri, 14 Dec 2018 16:10:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=h911hwbgt4R2XVW9i2h1mw8pGQbidqFcJxAaPVbO7vs=; b=DfZ7pIJI0hEWRG9Yt7HrYqffkhAT/7FZnXzLaDFvEjsDX4jr3fLtxlSt3A5vkhbMzW jcMHJvQLiE/hpsBjtwvQ2AgrHMp58K03h21wGklKSbnoMxCA+3eN339SvanQmA3IcJMS UE/mQqzOfh5of7/TV6icAjW+rjU3vDmf/zXuVECuuSsfL/uYS5yZaDNsguzoDAJdMvYu n9f+bkNSz56hJvfPQf0iP+CWn6iLIgL64XYp7prbPDM0sJVwWr4XxaML29+WoY/l3IXd p3bVdlzCAgkhf9K4d67ogcxXGdHzr+yUfcplvzv6wSBgga6OKrK3MpUyLou2ngh89CiS IAIg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=h911hwbgt4R2XVW9i2h1mw8pGQbidqFcJxAaPVbO7vs=; b=Kef8fLRL5zKB4B4Kr8sBlKIBCNfK18U2eg4k3miKGNvM0CwNPbTEcOI6JgRqCmWzzu giRJm+g2V8EDaQcU+7PrLKjLuuSAerqDbZbrytdJaYD9WIIJv7UfmuF+wOl0+oMWv93z GmjBRgNORL3X0YMOca5v+QPNJaaxldPaVBQRdQ7Sl6/jUi9sikS/tEHwjSkLgxDjCoeh AwCZa6Z9nnaYq1xWj0As4/sHU+iTGJ6FtVvtLHB7RqG20cQ3oxuPFlFCf+vlOq9hQ66f eGkFl+1Vxzx2skUGoP4fXBxVrd+ViJqZxvvGqItEpeQDxWbP1jA60GhgzauTq/biAVXX jXhQ== X-Gm-Message-State: AA+aEWbLXaja8UFNCezTV9/89IKR3T8thr+/xTxdicokhRoerouq3HBl i7HFsc/ci37BtlQb66uQvRRWbnvN3m2iDBDde2TiDMzt3KjE9t3xS6EXgFH+Ob9l1GPbfcmB1I0 IIlzzckimKwoOgrnALdgGoIvujt5jYJNf5/VDfwKjsDTaTZYLxWcnw498i1Lt X-Google-Smtp-Source: AFSGD/V0o8HRXKKzhoY0qkZUIGFC/Yzn3cVciTpB64EtYaJmJCqJeyMQzn44VKVyFz+lWl1BcZTwVIeJcJcx X-Received: by 2002:a25:e656:: with SMTP id d83mr2964448ybh.37.1544832628155; Fri, 14 Dec 2018 16:10:28 -0800 (PST) Date: Fri, 14 Dec 2018 16:09:37 -0800 In-Reply-To: <20181215000942.46033-1-sbeller@google.com> Message-Id: <20181215000942.46033-19-sbeller@google.com> Mime-Version: 1.0 References: <20181215000942.46033-1-sbeller@google.com> X-Mailer: git-send-email 2.20.0.405.gbc1bbc6f85-goog Subject: [PATCH 18/23] submodule: use submodule repos for object lookup From: Stefan Beller To: git@vger.kernel.org Cc: Stefan Beller , Junio C Hamano Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This converts the 'show_submodule_header' function to use the repository API properly, such that the submodule objects are not added to the main object store. Signed-off-by: Stefan Beller Signed-off-by: Junio C Hamano --- submodule.c | 75 ++++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 60 insertions(+), 15 deletions(-) diff --git a/submodule.c b/submodule.c index d9d3046689..4486ff664b 100644 --- a/submodule.c +++ b/submodule.c @@ -443,7 +443,7 @@ static int prepare_submodule_summary(struct rev_info *rev, const char *path, return prepare_revision_walk(rev); } -static void print_submodule_summary(struct rev_info *rev, struct diff_options *o) +static void print_submodule_summary(struct repository *r, struct rev_info *rev, struct diff_options *o) { static const char format[] = " %m %s"; struct strbuf sb = STRBUF_INIT; @@ -454,7 +454,8 @@ static void print_submodule_summary(struct rev_info *rev, struct diff_options *o ctx.date_mode = rev->date_mode; ctx.output_encoding = get_log_output_encoding(); strbuf_setlen(&sb, 0); - format_commit_message(commit, format, &sb, &ctx); + repo_format_commit_message(r, commit, format, &sb, + &ctx); strbuf_addch(&sb, '\n'); if (commit->object.flags & SYMMETRIC_LEFT) diff_emit_submodule_del(o, sb.buf); @@ -481,14 +482,46 @@ void prepare_submodule_repo_env(struct argv_array *out) DEFAULT_GIT_DIR_ENVIRONMENT); } -/* Helper function to display the submodule header line prior to the full - * summary output. If it can locate the submodule objects directory it will - * attempt to lookup both the left and right commits and put them into the - * left and right pointers. +/* + * Initialize a repository struct for a submodule based on the provided 'path'. + * + * Unlike repo_submodule_init, this tolerates submodules not present + * in .gitmodules. This function exists only to preserve historical behavior, + * + * Returns the repository struct on success, + * NULL when the submodule is not present. */ -static void show_submodule_header(struct diff_options *o, const char *path, +static struct repository *open_submodule(const char *path) +{ + struct strbuf sb = STRBUF_INIT; + struct repository *out = xmalloc(sizeof(*out)); + + if (submodule_to_gitdir(&sb, path) || repo_init(out, sb.buf, NULL)) { + strbuf_release(&sb); + free(out); + return NULL; + } + + /* Mark it as a submodule */ + out->submodule_prefix = xstrdup(path); + + strbuf_release(&sb); + return out; +} + +/* + * Helper function to display the submodule header line prior to the full + * summary output. + * + * If it can locate the submodule git directory it will create a repository + * handle for the submodule and lookup both the left and right commits and + * put them into the left and right pointers. + */ +static void show_submodule_header(struct diff_options *o, + const char *path, struct object_id *one, struct object_id *two, unsigned dirty_submodule, + struct repository *sub, struct commit **left, struct commit **right, struct commit_list **merge_bases) { @@ -507,7 +540,7 @@ static void show_submodule_header(struct diff_options *o, const char *path, else if (is_null_oid(two)) message = "(submodule deleted)"; - if (add_submodule_odb(path)) { + if (!sub) { if (!message) message = "(commits not present)"; goto output_header; @@ -517,8 +550,8 @@ static void show_submodule_header(struct diff_options *o, const char *path, * Attempt to lookup the commit references, and determine if this is * a fast forward or fast backwards update. */ - *left = lookup_commit_reference(the_repository, one); - *right = lookup_commit_reference(the_repository, two); + *left = lookup_commit_reference(sub, one); + *right = lookup_commit_reference(sub, two); /* * Warn about missing commits in the submodule project, but only if @@ -528,7 +561,7 @@ static void show_submodule_header(struct diff_options *o, const char *path, (!is_null_oid(two) && !*right)) message = "(commits not present)"; - *merge_bases = get_merge_bases(*left, *right); + *merge_bases = repo_get_merge_bases(sub, *left, *right); if (*merge_bases) { if ((*merge_bases)->item == *left) fast_forward = 1; @@ -562,16 +595,18 @@ void show_submodule_summary(struct diff_options *o, const char *path, struct rev_info rev; struct commit *left = NULL, *right = NULL; struct commit_list *merge_bases = NULL; + struct repository *sub; + sub = open_submodule(path); show_submodule_header(o, path, one, two, dirty_submodule, - &left, &right, &merge_bases); + sub, &left, &right, &merge_bases); /* * If we don't have both a left and a right pointer, there is no * reason to try and display a summary. The header line should contain * all the information the user needs. */ - if (!left || !right) + if (!left || !right || !sub) goto out; /* Treat revision walker failure the same as missing commits */ @@ -580,13 +615,17 @@ void show_submodule_summary(struct diff_options *o, const char *path, goto out; } - print_submodule_summary(&rev, o); + print_submodule_summary(sub, &rev, o); out: if (merge_bases) free_commit_list(merge_bases); clear_commit_marks(left, ~0); clear_commit_marks(right, ~0); + if (sub) { + repo_clear(sub); + free(sub); + } } void show_submodule_inline_diff(struct diff_options *o, const char *path, @@ -598,9 +637,11 @@ void show_submodule_inline_diff(struct diff_options *o, const char *path, struct commit_list *merge_bases = NULL; struct child_process cp = CHILD_PROCESS_INIT; struct strbuf sb = STRBUF_INIT; + struct repository *sub; + sub = open_submodule(path); show_submodule_header(o, path, one, two, dirty_submodule, - &left, &right, &merge_bases); + sub, &left, &right, &merge_bases); /* We need a valid left and right commit to display a difference */ if (!(left || is_null_oid(one)) || @@ -661,6 +702,10 @@ void show_submodule_inline_diff(struct diff_options *o, const char *path, clear_commit_marks(left, ~0); if (right) clear_commit_marks(right, ~0); + if (sub) { + repo_clear(sub); + free(sub); + } } int should_update_submodules(void) From patchwork Sat Dec 15 00:09:38 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Beller X-Patchwork-Id: 10731905 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BDA931399 for ; Sat, 15 Dec 2018 00:10:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 56B142D3F8 for ; Sat, 15 Dec 2018 00:10:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4AFCA2D404; Sat, 15 Dec 2018 00:10:33 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, USER_IN_DEF_DKIM_WL autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0023C2D3F8 for ; Sat, 15 Dec 2018 00:10:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730127AbeLOAKb (ORCPT ); Fri, 14 Dec 2018 19:10:31 -0500 Received: from mail-yw1-f74.google.com ([209.85.161.74]:39120 "EHLO mail-yw1-f74.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730107AbeLOAKb (ORCPT ); Fri, 14 Dec 2018 19:10:31 -0500 Received: by mail-yw1-f74.google.com with SMTP id v195so4313091ywc.6 for ; Fri, 14 Dec 2018 16:10:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=RS8nqdTcWQrvybApg60DULpMo6QPQB7tfPz5RUfnYdE=; b=MOdn3SNxNCYJbWWAdTzucWUu1XawyvX55lIxBXBIsH4hqTXzUuYHXmqmxw+dIKWvIu l6cwQnQXyQqeX5kqe57yFFkHFCzUz/5la1LCTb/canMLvIVmV8r9QDCKcBMUs1USTpiI i09hsgdSHtuGH3qZZlMedd/g+CgzT3M+gDl4717fo+86MK4ugLw0oKWKQC+D7ZDn1TVe Cs1vS1lohLfchNLeJjDYvHNPGgqenX01VHCi1z3QSoRcpPtIPKaXAiu8QJMoVtyzDY1a 5uzfkGf7ufhh7FpWXelcZVD2VvzXqZjDAY+psd/L5oEEwdKZYCfGGnvkjp5CrdCFCad5 YKXg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=RS8nqdTcWQrvybApg60DULpMo6QPQB7tfPz5RUfnYdE=; b=HLJMGqivEH4+5ggGkfkQE0FexK7zc8SDe/pTjQwM1xD9Uc9B8b9fHE4GXuGuHHmNoM 9+IQs4gAmp+uAssb4p1MFORAM46/3e/SLDeusHNIDWzeEOBR+Bd+2rumbERREgN+gB1K kxv8jYmtduz/ASEn7KV3K/mtbWJOLECn7ogWBvKxHRewf4hnhdgr9gEinAS+/UUg/jwl y8ZDy5vZPjQU0Ntg+FAMqw9r/pQKLSl1ponwPZJwu95rjaXJ0xRsRf1d/GVVqTHwxEwm bN5Z7UpUTybrSSnxQt89z1a/fIgFgyrAcXmv3Jo7mpJTnPZrMTwyZ2iSwkck5OT1k3D6 2wRw== X-Gm-Message-State: AA+aEWb3ZxI6j04+FSJIfl++1gTuQiN5HW78EKFoTADuXWeA0pObMUm6 WgZtm8qZKQ7jTxbwUfEu1SEosGUuXOQ2FQtdVknXyhRBnh/m3uZjrexQjJ5jdVkw5cpzAYLojqf FPqtSJ3ShiSR+x0qEkLZKtj3bPqKUfy6I1eQQPMf5ldsMyaht8FVSOLT2S/jR X-Google-Smtp-Source: AFSGD/WjXLlo8o1Enjh3MeL8rmRhohWCEkzidOs2feHFVB759ctpIwvmcucx3mHqAnJOWWDX4Pdd3ii8tgil X-Received: by 2002:a25:804e:: with SMTP id a14mr2784282ybn.77.1544832630529; Fri, 14 Dec 2018 16:10:30 -0800 (PST) Date: Fri, 14 Dec 2018 16:09:38 -0800 In-Reply-To: <20181215000942.46033-1-sbeller@google.com> Message-Id: <20181215000942.46033-20-sbeller@google.com> Mime-Version: 1.0 References: <20181215000942.46033-1-sbeller@google.com> X-Mailer: git-send-email 2.20.0.405.gbc1bbc6f85-goog Subject: [PATCH 19/23] submodule: don't add submodule as odb for push From: Stefan Beller To: git@vger.kernel.org Cc: Stefan Beller , Junio C Hamano Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP In push_submodule(), because we do not actually need access to objects in the submodule, do not invoke add_submodule_odb(). (for_each_remote_ref_submodule() does not require access to those objects, and the actual push is done by spawning another process, which handles object access by itself.) This code of push_submodule() is exercised in t5531 and continues to work, showing that the submodule odbc is not needed. Signed-off-by: Stefan Beller Signed-off-by: Junio C Hamano --- submodule.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/submodule.c b/submodule.c index 4486ff664b..d9c06767a1 100644 --- a/submodule.c +++ b/submodule.c @@ -1023,9 +1023,6 @@ static int push_submodule(const char *path, const struct string_list *push_options, int dry_run) { - if (add_submodule_odb(path)) - return 1; - if (for_each_remote_ref_submodule(path, has_remote, NULL) > 0) { struct child_process cp = CHILD_PROCESS_INIT; argv_array_push(&cp.args, "push"); From patchwork Sat Dec 15 00:09:39 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Beller X-Patchwork-Id: 10731907 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CCB261399 for ; Sat, 15 Dec 2018 00:10:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 65AE72D400 for ; Sat, 15 Dec 2018 00:10:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 59F0C2D40D; Sat, 15 Dec 2018 00:10:36 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, USER_IN_DEF_DKIM_WL autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CD3332D3F8 for ; Sat, 15 Dec 2018 00:10:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730129AbeLOAKe (ORCPT ); Fri, 14 Dec 2018 19:10:34 -0500 Received: from mail-oi1-f202.google.com ([209.85.167.202]:50380 "EHLO mail-oi1-f202.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726604AbeLOAKe (ORCPT ); Fri, 14 Dec 2018 19:10:34 -0500 Received: by mail-oi1-f202.google.com with SMTP id u63so3439245oie.17 for ; Fri, 14 Dec 2018 16:10:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=Mb+Sn/8mXWcnIHJo0dFLVb2/R3CSQuy8CSpA1ix1KZQ=; b=pFo/tA0JZ74iXQQqBik4D+4OF/jVAZwei7cSrLCCeC31Dh0ut4OPW+FapJq/Mw4y1l 9mJvNhQ16O7rvnqenaeh7lTPol+N5rzxvNheEQxcO6nSNqPcCC5+pf8vFTCwz85To3xU zrktpATjbC0FjxspWl1eVHdaTCi8UXQ+HKJC7emxfkxMNz/WUikxZLEO/yBtK5hE4Yof FfIFERe11ezOlGc9VF5gy502KcJPG+zi6qwvySW4eYOjOxnvuVLioQH5zRiogChPRe+K kF0gZwb6TSPUaCqAcThj1nyuY4xeuaeZuaQbwF0UEiqL6QLyUVkvPbK3JtGaOMemqtt2 SjtQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=Mb+Sn/8mXWcnIHJo0dFLVb2/R3CSQuy8CSpA1ix1KZQ=; b=YvJqiMnmpDVWdZn4dTX1cr15f623RQkMHeyxwIuaGWr+GV8VlaClTNARI5AMXI/P2X piGk3BH9sVJPbOsPNbzAnITMvD6PdRDeHA/BcEooC7+QKXBE5pwGa01iPNaW31tdwCKF THZA9JWQ9xrp1spVOFIjeMI/3CovfaI9F0xQjEhUTpXzAPJjBiJcuObLvQGES3V4COcy LWOb3858tWGtxsADXRJg1EsbLScdbrNS9xs4noOSDCEzbeb2Zg5g+JyMbR2QoPN8yLHW jezt6tGyWt0sh5c9A/vynINWNgM4ulAPtbJYWKyy1P0bldR9DcWUEwgrxP/FuaZguFEq 2s3w== X-Gm-Message-State: AA+aEWaIwjBs7yhR/8exKB2snG7UHeP9W0Z535j4/RH5lsh93JeWKq+4 Xvno1WaHhVObaQbjLz71cloUg+rN55JESXLyOyWmxpJHrVbvctYlWWNE3XpYxoudghnynTKtmX8 D5peX0nmtMb65PosIhyK/KWOWHTE7o/KoDc4BAJtiIzO/ZdKXRFX+Q+XwzEMD X-Google-Smtp-Source: AFSGD/VEiRPEyxMLFCIdF9UnlR8e8xu0Z7AidExUOI9F2qMfrmvWeTmNu0wmMJTx7Tv38rWL7uQUjmm1qjUJ X-Received: by 2002:aca:ec82:: with SMTP id k124mr4159137oih.36.1544832633182; Fri, 14 Dec 2018 16:10:33 -0800 (PST) Date: Fri, 14 Dec 2018 16:09:39 -0800 In-Reply-To: <20181215000942.46033-1-sbeller@google.com> Message-Id: <20181215000942.46033-21-sbeller@google.com> Mime-Version: 1.0 References: <20181215000942.46033-1-sbeller@google.com> X-Mailer: git-send-email 2.20.0.405.gbc1bbc6f85-goog Subject: [PATCH 20/23] commit-graph: convert remaining functions to handle any repo From: Stefan Beller To: git@vger.kernel.org Cc: Stefan Beller , Junio C Hamano Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Convert all functions to handle arbitrary repositories in commit-graph.c that are used by functions taking a repository argument already. Notable exclusion is write_commit_graph and its local functions as that only works on the_repository. Signed-off-by: Stefan Beller Signed-off-by: Junio C Hamano --- commit-graph.c | 40 ++++++++++++++++++++++++---------------- 1 file changed, 24 insertions(+), 16 deletions(-) diff --git a/commit-graph.c b/commit-graph.c index 40c855f185..f78a8e96b5 100644 --- a/commit-graph.c +++ b/commit-graph.c @@ -292,7 +292,8 @@ static int bsearch_graph(struct commit_graph *g, struct object_id *oid, uint32_t g->chunk_oid_lookup, g->hash_len, pos); } -static struct commit_list **insert_parent_or_die(struct commit_graph *g, +static struct commit_list **insert_parent_or_die(struct repository *r, + struct commit_graph *g, uint64_t pos, struct commit_list **pptr) { @@ -303,7 +304,7 @@ static struct commit_list **insert_parent_or_die(struct commit_graph *g, die("invalid parent position %"PRIu64, pos); hashcpy(oid.hash, g->chunk_oid_lookup + g->hash_len * pos); - c = lookup_commit(the_repository, &oid); + c = lookup_commit(r, &oid); if (!c) die(_("could not find commit %s"), oid_to_hex(&oid)); c->graph_pos = pos; @@ -317,7 +318,9 @@ static void fill_commit_graph_info(struct commit *item, struct commit_graph *g, item->generation = get_be32(commit_data + g->hash_len + 8) >> 2; } -static int fill_commit_in_graph(struct commit *item, struct commit_graph *g, uint32_t pos) +static int fill_commit_in_graph(struct repository *r, + struct commit *item, + struct commit_graph *g, uint32_t pos) { uint32_t edge_value; uint32_t *parent_data_ptr; @@ -341,13 +344,13 @@ static int fill_commit_in_graph(struct commit *item, struct commit_graph *g, uin edge_value = get_be32(commit_data + g->hash_len); if (edge_value == GRAPH_PARENT_NONE) return 1; - pptr = insert_parent_or_die(g, edge_value, pptr); + pptr = insert_parent_or_die(r, g, edge_value, pptr); edge_value = get_be32(commit_data + g->hash_len + 4); if (edge_value == GRAPH_PARENT_NONE) return 1; if (!(edge_value & GRAPH_OCTOPUS_EDGES_NEEDED)) { - pptr = insert_parent_or_die(g, edge_value, pptr); + pptr = insert_parent_or_die(r, g, edge_value, pptr); return 1; } @@ -355,7 +358,7 @@ static int fill_commit_in_graph(struct commit *item, struct commit_graph *g, uin 4 * (uint64_t)(edge_value & GRAPH_EDGE_LAST_MASK)); do { edge_value = get_be32(parent_data_ptr); - pptr = insert_parent_or_die(g, + pptr = insert_parent_or_die(r, g, edge_value & GRAPH_EDGE_LAST_MASK, pptr); parent_data_ptr++; @@ -374,7 +377,9 @@ static int find_commit_in_graph(struct commit *item, struct commit_graph *g, uin } } -static int parse_commit_in_graph_one(struct commit_graph *g, struct commit *item) +static int parse_commit_in_graph_one(struct repository *r, + struct commit_graph *g, + struct commit *item) { uint32_t pos; @@ -382,7 +387,7 @@ static int parse_commit_in_graph_one(struct commit_graph *g, struct commit *item return 1; if (find_commit_in_graph(item, g, &pos)) - return fill_commit_in_graph(item, g, pos); + return fill_commit_in_graph(r, item, g, pos); return 0; } @@ -391,7 +396,7 @@ int parse_commit_in_graph(struct repository *r, struct commit *item) { if (!prepare_commit_graph(r)) return 0; - return parse_commit_in_graph_one(r->objects->commit_graph, item); + return parse_commit_in_graph_one(r, r->objects->commit_graph, item); } void load_commit_graph_info(struct repository *r, struct commit *item) @@ -403,19 +408,22 @@ void load_commit_graph_info(struct repository *r, struct commit *item) fill_commit_graph_info(item, r->objects->commit_graph, pos); } -static struct tree *load_tree_for_commit(struct commit_graph *g, struct commit *c) +static struct tree *load_tree_for_commit(struct repository *r, + struct commit_graph *g, + struct commit *c) { struct object_id oid; const unsigned char *commit_data = g->chunk_commit_data + GRAPH_DATA_WIDTH * (c->graph_pos); hashcpy(oid.hash, commit_data); - c->maybe_tree = lookup_tree(the_repository, &oid); + c->maybe_tree = lookup_tree(r, &oid); return c->maybe_tree; } -static struct tree *get_commit_tree_in_graph_one(struct commit_graph *g, +static struct tree *get_commit_tree_in_graph_one(struct repository *r, + struct commit_graph *g, const struct commit *c) { if (c->maybe_tree) @@ -423,12 +431,12 @@ static struct tree *get_commit_tree_in_graph_one(struct commit_graph *g, if (c->graph_pos == COMMIT_NOT_FROM_GRAPH) BUG("get_commit_tree_in_graph_one called from non-commit-graph commit"); - return load_tree_for_commit(g, (struct commit *)c); + return load_tree_for_commit(r, g, (struct commit *)c); } struct tree *get_commit_tree_in_graph(struct repository *r, const struct commit *c) { - return get_commit_tree_in_graph_one(r->objects->commit_graph, c); + return get_commit_tree_in_graph_one(r, r->objects->commit_graph, c); } static void write_graph_chunk_fanout(struct hashfile *f, @@ -1025,7 +1033,7 @@ int verify_commit_graph(struct repository *r, struct commit_graph *g) } graph_commit = lookup_commit(r, &cur_oid); - if (!parse_commit_in_graph_one(g, graph_commit)) + if (!parse_commit_in_graph_one(r, g, graph_commit)) graph_report("failed to parse %s from commit-graph", oid_to_hex(&cur_oid)); } @@ -1061,7 +1069,7 @@ int verify_commit_graph(struct repository *r, struct commit_graph *g) continue; } - if (!oideq(&get_commit_tree_in_graph_one(g, graph_commit)->object.oid, + if (!oideq(&get_commit_tree_in_graph_one(r, g, graph_commit)->object.oid, get_commit_tree_oid(odb_commit))) graph_report("root tree OID for commit %s in commit-graph is %s != %s", oid_to_hex(&cur_oid), From patchwork Sat Dec 15 00:09:40 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Beller X-Patchwork-Id: 10731909 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 34399746 for ; Sat, 15 Dec 2018 00:10:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C21DB2D3F8 for ; Sat, 15 Dec 2018 00:10:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B63702D40D; Sat, 15 Dec 2018 00:10:38 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, USER_IN_DEF_DKIM_WL autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3D5012D3F8 for ; Sat, 15 Dec 2018 00:10:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730148AbeLOAKh (ORCPT ); Fri, 14 Dec 2018 19:10:37 -0500 Received: from mail-ua1-f73.google.com ([209.85.222.73]:40305 "EHLO mail-ua1-f73.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730140AbeLOAKh (ORCPT ); Fri, 14 Dec 2018 19:10:37 -0500 Received: by mail-ua1-f73.google.com with SMTP id b4so1424710uan.7 for ; Fri, 14 Dec 2018 16:10:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=YWlkob6bKD+qg47OReQkQzL3EOclnLQ7tkRRSTXvGOs=; b=djXZQYPgA2xm8+vkW/VBb+kZzpgJhGHTS4xTQYcAHt6SniVs3424l6UVlR3keyuciu fYOOwFPafgrkuaDTJe99Do2im5ys+klLXXR4W6dI1x20jO3fgEbAb+Gd84Tc5ZsDFi4w b9IadsSnKXcoKUAgXsW0NoOZZR2/YLHNhlDu0rSliIRYr7N4V3rH69MXXlF2ecW5EanD H6mt+yE5JC8TgnTrJg3wrgcmf7hmZXKloa7ld1ZuKkWVW5nsnFfMCtI898T7rWXTlknd 7B6m49VAWuEziRHCGX3jn6Qbtgo2ThFxN40IQuti3BMKHgJlQpeC94tuZbaqUKElxHIV 8iyw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=YWlkob6bKD+qg47OReQkQzL3EOclnLQ7tkRRSTXvGOs=; b=lAtNikwHLZRH8sVnjPgsYR79wGCQnJRGiwnIiM1hep+6vQuUaUD/zwHaonkrq6mug7 BnB8PzehR5+EANIQyOWaPPvvO8fFvjKwVejiXdxsGRYAljZrTSxmNo9qlzUEVw6s+wDg mdU7YVpZBUjV03fYVYQ7UAI+1NdIsNMLCCKvdb1QtRsnBlB8Y6QDgbKDxsdasYM5t/dj rMhRMRRkYubnmpOqytEa5aZpGuOLXYC96zgjSsFjqaAI6+ab452D+q8VjSgR2oujFbfT 9leQPqZLeaNEGz95nqF0qJ4WfYsCJ4WFBPM9TLIBUXXG4DUCq6Kfswl45ipArndoBDla yKYw== X-Gm-Message-State: AA+aEWZYN37PLekpNGJHisGCGsw4+Muz8hYWUYHeIemM41sxFUzZAjUc FOhgvkGZKlVfFFnyjWTora95Hzx3mNJHIkUPEKdNx9B/8Ze6s4J8hrL2Jyo5HfRC80W3Ax3mDXA smTE193aRU9xtiGZcclupOe1WCO7yoaU8RERI746sJSS3VyT7dHsD8Nq3MzqP X-Google-Smtp-Source: AFSGD/Ukeo8tPm1fW0y3USxpMl2TP++NFp0yYZR/VaUEKtMgYlwv4fczPJ5RMhVVgRj4X89Jow2zGLOJHG9+ X-Received: by 2002:a1f:34d2:: with SMTP id b201mr4860909vka.24.1544832635477; Fri, 14 Dec 2018 16:10:35 -0800 (PST) Date: Fri, 14 Dec 2018 16:09:40 -0800 In-Reply-To: <20181215000942.46033-1-sbeller@google.com> Message-Id: <20181215000942.46033-22-sbeller@google.com> Mime-Version: 1.0 References: <20181215000942.46033-1-sbeller@google.com> X-Mailer: git-send-email 2.20.0.405.gbc1bbc6f85-goog Subject: [PATCH 21/23] commit: prepare free_commit_buffer and release_commit_memory for any repo From: Stefan Beller To: git@vger.kernel.org Cc: Stefan Beller , Junio C Hamano Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Pass the object pool to free_commit_buffer and release_commit_memory, such that we can eliminate access to 'the_repository'. Also remove the TODO in release_commit_memory, as commit->util was removed in 9d2c97016f (commit.h: delete 'util' field in struct commit, 2018-05-19) Signed-off-by: Stefan Beller Signed-off-by: Junio C Hamano --- builtin/fsck.c | 3 ++- builtin/log.c | 6 ++++-- builtin/rev-list.c | 3 ++- commit.c | 9 ++++----- commit.h | 4 ++-- object.c | 2 +- 6 files changed, 15 insertions(+), 12 deletions(-) diff --git a/builtin/fsck.c b/builtin/fsck.c index 06eb421720..c476ac6983 100644 --- a/builtin/fsck.c +++ b/builtin/fsck.c @@ -382,7 +382,8 @@ static int fsck_obj(struct object *obj, void *buffer, unsigned long size) if (obj->type == OBJ_TREE) free_tree_buffer((struct tree *)obj); if (obj->type == OBJ_COMMIT) - free_commit_buffer((struct commit *)obj); + free_commit_buffer(the_repository->parsed_objects, + (struct commit *)obj); return err; } diff --git a/builtin/log.c b/builtin/log.c index 061d4fd864..64c2649c7c 100644 --- a/builtin/log.c +++ b/builtin/log.c @@ -395,7 +395,8 @@ static int cmd_log_walk(struct rev_info *rev) * We may show a given commit multiple times when * walking the reflogs. */ - free_commit_buffer(commit); + free_commit_buffer(the_repository->parsed_objects, + commit); free_commit_list(commit->parents); commit->parents = NULL; } @@ -1922,7 +1923,8 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix) open_next_file(rev.numbered_files ? NULL : commit, NULL, &rev, quiet)) die(_("Failed to create output files")); shown = log_tree_commit(&rev, commit); - free_commit_buffer(commit); + free_commit_buffer(the_repository->parsed_objects, + commit); /* We put one extra blank line between formatted * patches and this flag is used by log-tree code diff --git a/builtin/rev-list.c b/builtin/rev-list.c index cc1b70522f..2b301fa315 100644 --- a/builtin/rev-list.c +++ b/builtin/rev-list.c @@ -196,7 +196,8 @@ static void finish_commit(struct commit *commit, void *data) free_commit_list(commit->parents); commit->parents = NULL; } - free_commit_buffer(commit); + free_commit_buffer(the_repository->parsed_objects, + commit); } static inline void finish_object__ma(struct object *obj) diff --git a/commit.c b/commit.c index 7d2f3a9a93..4fe74aa4bc 100644 --- a/commit.c +++ b/commit.c @@ -328,10 +328,10 @@ void repo_unuse_commit_buffer(struct repository *r, free((void *)buffer); } -void free_commit_buffer(struct commit *commit) +void free_commit_buffer(struct parsed_object_pool *pool, struct commit *commit) { struct commit_buffer *v = buffer_slab_peek( - the_repository->parsed_objects->buffer_slab, commit); + pool->buffer_slab, commit); if (v) { FREE_AND_NULL(v->buffer); v->size = 0; @@ -354,13 +354,12 @@ struct object_id *get_commit_tree_oid(const struct commit *commit) return &get_commit_tree(commit)->object.oid; } -void release_commit_memory(struct commit *c) +void release_commit_memory(struct parsed_object_pool *pool, struct commit *c) { c->maybe_tree = NULL; c->index = 0; - free_commit_buffer(c); + free_commit_buffer(pool, c); free_commit_list(c->parents); - /* TODO: what about commit->util? */ c->object.parsed = 0; } diff --git a/commit.h b/commit.h index 2e6b799b26..d2779a23f6 100644 --- a/commit.h +++ b/commit.h @@ -140,7 +140,7 @@ void repo_unuse_commit_buffer(struct repository *r, /* * Free any cached object buffer associated with the commit. */ -void free_commit_buffer(struct commit *); +void free_commit_buffer(struct parsed_object_pool *pool, struct commit *); struct tree *get_commit_tree(const struct commit *); struct object_id *get_commit_tree_oid(const struct commit *); @@ -149,7 +149,7 @@ struct object_id *get_commit_tree_oid(const struct commit *); * Release memory related to a commit, including the parent list and * any cached object buffer. */ -void release_commit_memory(struct commit *c); +void release_commit_memory(struct parsed_object_pool *pool, struct commit *c); /* * Disassociate any cached object buffer from the commit, but do not free it. diff --git a/object.c b/object.c index 003f870484..c4170d2d0c 100644 --- a/object.c +++ b/object.c @@ -540,7 +540,7 @@ void parsed_object_pool_clear(struct parsed_object_pool *o) if (obj->type == OBJ_TREE) free_tree_buffer((struct tree*)obj); else if (obj->type == OBJ_COMMIT) - release_commit_memory((struct commit*)obj); + release_commit_memory(o, (struct commit*)obj); else if (obj->type == OBJ_TAG) release_tag_memory((struct tag*)obj); } From patchwork Sat Dec 15 00:09:41 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Beller X-Patchwork-Id: 10731911 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 30C9C1399 for ; Sat, 15 Dec 2018 00:10:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BEB222D3F8 for ; Sat, 15 Dec 2018 00:10:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B33A52D404; Sat, 15 Dec 2018 00:10:40 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, USER_IN_DEF_DKIM_WL autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6C4842D3F8 for ; Sat, 15 Dec 2018 00:10:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730162AbeLOAKj (ORCPT ); Fri, 14 Dec 2018 19:10:39 -0500 Received: from mail-qt1-f202.google.com ([209.85.160.202]:56253 "EHLO mail-qt1-f202.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730140AbeLOAKi (ORCPT ); Fri, 14 Dec 2018 19:10:38 -0500 Received: by mail-qt1-f202.google.com with SMTP id b16so7191201qtc.22 for ; Fri, 14 Dec 2018 16:10:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=i8EpahsQxzhhhw8wlrISW123HOH1xuSdTKzvv2F7mf8=; b=OzLI2DAiLWJQYIzjT8icJcP9lTtN+P/Zm/ys0tPVhCNbljCdyoGhrnV4vuOz72d9+m MM8oTcEBlkVm9BsgTCDE9bugVw2vvaxXemsTQ+a9CLZeDXIPr6nCBBawLcoBpTN1pRk/ kTv5J1yN7n5rG2j1K0umEd48CwgTJjSWMkvW+WtWvj2KFAqy63Azrd7gbqFsFhsYAUO/ iB1MXdKaoVvieGwAOmzzIgbVmxsszqz8XQqdAyAaGjlpXQ0nmRKYwQpzeBNZN3jRksaY xOONyVZ20TsaqTrwPvXRfCHqYvBK5Bc3Lk0Ts/8HGYGqrXFKl/69B0p9jtyKD82L4dK3 8NvA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=i8EpahsQxzhhhw8wlrISW123HOH1xuSdTKzvv2F7mf8=; b=Qhrx6jREPRs/d+dmDDDFoxdcoU76JUPonDEUaZDOfBsR40q42sRHOFHO+AwYA8DLrl dkJLkrc+30W5pjZdSQONhu1AwJtohZBs7wEhzcBlbDam8w1eHDuX7Uc1/NpnfkIO9jnN QqgkEQdFvH9GuqsHWGPfFwvpn1aX3endnlB99xekQzR6NV5KyPoxefMDPNMUX2S5L6sU 8yBe86bWVQIPU/WG4wEbWq3RqzkM0kWeWvb3n24fzeTn89TUpstHZEWTNrVkjUCCdhkV OT+FQcV8FJgIRdMOnvwGTBdcZ26f1oER6ebBLVCf+u21Yg3p6ArLujkw1ADceyoaQMDj c6vg== X-Gm-Message-State: AA+aEWbPGx0lkDmMN3Rcpd2uifSp3NfsfHrfG3MMuo7AGNFh6kgzfltZ rzRxzYWI/M9vVv9+cpxTQ1Vnf0Dvj7zXtYeI2kQLztXgx7IaQo3G93xoCnk9rMxQtU14M1dIHPC rmtL7qNgQAGBmtgq/UbzNI0/A4e/w6xEuitPbcq2kEF8SVtZFrfxnUp6kMxrk X-Google-Smtp-Source: AFSGD/WFHjcJDYUWi6xtHTs17aKVcm4TSyZjzghNDNqz3mn+tF8fbronEGKaH/L8JGsKdeUDzfchrPbnyrrz X-Received: by 2002:a37:5246:: with SMTP id g67mr4793286qkb.40.1544832637992; Fri, 14 Dec 2018 16:10:37 -0800 (PST) Date: Fri, 14 Dec 2018 16:09:41 -0800 In-Reply-To: <20181215000942.46033-1-sbeller@google.com> Message-Id: <20181215000942.46033-23-sbeller@google.com> Mime-Version: 1.0 References: <20181215000942.46033-1-sbeller@google.com> X-Mailer: git-send-email 2.20.0.405.gbc1bbc6f85-goog Subject: [PATCH 22/23] path.h: make REPO_GIT_PATH_FUNC repository agnostic From: Stefan Beller To: git@vger.kernel.org Cc: Stefan Beller , Junio C Hamano Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP git_pathdup uses the_repository internally, but the macro REPO_GIT_PATH_FUNC is specifically made for arbitrary repositories. Switch to repo_git_path which works on arbitrary repositories. Signed-off-by: Stefan Beller Signed-off-by: Junio C Hamano --- path.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/path.h b/path.h index b654ea8ff5..651e6157fc 100644 --- a/path.h +++ b/path.h @@ -165,7 +165,7 @@ extern void report_linked_checkout_garbage(void); const char *git_path_##var(struct repository *r) \ { \ if (!r->cached_paths.var) \ - r->cached_paths.var = git_pathdup(filename); \ + r->cached_paths.var = repo_git_path(r, filename); \ return r->cached_paths.var; \ } From patchwork Sat Dec 15 00:09:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Beller X-Patchwork-Id: 10731913 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DBD331399 for ; Sat, 15 Dec 2018 00:10:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 756E72D3F8 for ; Sat, 15 Dec 2018 00:10:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 69FF92D404; Sat, 15 Dec 2018 00:10:43 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, USER_IN_DEF_DKIM_WL autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0EC662D3F8 for ; Sat, 15 Dec 2018 00:10:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730168AbeLOAKm (ORCPT ); Fri, 14 Dec 2018 19:10:42 -0500 Received: from mail-it1-f201.google.com ([209.85.166.201]:55079 "EHLO mail-it1-f201.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726604AbeLOAKl (ORCPT ); Fri, 14 Dec 2018 19:10:41 -0500 Received: by mail-it1-f201.google.com with SMTP id v3so7434989itf.4 for ; Fri, 14 Dec 2018 16:10:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=gsNcA98bV/H6Yf7PlDzny9PrakCE9G8VUa4MitNMiS8=; b=Q3jMdzsrb8nTxQd5AzALJdxH1wI3eaQZadjYcw7Tcc4TbU7SbSy3Toos0lkcU68clu 1jJv2CUJZGL3iglFQMcg+2FZuCPCYmLUIIKJlsBFVPOExNLaZ+HCb/sZgJoxSpu9RS6c FfxHjSuWVAkcbvpPx0DVVHY4Jped0HEFK91zoWZRDYgzy9Wgz5zA3k16GxBzoav5QArF mTOcUFxkVN8Su1/sgIpcLaaIaFRiEpehnpQa4ya6nomnOCxumX1zw58MbRJ70pMh/GeZ Q3pxLgFODHngTqOdpCxVTk0pEBnbVqU7cs1mUxF+1eKdQOCJjj15PaH+qxtmId8HRl5G OvaA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=gsNcA98bV/H6Yf7PlDzny9PrakCE9G8VUa4MitNMiS8=; b=YQeSx+cFcvkEIvkMQkbobdJOOdN24KsxOvoxrCuus1CV8oGOuoG4cSe+UZr09zcGCq hYaDKXcLtMMXZYRjkoHJltujSg9AHEcMOZ8mMWUsIi4rOQAfuXMXD3+azL9Bt8k3R9+8 o1st13cOXmDoLgDwfj1orA+8lyqhpVewkES8i+ABFIS2GHB2zB91iBsPD4mKTJg/+F3h LBaqFpRE52alVm/htd8ZYrOzsGEKWjbHOe5QHUhpFU8A2ruUqP0LCO4u2+SI1kTSWiJl jLxJpaLYJHa5DmSuFi5RcUm+jSyEHOdNkxb9maPnNnFTf8UU09Tih04U64fkJl3dAb/t vgKw== X-Gm-Message-State: AA+aEWbF1YuBCBaEeFqBpDEegtA4SRj585j/IGNVauwmgIGE5cE725QA TDPOZ5787do82+JU1lpFexi5PHHFXGnq0GND9moJ6KufeOhHmEZhQjiDaQp47CdY8Ahg4iCRfoq 5NgDF8KnKgI5lnCZ89c2dczdiIkqS4u+Mhzg/tomzqDekf3QPqPmKP6gTA71N X-Google-Smtp-Source: AFSGD/XSAvs2e3vDsjztyhKRfQVjxpikqSozPQXvkqRhFzYHSN0PFNvJi1JEoI9Dg7c62Zgj4lLcgJcbEWzL X-Received: by 2002:a24:244:: with SMTP id 65mr4744988itu.3.1544832640508; Fri, 14 Dec 2018 16:10:40 -0800 (PST) Date: Fri, 14 Dec 2018 16:09:42 -0800 In-Reply-To: <20181215000942.46033-1-sbeller@google.com> Message-Id: <20181215000942.46033-24-sbeller@google.com> Mime-Version: 1.0 References: <20181215000942.46033-1-sbeller@google.com> X-Mailer: git-send-email 2.20.0.405.gbc1bbc6f85-goog Subject: [PATCH 23/23] t/helper/test-repository: celebrate independence from the_repository From: Stefan Beller To: git@vger.kernel.org Cc: Stefan Beller , Junio C Hamano Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP dade47c06c (commit-graph: add repo arg to graph readers, 2018-07-11) brought more independence from the_repository to the commit graph, however it was not completely independent of the_repository, as the previous patches show. To ensure we're not accessing the_repository by accident, we'd ideally assign NULL to the_repository to trigger a segfault on access. We currently have a temporary hack in cache.h, which relies on the_hash_algo (which is a short form of the_repository->hash_algo) to be set, so we cannot do that. The next best thing is to set all fields of the_repository to 0, so any accidental access is more likely to be found. Signed-off-by: Stefan Beller Signed-off-by: Junio C Hamano --- cache.h | 2 ++ t/helper/test-repository.c | 10 ++++++++++ 2 files changed, 12 insertions(+) diff --git a/cache.h b/cache.h index 59c8a93046..8864d7ec15 100644 --- a/cache.h +++ b/cache.h @@ -1033,6 +1033,8 @@ static inline int hashcmp(const unsigned char *sha1, const unsigned char *sha2) * * This will need to be extended or ripped out when we learn about * hashes of different sizes. + * + * When ripping this out, see TODO in test-repository.c. */ if (the_hash_algo->rawsz != 20) BUG("hash size not yet supported by hashcmp"); diff --git a/t/helper/test-repository.c b/t/helper/test-repository.c index 6a84a53efb..f7f8618445 100644 --- a/t/helper/test-repository.c +++ b/t/helper/test-repository.c @@ -17,6 +17,11 @@ static void test_parse_commit_in_graph(const char *gitdir, const char *worktree, setup_git_env(gitdir); + memset(the_repository, 0, sizeof(*the_repository)); + + /* TODO: Needed for temporary hack in hashcmp, see 183a638b7da. */ + repo_set_hash_algo(the_repository, GIT_HASH_SHA1); + if (repo_init(&r, gitdir, worktree)) die("Couldn't init repo"); @@ -43,6 +48,11 @@ static void test_get_commit_tree_in_graph(const char *gitdir, setup_git_env(gitdir); + memset(the_repository, 0, sizeof(*the_repository)); + + /* TODO: Needed for temporary hack in hashcmp, see 183a638b7da. */ + repo_set_hash_algo(the_repository, GIT_HASH_SHA1); + if (repo_init(&r, gitdir, worktree)) die("Couldn't init repo");