From patchwork Tue Oct 30 22:07:54 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Stefan Beller X-Patchwork-Id: 10661621 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 5018B1734 for ; Tue, 30 Oct 2018 22:08:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3C9A82A7FA for ; Tue, 30 Oct 2018 22:08:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 30CF22A7F2; Tue, 30 Oct 2018 22:08:37 +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 0AA7D2A7FF for ; Tue, 30 Oct 2018 22:08:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728448AbeJaHDs (ORCPT ); Wed, 31 Oct 2018 03:03:48 -0400 Received: from mail-it1-f201.google.com ([209.85.166.201]:59041 "EHLO mail-it1-f201.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728440AbeJaHDs (ORCPT ); Wed, 31 Oct 2018 03:03:48 -0400 Received: by mail-it1-f201.google.com with SMTP id j7so12258045itd.8 for ; Tue, 30 Oct 2018 15:08:33 -0700 (PDT) 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:content-transfer-encoding; bh=MNojA5uCyoBReYWk+/uamYgjAi7b0DBMdws//zOTtX4=; b=TyCMEOmB0d7rqQyIcuoRtZ+VhaUujZFRVNl6054qQXytyGM6NH7girbxlFKp9bexhZ 4B3EF9QFsg6lnN3nqHL0hyKBtkQMu/+ZokC8Fu0BjjxtVzvaPykW5e1sfDDME7P6h1fi /NIv8T/YJ5DRyi4YVi7BoEI8U8UeWocjgj1ztA8KG4RjZB6sf8ul5B0tG/71mox/AVBz lmOwW5dqaDKfX32EtjJNz/OzoQVzewd2BQpSJOq9KIap6PTBKSYFPo8+1jSlvvvxmTWh UjD8l6EwgiffGx4TjOJul4pcCdenl65QLXQDXVjiGg1Dvrv3Ug5Ew0s824zP/s5jxhUx 7iww== 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:content-transfer-encoding; bh=MNojA5uCyoBReYWk+/uamYgjAi7b0DBMdws//zOTtX4=; b=rIVvzdOJBLsfEskPTdcpYrK+0JF017M5JR9pjOoKdQxn15oCU2prt+c9cASAENz6s+ lvPmNq24fJZTodPhtEkFLj5NYH3kKUyuLKZrSBCDtQDD9QMK3OuOyXbZ4kaGOxcnJ1xT NpXXh1tnpDz2gxUBW1ZI5grUCFFroXCnFRAKH8NGi63TVwo9Wjy37B1b5v+ouZRy50Qa S6SVDJm6CJqq3dOhYAoombiNeY6nhOgbrR90K+Cp0ySHwZJA3EL1hpou67Fbkpm8T6y2 JYZJeL7ADOf6bdHqSCZGo7emJol+pfeTZIaMGYXljDxBCxlcZovGZ3jbSnGedTDHIWnl VXYA== X-Gm-Message-State: AGRZ1gJ+hkOB00sPi6Tm5iqjbBDuRGFYDzMshw94aek8O2EzWuy5nwN2 HWxriBcQcaub0dPIK46+HTz5neqEF+LYPkLzJnYYw803rkEwjXvRCyBVpzBlAzYUScKjpBi+nH8 vYjbOE/zBW756LPVrrhn+SwYlOOvJ2oSbP8s+L335586sJUN6BIMrSdEZSKIR X-Google-Smtp-Source: AJdET5ddiiPIq6xjbPr3jIJ1W4IMc2ZhB7m6jur5hMibyEQX4T3NFCIWQK3JnXRBOGFj19cjVHlXFSIfEwL9 X-Received: by 2002:a24:8903:: with SMTP id s3-v6mr333793itd.26.1540937312932; Tue, 30 Oct 2018 15:08:32 -0700 (PDT) Date: Tue, 30 Oct 2018 15:07:54 -0700 In-Reply-To: <20181030220817.61691-1-sbeller@google.com> Message-Id: <20181030220817.61691-2-sbeller@google.com> Mime-Version: 1.0 References: <20181030220817.61691-1-sbeller@google.com> X-Mailer: git-send-email 2.19.1.930.g4563a0d9d0-goog Subject: [PATCH 01/24] Makefile: add pending semantic patches From: Stefan Beller To: git@vger.kernel.org Cc: szeder.dev@gmail.com, jonathantanmy@google.com Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: SZEDER Gábor There are basically two main use cases for semantic patches: - To avoid undesirable code patterns, e.g. we should not use sha1_to_hex(oid.hash) or strbuf_addf(&sb, "fixed string"), but use oid_to_hex(&oid) or strbuf_addstr(&sb, "fixed string") instead. Note that in these cases we don't remove the functions sha1_to_hex() or strbuf_addf(), because there are good reasons to use them in other scenarios. Our semantic patches under 'contrib/coccinelle/' fall into this category, and we have 'make coccicheck' and the static analysis build job on Travis CI to catch these undesirable code patterns preferably early, and to prevent them from entering our codebase. - To perform one-off code transformations, e.g. to modify a function's name and/or signature and convert all its callsites; see e.g. commits abef9020e3 (sha1_file: convert sha1_object_info* to object_id, 2018-03-12) and b4f5aca40e (sha1_file: convert read_sha1_file to struct object_id, 2018-03-12). To allows semantic patches of the second category, we'll introduce the concept of "pending" semantic patches, stored in 'contrib/coccinelle/.pending.cocci' files, modifying 'make coccicheck' to skip them, and adding the new 'make coccicheck-pending' target to make it convenient to apply them. [Missing: SZEDERs sign off, so I also do not sign off] --- Makefile | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index b08d5ea258..6ea2bbd7f5 100644 --- a/Makefile +++ b/Makefile @@ -2739,9 +2739,11 @@ endif then \ echo ' ' SPATCH result: $@; \ fi -coccicheck: $(addsuffix .patch,$(wildcard contrib/coccinelle/*.cocci)) +coccicheck: $(addsuffix .patch,$(filter-out %.pending.cocci,$(wildcard contrib/coccinelle/*.cocci))) -.PHONY: coccicheck +coccicheck-pending: $(addsuffix .patch,$(wildcard contrib/coccinelle/*.pending.cocci)) + +.PHONY: coccicheck coccicheck-pending ### Installation rules From patchwork Tue Oct 30 22:07:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Beller X-Patchwork-Id: 10661623 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 1211C13A4 for ; Tue, 30 Oct 2018 22:08:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F3B9B2A59F for ; Tue, 30 Oct 2018 22:08:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E482B2A89D; Tue, 30 Oct 2018 22:08: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 75D3F2A7EF for ; Tue, 30 Oct 2018 22:08:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728452AbeJaHDv (ORCPT ); Wed, 31 Oct 2018 03:03:51 -0400 Received: from mail-vk1-f201.google.com ([209.85.221.201]:48782 "EHLO mail-vk1-f201.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728440AbeJaHDv (ORCPT ); Wed, 31 Oct 2018 03:03:51 -0400 Received: by mail-vk1-f201.google.com with SMTP id q9so6424545vkq.15 for ; Tue, 30 Oct 2018 15:08:36 -0700 (PDT) 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=mE77VqErJkZ6tm2ocITNyv0qJQ5oZq2d/KqboojHHZI=; b=rE9MjU63Uzdt/rsobylJNu6DEk0xavu/RBbKPiWgAH8HXDX8erOWSI1+M6ggjuA+5V eeuI4cHIq076+wcILV/Q0wgMmUwJxcVXPzEypS0W2PD6azoIeNDzp0OK3g5sNxiJmQwD G+oU3CZCPPoWbB5zTnMRHPpUn0DQITOk85Q9bIq1OqGPdogWvtVPgv7XWHCr5lGK9tvD ZtxenC0+9BQtri0uq9vWzWbH+cd5d00ylqS2wjp6625DCWnOqRx+pV7USmNX0JEhbSPU Wr9K8WlkDLIrQCPjJZqniPIDxgmNOAq5akLwDaNA2YYJcDAfjITVWFpmsZESIOar86uG GD/Q== 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=mE77VqErJkZ6tm2ocITNyv0qJQ5oZq2d/KqboojHHZI=; b=kBKiGrr6SZ1T+U3+50NbQQLwhnIdmjpRSudC4ldEirzh4K+vlW0pdQi4DeyCfSMbQX M9Dxynny/M3BCvhpNigiWTcLySz2pmn7URJqNE1dx5+zCB8P7bCiGde1RvrxBhUJLpta 72Rr4OTB6fvopPcM+spr2T/0gPRQAmsmdCEf2iZpCko/xxiLetJht8KHu+Mt2Br1JblR mgrWa6zKkdDtjbWSVkWg38SpAyfIwC82Q7gsjdfYxzgXz3otA7dO6fcPUWD8ffXDCSGd Ax48cyJmapOx4mvHyExyjf7/CDUFdN0pn8iPqIHz4eRTx9HJ7ubzUGyXZOSRJAOFZryY Xx8Q== X-Gm-Message-State: AGRZ1gKWtuuPczla0TLGkkvQU2KS1kCkj683e2hEGy2R98/bgKlj6sqT 0PJbIHrp0y0lIYrR4SV1LJEu4TwWohwxCFlUdchd98p5gzUZvxZvmOJDlUVhKlqTIiGxehfh9qe Wsff8wR11sCzqGqpY8kxpjET9WCWLHved+x+ech0smWqj9M0GcMg66mA9dMU0 X-Google-Smtp-Source: AJdET5dTIhrhdlNIrXF0I0YVKqlxyF8PwACqRe/oRGBhoOjgM5qNwuUxKD1ZrUWX9FzNTarka+qioLqXbV/B X-Received: by 2002:a1f:fc0b:: with SMTP id a11mr488633vki.23.1540937315860; Tue, 30 Oct 2018 15:08:35 -0700 (PDT) Date: Tue, 30 Oct 2018 15:07:55 -0700 In-Reply-To: <20181030220817.61691-1-sbeller@google.com> Message-Id: <20181030220817.61691-3-sbeller@google.com> Mime-Version: 1.0 References: <20181030220817.61691-1-sbeller@google.com> X-Mailer: git-send-email 2.19.1.930.g4563a0d9d0-goog Subject: [PATCH 02/24] sha1_file: allow read_object to read objects in arbitrary repositories From: Stefan Beller To: git@vger.kernel.org Cc: szeder.dev@gmail.com, jonathantanmy@google.com, 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 Tue Oct 30 22:07:56 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Beller X-Patchwork-Id: 10661625 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 5F3F513A4 for ; Tue, 30 Oct 2018 22:08:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4FA012A8A9 for ; Tue, 30 Oct 2018 22:08:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 43EA42A8D0; Tue, 30 Oct 2018 22:08:41 +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 DF6D82A8A9 for ; Tue, 30 Oct 2018 22:08:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728456AbeJaHDx (ORCPT ); Wed, 31 Oct 2018 03:03:53 -0400 Received: from mail-it1-f202.google.com ([209.85.166.202]:54662 "EHLO mail-it1-f202.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728440AbeJaHDx (ORCPT ); Wed, 31 Oct 2018 03:03:53 -0400 Received: by mail-it1-f202.google.com with SMTP id t5so6112145itk.4 for ; Tue, 30 Oct 2018 15:08:38 -0700 (PDT) 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=vJly1bdEYz4Ov8RMEYfidWD4NO7Q4BvqJSEKZJG4J7c=; b=aR1sAAnNTpeWc2j+U6TMJ1mJ+XB/NTCBwiaSv77xjE8a8Hq8WcUjTFia8pNcbqZ+ld Bz2V5M72SEgt268m5m35z65YEQAHJGaqwKBxVUvCXnUUPjjbtUljcUSJpbfTRz7miBSX gfEysQgfuNTvYtLUL/7pSMQZgo1dTX/+o9NojXELzK0wlpWS+SgmGPFQ8AuqY0/5D2up ZZt+pAaA+Q6sThVzGuu0MsKbE6JSkHF7Xeam/U8r1+8tyBU06RJKw4v/5pNPAKgDE9Vu ZgdiJ89NimwbH/WVkIFBrtgFSqbyR/8v+K87LVp27s23k0ZsuMn5ldi8QxdNVL1bEz4D l+GQ== 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=vJly1bdEYz4Ov8RMEYfidWD4NO7Q4BvqJSEKZJG4J7c=; b=e97YOL7lX6a45ubAcS+GUNdW7G+znMHbV0AhLlkPiZX9uJzgD7u2QzOu+0cZ+SXDBD GiZaZGbbEJsHLIxnX0+ZuGYYdSP52ooo+eJZTJV+vkmAtcA1a3Q9heSGjwjtPsR7cxcG 4uvYGKCuE0TAyxVpHAhpec4GKXzmWdFnZ9fzBpsBtxlL2wUASpjnH0MpwnXubowoCJiO uNIU0NARle6/mrB67mTj5O9r9x+bwb63mWItQjLCnu1QfWyBJjIx5SJ64clw/6JLJmMO Rb0UpCvmNI4WIvIE5szC1LrR4YZCa+zB0qeR+oqRic/x8HvdaHGrwtxyah6EB9cu9Ltf h32w== X-Gm-Message-State: AGRZ1gKl3wwQFrjTculpiJtW0TOPYqLRRqAPDfzM40/j2UXPzmQW2wzG XfO0n+e+ah1kpBN/Yx8kWYPJFDcwMdodvlOKR+ZBvfgDbqY1nPPjtq2kT8KFkpBRUIOXFZcStNF MSDRy7UueLvIs5dRLVMf/O1ma6jcX3OC/2cbnOLZgcIwA8lN+iMpMI7+ghxFX X-Google-Smtp-Source: AJdET5fsFrDvKZorrCJkbyejFQMXHSoC72KZSJ9EaYaIVGoCRfW8i2vTdaVN0LqtkXjdQnQlopcmCx4f2aGH X-Received: by 2002:a24:2795:: with SMTP id g143-v6mr328620ita.38.1540937318430; Tue, 30 Oct 2018 15:08:38 -0700 (PDT) Date: Tue, 30 Oct 2018 15:07:56 -0700 In-Reply-To: <20181030220817.61691-1-sbeller@google.com> Message-Id: <20181030220817.61691-4-sbeller@google.com> Mime-Version: 1.0 References: <20181030220817.61691-1-sbeller@google.com> X-Mailer: git-send-email 2.19.1.930.g4563a0d9d0-goog Subject: [PATCH 03/24] packfile: allow has_packed_and_bad to handle arbitrary repositories From: Stefan Beller To: git@vger.kernel.org Cc: szeder.dev@gmail.com, jonathantanmy@google.com, 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 f2850a00b5..63f8dc7b98 100644 --- a/packfile.c +++ b/packfile.c @@ -1138,12 +1138,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 6c4037605d..d70c6d9afb 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 Tue Oct 30 22:07:57 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Beller X-Patchwork-Id: 10661627 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 0E7D513BF for ; Tue, 30 Oct 2018 22:08:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F276B2A8A9 for ; Tue, 30 Oct 2018 22:08:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E707A2A8D0; Tue, 30 Oct 2018 22:08: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 817B92A8A9 for ; Tue, 30 Oct 2018 22:08:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728459AbeJaHD4 (ORCPT ); Wed, 31 Oct 2018 03:03:56 -0400 Received: from mail-pg1-f202.google.com ([209.85.215.202]:51295 "EHLO mail-pg1-f202.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728453AbeJaHD4 (ORCPT ); Wed, 31 Oct 2018 03:03:56 -0400 Received: by mail-pg1-f202.google.com with SMTP id z13-v6so10048666pgv.18 for ; Tue, 30 Oct 2018 15:08:41 -0700 (PDT) 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=XrsL5O26Au2090hyQQFE6jISbSI1/0Sj/6+EljMEBrw=; b=HQwnI5JQgvO3VdM1jQgbWm62EEoKxiahOlNKpBXcAsoarZ6ePhwkgN3GSEuNR1GT0H P+vzLqTJ9ls9tizcB8Hj2Rts6yahkaJZo5mR793Y2rZ4H37nhts9vO3ndIPpoY5BexX/ mpvPK+VGkOwD/oryvCwytWMilbQ4CO3ruRLtbhPpf6h2/lkhIX+1R9pm706w/cU1WCJq bt0G40jStURkDP+RSubhPN/aME1L7EQ7+D5jWfuY3OBxJI1oZpDT9aWa/amujB/LZv51 zy4Nwgv/kxMI+/eqgtlpHe52W0aT+f+0WBep2iHNrJWyKY2yQGiF8svfcj9i/gMFi9tm L81w== 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=XrsL5O26Au2090hyQQFE6jISbSI1/0Sj/6+EljMEBrw=; b=TtKkfwtMc9Sr3QwwbP6JwvxO2QMkTKG0b+r6aVeNldVcLvJn51WaJP3d+3FwRFVsYP JjOdeu2uNexLkMU/Dj4t7CZX3eNzEW/1iHc1UyAE9fdsy9I/vi53eaICnfx2vwLhLj9K nKsyUCQxFnSgrkrIADwjcsDavK7/1fuqmhPllUCAbuYQ2cyk+p4MlwKQ2fLVtXrYsfMJ wRJoDJJViOgffWa9uZBhd8Mhl5HixGEGGGh20pA9CZYKZQCTFOMgSpmV9eiU46IcumoQ rZUy6z670qX7QeOvTRWK7cJc5XweJZSxQnWPGMSsUuwids/4ePOXhvRwdntAvTKi1CLE v1OQ== X-Gm-Message-State: AGRZ1gK8cP3M5/a30cn3VA9a3G9N+ye//rIxIRJSVNnZun5IbMOGzSWx 6CO0SisoWRQRyMTd7MniiX36EpUe0Y4uX9A6TGjw0c8Wq7q+wMjPMQBz8fpalKAy2dabey9u2c4 X+V1iW0/kN24RxvZiWDJ4gAgWnxhSbWtUM1PxMGiz48r9piABNlzHbKUK8KLF X-Google-Smtp-Source: AJdET5d06Usp5tH58tx6KrV2QQMjOSS2go0zkX7dqbZM7KcikAX4sWfcoI1G7ywRzgBLoB44jPErC3uY24M1 X-Received: by 2002:a62:11dd:: with SMTP id 90-v6mr273891pfr.142.1540937320947; Tue, 30 Oct 2018 15:08:40 -0700 (PDT) Date: Tue, 30 Oct 2018 15:07:57 -0700 In-Reply-To: <20181030220817.61691-1-sbeller@google.com> Message-Id: <20181030220817.61691-5-sbeller@google.com> Mime-Version: 1.0 References: <20181030220817.61691-1-sbeller@google.com> X-Mailer: git-send-email 2.19.1.930.g4563a0d9d0-goog Subject: [PATCH 04/24] object-store: allow read_object_file_extended to read from arbitrary repositories From: Stefan Beller To: git@vger.kernel.org Cc: szeder.dev@gmail.com, jonathantanmy@google.com, 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 Tue Oct 30 22:07:58 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Beller X-Patchwork-Id: 10661629 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 6B60A13BF for ; Tue, 30 Oct 2018 22:08:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5B1A52A8A9 for ; Tue, 30 Oct 2018 22:08:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4F7612A8D0; Tue, 30 Oct 2018 22:08:46 +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 E662A2A8A9 for ; Tue, 30 Oct 2018 22:08:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728464AbeJaHD6 (ORCPT ); Wed, 31 Oct 2018 03:03:58 -0400 Received: from mail-yb1-f201.google.com ([209.85.219.201]:39274 "EHLO mail-yb1-f201.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728460AbeJaHD6 (ORCPT ); Wed, 31 Oct 2018 03:03:58 -0400 Received: by mail-yb1-f201.google.com with SMTP id d196-v6so7114155ybh.6 for ; Tue, 30 Oct 2018 15:08:44 -0700 (PDT) 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=pJc2ZwdK7zREJfx7PXoDzDUoawH9Dw3v1oySPEl91f4=; b=DO+M4PtSu1NAIvr3bgwOhDsgKfgTSpu+Y6Vblt2jgpg0Cg/KeJeSCrU591WzeumhVo mFiDmvegRj4tr6OJjDuChC0MOOTdrBJgRHYo5FHxEgo9fxtCHcIYDtU744+icZjjiXY/ XrOdi0Ru7Ncc+y7Vx2CZTpNuRzcc53esMZ34iNgnYtT2FMZImwDwDVjlsQlMgvO3s+te SbRFAWhdyMWZ2g0Q4jYPZ6xdyrkUypB4j/TGWCkOCtOcivAfxMIoBEQvLZgQS8V1miyI /iPfw1N8PE72BV8JxoJXulgpB3HDi1jFJ52cXDOn+NOiFgtdLhAsVhn6OWPV5j5/8Lj4 rOFw== 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=pJc2ZwdK7zREJfx7PXoDzDUoawH9Dw3v1oySPEl91f4=; b=jlSAjw78YofbKHIG/nsCI103zaSDr5N7yroSygnXH48g6jlvZ7SPI613+fmA1YFybr hzUCS1nUvybiNXZTmCAPXQGQNgZhVAVwbsAY9duREW3kOkG1gQAWl8goTiH0f8Xx/OkT eofbbXIpV+/aiOwOiCsCvuFsfMJMlyQMxMscQ6va9nMsExuZjKy9UZ8PPmuh63gquWWj GoXXjnJsLdyofqfUN9bUkf4NlEoutFrw0Ni4OqjGz7chFkcqDJxLJ1MElWjimhYqssDE b5S4WqcFMezKKvnJqvJXvn3IbqyNEtk0JKxL8OniVKSRb/zp86w7b8jtyRRkehSuak15 2pfw== X-Gm-Message-State: AGRZ1gI6edKw5FdhzX6g/xYryAgg9hkfW1h92sJ54qd1uOCnwkJ4dygF 2T6hv7tnyMuymVMLDZ1zvAnsDuS3jF9st4iVWJwywmIUeuKhhG5ZS4RSOID9H90e7wg+2tZId0M pMVGs9aiOujEjPIHnJKCGHE5EpTfk8AIf/3fDfip56sI2AMXhEHQ9dymGewib X-Google-Smtp-Source: AJdET5dJmFtpQNx0r/jJwgpWJUeONiUNzjJ9cRW9E9qz73RhWeKWxCRsLappQdY9K195QuqvQGjbjGTRHUbM X-Received: by 2002:a25:37cb:: with SMTP id e194-v6mr398747yba.53.1540937323764; Tue, 30 Oct 2018 15:08:43 -0700 (PDT) Date: Tue, 30 Oct 2018 15:07:58 -0700 In-Reply-To: <20181030220817.61691-1-sbeller@google.com> Message-Id: <20181030220817.61691-6-sbeller@google.com> Mime-Version: 1.0 References: <20181030220817.61691-1-sbeller@google.com> X-Mailer: git-send-email 2.19.1.930.g4563a0d9d0-goog Subject: [PATCH 05/24] object-store: prepare read_object_file to deal with arbitrary repositories From: Stefan Beller To: git@vger.kernel.org Cc: szeder.dev@gmail.com, jonathantanmy@google.com, 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 from 'make coccicheck' 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 | 13 +++++++++++++ object-store.h | 10 ++++++++-- 2 files changed, 21 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..3c7fa70502 --- /dev/null +++ b/contrib/coccinelle/the_repository.pending.cocci @@ -0,0 +1,13 @@ +// 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 Tue Oct 30 22:07:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Beller X-Patchwork-Id: 10661631 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 AB17013A4 for ; Tue, 30 Oct 2018 22:08:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9B0D42A8A9 for ; Tue, 30 Oct 2018 22:08:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8F65C2A8D0; Tue, 30 Oct 2018 22:08:49 +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 27E172A8A9 for ; Tue, 30 Oct 2018 22:08:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728470AbeJaHEC (ORCPT ); Wed, 31 Oct 2018 03:04:02 -0400 Received: from mail-qk1-f202.google.com ([209.85.222.202]:34972 "EHLO mail-qk1-f202.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728460AbeJaHEC (ORCPT ); Wed, 31 Oct 2018 03:04:02 -0400 Received: by mail-qk1-f202.google.com with SMTP id k203so11023885qke.2 for ; Tue, 30 Oct 2018 15:08:47 -0700 (PDT) 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=HKzBptzwt/8MxGuMdHeqHyu9K3obRPLmxcelYb3iMzU=; b=NUHGqmN90+QGHNZQEyNgEujJYQjlJ+XNdKTQnY03CTUkZJTCfYgAzda6xAuNlGo6il dJczAxEfIctqRU+MViCHShlYnGb3umwDW79zVEzL9xjLghlyHmfr2An1CRVKGLcG/kQR 8qDqybKIwOtSWRb4w/aAp1lau0BBe/mTJRhkvNcCWkDAOwTdiPDvPkJzMfVp7FQJxAWD K4b9t6PixFc8EB/dMrFaYyrc0Kx7uM1+8BtJRoefvmpemL8lsCWfPTMZ2Kb+7G8dqNkG utUANsEPkOQN6wA/85WVEZAXXnJXvxD61EyCDPjJDmtJrAqJvX8q9xRa44TrZ/Ib+vFf OFng== 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=HKzBptzwt/8MxGuMdHeqHyu9K3obRPLmxcelYb3iMzU=; b=YLViGkOcIZoKOuV7d2SbwTDB4vEWBg9McE0ZjZXZqEO3KmQksIN7Wmq9ieJX/xq5It kraic23CLAEQVixEdcw/0/sxoFiKhyOpbCat5nzhYvdbpW1v5Bf4/9Y2iWctuSUeCC3y EBA512VbyOepjXzGEGC452oypEk1ORHJaRYlz5XJ4TPmeC9dV6xdIFI+JBme5V9zYkSu rjQeWXnybC74H9o5sOwfR7SqctptKVlYG/W65TSoTBcIb2zkgALS128/Tay7R26CcoCV 092ufQQtmFop2BGrEdU6vSIODdzZm8CWC4AKUx7IF6Tq6N/6S9GWcQV+grcCV//dkBSw gUMw== X-Gm-Message-State: AGRZ1gKEbz8SHU1ZUsAI0OEUxMDlW4hPPkvBUMaVWdHEYOr84BOtSc+O GfwzYb59Z/HL0JYT2KFG09orOOjZKLWZSmTKrBjg6cDToUbnvwZb7qFw176ul0++Mx0TlfKqvuB jAy2vzmIHR02yKxrNVZTR3AMIb/Ib804qZ7xnRc7rz43FYUQ+UE8Olnp1xlDU X-Google-Smtp-Source: AJdET5dfFC37UbfVlgAav6bQn+2RMqiKBxqu31iKJy7g7cZlVHDhTszOgpURrDCFO1NP1h7VqXKgwftQIf4d X-Received: by 2002:a37:110d:: with SMTP id b13mr445493qkh.15.1540937326571; Tue, 30 Oct 2018 15:08:46 -0700 (PDT) Date: Tue, 30 Oct 2018 15:07:59 -0700 In-Reply-To: <20181030220817.61691-1-sbeller@google.com> Message-Id: <20181030220817.61691-7-sbeller@google.com> Mime-Version: 1.0 References: <20181030220817.61691-1-sbeller@google.com> X-Mailer: git-send-email 2.19.1.930.g4563a0d9d0-goog Subject: [PATCH 06/24] object-store: prepare has_{sha1, object}_file[_with_flags] to handle arbitrary repositories From: Stefan Beller To: git@vger.kernel.org Cc: szeder.dev@gmail.com, jonathantanmy@google.com, Stefan Beller 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 --- .../coccinelle/the_repository.pending.cocci | 29 +++++++++++++++++++ object-store.h | 22 ++++++++++---- sha1-file.c | 15 ++++++---- 3 files changed, 55 insertions(+), 11 deletions(-) diff --git a/contrib/coccinelle/the_repository.pending.cocci b/contrib/coccinelle/the_repository.pending.cocci index 3c7fa70502..46f3a1b23a 100644 --- a/contrib/coccinelle/the_repository.pending.cocci +++ b/contrib/coccinelle/the_repository.pending.cocci @@ -11,3 +11,32 @@ expression G; + 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 Tue Oct 30 22:08:00 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Beller X-Patchwork-Id: 10661633 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 9B21A13BF for ; Tue, 30 Oct 2018 22:08:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8C25A2A8A9 for ; Tue, 30 Oct 2018 22:08:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 804012A8D0; Tue, 30 Oct 2018 22:08:51 +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 292012A8A9 for ; Tue, 30 Oct 2018 22:08:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728473AbeJaHEE (ORCPT ); Wed, 31 Oct 2018 03:04:04 -0400 Received: from mail-io1-f74.google.com ([209.85.166.74]:53578 "EHLO mail-io1-f74.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728461AbeJaHEE (ORCPT ); Wed, 31 Oct 2018 03:04:04 -0400 Received: by mail-io1-f74.google.com with SMTP id z17-v6so12209503iol.20 for ; Tue, 30 Oct 2018 15:08:49 -0700 (PDT) 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=qLO1hb3VDzg+QvZCbuAypDEvdjntachOQbhLME79B8g=; b=VnfJXrSGRGzkWo0amkgwic87+ca7TgER2UKSQxtWv+0487dG5lU+Y+zc7vzLHpWNE4 AActVO2SVpR8NxlUQNpE3OHRkzOSI99HVo0HamfIqM5pQJH9S+BNpAQY0Lo3dg4R7kb9 EvITcefa0gVM0bj3ka5g3FF8feVsJ6AJN9hvFlz//OSj1PANGN+9bw5TkGa6BgT1jX8F MMivHX2EXEqCvNBEb5zHksn8Mr+RgxRz+UFiCNE/Do8gToP7vI01N8G2OaI2QLmsq5fQ ZDujtGYpP5nzoqW/M/sC0rycuNkmn26Bt+DYjlDo2XcfM6PhzhBuA3A9834FSiIXQo8L Odbg== 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=qLO1hb3VDzg+QvZCbuAypDEvdjntachOQbhLME79B8g=; b=NTZW0xPPJChSDPGIY815uPWeG6sJsO0zKaaQkgB7xKc4IRIWhCS6ouHOiyGYVWzLpI BXYB1a4o91Cl8NQTDAxhKZBSlsUKsFJWF754FHx3STm1fuXU1hDMz1Qby5eePb4/TmLB rAMqJrYciqa4jHLo14ITsqvQVJW4cnYEPUlKbQl31aFi6W7RyEfG69R9PW57dphQ4Kgy 5uc2pJ3zkac9kKRZoYTTaIoy7bm8X7RjEtjDvb8AFZvf8+AL0ObcjAYHB7er1S4KdiNs EqPIUxK34h+pBOP3WCNE2gfPE/S0mU7DfwZPi9LpcJMOikSbXF34M9+6PVgvDs6uqwjd 6P5Q== X-Gm-Message-State: AGRZ1gKfcwx11xAMlkE9QGK0vmSPk9ZdMgwRkmWRhU7o0VT/0QkYZxNe 9El4xI4K2qmzG4chsH/+lWq11Iw5D5w1K7jyaxMdk7s201FTdd6gzVnzqApsSdS75Cx88Teuivr YlKpiMB+GRHcpKaEZiH452G4OWkp9rJ66GRy5DLt5wVoSyeD7sGFfVmNv+lMw X-Google-Smtp-Source: AJdET5c/lUMTquvrppsBEm3tQ2WDYgVg6Hgd8qu0yDaaCteMTlG3A80YVg98nBa0iz6u59T9jIIwXrkm93gR X-Received: by 2002:a05:660c:8d1:: with SMTP id g17mr331927itl.1.1540937329082; Tue, 30 Oct 2018 15:08:49 -0700 (PDT) Date: Tue, 30 Oct 2018 15:08:00 -0700 In-Reply-To: <20181030220817.61691-1-sbeller@google.com> Message-Id: <20181030220817.61691-8-sbeller@google.com> Mime-Version: 1.0 References: <20181030220817.61691-1-sbeller@google.com> X-Mailer: git-send-email 2.19.1.930.g4563a0d9d0-goog Subject: [PATCH 07/24] object: parse_object to honor its repository argument From: Stefan Beller To: git@vger.kernel.org Cc: szeder.dev@gmail.com, jonathantanmy@google.com, 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 Tue Oct 30 22:08:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Beller X-Patchwork-Id: 10661635 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 01B1013BF for ; Tue, 30 Oct 2018 22:08:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E58562AA6A for ; Tue, 30 Oct 2018 22:08:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DA17B2AA6E; Tue, 30 Oct 2018 22:08:54 +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 689AA2AA6A for ; Tue, 30 Oct 2018 22:08:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728479AbeJaHEH (ORCPT ); Wed, 31 Oct 2018 03:04:07 -0400 Received: from mail-vs1-f73.google.com ([209.85.217.73]:49422 "EHLO mail-vs1-f73.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728474AbeJaHEH (ORCPT ); Wed, 31 Oct 2018 03:04:07 -0400 Received: by mail-vs1-f73.google.com with SMTP id r192so3656287vsc.16 for ; Tue, 30 Oct 2018 15:08:52 -0700 (PDT) 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=YDTTlB5jX5FvYBozCH4sIUNMVT2HM9jW29X/gDs4ntc=; b=QO4Ffo7PQDw5MPKa1N6lL8bp0faKN7UUfO8CziKBmF8fecmKY4MQEbiDXNjEZcoTET ke9lejTiXQFAtwBZe2L0/lWUai3+zY7gOMk3GwG6qDyfkmKlniaXLnoeRIocdFI5zmyb AvLb+gdDxZ8lK6GW861Z9ELTxoxoZ1vYRMO1thCuay0keU4+vp1DRD+4GqWNtcq2ii49 8YrQaO9wqh9BfpwdxrL+bdWD8pzGgqu4U6Ux4dxk7NHuZ9+gUALBY6tfsNQcXzjlsvMy HDXqFoBj+70lEpLk41oMS/GhxFLnsxFyfqrOhJd4cmEhPtgX531COGzecoe1pHJ1Mkhd ZBuA== 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=YDTTlB5jX5FvYBozCH4sIUNMVT2HM9jW29X/gDs4ntc=; b=JX/fWNoZ1H9GyVr21qSjAvRgSx3GSqyGIg7ym5gSV60gVf9qbfo4t0ohXD2ofzrD3Q 0gxO7RLh1Y2DD2+Xdmv+iODBrbR+f2giPRUhXTdJvOiB8r7HWP/oVhAHd6uoRTKKwRO1 lKV4iF8GFPCqJTneBfMqseExY1Iec5+pd2Bl5aqxa+vhHyGBt1RpGDih4LHANBaPMde3 q5/sNbPHYWVoyDGfb6SlSZKxfjDNHXgCVqLFlCjGO27mVnZcv+rj6ONE/VehoWK7M5FL kEGpdMj13E1kr0uEZkadhDKkU6QxhYV+rcj57WpqejdzCguRqjV4yc8BQ8txGRpWQxVd 2dCw== X-Gm-Message-State: AGRZ1gJ2GcW0YcyHX4KUbwwz1EHNGDkBSWQYKdHUKxVPKujwJd00QBta j6SmQEeCz9NlHgX/Gy6H/MWweYzsJ+9sUdG9U4VA4RPsEQY+/mlA5eFQ0/s5nupw2/OXKH/NFkm 7N6Vk0r0KJOoTOHA98+4mYEerFRbHLY0+9my9CdchwP+oOdmgKG7TVREHnto3 X-Google-Smtp-Source: AJdET5cUAXRsQES/eSZyXm1Y5B9MO/33/ha6VMGs50dSr3GLBAQgEHt/oEVulTsgCOShD/ltE2r5zxRA2Y8h X-Received: by 2002:a67:3b06:: with SMTP id i6mr511820vsa.42.1540937331732; Tue, 30 Oct 2018 15:08:51 -0700 (PDT) Date: Tue, 30 Oct 2018 15:08:01 -0700 In-Reply-To: <20181030220817.61691-1-sbeller@google.com> Message-Id: <20181030220817.61691-9-sbeller@google.com> Mime-Version: 1.0 References: <20181030220817.61691-1-sbeller@google.com> X-Mailer: git-send-email 2.19.1.930.g4563a0d9d0-goog Subject: [PATCH 08/24] commit: allow parse_commit* to handle arbitrary repositories From: Stefan Beller To: git@vger.kernel.org Cc: szeder.dev@gmail.com, jonathantanmy@google.com, 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 Tue Oct 30 22:08:02 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Beller X-Patchwork-Id: 10661637 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 0A42513A4 for ; Tue, 30 Oct 2018 22:08:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EF4DB2AA6A for ; Tue, 30 Oct 2018 22:08:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E39A92AA6E; Tue, 30 Oct 2018 22:08:56 +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 8C34D2AA6A for ; Tue, 30 Oct 2018 22:08:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728481AbeJaHEJ (ORCPT ); Wed, 31 Oct 2018 03:04:09 -0400 Received: from mail-yw1-f74.google.com ([209.85.161.74]:46092 "EHLO mail-yw1-f74.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728393AbeJaHEJ (ORCPT ); Wed, 31 Oct 2018 03:04:09 -0400 Received: by mail-yw1-f74.google.com with SMTP id i82-v6so4683485ywb.13 for ; Tue, 30 Oct 2018 15:08:54 -0700 (PDT) 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=Ex0Go0raPxBYi3w2kEg8nl/ESMviQ+YVucF1o3Zjrng=; b=kL+Xmi1jOlIGDhUqO6OL7EnALioYa/SoidfmAXZKnnVk7PGRHdAL8Ca5RFZR41qfyI Lv6WJ6xHZvLurjTDR8aUTKTajHJOAwRMoUL+ZURrV0HiiPHTF9EwMAi7DiAFHRQKM3eh gV/HXrFtvg/c5kfR+QHZXdVPtB614lUE35D6C45+rHgVoJqR9vV+VWghVGzgqS4wJrzU 9d60A5Epci2JYduR75K/8jM7KGa/zkcIXe6cDugB2D8ttlet8MzUmwkEq49hzLP3Giry 858ZhcCTagSZeU//G+rOHJjQ315pQ1AnsXRvQPu6+vF0N9Pj9Ujt0Rl4NUyoQY7Jhoqy PFkw== 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=Ex0Go0raPxBYi3w2kEg8nl/ESMviQ+YVucF1o3Zjrng=; b=LVfYlFOjgXuKOwTOnhDu9nM+O4Ysa6SmyCkRyMXtHfIFVqdYCams3JMlmd55duhTSL BT/FhMcDJnZ/bB8UZ02PjBz2kNFmxzYniXPtAjAQN3ZH+m/DsvzDMLQe9rv7okXNTqQs A8hgtZBk6B3ZBlC4z/TbB7RPr88HnTlExlePN3O/zOqLyKA+OK5x0RQ4jzMSKTUteeCf y+1stlGRZOxmtBQ1PNCIzCIe8iMRgr9OwWh2mGoTO3cHcnChlUamSaPSpK7BlvnjUcvH 322iQKb4IhWhQ8RySehFRhZuko8uSP7ek5IlRiakcG/yDxLrvtkU06LIKxCC7MFVpunw IPNA== X-Gm-Message-State: AGRZ1gL7USDHhqZiYi/4rrlhBNVRIs3KcV8+yiJiyt2JAzq9J0lJsMgC Ke7bCV/vwJAhsn0273kdMDGse/hr1efm4ufYgZLpB1PcbFXOvAHpkFdA3u57melfsrINeliOsLg IDohnLXAg88KXlC40BK5injgy92Uxv8o8rHJmoGr9fSWq3x1hbmIU4n17NG5y X-Google-Smtp-Source: AJdET5dl46RvyJb4RT+3KJNkfVzDz9I7PuhEuoZj7U86+Alwj0KSAlecF9zBDsNq1lkqQsZZUpon6SKTxmlV X-Received: by 2002:a5b:3c8:: with SMTP id t8-v6mr367606ybp.55.1540937334471; Tue, 30 Oct 2018 15:08:54 -0700 (PDT) Date: Tue, 30 Oct 2018 15:08:02 -0700 In-Reply-To: <20181030220817.61691-1-sbeller@google.com> Message-Id: <20181030220817.61691-10-sbeller@google.com> Mime-Version: 1.0 References: <20181030220817.61691-1-sbeller@google.com> X-Mailer: git-send-email 2.19.1.930.g4563a0d9d0-goog Subject: [PATCH 09/24] commit-reach.c: allow paint_down_to_common to handle arbitrary repositories From: Stefan Beller To: git@vger.kernel.org Cc: szeder.dev@gmail.com, jonathantanmy@google.com, Stefan Beller 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 --- commit-reach.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/commit-reach.c b/commit-reach.c index a9da65c462..080ae0a758 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 Tue Oct 30 22:08:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Beller X-Patchwork-Id: 10661639 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 30A6F13BF for ; Tue, 30 Oct 2018 22:09:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 20FEA2AA6A for ; Tue, 30 Oct 2018 22:09:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1595D2AA6E; Tue, 30 Oct 2018 22:09: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 B9CF92AA6A for ; Tue, 30 Oct 2018 22:08:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728485AbeJaHEN (ORCPT ); Wed, 31 Oct 2018 03:04:13 -0400 Received: from mail-pf1-f202.google.com ([209.85.210.202]:37851 "EHLO mail-pf1-f202.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728482AbeJaHEM (ORCPT ); Wed, 31 Oct 2018 03:04:12 -0400 Received: by mail-pf1-f202.google.com with SMTP id c28-v6so12099550pfe.4 for ; Tue, 30 Oct 2018 15:08:57 -0700 (PDT) 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=Si5tqxeGXLH4OHDQBmBGaj2ATNe3+UKeenVXQDU6znI=; b=U2NXHf+rKfu8jJU9sp6etsspFhX43Z5kkLyhNjO9IW9sE06lH0fjSTf4MnKXrMFKgh JPdvWHLjrRZKYQrjxKiz5BZljiT5laNQeCDyFxXBLS/WbtROk8Y3g4jaEZ/FqR9qgffw g/pX2c2xhDmS3aQCs87uV7n+0AJDHm4Hsobn2lpH6x9hFWWpsHHrP2U9Ch6jgvR4Lhbp kqzfRNwLxvn4qOS8xAYIzLY0cMGbgGLgO3L06+VLUSbx17M0BoeHyir8M9PVbBqhlZXp 1u5uAsUCR63xrAnfyb+DTHoOeqx3N6zm2tXqRX/WciY6YfFdM3QEl38CiPxSN5Ryel+e iH0g== 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=Si5tqxeGXLH4OHDQBmBGaj2ATNe3+UKeenVXQDU6znI=; b=IO0eh+WAZ657dMnL8Xiw03VVqUJmrV//c/MoRiwIC/JDqz5iLFXxvOtRWaHsTQZoPC LWm3B52ycahu+sxPaRKj47HJUISoPlZmIzo4xvSiu03CsfXZQjFmQZh8Q4z0Dl0h0Dlf 0+g76aWjGqWVL5KBXWRJu2jTHTxhkvjSHKbNxOD3Kan4o4m0N5QDvUKso3PRfqWxWnXC rXOJkieb19NOdTKjgSZzEli20czuwA12v95NVi20YSvUs5FXRif1adr2f9oR7SBXOs9e 5e/wv2nIOYe2DbLH4Pqv3S5XggC8Pnsuk53c5LT2RFzqolsM5llgjQubvhwm/7z1lLeo 3Pig== X-Gm-Message-State: AGRZ1gK07RCUKiDNGSdQAy0ungWOS6Mie4pq+cjBZC/g06kYisqTP4vH +VjUVdwwzhrlLEjALG/Dub+a1n0bvcgkyNYiXTjUVHKn/VoPXq8xHBEE0bO/jvksd7HZ5dt6iiV cjvdM6cgRk+wkK1gr85lxOK7L+ONCGh9SuAIvFfQD3kvcXJDMAoUogBzWFB38 X-Google-Smtp-Source: AJdET5c6D0/bCL12643kXPlhkJJ8O9JnXUHc3VjT2AGbu70m65sxmQfHj3P1x3L3tnOfNQaBVIlmMJQHALZr X-Received: by 2002:a63:575c:: with SMTP id h28-v6mr249161pgm.71.1540937337059; Tue, 30 Oct 2018 15:08:57 -0700 (PDT) Date: Tue, 30 Oct 2018 15:08:03 -0700 In-Reply-To: <20181030220817.61691-1-sbeller@google.com> Message-Id: <20181030220817.61691-11-sbeller@google.com> Mime-Version: 1.0 References: <20181030220817.61691-1-sbeller@google.com> X-Mailer: git-send-email 2.19.1.930.g4563a0d9d0-goog Subject: [PATCH 10/24] commit-reach.c: allow merge_bases_many to handle arbitrary repositories From: Stefan Beller To: git@vger.kernel.org Cc: szeder.dev@gmail.com, jonathantanmy@google.com, Stefan Beller 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 --- commit-reach.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/commit-reach.c b/commit-reach.c index 080ae0a758..4cf471bfaf 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 Tue Oct 30 22:08:04 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Beller X-Patchwork-Id: 10661641 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 EACC513BF for ; Tue, 30 Oct 2018 22:09:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DB4692AA6A for ; Tue, 30 Oct 2018 22:09:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CFA642AA76; Tue, 30 Oct 2018 22:09:01 +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 7B6E22AA6A for ; Tue, 30 Oct 2018 22:09:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728489AbeJaHEO (ORCPT ); Wed, 31 Oct 2018 03:04:14 -0400 Received: from mail-pl1-f201.google.com ([209.85.214.201]:57156 "EHLO mail-pl1-f201.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728482AbeJaHEO (ORCPT ); Wed, 31 Oct 2018 03:04:14 -0400 Received: by mail-pl1-f201.google.com with SMTP id v7-v6so10752532plo.23 for ; Tue, 30 Oct 2018 15:08:59 -0700 (PDT) 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=sKk2u9G+3MWGs877csYKraZaKSP2qAvAYU+zayAuQvY=; b=t1wh39eCcEAzkIkVifqBmLeT1J+OY+eS/JApWXvVeTnYDgI07Wz5S9U6XOzooKjH1m DnjsxvZhes4jtU6eoXXnmhhiYDv4vDmuIe2vdnyhcQ9w7Apm7fovzfSKPGRwqcT9uwVc ShuA8c6rJsDWY9dMmlMe5QB6ujj8rywNTXzOEtVBTV11/s5G/0f2s+5scxudjotS4I9W EX4g1ToyGLHg1JGS6EMkxumc1c3InG0hjjI+uj6bTzfXguUxmyJSn9AghDER5EMxUQnR l9Tg88qmKT3T8gESHyDh++8b+Bh/TPZ+925fiM//0MITvjphUJeL6MvD4JPMqqR5H69c 7tzw== 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=sKk2u9G+3MWGs877csYKraZaKSP2qAvAYU+zayAuQvY=; b=JqdT9kf4f2gV7l2iKkY2l9ZApB7Gj3LShsldlZvs10XKOQhXxzHR9sWCRgDeVDbrXZ YcAf6MUg4O4/OYnb9GhrAFqfx583ePnxo1AFu/t9LnwUplr/y2h5R2LjHEAQGh6edpYB pD5dVkr8w3TjAIT8vin6rzEExqFyykacgJnhDvPwKXN9urVQVCkJV2xiLO9cRtHU3rJB mUocj44XouKavx8dFlhqvfn8juGEvVZ91kppVpFJLFqzoZqcU9AYrZAVKwoIHZTg+U1V cVfipIdhJtyZX8Gtjih4oGiuH4HU/RCaCeYLZre1nEzhE4xecKq1iQy6hR271MaP9cp8 4D/w== X-Gm-Message-State: AGRZ1gL4Al3+sOW21S5lxNFqPi1D8dzXxnsarjPLxW/dP+pKHqNHpWyZ 34X88J6bfKGQOo5NdzfZe4seJ6HugPobSXFyDyuLsgNNYGImQE9Mp/7WXJqsROG89bfw+uHLWI+ i5euSIITAcnUK07jThV+VyzOwQ6DY6ZUGQ0FkQbT63wh0WcrioyxQi9EyWNZ3 X-Google-Smtp-Source: AJdET5dURuUQonRRDWiIihRGOUduzAGOARru5S6cnUYZ/Km4hCwaRAaWhiTtdqGUW0dXoz0kdKOlsDiHGbcM X-Received: by 2002:a17:902:8605:: with SMTP id f5-v6mr213320plo.106.1540937339347; Tue, 30 Oct 2018 15:08:59 -0700 (PDT) Date: Tue, 30 Oct 2018 15:08:04 -0700 In-Reply-To: <20181030220817.61691-1-sbeller@google.com> Message-Id: <20181030220817.61691-12-sbeller@google.com> Mime-Version: 1.0 References: <20181030220817.61691-1-sbeller@google.com> X-Mailer: git-send-email 2.19.1.930.g4563a0d9d0-goog Subject: [PATCH 11/24] commit-reach.c: allow remove_redundant to handle arbitrary repositories From: Stefan Beller To: git@vger.kernel.org Cc: szeder.dev@gmail.com, jonathantanmy@google.com, Stefan Beller 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 --- commit-reach.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/commit-reach.c b/commit-reach.c index 4cf471bfaf..ab2bb1e5d5 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 Tue Oct 30 22:08:05 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Beller X-Patchwork-Id: 10661649 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 4EC3C13A4 for ; Tue, 30 Oct 2018 22:09:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3FBBE2AA74 for ; Tue, 30 Oct 2018 22:09:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 340FA2AA78; Tue, 30 Oct 2018 22:09:14 +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 D20E82AA74 for ; Tue, 30 Oct 2018 22:09:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728497AbeJaHER (ORCPT ); Wed, 31 Oct 2018 03:04:17 -0400 Received: from mail-qt1-f201.google.com ([209.85.160.201]:39039 "EHLO mail-qt1-f201.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728482AbeJaHER (ORCPT ); Wed, 31 Oct 2018 03:04:17 -0400 Received: by mail-qt1-f201.google.com with SMTP id c7-v6so14583621qtj.6 for ; Tue, 30 Oct 2018 15:09:02 -0700 (PDT) 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=YO3O9ao+a380ah4iINvvvfgfIz8RhV8ESC9cQKn4NoQ=; b=hYnqCjHgEev0OqKBr69ttx4Fbu5x8lXWnGqbL78Hp1ukzT56JggCznmQLRzceBEC5I 70DA06uPd85h2p3PlrfPHqpiV2LUPytE3NnNVjqFKCfgroL6F7UOmZTvR1PbHFSk5ULG g+pkid8UhzBtPdEv9tiOCw7cumZCOeBO8fxrpZ7F81rvm9fzx2qjrcwafQHueMOjBzYv OsmJfKrlfRcnO/iu0G7pGWzl3TEDobtQgYL1NjrehXcJPQ0CNJKPJlMYSqmmUsLrP5bw vh3xp3bXFBSm04ctmi3rNze0XBe0DmMEHPGpw9L+eCBMN25zzu+CkcqiEHbM7zeKP8Xk MDSQ== 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=YO3O9ao+a380ah4iINvvvfgfIz8RhV8ESC9cQKn4NoQ=; b=Q2zb+kKeLDNg/INfQ6Uio1H7yYlV6XDrBlOU5VHtWr81ub8jCGUJas2IrbCm8KDo+E 5vVis8iRhsVF5ETtbOHtN4qmTJQQm8LJgu2nBdBGZmGy/ei+vnPNaiYlK3VSw0H+X7+E SHYKjF9JbipWBMW8tNH0RH2BpweRUvIQa+23O05wbYenuhw4UYx98ZE6nOmQr29wsIXg 8bQt3GTk5372nk50Vd2ZgYcqKg5ROWObxoTQRVPiumaJ2ACPD8yBDf51WwhaOx0ZHhSL nwG5MAAVRifUrsvVEA/qLO0R9J2lBt0W9hoDft7jFSTfPBtKQlLadW2fPHKFSfkv7V57 RFmg== X-Gm-Message-State: AGRZ1gLcNvPsabBvnsSZALxeXEtJGnF/FCizif1VLIWY9e4lmVYtM6rF uAnG14wAgU6645LUyZCO9TZjTPRp/+4+E/1pf0pmr9cWZpSR27dclAGUfLA0Tq2K8Om0Dab3gQY PNjomuwvU2JVMOcvkNBghBtC63Y7sNRUseHf448vrcf03odGrrIevigHpOOf4 X-Google-Smtp-Source: AJdET5eDd3McvFQ6/2CAi3ZU7veFbSrqc3xf3v+In2D61IJ7w3oEBvqT8KmR+XF+3k1Cxl/wdZP4zAmRKXmN X-Received: by 2002:ac8:6b82:: with SMTP id z2-v6mr443072qts.11.1540937342020; Tue, 30 Oct 2018 15:09:02 -0700 (PDT) Date: Tue, 30 Oct 2018 15:08:05 -0700 In-Reply-To: <20181030220817.61691-1-sbeller@google.com> Message-Id: <20181030220817.61691-13-sbeller@google.com> Mime-Version: 1.0 References: <20181030220817.61691-1-sbeller@google.com> X-Mailer: git-send-email 2.19.1.930.g4563a0d9d0-goog Subject: [PATCH 12/24] commit-reach.c: allow get_merge_bases_many_0 to handle arbitrary repositories From: Stefan Beller To: git@vger.kernel.org Cc: szeder.dev@gmail.com, jonathantanmy@google.com, Stefan Beller 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 --- commit-reach.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/commit-reach.c b/commit-reach.c index ab2bb1e5d5..bf7a513991 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 Tue Oct 30 22:08:06 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Beller X-Patchwork-Id: 10661643 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 94ECC13A4 for ; Tue, 30 Oct 2018 22:09:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 84D752AA74 for ; Tue, 30 Oct 2018 22:09:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 791FE2AA78; Tue, 30 Oct 2018 22:09:09 +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 0FABF2AA74 for ; Tue, 30 Oct 2018 22:09:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728515AbeJaHEW (ORCPT ); Wed, 31 Oct 2018 03:04:22 -0400 Received: from mail-pg1-f202.google.com ([209.85.215.202]:45718 "EHLO mail-pg1-f202.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728491AbeJaHET (ORCPT ); Wed, 31 Oct 2018 03:04:19 -0400 Received: by mail-pg1-f202.google.com with SMTP id q143-v6so10053331pgq.12 for ; Tue, 30 Oct 2018 15:09:04 -0700 (PDT) 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=D60Fa8xjxoteOpd09eFgbkBLqSxTQwO03sBuEGOWa58=; b=GoNWPkHmiqD3T3IXOSBWUiRVqBokVHv//U6ANW66p8zU8ccLYNhbR2h8W2fFBT++tB ZBC7TTLHMBjSo84apiTWojaBuHau99XjNCPs5gOOtZ2Xy+GNOhCUZhTHBGyFGNMpVpnJ v9AqV7cBsbL0ziW/psUBJSYZ2au+F0lsOkhBpWylbuwDSjriaFSoosV3UOaII6Qc5Qcm oM4iB8JXGOMPrJ2KgRg6+F0/nOMWWTjCnTJYFmIlKTVN0xi9+2YMK7vruF3r2SipAx3v vE6ceYTcci/p+Z9x3FjPL5HPL68TpkuQg0DbyglRVBzFzEefh6d085Qu3CX4S+RJTqV5 IQMQ== 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=D60Fa8xjxoteOpd09eFgbkBLqSxTQwO03sBuEGOWa58=; b=aL94wPCcc2eGvx928aKuiqQnl46UZb2uOMPjONWyHu71ej6hSiTKUJb5u5rCFsZVW4 VWGCLjl/du+Oo6rBaguNqucvtVS8ZuxlzY1ZCcyzzFWNXm7xm8aOH6st5dYfU57Xwj3p /EUCfHBBZPqwkmhwK2VOzmdF8xAyrHPDDsYOay7T2kAuMw4eMRpIfi2Ct2gCTtzliAY/ hikOU7OfrX65wg2GBifKhBcIfFPk+Go1e/kTRWzotQ5aBy+9Bni9ePNiJAtZP6/ZFc8k 4RoidbHGrOVfuVUsjXh/zxQO5Cfm6ctBOoL88cQKRJ+mIRh1amjRxOgpFPz25PSsFmfZ neQA== X-Gm-Message-State: AGRZ1gI4/PfgHatG4bkkWV9dQFHNdJuItbOeo0XkG1EEgNca322zq61t jxgNK39XjKVuLxR23AJJCrV9kY9Nff8lt+FIXqn69U/pc44O8tgRyRCqWKC3t3TWgfQFn+9SUbI MQsaOznMuwFq/Dm9mZkamnbLT9GRuQxw1t/yoLU5rio4OLPjkDttgVYhjdUAK X-Google-Smtp-Source: AJdET5dqzNoM8KbyYSrnbZJHSxmeUKtOSWrBlbO2ywFJkX3HJpbtJh0YF9E0KJk/oL9Xobb+9y0c+5Hi8vrp X-Received: by 2002:a17:902:8f94:: with SMTP id z20-v6mr204919plo.142.1540937344177; Tue, 30 Oct 2018 15:09:04 -0700 (PDT) Date: Tue, 30 Oct 2018 15:08:06 -0700 In-Reply-To: <20181030220817.61691-1-sbeller@google.com> Message-Id: <20181030220817.61691-14-sbeller@google.com> Mime-Version: 1.0 References: <20181030220817.61691-1-sbeller@google.com> X-Mailer: git-send-email 2.19.1.930.g4563a0d9d0-goog Subject: [PATCH 13/24] commit-reach: prepare get_merge_bases to handle arbitrary repositories From: Stefan Beller To: git@vger.kernel.org Cc: szeder.dev@gmail.com, jonathantanmy@google.com, Stefan Beller 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 --- commit-reach.c | 24 ++++++++++------- commit-reach.h | 26 +++++++++++------- .../coccinelle/the_repository.pending.cocci | 27 +++++++++++++++++++ 3 files changed, 57 insertions(+), 20 deletions(-) diff --git a/commit-reach.c b/commit-reach.c index bf7a513991..3be5526957 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 122a23a24d..c647447263 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..5e037fe428 100644 --- a/contrib/coccinelle/the_repository.pending.cocci +++ b/contrib/coccinelle/the_repository.pending.cocci @@ -64,3 +64,30 @@ 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 Tue Oct 30 22:08:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Beller X-Patchwork-Id: 10661645 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 160EB1734 for ; Tue, 30 Oct 2018 22:09:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 05E3F2AA74 for ; Tue, 30 Oct 2018 22:09:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EE2282AA76; Tue, 30 Oct 2018 22:09:09 +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 8A6C92AA7D for ; Tue, 30 Oct 2018 22:09:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728519AbeJaHEW (ORCPT ); Wed, 31 Oct 2018 03:04:22 -0400 Received: from mail-qt1-f201.google.com ([209.85.160.201]:42140 "EHLO mail-qt1-f201.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728510AbeJaHEW (ORCPT ); Wed, 31 Oct 2018 03:04:22 -0400 Received: by mail-qt1-f201.google.com with SMTP id j17-v6so15084868qtp.9 for ; Tue, 30 Oct 2018 15:09:06 -0700 (PDT) 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=g0TIQKkG9jM2my7wQxM0fdqysg1lbQu2ZA2GmZvtezg=; b=vDSoShlL+Zh/tzUlh5O9MzFZBRGtU6+t/Bdc9pECYW6o35quqzRbi6sEbtXSnasRzu gsX3kKArBibgmaIMLdVre3KlGcU0FCp0EDlEK+LUII9F2HufL5Wqr38BpzDZWQe3i4KW bGjKt6+QKD9lrc+Ky0yvPZqwa45Y2C2zMC8/bnBJ4vA10pJ15PuS6fIQ8mll3JvbXuaO 03uv1j3cf7vydUrQ5/JzWmXnPR7nRPm+ujZzQYP6Of7e2RvBeWpEcAjBQjMkbFby/Ayw CvID55htyK8iv4bHacgHyU24dWrWrwu1XI76rgTs7E+C2rEMNabm1AJMyHLlQKSL7I6m I0fw== 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=g0TIQKkG9jM2my7wQxM0fdqysg1lbQu2ZA2GmZvtezg=; b=n/0w8x8ioCaRqamXqh5jc22LmUuixoXFm588cQNCfw1hDQrNRPPOlp+49QdfqRPofA n46vG+n8Dg1hql4fZOIwHJ0tJ+h+8ywsVsYN7YhkIpdj3u0SgiyctBbAdebLPcvopR3l CVyDceWCXOEXI/HuuyH+l27LpJzy7WzOUETHkdiZRZEM/Me5zvomCLoLbLx3QVoVzcLz vL7Ro+TvZL3LfCTle1jkmopI3c8bm0eKa4BhVDlh/Vfvko/EariCXRn8NX1PKs+oC8Yw 3SuA46oF0shafOrq8nKlQ/C/KN8nglh17rGxBWf0jigEGyThd8+8/n0VQnZobpPRwAsC 4tRw== X-Gm-Message-State: AGRZ1gIZdwpysIFu0qwF8Qm9L7E+BcWa/Sstk86nd0ap1j2QTFWrsK4L nS6rLh385NzPaSFCwi79GTQ8RBnAa03jLpNRo4+eZrl8cE7+CZfCOUD7AW0mC00VN8ZC11xUl/E p0qbbH2lWZvWauEx7FPi6WKwLkZysyOYjaNXmjXfIvJ6zhdqbwrt6l4UB/+cn X-Google-Smtp-Source: AJdET5fKH6Rn4jpiZppJXf62MsZd1tMs22hOp9BDEv+htl/9IFWwIhJYCEJICv7oSNCxw8RZX/wqXgHAcfeo X-Received: by 2002:ac8:2bb8:: with SMTP id m53-v6mr432769qtm.58.1540937346625; Tue, 30 Oct 2018 15:09:06 -0700 (PDT) Date: Tue, 30 Oct 2018 15:08:07 -0700 In-Reply-To: <20181030220817.61691-1-sbeller@google.com> Message-Id: <20181030220817.61691-15-sbeller@google.com> Mime-Version: 1.0 References: <20181030220817.61691-1-sbeller@google.com> X-Mailer: git-send-email 2.19.1.930.g4563a0d9d0-goog Subject: [PATCH 14/24] commit-reach: prepare in_merge_bases[_many] to handle arbitrary repositories From: Stefan Beller To: git@vger.kernel.org Cc: szeder.dev@gmail.com, jonathantanmy@google.com, Stefan Beller 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 --- commit-reach.c | 15 +++++++++------ commit-reach.h | 12 ++++++++++-- contrib/coccinelle/the_repository.pending.cocci | 16 ++++++++++++++++ 3 files changed, 35 insertions(+), 8 deletions(-) diff --git a/commit-reach.c b/commit-reach.c index 3be5526957..88a65f854f 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 c647447263..6b16f12467 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 5e037fe428..8c6a71bf64 100644 --- a/contrib/coccinelle/the_repository.pending.cocci +++ b/contrib/coccinelle/the_repository.pending.cocci @@ -91,3 +91,19 @@ expression G; + 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 Tue Oct 30 22:08:08 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Beller X-Patchwork-Id: 10661647 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 9F3B413A4 for ; Tue, 30 Oct 2018 22:09:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 901362AA74 for ; Tue, 30 Oct 2018 22:09:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 848E52AA78; Tue, 30 Oct 2018 22:09:11 +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 2F0652AA74 for ; Tue, 30 Oct 2018 22:09:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728521AbeJaHEY (ORCPT ); Wed, 31 Oct 2018 03:04:24 -0400 Received: from mail-oi1-f201.google.com ([209.85.167.201]:38605 "EHLO mail-oi1-f201.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728491AbeJaHEY (ORCPT ); Wed, 31 Oct 2018 03:04:24 -0400 Received: by mail-oi1-f201.google.com with SMTP id b5-v6so10739263oic.5 for ; Tue, 30 Oct 2018 15:09:09 -0700 (PDT) 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=RrrSrj4uGteYbSs+MvRgYtPk39MXieBiTAQIPoLXx4s=; b=SAofBrEmhV/tJjhlmF72ZBwDSrxum+M+YrJxaQ4m2RVemx9hfEFRWf5uH4mxvMdXYd pndYR4Hzm2PIOqLM5MkaAnoXjUDHeEXnsJLpSwjbnzmKj5cTLZUi5wecpIhrJoA3ane4 v1d/1wromsWlU/rw03cJrmSonZ0hMR6s5/0LZPewfUxbTj7Ofk8OSq5wpE46eJhKttRu kRr+EmveWaweZ1jl8pk+9357jAxThImtn5/8hRdkljwJ8AE4oR7+UYqQ5IOP55JQh6vE 8eDzfGDn6zVzYijyP70dfOkCCDo0qnIFgqqWo3JuwkUYVXNVMuaQeOrWM1hdUCD+PieT bm3g== 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=RrrSrj4uGteYbSs+MvRgYtPk39MXieBiTAQIPoLXx4s=; b=dweWKiO0MHMbngGoTIK0qJrkWhir40BzTZ4dprFbh+BhMIzO+uD9e+qy/JIY1/lMuo 9zj7YHQedVj9gY0zdlL/EkTQJLJTv0m2d5VDaAm9pCb0cXhdDy06M2RezihEa2V2VnGi cjXTEeOr7P/a28tIxflyWwmLb0K93DLcNP0tjcPgqgU08xkXZIK2AnFlq8EzdBZ9fbcV 9s9AmRvKcgJc3xc8eBeMHfyKn7AkAoOp/5+KovpndLyzykkwHhCnSUrR5o/QVYu8na6E YvmS/CAqEMx3hU24heeB22RsAbvg6lufvWn+jC6IsuvwyaiOuaCvfb8YTPBsebaFAALv MorA== X-Gm-Message-State: AGRZ1gI8tRWovg/fMnxvgugaI9r7ZYONXjho2SgLT9dC47NOlacy1FEx g5wVVYNtQYFhnV50lTSov/Irx88kydABpr6PIX7a1BXgRr+mz9zRRsTWVhwDWTSaIjXs9vHFX6E B1HlVB1PxbnaDriScCFuImu4tQeOqtL8oM/BDwxLrolszxtWf+7woJrzwqI0a X-Google-Smtp-Source: AJdET5fp6M5mOGlMzPWbX3tk3+3pqfv8D0AvzyK4Sp5TkVekotAYwD1RkjKk5PvuEXzwarZxhm8YVyv/gjsN X-Received: by 2002:aca:dd55:: with SMTP id u82-v6mr390606oig.58.1540937348959; Tue, 30 Oct 2018 15:09:08 -0700 (PDT) Date: Tue, 30 Oct 2018 15:08:08 -0700 In-Reply-To: <20181030220817.61691-1-sbeller@google.com> Message-Id: <20181030220817.61691-16-sbeller@google.com> Mime-Version: 1.0 References: <20181030220817.61691-1-sbeller@google.com> X-Mailer: git-send-email 2.19.1.930.g4563a0d9d0-goog Subject: [PATCH 15/24] commit: prepare get_commit_buffer to handle arbitrary repositories From: Stefan Beller To: git@vger.kernel.org Cc: szeder.dev@gmail.com, jonathantanmy@google.com, Stefan Beller 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 --- 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 Tue Oct 30 22:08:09 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Beller X-Patchwork-Id: 10661651 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 559B613BF for ; Tue, 30 Oct 2018 22:09:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 472D32AA74 for ; Tue, 30 Oct 2018 22:09:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3BD2F2AA78; Tue, 30 Oct 2018 22:09:15 +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 DC4692AA74 for ; Tue, 30 Oct 2018 22:09:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728527AbeJaHE2 (ORCPT ); Wed, 31 Oct 2018 03:04:28 -0400 Received: from mail-vk1-f201.google.com ([209.85.221.201]:47959 "EHLO mail-vk1-f201.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728491AbeJaHE1 (ORCPT ); Wed, 31 Oct 2018 03:04:27 -0400 Received: by mail-vk1-f201.google.com with SMTP id m185so6430194vkf.14 for ; Tue, 30 Oct 2018 15:09:11 -0700 (PDT) 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=MhE5q6S1YU+4LARM6xli8HeegWRWqtTX3ZRv0PbjFH0=; b=Yv1Ch5P0smXXzqrtlaKDCGW2QFzxs36YsQbeG+gP+DETAwBJxKoOeA+nbE5AszRdSm qIXege7N9DaMxR60FL7GTm0IkVwK7AIPCb8y0Sr7kOEr7Eo4/jYweH8ic/A/DixQyvKP nD3Tp2mLZH+7SK+7wJiJfweSY2yxsPEB2eqE/uENts0vJJPt7G+vXAS1Q453m2nEtfPa OObM+C66dIlYkQdGb9ifuSTi7tehba6o6EvV84d7NvddPLEIeXFX8RdxR72YisQ4mnUX 0/gZMiWmJaP+QIsveq/wma4qob9CiF11SAhrjtTvlCM6SRuK7FPPxbh8R+yVLqHXvP4e mvNA== 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=MhE5q6S1YU+4LARM6xli8HeegWRWqtTX3ZRv0PbjFH0=; b=jA2SRHDrgBx2Pqp0DeIDQTU+RPK1mYG6B2etMnq9G1460NTvJ2jwt6v1TnHj98YDYS cHEzZ80chYqR6m+oFI/L4TzPMQO22MD6hbY5UeeLGRuo3QJBIYvLoGhGF1/JwdAs+Khg RKAUqKbRk1uqdM/+MdB5cbO7yvqGUPosvmYL62U8a/YeC/ejQgDMG9jMlEY//JjWPl9y vVzu3AyAM2yzj9Cn5dRsHBMiR0J2gJH6pjd8Y0h5lp4LkFIyFdHLUWoh1nO3VtWaTy+t inzvowDoz1rHGQJ5f1hwEdQZ2Cwa3Sw361vStq7D5KHXAGpyH5aKg/dvr3nY++P6a9a+ Koow== X-Gm-Message-State: AGRZ1gLueuG3EXm2xta+F587pGwaUZ2NHnzhAZKFByzv4cq4kV5zQIh/ B4SPKpD+lH5lust/QFm21liVChnlyM5FYKn4RqHGHDcQqVb0lTDGNxDA1qzGH/F+Uco3Odp4m5g BKPQiKhHMG65LZj3mhOXOFahIOlL/Ol2gV3IRvbCxX9guqTLxsHEW6DRLg59H X-Google-Smtp-Source: AJdET5e9K9nzkeDRY43yTSc7+6N5cobe2YZUnQC7eDDeIs0OmEayyFaKTUcos+NYtXkLOsmyVcUjyy9vJQCY X-Received: by 2002:a67:4a0c:: with SMTP id x12mr513901vsa.11.1540937351585; Tue, 30 Oct 2018 15:09:11 -0700 (PDT) Date: Tue, 30 Oct 2018 15:08:09 -0700 In-Reply-To: <20181030220817.61691-1-sbeller@google.com> Message-Id: <20181030220817.61691-17-sbeller@google.com> Mime-Version: 1.0 References: <20181030220817.61691-1-sbeller@google.com> X-Mailer: git-send-email 2.19.1.930.g4563a0d9d0-goog Subject: [PATCH 16/24] commit: prepare repo_unuse_commit_buffer to handle arbitrary repositories From: Stefan Beller To: git@vger.kernel.org Cc: szeder.dev@gmail.com, jonathantanmy@google.com, Stefan Beller 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 --- 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 Tue Oct 30 22:08:10 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Beller X-Patchwork-Id: 10661653 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 1F4F713BF for ; Tue, 30 Oct 2018 22:09:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0D2562AA78 for ; Tue, 30 Oct 2018 22:09:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 01C312AA7D; Tue, 30 Oct 2018 22:09:16 +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 94B222AA76 for ; Tue, 30 Oct 2018 22:09:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728530AbeJaHEa (ORCPT ); Wed, 31 Oct 2018 03:04:30 -0400 Received: from mail-io1-f74.google.com ([209.85.166.74]:47088 "EHLO mail-io1-f74.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728491AbeJaHE3 (ORCPT ); Wed, 31 Oct 2018 03:04:29 -0400 Received: by mail-io1-f74.google.com with SMTP id e144-v6so5314625iof.13 for ; Tue, 30 Oct 2018 15:09:14 -0700 (PDT) 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=77KwkQnTpoDihUcPr5v1lgZeXr80vh4ZlKHFCgn/I1U=; b=ilGCl9dQjL8kjVOp9rXXo6JxVAmUH4g5Grzd3MY9Bz197W2AQqtMqS5EJHK78ElLqf HORBsN96Fb9kfuRVeYZ3T6HPUYQikFQClMXCMaJ+mKJnOBc7pPSNlE4wpdOn3ZjRHFmS rs/vtfONKetMTEoaaNgnTNyhmM9EPeM1j2IrDwqlYk+rx/4mkvNFi7N6i2JV0Q49eIzh wAJ7L81m97ATP83mGRBZzqSPNLLHurh7ONWKxMG8Owq2dAkn4Pti0ZJ8qi2MkVmjLyeR JH8i1eUL+A2WLh25xgC/kR+1XBVjzm+NsXGifuxoCFW60JTvl5sbvE01kLiFQdIXOiL3 05Pw== 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=77KwkQnTpoDihUcPr5v1lgZeXr80vh4ZlKHFCgn/I1U=; b=pYOlc16LgNdTvRArpliuT27L0ZdNA7I12Zbcew8wI8qphk6c+JUIx/W2Njq5jHYRZq gNcZDzDL2JLjDtDSxYC/8g0cQekIFLOiUN/Lx9rDhvNMbuqweYwhEOxlnzwWi0uKZHYO aYhiZTRTf3DXWBZWxXUZOuUKXFY0vdfCq3ZkyKDoXNDOO1KQuEKdP0m/BKcZmoVVZoUe 8VOJzFK+Bt/lUlCHum+LGIMxl+j00qmKhO6ygXmukMr7gPfGzfIcBW5/RrbtBPsSlsUx 140VuzhSgESUZYWSGP2Vh53yARwvBpAyixCsIbZg9auY7GKTf372b6FEf1VLvRTGrUHO 7aWw== X-Gm-Message-State: AGRZ1gLzvkNbkJ+7dQ5XrOs/NliwOmiFzlzcv0AK8Vye2bKC6R2mEvVY jFcHd2lpgR62lLbRq41n/Qla1OJzECYh3IG7tU6fnoi5EOyvMzz/AD56t5b6SgTHM/vr9N0NOR0 44cculE/FJLGLEYLDWV4fN9KQ5HTE691sf5XWu/A9ILP1zGpm+g7Rr2+fuGqk X-Google-Smtp-Source: AJdET5fX3pjqkN3Njv5gprB6q5/FHzv/SNoO99qn+Wz5/TnFfD0msxRw+uVdQYj+NiYKWzU8YpHrlXrCkfjL X-Received: by 2002:a24:8044:: with SMTP id g65-v6mr346597itd.10.1540937353986; Tue, 30 Oct 2018 15:09:13 -0700 (PDT) Date: Tue, 30 Oct 2018 15:08:10 -0700 In-Reply-To: <20181030220817.61691-1-sbeller@google.com> Message-Id: <20181030220817.61691-18-sbeller@google.com> Mime-Version: 1.0 References: <20181030220817.61691-1-sbeller@google.com> X-Mailer: git-send-email 2.19.1.930.g4563a0d9d0-goog Subject: [PATCH 17/24] commit: prepare logmsg_reencode to handle arbitrary repositories From: Stefan Beller To: git@vger.kernel.org Cc: szeder.dev@gmail.com, jonathantanmy@google.com, 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 Tue Oct 30 22:08:11 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Beller X-Patchwork-Id: 10661655 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 6A00813BF for ; Tue, 30 Oct 2018 22:09:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5B1162AA74 for ; Tue, 30 Oct 2018 22:09:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4FAA42AA78; Tue, 30 Oct 2018 22:09: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 DF9FB2AA74 for ; Tue, 30 Oct 2018 22:09:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728533AbeJaHEc (ORCPT ); Wed, 31 Oct 2018 03:04:32 -0400 Received: from mail-qt1-f201.google.com ([209.85.160.201]:47231 "EHLO mail-qt1-f201.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728491AbeJaHEc (ORCPT ); Wed, 31 Oct 2018 03:04:32 -0400 Received: by mail-qt1-f201.google.com with SMTP id u2-v6so15088077qtg.14 for ; Tue, 30 Oct 2018 15:09:16 -0700 (PDT) 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=MnFi4vDa1i8EwOn6Hm6HfdZKWR7jua7aVdTf7uKmqO0=; b=GH2WxTlDO4ub17Yve1H4wj/HINJcALBvs717NwmSiUGMJtGIwqEfVrnfJd0cWDwbwc 9dhZxnmbdt1OPseII1kSPTEeCqGetPrpJexTPoGkMmBdt1dGGD38VK7a2zK8HcP0CtMw brxGK0TpcVrJMGCVKLivMBCWBEUDLqwlLEb4lDjPYqwk2nKPtk8iyKSss0eBehnS7ERH oMGbqudKM30cFBpiKStkWH1D86EGfp8YZaLRzVJUe3Efcz9HlImY1mjmQSSY5FOqQiJ0 q3SowfOUO3L0QhNRFJUIVXtvsp5KQgCx1VlI3frJiXiLZvCk2XwqhLP0mml4MhYPMYdM K5+Q== 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=MnFi4vDa1i8EwOn6Hm6HfdZKWR7jua7aVdTf7uKmqO0=; b=iTaWvOvKI6ceSlXVDBphOKS/IafQRvbQ212Qe9Djt5xGjkIo1Q9xWtMa6zngR260Dc Rx+VJnZ528NVGuH3a+pH8RkVYCjUqOQ+SeBRY2pg/AJ2GRsafhumY08nCoCmqSI3NTXS rXSsGi2CvlJ5OM2WuNcCfgINaYq297FveuNpmw/XYen+yk6QhXyV3jt8Vo8K0Y11anbM A91U226pVjE/CljoqoXJJ7it7wNzzCqgeWK8YUxCUL05HLysQLx0w1IXP/u6PLelDQjy j6rnQONUlUAk1C7pEIZeZ/QA16F4pR2k4Yq2C0+WcxNgBTLk3lQRL8Ow3I0gaXiavXR/ TwAA== X-Gm-Message-State: AGRZ1gI8p6W9S+8yl1E+kInnhZmQ0xTkRNdMFnP7tYwhjmO9Bt+hAoIM SmqoRKesgfn+511Ff0YWup74GOsHzq32+5sT2UNFnsWAh1+56XeHozQh40dKeIGlK0NGMgqeZrd S53ZbqBGRG/2ePhdN5sxXrM2oUsaif3QJt3DD0bviwOEIpToOYwxYoLqreG3d X-Google-Smtp-Source: AJdET5dZfXmxjO8YpRvOmiIgxJgJSn/yHkaGkviSCMA0O9o2cV5Sf6TpX5dc6mX0L+esgcYLvP6cX3qSREfx X-Received: by 2002:a37:3508:: with SMTP id c8-v6mr431504qka.62.1540937356493; Tue, 30 Oct 2018 15:09:16 -0700 (PDT) Date: Tue, 30 Oct 2018 15:08:11 -0700 In-Reply-To: <20181030220817.61691-1-sbeller@google.com> Message-Id: <20181030220817.61691-19-sbeller@google.com> Mime-Version: 1.0 References: <20181030220817.61691-1-sbeller@google.com> X-Mailer: git-send-email 2.19.1.930.g4563a0d9d0-goog Subject: [PATCH 18/24] pretty: prepare format_commit_message to handle arbitrary repositories From: Stefan Beller To: git@vger.kernel.org Cc: szeder.dev@gmail.com, jonathantanmy@google.com, 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 Tue Oct 30 22:08:12 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Beller X-Patchwork-Id: 10661657 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 6728E13A4 for ; Tue, 30 Oct 2018 22:09:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 571B02AA74 for ; Tue, 30 Oct 2018 22:09:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4B6B42AA78; Tue, 30 Oct 2018 22:09:22 +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 B216B2AA74 for ; Tue, 30 Oct 2018 22:09:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728537AbeJaHEf (ORCPT ); Wed, 31 Oct 2018 03:04:35 -0400 Received: from mail-io1-f74.google.com ([209.85.166.74]:57179 "EHLO mail-io1-f74.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728491AbeJaHEe (ORCPT ); Wed, 31 Oct 2018 03:04:34 -0400 Received: by mail-io1-f74.google.com with SMTP id x12-v6so12071119iob.23 for ; Tue, 30 Oct 2018 15:09:19 -0700 (PDT) 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=tBH/nMpD/A+qFk1i7otVxC5dn/xz25wAO2NOMDggQmg=; b=mvGUIZB1QmxO/qUj0Op/y7L4b9ZFSHLVbxm9k06CHgLMiIRXmutsYxWo196QNKf4/Q 5ClvaThM3XYl5/hQzMpGxibMzQrmwYSXP6vEfZ8wxnDdnTqhFcGJmV4r0k/zXZFga1bh tnxJE9E1wKfLtmmb7rZqwuJT+pGh252PgNL7F+p39GV+rgQXOe1+9DI6tAuiuiluuLWC EDgSYTTWx9eYUDCYKedCk/+Og00wXyyNzBS/CT4vnXZ7gwcGZHr1GL8hrl05dbk0cq1V c2UBd0NDE4mcoaV5QwA4Aq9DCL9zBuYAWqzRlgomkCaA9hV4Cc7DzVTBx/zQUJTm4vYx Avpw== 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=tBH/nMpD/A+qFk1i7otVxC5dn/xz25wAO2NOMDggQmg=; b=TocrK87V9yhwguOJLTnYvLfNkslbercDhpE5gCmhYINc+C2SxmX8xd3BFIeacDLup7 aGVQYS6FbUo1fe4V3WS6Tq8Dn03CTkPuNeIizEX5PZylE6kgVR3+CCZ1ibpX8fhB2f3s bHCxada4DNbqHpdF4vvlXdfA2x9YW7Ufo1I+nVnXvXjOa4GoABCBNHCf43V5lz8j1lXP uMaap9X0RwPqBJ6NrFdNa9a9dWubZevUugK1uIKZArxrpCBCtosDBOzC1r7GEdgE2Tr7 BR2Tl3Uy9dclxtCAOZSvigqbL4usuuglvtfV4TKQRtyCG8IcFWyT3n6hEwD7MltZzKZv IwHg== X-Gm-Message-State: AGRZ1gLkWdyKUnan1ln1Zrdc8tJ5F7/5b7ttuIzvVHGudUrTlLKHpKQn pxTi9IlRl3l5/AB3AQr+kIEgwLlfM0lUMDm4cP7H8PLOienJXsPyksWnvIF8IjkOJwdWMSWses4 1KpHhxs66TbzGH7E1LbdZJixuZ82bYIuzdRMQP8bCfBQbVmzepVomD81ONPUE X-Google-Smtp-Source: AJdET5ePnvTPKUBRGlHx4WZWMCmZabcxvlOX/lJcXmDGjL+ZfBpfza67T0PGjDO+sMRy/IukCEvRSAHfevCJ X-Received: by 2002:a24:2bd3:: with SMTP id h202-v6mr301216ita.21.1540937358896; Tue, 30 Oct 2018 15:09:18 -0700 (PDT) Date: Tue, 30 Oct 2018 15:08:12 -0700 In-Reply-To: <20181030220817.61691-1-sbeller@google.com> Message-Id: <20181030220817.61691-20-sbeller@google.com> Mime-Version: 1.0 References: <20181030220817.61691-1-sbeller@google.com> X-Mailer: git-send-email 2.19.1.930.g4563a0d9d0-goog Subject: [PATCH 19/24] submodule: use submodule repos for object lookup From: Stefan Beller To: git@vger.kernel.org Cc: szeder.dev@gmail.com, jonathantanmy@google.com, Stefan Beller 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 --- submodule.c | 76 ++++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 61 insertions(+), 15 deletions(-) diff --git a/submodule.c b/submodule.c index d9d3046689..0fdda45252 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,47 @@ 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 'out' based on the provided submodule path. + * + * Unlike repo_submodule_init, this tolerates submodules not present + * in .gitmodules. This function exists only to preserve historical behavior, + * + * Returns 0 on success, -1 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; + } + + out->submodule_prefix = xstrfmt("%s%s/", + the_repository->submodule_prefix ? + the_repository->submodule_prefix : + "", 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 +541,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 +551,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 +562,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 +596,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 +616,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 +638,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 +703,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 Tue Oct 30 22:08:13 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Beller X-Patchwork-Id: 10661659 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 5142913A4 for ; Tue, 30 Oct 2018 22:09:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 41F422AA74 for ; Tue, 30 Oct 2018 22:09:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 364D12AA78; Tue, 30 Oct 2018 22:09: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 E134D2AA74 for ; Tue, 30 Oct 2018 22:09:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728540AbeJaHEh (ORCPT ); Wed, 31 Oct 2018 03:04:37 -0400 Received: from mail-qk1-f202.google.com ([209.85.222.202]:47812 "EHLO mail-qk1-f202.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728534AbeJaHEg (ORCPT ); Wed, 31 Oct 2018 03:04:36 -0400 Received: by mail-qk1-f202.google.com with SMTP id f81-v6so14905835qkb.14 for ; Tue, 30 Oct 2018 15:09:21 -0700 (PDT) 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=vuV8ZxSueg+saTYiqp0ei1lG+d06gAWfJrnhI+UF3o8=; b=v51WHpWAd+xfUoT1HYULuHd3U4z0QdzkMU/S2nlk6BIw3b1/YUTIJHmFs9G7+oLy8O lzZ6WZXZ2Lh5/jwCBYEUj/+jiEA6qAZ3BFXhuf1XiOYsXHgWXs3AfhRdrgrPictReqqe 8ch8m9GQ7W4mKhNmADuqmINerhvjKgpLF+KE+Bwuom1wViOW2L1jsNI5Mt8GSjbIrR73 gF3LH5HJ3ieRD0vX7XYYBXXMpKh1UIBaHeO6tDWXVGoSqxlyXpU4nFdT/0buZTK3jQUT cfqH8I+91LoOo/a0eubsGdAR4dZQOj72I91+Hb3WY/X4jBrTOdgQXEKsWXx1Zm3Tm+cC lylQ== 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=vuV8ZxSueg+saTYiqp0ei1lG+d06gAWfJrnhI+UF3o8=; b=lUIirt4icNeZ6ytKVHC+6J8OTSgzRZpvfAvBByqep1hdyUEn0yL90DpX5Sec/IBzlD SdUc1qVfjGf27d8PWtJYBVT+7ETcm55MAwownE3x4OcDAE2A08sAPplymFPVZv+40kB7 l67Iizwe4xgr+sZqg1tcMrRmEq3eHvjkWorQ9OGf3lfoGxnst4KgNaWbuFkuB/vOkPVL MdsF5F/XiRKRQbmGZMMgnWd6clNZ0jrUnnMlYf1GX2r27n/8nwbM2w8jTsbYgf3+gSXd Gp9nUqVAPK6MxVPe7OqHIKYZDkYWXfmP1xMJVKOi4y6LPt0aldzkp0Ua/VMKLNUkwbi+ 4v6g== X-Gm-Message-State: AGRZ1gLe7nd/QgWAW9pn58tBBGeZ6kqlhiTtTnN1tyMmhWMfjFQMulhB SnWemuU3DoJ7EJRYZFjEZJUzs6AusE+VtzNYAjuZs71Z+8D9OwOcWOnBeEa+hAyEGLJt/5cWX7x jg3178gwGGYGLiCBiAw1+rmvO78mtsUf43rAqu7bi3ivg55q/PdaXKleOcI93 X-Google-Smtp-Source: AJdET5fP+YWT6agB2TDEAu0laJhNL+7bVnU1VS/0MQUFhLeA3AwgybjOd/Nbh9Ltor5IXHMIHNzVdYMLU9C4 X-Received: by 2002:ac8:5488:: with SMTP id h8-v6mr427277qtq.51.1540937361488; Tue, 30 Oct 2018 15:09:21 -0700 (PDT) Date: Tue, 30 Oct 2018 15:08:13 -0700 In-Reply-To: <20181030220817.61691-1-sbeller@google.com> Message-Id: <20181030220817.61691-21-sbeller@google.com> Mime-Version: 1.0 References: <20181030220817.61691-1-sbeller@google.com> X-Mailer: git-send-email 2.19.1.930.g4563a0d9d0-goog Subject: [PATCH 20/24] submodule: don't add submodule as odb for push From: Stefan Beller To: git@vger.kernel.org Cc: szeder.dev@gmail.com, jonathantanmy@google.com, Stefan Beller 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 --- submodule.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/submodule.c b/submodule.c index 0fdda45252..da1ac1e6f8 100644 --- a/submodule.c +++ b/submodule.c @@ -1024,9 +1024,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 Tue Oct 30 22:08:14 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Beller X-Patchwork-Id: 10661661 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 7272813BF for ; Tue, 30 Oct 2018 22:09:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 60F712AA74 for ; Tue, 30 Oct 2018 22:09:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 540772AA78; Tue, 30 Oct 2018 22:09:27 +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 C4E782AA74 for ; Tue, 30 Oct 2018 22:09:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728544AbeJaHEk (ORCPT ); Wed, 31 Oct 2018 03:04:40 -0400 Received: from mail-yw1-f74.google.com ([209.85.161.74]:48884 "EHLO mail-yw1-f74.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728534AbeJaHEj (ORCPT ); Wed, 31 Oct 2018 03:04:39 -0400 Received: by mail-yw1-f74.google.com with SMTP id v132-v6so9938807ywb.15 for ; Tue, 30 Oct 2018 15:09:24 -0700 (PDT) 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=ihuv0b8kbZ6CR3EhoQEBR9jxAwJ1ukt/7uhzNErL5jI=; b=Gv+XjylKedilxHmYwzXrxB2JXYxpATBkoVVcR2ri6+acDSeoe1CaJIKZk80tvWikNg hC+rvROpJeIvPbd9Llt+nCTrEsBwRr1LWiguqHI/pYrU5GR7XWjjmJa4H6OA6GwPU7r0 zvSAOAMdAv15RsDb/FbiL04WUUPVT2HKXOpJlJ5B4CxVoZS+W51L//nC6eIGl/xh7Yl7 38JUnNOuFSeuvkLlNN3KtkH8hDd0hM86x6tfO6UTorE9qOhdL6HfR/frTwcXUP56K9mu oQ2mgxz7Imdq+vdZUovDmrguq41duwIcS+Akh5CV/AhrcM7gPyryK1eC4DQ8JCkCb/Ut 6qQQ== 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=ihuv0b8kbZ6CR3EhoQEBR9jxAwJ1ukt/7uhzNErL5jI=; b=BSaARr9oC7UY3zgYX+X9Uhq1WDkBvxeNMPNT19zdD6Fks5eeudMOLDJBjzcBCQBhH9 U5++3ftZ+c0pk0JbvXG/0JYZg1psTPxu6KpHpVWqZKQIKthWypwCd2MHrliYWfXlPX5E FyiaMBnB79bIh22rxEnIZXUlIpThJR2ydBudN6eVUcUcgbGoN/RFnttAmwVizvDegIXZ UbYUTO4bmu1l1dUpDBMKe5NoW9lsynCxGpZDAuJ9j0Wu5vMT4/SaC1pfCRxvGQnDFaDL 1pPtDaMQo+2CwImpKLsD1nf8RPjnYe7DZC3mo8Tz3W8aHin/zJP1S1KQkVPzdTTC/zzf 9aMw== X-Gm-Message-State: AGRZ1gK98l+oLbup03fVD78i/8QDU90IKjPMnoT7T6O9YgmsVP4CAXM6 WjkUzHOX9M67A5zFvMxmv3Y0ZNVPF+m3J1bsJtCo8OQnZaDK6n3Wj3XyTqY7M6ez/XlGIgS8cUX KN7fVSpE78YtmTXpjOcPNYyHT8CwJnSRXIveqqenovkF35tPZP7AOMQaBUEuV X-Google-Smtp-Source: AJdET5dTy8lTe6DPhf1olTGL3kJZaVmYip6Dx1+J0K8tW0cMEaGx7pV/ighj8OywSQFHkREYIXuPqwGeVTWx X-Received: by 2002:a25:2708:: with SMTP id n8-v6mr383794ybn.96.1540937364181; Tue, 30 Oct 2018 15:09:24 -0700 (PDT) Date: Tue, 30 Oct 2018 15:08:14 -0700 In-Reply-To: <20181030220817.61691-1-sbeller@google.com> Message-Id: <20181030220817.61691-22-sbeller@google.com> Mime-Version: 1.0 References: <20181030220817.61691-1-sbeller@google.com> X-Mailer: git-send-email 2.19.1.930.g4563a0d9d0-goog Subject: [PATCH 21/24] commit-graph: convert remaining function to handle arbitrary repositories From: Stefan Beller To: git@vger.kernel.org Cc: szeder.dev@gmail.com, jonathantanmy@google.com, Stefan Beller 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 --- 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 Tue Oct 30 22:08:15 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Beller X-Patchwork-Id: 10661663 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 4931113BF for ; Tue, 30 Oct 2018 22:09:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 38EA22AA74 for ; Tue, 30 Oct 2018 22:09:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2D39E2AA78; Tue, 30 Oct 2018 22:09:30 +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 AD3732AA74 for ; Tue, 30 Oct 2018 22:09:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728547AbeJaHEn (ORCPT ); Wed, 31 Oct 2018 03:04:43 -0400 Received: from mail-vk1-f202.google.com ([209.85.221.202]:45197 "EHLO mail-vk1-f202.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728534AbeJaHEm (ORCPT ); Wed, 31 Oct 2018 03:04:42 -0400 Received: by mail-vk1-f202.google.com with SMTP id 80so6289264vki.12 for ; Tue, 30 Oct 2018 15:09:27 -0700 (PDT) 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=suUvYMkFhHxpFyjcRNjnXkTTU2MrTIKqbpAuOttG/dA=; b=kDFXR3zLGuR8KbgU0iaTq5SM2ffTuLddpqSvn5ct1ZUWLhmoZ6tMW7f/4lhbyIm5ZP zkh7gEb2vv9FmuQIsB736OOzLtSQ338Bwle5VUUaxowXUHGQM3329D831zvbSJsw+98n ueRzF+VaRGYVcVVm16nGUukF3mS9WnqN1TahERxGT54i1KzwBHIzO1g6s2F+rmASdEsf Ok7pKmP3Z7pssXutJIaCG3ZEVRNUY7FShZKod3oC4XFidl0hSO0XaRBWBjUfpP5m200r qMhUJu0ifsc9tu4keTzv+Bnn3aWyv5u4W9IOZ2qvUOhu18GJEhOP52vO771XC+3TAQrW EJ/g== 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=suUvYMkFhHxpFyjcRNjnXkTTU2MrTIKqbpAuOttG/dA=; b=P1wppIGcv9YQYq5cCKcjIX3Yt4GRRnf/ts8B8VAjg5GNKK/pv6tILmUJKGtMXiPq5e OCYjXqqtXN3vhrbruaBDcEEXgW7Erz5969dO8q1PGtTJiPpvCklj+bMMOra4jAb9WKfR JtH/pFutbO0DiB4z/5xA+Z3rAEyGY3hwI7g+dwEk9PejqZdQbfo4eReLrsIlYAU93mZ+ UNiLa3XYT2UmCJ1AMc58LrlTvqemcye+T3oZCA72bwaHy9f4uNZdCR/iWSzTLzjOV79b 3sRYY21AHi2lYVQSJ0MRDpxiLibEQlFW3649v668ql91/rtz1kIeOEik7cW5/2RQY22d KDwg== X-Gm-Message-State: AGRZ1gKu18PpDuY8yHT18cPMXzPu+jrB9twSSB6I4D532ixOPXCuB6ox k3O54clCi9sW+INxZ44HSq/Kqxg8R1/ntsw6ozOUpCltsmL93aF+26cN4xCLoAD2KlfOTpAF2L0 zqrSlx9BYcjetwrIXCXt7tqYNAdL1lh/k8C0O6TRTjxz0Ys85VyH1mcsyTdYJ X-Google-Smtp-Source: AJdET5dEPrhYDcYd84pEqmVH2/cqRcMb6Gmiu2XiXPxzkRYznwubQRgNYUzxdyVqWxP8HMxSTU5ccujSnkdV X-Received: by 2002:a1f:8ac4:: with SMTP id m187mr510857vkd.3.1540937366948; Tue, 30 Oct 2018 15:09:26 -0700 (PDT) Date: Tue, 30 Oct 2018 15:08:15 -0700 In-Reply-To: <20181030220817.61691-1-sbeller@google.com> Message-Id: <20181030220817.61691-23-sbeller@google.com> Mime-Version: 1.0 References: <20181030220817.61691-1-sbeller@google.com> X-Mailer: git-send-email 2.19.1.930.g4563a0d9d0-goog Subject: [PATCH 22/24] commit: make free_commit_buffer and release_commit_memory repository agnostic From: Stefan Beller To: git@vger.kernel.org Cc: szeder.dev@gmail.com, jonathantanmy@google.com, Stefan Beller 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 --- 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 5064d08e1b..a8867f0c4b 100644 --- a/builtin/rev-list.c +++ b/builtin/rev-list.c @@ -197,7 +197,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 Tue Oct 30 22:08:16 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Beller X-Patchwork-Id: 10661665 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 5D7B213A4 for ; Tue, 30 Oct 2018 22:09:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4E67A2AA74 for ; Tue, 30 Oct 2018 22:09:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 42F382AA78; Tue, 30 Oct 2018 22:09:32 +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 EEF782AA74 for ; Tue, 30 Oct 2018 22:09:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728551AbeJaHEp (ORCPT ); Wed, 31 Oct 2018 03:04:45 -0400 Received: from mail-qt1-f201.google.com ([209.85.160.201]:55955 "EHLO mail-qt1-f201.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728548AbeJaHEp (ORCPT ); Wed, 31 Oct 2018 03:04:45 -0400 Received: by mail-qt1-f201.google.com with SMTP id b16so7954886qtc.22 for ; Tue, 30 Oct 2018 15:09:29 -0700 (PDT) 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=EHSIh9Pm1e+80GSkmEQXSv47yZnmKq38dWRt9OP6SZY=; b=mDVmAJI875u3Qp7cQI8Ta96ZpC3kU1OL0LG+j+YP8nboxEN4I9BCEMlE7fqq2/hGZK nuP+0GGJwuGq7tTAmXzTi+8ds4JIlLXXl3zTwn6LVuvS2TPoIi5/fiKLEdF/HZ4OtxYo FdY0D68yTUIkuzxGi1rziwkfafsAcKEL3WeG8E1hpbi3q2631MehRC5dZ6W2xRJ3KiDf 2AGcX/gBeJxRY9xMsymYs3gXT8Dfbl03DZVHdVHebnHzCwB08t/abL8ujdmVkztEz7hG 2JQmuhMObAoWuyxfB0ZJ8WnigzwhaBAEvK/woQ/oOpAGE3Tda8oJX1ZTQ5CbZEV4A8VJ 4ucw== 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=EHSIh9Pm1e+80GSkmEQXSv47yZnmKq38dWRt9OP6SZY=; b=cvk28XLKzuyxL1jnMkrTpimhnZ07mlguIhf8YBBsX9N9wHnAWsAOSBdics5U/XQGBc t4VtTI4XcnCqOaKhJbqlEZAkqdCIJTIuW/Kvj3HliiPyxlZLdfdton5eHRyE4ZiV443c tCs+BNhQKWM5Kkm/GWCuYVXf2dN935yzCV6b4+avv5VSbCa+ZwgjKxAlEwuqaMk6Oxmv exkYudxKrpQg+WKKsK5pmUDo/ctXLHPReRYMmCnfRezOF8TdVGXnkDPBBGlTHo96mgAZ OjZ38TJfw/Qgikc5Y/iAUNDHySgwm7/ZKYmefu88YMUVRuiZFGi0cEVv2jgIXjoCexrd /iGw== X-Gm-Message-State: AGRZ1gI+aCI8D0FKv9P0ExGVtwmdb++UrQGwGjCpCdGuOf+xcfrXwKht PG0TevKyfnphXUOASCmuXGMaIeK+X4pLyapgELNSPxsH/ykk/2hVLhV9WR5sGwIvBNcdCvgkIqw gVsFtnrR+vePUxtI1BInT/Hpg1YYTP5lTeOu5EbnONqqK6zLGduRrL0edyy9m X-Google-Smtp-Source: AJdET5e25I47Q/NaHZ8w+gAURhiduMnqC7nsJozWNFlnIOkaauRVIpj7NkjGFVDk7JF6OkfyBhPIqTNYtbXw X-Received: by 2002:a0c:ad8e:: with SMTP id w14mr464318qvc.16.1540937369465; Tue, 30 Oct 2018 15:09:29 -0700 (PDT) Date: Tue, 30 Oct 2018 15:08:16 -0700 In-Reply-To: <20181030220817.61691-1-sbeller@google.com> Message-Id: <20181030220817.61691-24-sbeller@google.com> Mime-Version: 1.0 References: <20181030220817.61691-1-sbeller@google.com> X-Mailer: git-send-email 2.19.1.930.g4563a0d9d0-goog Subject: [PATCH 23/24] path.h: make REPO_GIT_PATH_FUNC repository agnostic From: Stefan Beller To: git@vger.kernel.org Cc: szeder.dev@gmail.com, jonathantanmy@google.com, Stefan Beller 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 --- 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 Tue Oct 30 22:08:17 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Beller X-Patchwork-Id: 10661667 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 C1BBB13BF for ; Tue, 30 Oct 2018 22:09:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B33CC2AA74 for ; Tue, 30 Oct 2018 22:09:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A787B2AA78; Tue, 30 Oct 2018 22:09:34 +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 479C92AA74 for ; Tue, 30 Oct 2018 22:09:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728553AbeJaHEr (ORCPT ); Wed, 31 Oct 2018 03:04:47 -0400 Received: from mail-it1-f201.google.com ([209.85.166.201]:42203 "EHLO mail-it1-f201.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728355AbeJaHEr (ORCPT ); Wed, 31 Oct 2018 03:04:47 -0400 Received: by mail-it1-f201.google.com with SMTP id v125-v6so15004305ita.7 for ; Tue, 30 Oct 2018 15:09:32 -0700 (PDT) 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=oCFpG/Wk+VMsIjbN9prN7LaRV6lmcmh4LeWkH2+hnFA=; b=KLdtE5pMDZg/2Xp52JudCrZ8qx2Ok7uqvWsBtUcr9OZc69IHzrEC+NudF3mKw11TxO fFPaHJV2SODMSZiG6V5vaY9ESMpLC+cMSNdFGkuZUudIabPd6tA7+opNolkSrCpN993S +4X3md7O1nNgyX/wYaqLsPgyXG1XyhUcm6YZnSY320HUkKk3DL0cQYz7hSggdH4NwvOv dELkiM2ABS6CXRpN6An/b93ABQF+Wm+MQQrFT+y6+8mhWuXSsmngqvkloBefXCeEDq3q szqoidmsMQA8MLcs/ZRg7HtquZDjBn52pgf1SvljrkpByq+FaKKzlXItl204fTaMcTxW /w1A== 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=oCFpG/Wk+VMsIjbN9prN7LaRV6lmcmh4LeWkH2+hnFA=; b=fPx242nrMHSTKvgpXDtlZcSg34JC6LiG1+VRdHjv6RgAl+2xrrLOd0QWryUokUyr5/ k0Abgsxku862VYdSILq/74Xmvc9NTJDS09Uy/YK/oYl1Api+UiIS29IA6O7Q895gpSMe bZbr+jxITB2X8tJrccFEa64+sZPkut0MLK8fZryRZzVEw18dmJgzrJUBCPkKr/pInF17 WVtgrTKttNkehttjGzEPgiSMYlGT2vfeZC9vVAltR7GoTFvHtFWrHScRTWCT8H+pule3 MGk5HcFJU3u8D/4UByNH1cvB1Ylo5dmIud4cXZd/wg74jW/Umr/iMF6NfhGoz67s0wbF dYcQ== X-Gm-Message-State: AGRZ1gK/sBVUMCqADMgyKEkJ5941gZMf47jo2tkXwaSe4N04HboyVUHS /qR3Z5XWKHL6teyEMC+URFxAFHaF0B4fyZYRGWbdN2dIn3sNOFOFB9vBRsKoI42mN2LI+VyXmiW d87f8XlGCffYMWksngV+M32taoBGDApyMf+l7fv23MjTCVo4GyuB1r51TRjvl X-Google-Smtp-Source: AJdET5eMNwamD/gyKDgHK6zIEYjuukyzhkh3XHzIno2CdjDTElStZm1yFezzc6LKvttYaUH+jtY8QbbxK/Vq X-Received: by 2002:a24:1d0b:: with SMTP id 11-v6mr315075itj.11.1540937371924; Tue, 30 Oct 2018 15:09:31 -0700 (PDT) Date: Tue, 30 Oct 2018 15:08:17 -0700 In-Reply-To: <20181030220817.61691-1-sbeller@google.com> Message-Id: <20181030220817.61691-25-sbeller@google.com> Mime-Version: 1.0 References: <20181030220817.61691-1-sbeller@google.com> X-Mailer: git-send-email 2.19.1.930.g4563a0d9d0-goog Subject: [PATCH 24/24] t/helper/test-repository: celebrate independence from the_repository From: Stefan Beller To: git@vger.kernel.org Cc: szeder.dev@gmail.com, jonathantanmy@google.com, Stefan Beller 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 --- cache.h | 2 ++ t/helper/test-repository.c | 10 ++++++++++ 2 files changed, 12 insertions(+) diff --git a/cache.h b/cache.h index f7fabdde8f..9f535040af 100644 --- a/cache.h +++ b/cache.h @@ -1035,6 +1035,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");