From patchwork Tue Oct 16 23:35:32 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Beller X-Patchwork-Id: 10644315 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 8B57C1057 for ; Tue, 16 Oct 2018 23:36:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 769C0295F3 for ; Tue, 16 Oct 2018 23:36:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6AB342945B; Tue, 16 Oct 2018 23:36: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 04D0F2945B for ; Tue, 16 Oct 2018 23:36:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727152AbeJQH2n (ORCPT ); Wed, 17 Oct 2018 03:28:43 -0400 Received: from mail-ot1-f73.google.com ([209.85.210.73]:36427 "EHLO mail-ot1-f73.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727020AbeJQH2n (ORCPT ); Wed, 17 Oct 2018 03:28:43 -0400 Received: by mail-ot1-f73.google.com with SMTP id y22so18332352oty.3 for ; Tue, 16 Oct 2018 16:35:58 -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=WXc/W7WM7svmOBnFamHW+1HsHd8RooyP9LEyJ6h6gzI=; b=wQQnAT/oJLe6Iu+Xo0E3vqXnBnV2+Z9NxONoL7WDH75eVdo2XKh4A8GyriLfJNY5Hs 3UyYYk0GJI14GdLjX2I/AWd5jAuCSI901KHdkOcKflzT0+6xCxToot0IK/K4qBiTA2Ha 4RhWlBnrCXy83GRcWAzEmy3kz8brC2j6/Y1s0YguAMqpEpT1r784v3pvyJScP7VLZMmi r/PbgA50WgxKz7c4GmgnVnIMfQTYCQzpKVkIyoD3YT7hJFCS2Wxmn97y4U+R5Jn6QoVo tAb9YydolHNys1A+tYXFgl1BiMk4uoiZe72gHBd75JE3286ZQ/Sa5lXmvaPhchy6XFtC k8ig== 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=WXc/W7WM7svmOBnFamHW+1HsHd8RooyP9LEyJ6h6gzI=; b=uTEy8eF9UbHwiwU55bZIXBHDUqObudAcruvPSZuCOedzDAI+sqFd8EtmHnfki3zzpZ 2oL0QEAa9pB1RW3GgrljMxckJdPva8WX4Iw7dIcI+ShAW7x42Tasu0l7xGsJrrJj0WxK h9f/pNmbZACr+f+baZT8iEIDcZJsKSTZ0Xt5ONujdRU3SZ27p0wj0hBNT4VhwIB3/ld3 wy7YFanGt+QElwJKj9e1wihj91uzxl4y9Ub8ElTvuDZVFmYWLmfVB/dzCtXhFciRkifT ka0NJUIxTWr92hvtmtc9NRq6KOx+5Tl0ydCRMzHaAaKj/YBAZcg0RSGQzaEjDbQEQWQO Ga+A== X-Gm-Message-State: ABuFfoj5hSt6T4496KwA4s5CIs8j5DCEDI1QWeaJ5edzZcxv8GpZ1WFY NF1h6K8f8saSl19M2uyGbf4FP+n9NwF0JzuCKN3msdkKIe5Pw4f7+sBDT3ScowJroXd2JEuz3Jp jGW4d8FmuSRJH95ybMUNEjV0rBAQCNFsY22xFprgKcmCUcYgyHt5Ce74Gruqh X-Google-Smtp-Source: ACcGV60pVMqd9A8sVxSv05bHOASXkEXsff6K3zd6ma9XrvhI+XtsXf/k8mzxFoypxkA26PGoPLby8IP158q9 X-Received: by 2002:a9d:b9:: with SMTP id w54mr19572187oti.30.1539732958239; Tue, 16 Oct 2018 16:35:58 -0700 (PDT) Date: Tue, 16 Oct 2018 16:35:32 -0700 In-Reply-To: <20181016233550.251311-1-sbeller@google.com> Message-Id: <20181016233550.251311-2-sbeller@google.com> Mime-Version: 1.0 References: <20181016233550.251311-1-sbeller@google.com> X-Mailer: git-send-email 2.19.0 Subject: [PATCH 01/19] sha1_file: allow read_object to read objects in arbitrary repositories From: Stefan Beller To: git@vger.kernel.org Cc: 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 308d5e20e2..647068a836 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 16 23:35:33 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Beller X-Patchwork-Id: 10644319 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 718D81057 for ; Tue, 16 Oct 2018 23:36:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 639DD292D4 for ; Tue, 16 Oct 2018 23:36:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 58216295F3; Tue, 16 Oct 2018 23:36:03 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, USER_IN_DEF_DKIM_WL autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 004C2292D4 for ; Tue, 16 Oct 2018 23:36:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727171AbeJQH2p (ORCPT ); Wed, 17 Oct 2018 03:28:45 -0400 Received: from mail-pg1-f202.google.com ([209.85.215.202]:42567 "EHLO mail-pg1-f202.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727020AbeJQH2p (ORCPT ); Wed, 17 Oct 2018 03:28:45 -0400 Received: by mail-pg1-f202.google.com with SMTP id s15-v6so18747553pgv.9 for ; Tue, 16 Oct 2018 16:36:00 -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=o7I7Ak/8GnkK2vi4y9xPluiGxF5/EQ3Xj+ItwOtXWLI=; b=Kkkj/a3sCuOozNADyXkbJF6IfmuIPwQuWFwDZ6BeRqN+pleb/1VETHK4eUcs9VUVzv ttai3BXSBGufVw1ydISLX1PZC5of13+BBMqa0/RfEWsxvwpt9scLrwiHX9SjhN8LSrf9 XCrPZSifvVdZLwgS7/zt47z5U28/9MSrMaUfvXtNRaUf4/3VO2cQIxnUu0JvjWUpPH95 zK2gAzz6x97iJ6ZEaHmP3WP4Wxy+WM1gDQ2qPiXeYvyE8XCK0yi88hmUsGVwuag7XQa+ YYeajU+5vqs2NpdHFzD+3WyibSmt+hBNW1G9I7p94YeBKABxG6v628bDii9Y3Q0bEi50 0IPw== 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=o7I7Ak/8GnkK2vi4y9xPluiGxF5/EQ3Xj+ItwOtXWLI=; b=NUHVK13YCuRLeG3zNOE6f0TuaYVkzlBogylV24F/JWKZz6taex6c4j6QgjTKuFx4oM DkvcX+2m5Dxotru+gh4zuWWUupy1JmDPnkC2LxFrf4acoOqO02NYr85tg7DMF6poyzHX 3Le6W+OPa087avdmgKNwFNHYiEIVUnAobiZDlYG2RHlaN0a4atKzpbNate/NwkFxQt7P XGd3IHLPrVq0EwXRn7Nx9NGpKNx4iJxeNmbgMTcQgSkerd+K5ttl0+PZtqKoN3yJDxgz z186obTIBnIi3sg8x+jB59tnVavDoLvhSFJbMc3tkQ3tVVVaB3L8ipOt7/nUx6/Rcx+k BUEw== X-Gm-Message-State: ABuFfoj+vO1kOAcjIz/jmeZRkal3F2E1KEk/Sk57YbZwlPkE6K7EecRF 64haxZCPMhGP+dqIFZY/bFwRcjmfmpY2YwGjRAOf3ZJsyk7lAQ7RqQ+XiRt3Dktp5p91+zjDdEc xjeDvYXh1pJOU3us39TvJWsz7oBrJ1KKO3fDe8GgvCh8w8wnESjZYe5f3AtQb X-Google-Smtp-Source: ACcGV62nAsxvvB7MSajPW7La2hZxm8FGi8w9rcZlZVL15u5Lt8mCeOPfVeDNFTFW5hyGqB9PkF3iaX03640/ X-Received: by 2002:a63:5a55:: with SMTP id k21-v6mr11088686pgm.67.1539732960549; Tue, 16 Oct 2018 16:36:00 -0700 (PDT) Date: Tue, 16 Oct 2018 16:35:33 -0700 In-Reply-To: <20181016233550.251311-1-sbeller@google.com> Message-Id: <20181016233550.251311-3-sbeller@google.com> Mime-Version: 1.0 References: <20181016233550.251311-1-sbeller@google.com> X-Mailer: git-send-email 2.19.0 Subject: [PATCH 02/19] packfile: allow has_packed_and_bad to handle arbitrary repositories From: Stefan Beller To: git@vger.kernel.org Cc: 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 ebcb5742ec..40085fe160 100644 --- a/packfile.c +++ b/packfile.c @@ -1024,12 +1024,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 (!hashcmp(sha1, p->bad_object_sha1 + the_hash_algo->rawsz * i)) diff --git a/packfile.h b/packfile.h index 630f35cf31..1d2d170bf8 100644 --- a/packfile.h +++ b/packfile.h @@ -136,7 +136,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 647068a836..13b3c5cb79 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 16 23:35:34 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Beller X-Patchwork-Id: 10644321 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 A278A157A for ; Tue, 16 Oct 2018 23:36:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9180E295F3 for ; Tue, 16 Oct 2018 23:36:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 857C32980D; Tue, 16 Oct 2018 23:36:05 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, USER_IN_DEF_DKIM_WL autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2004A295F3 for ; Tue, 16 Oct 2018 23:36:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727192AbeJQH2s (ORCPT ); Wed, 17 Oct 2018 03:28:48 -0400 Received: from mail-ot1-f73.google.com ([209.85.210.73]:49196 "EHLO mail-ot1-f73.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727020AbeJQH2s (ORCPT ); Wed, 17 Oct 2018 03:28:48 -0400 Received: by mail-ot1-f73.google.com with SMTP id j47so18225391ota.16 for ; Tue, 16 Oct 2018 16:36:03 -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=r6pZnj6NNpuuleQyLYwbmCqXJeAhN5KJ5Dg6i/99Mwc=; b=WkxVLO4/zcWWiJzyR0wSXcOGFMX8ljTkXRk88A9fE+HtnEgYtbabxyUS5xmHeleIBf KTAE2g5RdsUgoe4rTM5CIjDAuEBPFGOtsJIDbWNQHw3b0fVRONbJkZ8chqBmG9F2jpRP bCv0Dz2ia4BUnjR15gxlysK6KCiikhaQuiHEgHtuxxnpYXm0mcoUMJDaCbUxWErGCZww FAowxUNrKVA/fYCovCUVDeds/W1vXRgDyZAT4+/FNsWYKtn3+qsoWHSTfodKhiY2cmqt NfnyQeVBu9NW9VfsbolMPbGPkOLnB3MyF6x2W1FGWExYe8HrJcc5lrzq7fwalDNWL6Uv pg9w== 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=r6pZnj6NNpuuleQyLYwbmCqXJeAhN5KJ5Dg6i/99Mwc=; b=mzLkmZY2ZRvJQcFxtpH/uSacTGs8qtT2TqDVZJwldO383E0KxqHaRZYQVcYmv0KrWO Tc5Zs+mfoJexMkTA187FxSjOrBzhhqUtY3DU8XTQMSDMznMf6RtsKNZu/2SkIAwyYxUK YIRGPr59l27cRKxdLBwskDsXa+/HPZSsH3UGgtf2Irwadb1RTIyQtDBgKAoMw0pU4+LJ wyiw8MarwbBjADfikdIMhYru9lViXZe5gL4YWIQ2nLjDKEVt1CAPwFO9m4kf7L3BUG6Y SGIntZLtY7/cANWl6AQ0VmqTaNQCqY+bu/FZxQ6ujPA1om+TYGe+zyBE341OZVr2RnWs dhNg== X-Gm-Message-State: ABuFfohUaOC9BdVfacFpCFlNJ+W6j7IEDNuDJ66KO3yMlWUuWmJw55Ea J3VLUDGZWspYdtwxJkgeRx5qBE8Nw61hUolweUWqivRpIwIuso/tw29Fuv81fhvrGSSpzwsdNeZ k6sstT1YkRNpQ61BxXIliyY5vBQTvPVI53yUIdnL7g+REPkIqmeP+R9dSCTUq X-Google-Smtp-Source: ACcGV62RaxZ3Wp1jiBS+h52FVgKwLxUnfL2P2TXJ+8O8wAENgWTv7VCL57kC/5o8PPOiuUfLQ8KBWXxsP5gV X-Received: by 2002:a9d:4a0b:: with SMTP id h11mr19512089otf.65.1539732962989; Tue, 16 Oct 2018 16:36:02 -0700 (PDT) Date: Tue, 16 Oct 2018 16:35:34 -0700 In-Reply-To: <20181016233550.251311-1-sbeller@google.com> Message-Id: <20181016233550.251311-4-sbeller@google.com> Mime-Version: 1.0 References: <20181016233550.251311-1-sbeller@google.com> X-Mailer: git-send-email 2.19.0 Subject: [PATCH 03/19] object-store: allow read_object_file_extended to read from arbitrary repositories From: Stefan Beller To: git@vger.kernel.org Cc: 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 67e66227d9..6bb0ccbf05 100644 --- a/object-store.h +++ b/object-store.h @@ -146,12 +146,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 13b3c5cb79..ce47524679 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 16 23:35:35 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Beller X-Patchwork-Id: 10644323 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 6AFED157A for ; Tue, 16 Oct 2018 23:36:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5BB32295F3 for ; Tue, 16 Oct 2018 23:36:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 505632980D; Tue, 16 Oct 2018 23:36:08 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, USER_IN_DEF_DKIM_WL autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E5220295F3 for ; Tue, 16 Oct 2018 23:36:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727214AbeJQH2v (ORCPT ); Wed, 17 Oct 2018 03:28:51 -0400 Received: from mail-yb1-f202.google.com ([209.85.219.202]:57045 "EHLO mail-yb1-f202.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727208AbeJQH2u (ORCPT ); Wed, 17 Oct 2018 03:28:50 -0400 Received: by mail-yb1-f202.google.com with SMTP id y12-v6so13663440ybg.23 for ; Tue, 16 Oct 2018 16:36:05 -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=eskJwk4pnUYO394rRuJy3bhhNNUW4Dxfs+Q24LiF+Ic=; b=g/FwXom73CDqsipdlfoiq3vLTO/8TJubcj5YcK0M7tjiO8zLD0+MmJKMg2gq0UvpO8 ish3LS/8hpNO5MEUqPz6HaEhLXI30rInxx654LWKQPEqWgt8AMzHJeZ5OqjCNvH4FHLL A5QV3sAW9C2WlDoEq9giqhr24V/5mb7UoKSIjdzBQ7bBtgHYRMZPybo09HOmEEH+Yih5 41/gTHEyQ+/CuQ2GxH+7yVkU6OeXSOpPpdMScdIMMXVfG/F6AzUhBei9CvVfaszHWgvm xpT+dj46c4dKWH88bZzvnWf+h3o+SquCwifFxMFWpWp/YUMzl52z3pEQMsMqaJYPtlHE iw3g== 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=eskJwk4pnUYO394rRuJy3bhhNNUW4Dxfs+Q24LiF+Ic=; b=eBdGdi0ssV9mY/fcnXPqjcO6MKT0TjSESJy80wGxdqFvnTp4J6h3c6kq08N1mHHgWv 7ZGNh1+SdF9mTeCY9QXpliLF2+HE9lIPPazyHUrSDhKS9JMJ8Jd/C+PyuazsuLBbPlkW uPsmODuMfv1uj4uuZMKnyURsoS6xAxXDDyFLf+lDecCgeKK2w03rL5CyyQi50ENSMOU9 QdXyjk7lSuQN/qWAoVc5v9BV3B+U/Xon7JUZcf7Uc6029iak10GgzqOeBP9y3VFVV3k9 m7+i8N4lgj3QwDMfKXxs+Mm/+YKlgNp1QWIlMFHAxfIsOjkpw8KKFqLvzp/k2qzy3mIE Rl0A== X-Gm-Message-State: ABuFfohTFgbZ925DKQSghDhqgCAxN4C7I6aE42BzUaGiMzW9uIlzC1aO hTXDuZ94CtM4Z3mVASxfdyTaIvlN984ipK+PiJ40V7dko4aXi2GwC8XsgE4yhBUTto8oWa+cfps +vzirKaE/j/B7Xtt3sz6PvcsviVsRWcJ+ILaXqhghFsxEg0Xnj7mld18owgq7 X-Google-Smtp-Source: ACcGV62x2FmUc6GTXRuXkoAhpzgZBKXCvSjg9iI8XVvnzbpNK49KuKy4vyxNVALbX58GiHC9Z94ZrPDGw+MM X-Received: by 2002:a25:5f4b:: with SMTP id h11-v6mr2802364ybm.67.1539732965257; Tue, 16 Oct 2018 16:36:05 -0700 (PDT) Date: Tue, 16 Oct 2018 16:35:35 -0700 In-Reply-To: <20181016233550.251311-1-sbeller@google.com> Message-Id: <20181016233550.251311-5-sbeller@google.com> Mime-Version: 1.0 References: <20181016233550.251311-1-sbeller@google.com> X-Mailer: git-send-email 2.19.0 Subject: [PATCH 04/19] object-store: prepare read_object_file to deal with arbitrary repositories From: Stefan Beller To: git@vger.kernel.org Cc: 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.cocci | 13 +++++++++++++ object-store.h | 10 ++++++++-- 2 files changed, 21 insertions(+), 2 deletions(-) create mode 100644 contrib/coccinelle/the_repository.cocci diff --git a/contrib/coccinelle/the_repository.cocci b/contrib/coccinelle/the_repository.cocci new file mode 100644 index 0000000000..3c7fa70502 --- /dev/null +++ b/contrib/coccinelle/the_repository.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 6bb0ccbf05..41ceebca48 100644 --- a/object-store.h +++ b/object-store.h @@ -150,10 +150,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 16 23:35:36 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Beller X-Patchwork-Id: 10644325 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 B8EFD1057 for ; Tue, 16 Oct 2018 23:36:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A9AF5295F3 for ; Tue, 16 Oct 2018 23:36:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9DFD62980D; Tue, 16 Oct 2018 23:36:10 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, USER_IN_DEF_DKIM_WL autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 34C6D295F3 for ; Tue, 16 Oct 2018 23:36:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727249AbeJQH2x (ORCPT ); Wed, 17 Oct 2018 03:28:53 -0400 Received: from mail-yb1-f201.google.com ([209.85.219.201]:57045 "EHLO mail-yb1-f201.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727208AbeJQH2x (ORCPT ); Wed, 17 Oct 2018 03:28:53 -0400 Received: by mail-yb1-f201.google.com with SMTP id y12-v6so13663509ybg.23 for ; Tue, 16 Oct 2018 16:36:08 -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=rE9ojvZfm4LkwguVwggNmT/vpPJFWZRosJNFnkQh9i8=; b=gsXiWxdfwbzgExSaw7TIHLBUfCw0QTYGcwziw6ex0hkH0vR9RQcWmf/0+XwPHgMN61 MR5rJ9WPjnNfolQmjL19D+rSLL7NG4sQeghHB7QvlT53tc3e6f1qtSllGd5AwZZ0gkG+ q23lE5c3tXRkYfeubCqCh4p0CV63d2IImtbf+hx11mJIqcw3AyP5mlyD47LIIrsKuTqu V1bp+VlfsDH3SAO9Fi6/xfK8fkf1NrU+YEgRMUJzz9YM2jjygaBclebhjWesI7hzSmwm KtFhD49pH9ebAxOukBvYr94o42bDF/v3SW08641qv2cw9HSqoevsqRpD2mpxUSf8u/hk w5NA== 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=rE9ojvZfm4LkwguVwggNmT/vpPJFWZRosJNFnkQh9i8=; b=jWYnTdVmTL7m9eKQCOBtE3fEGg3oAbJj4VqNZD43cGspwfrP8PJp6PpBu6rYiUj5Ub C7RtlsHMIxhW5hf/Kdk5O0av3LtSJ6NR1LRy+bz5bY+dGFug1WCOwl8aNtIsuauYRc3X yO/2i3sVCall17GU3gzWpUcRrmnieXpQ+yU42+XlFdGzcgw/9ztyshFdAARHfyBXeulA CInv8itxaME2a5ERHHh0EekppUPkkzF0aEymAGibTycbWToHkLx79TigDMJvFE87SeTN 6E7RSyYMzH+7kxMFnSun2ZykD1KJ4r5p55VvW2L72WS6gPND8vEY+FWy1qJbOeWcgUip lkYQ== X-Gm-Message-State: ABuFfohmViCRCsoQ0dK5P7uJI3WfACoTcdPfUSy41uNPAnJRkKMVrLPd oiwN1lePtztKFiGU8WLl4N9szpxp3sQNXqGDo5WzG8JtNVZH/n/bmgnfrcurKI77LSNFsbuu6Q0 GeO/p9XuIat3BsxirzF4oGITWx3MtDntqJF82vdir0CHWr9gdR7KfQWQ7F2Pa X-Google-Smtp-Source: ACcGV63bXdMsHIZ+WPA39Vug+0eZ2dJutfMWMgPLG1g8WZz0qhDxXLPdFtpodPnEAP+KlRsuGHmJTKV50E37 X-Received: by 2002:a25:be85:: with SMTP id i5-v6mr14248846ybk.19.1539732967653; Tue, 16 Oct 2018 16:36:07 -0700 (PDT) Date: Tue, 16 Oct 2018 16:35:36 -0700 In-Reply-To: <20181016233550.251311-1-sbeller@google.com> Message-Id: <20181016233550.251311-6-sbeller@google.com> Mime-Version: 1.0 References: <20181016233550.251311-1-sbeller@google.com> X-Mailer: git-send-email 2.19.0 Subject: [PATCH 05/19] object-store: prepare has_{sha1, object}_file[_with_flags] to handle arbitrary repositories From: Stefan Beller To: git@vger.kernel.org Cc: 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 --- contrib/coccinelle/the_repository.cocci | 29 +++++++++++++++++++++++++ object-store.h | 22 ++++++++++++++----- sha1-file.c | 15 ++++++++----- 3 files changed, 55 insertions(+), 11 deletions(-) diff --git a/contrib/coccinelle/the_repository.cocci b/contrib/coccinelle/the_repository.cocci index 3c7fa70502..46f3a1b23a 100644 --- a/contrib/coccinelle/the_repository.cocci +++ b/contrib/coccinelle/the_repository.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 41ceebca48..e1c68d0774 100644 --- a/object-store.h +++ b/object-store.h @@ -197,15 +197,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 ce47524679..6153cedcf3 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 16 23:35:37 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Beller X-Patchwork-Id: 10644327 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 52E2E1057 for ; Tue, 16 Oct 2018 23:36:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4459B295F3 for ; Tue, 16 Oct 2018 23:36:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 38A462980D; Tue, 16 Oct 2018 23:36:12 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, USER_IN_DEF_DKIM_WL autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C8AFE295F3 for ; Tue, 16 Oct 2018 23:36:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727260AbeJQH2z (ORCPT ); Wed, 17 Oct 2018 03:28:55 -0400 Received: from mail-pl1-f202.google.com ([209.85.214.202]:50990 "EHLO mail-pl1-f202.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727208AbeJQH2y (ORCPT ); Wed, 17 Oct 2018 03:28:54 -0400 Received: by mail-pl1-f202.google.com with SMTP id ba5-v6so15666020plb.17 for ; Tue, 16 Oct 2018 16:36:10 -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=7A3DKYGMNIc9XIZGWKquN69jLzxcxWQvlX+UIOP8c+A=; b=u6X+OKFcNyK9QcYjq+0vlXmAXjzGXxrlaAjTaGOrUFOKCcifDuI1E+ecviMBlvVThs PBQOslKN1JYmIIoOwYnbbvn81/GPwJdWRd2NfACXHKWZnvs19Da1nPUHvMzPfmxX6BjU gDJAhxOQqShu1+lNaRnlF5eYDqHnqp0QqZ2yxlT4z+7D6TaSkm28vNxBWeZGFWRD95tM ttRsCSdgGwsdWqy8r+b6azZfa8xtTO1OdPYNI9Yv2nt6QdInb0gmuKL5G7ZqZT8lQj1V 5rHt9GR3zdGYjfdfDweu5nR4LaTN9eDgUh4cvt2D9n00LeOGkYAr0TRbn2h1XagfCCbY nOTA== 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=7A3DKYGMNIc9XIZGWKquN69jLzxcxWQvlX+UIOP8c+A=; b=K/mSqzQsSXKy57sKEcXHf3meJhhT8raQ4I+180ckVEumeoXRGFmOkqChAz249k3JDq BWS+YYcJ+D8/cbRxY8IdwbWnSBuIwoG2Hrjc/muDRZOuUQGGeQ5GHMj+WisabwyEg0Cu XktiWpNTL41PzcnygYNZIVCLb8n0GwAX90lnYWcx2v+3KDmCOvcSK4qcxzOpPSNnaXmI lay0d5NCR482+kyq4O97ol4gzkaEXg1ejzLm/TFAnIPYCmNen8boec2XGe6qXLGxQvzP mMUhWReW9HLlV6WP+ZY3QwFNLxSXVlyQ2fCH5g1sR9no9ECPo8vw/0BguRbaHxMop6VQ mJHQ== X-Gm-Message-State: ABuFfojZTaqwRcEvZf+Sp1IlyN3le0G8aHVu+DdICPgtjHTVxtClNa7U 2EBf/lBvaDP5gb7yU+yVDcCiAVgyHHp9TWjB0hlhyRQ+WqbFmLH+vnRMQepSC2WFZmD88aQxw3U Gqs7WzOMT0VGcgkbKBbZ0VFZ7+lCok+WAKGDnW0aEx3nkGwTp3Radqck+/Qcn X-Google-Smtp-Source: ACcGV60Gkuc/S2d97SiKihwY7YRmBW5Rl3GwLn+fe7eXZ4zN22gyyDIWBoHzkGvblKT3eZt9uqVaxlhrau3e X-Received: by 2002:a63:7d0a:: with SMTP id y10-v6mr4005172pgc.62.1539732969880; Tue, 16 Oct 2018 16:36:09 -0700 (PDT) Date: Tue, 16 Oct 2018 16:35:37 -0700 In-Reply-To: <20181016233550.251311-1-sbeller@google.com> Message-Id: <20181016233550.251311-7-sbeller@google.com> Mime-Version: 1.0 References: <20181016233550.251311-1-sbeller@google.com> X-Mailer: git-send-email 2.19.0 Subject: [PATCH 06/19] object: parse_object to honor its repository argument From: Stefan Beller To: git@vger.kernel.org Cc: 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 51c4594515..a32afa14df 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 16 23:35:38 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Beller X-Patchwork-Id: 10644329 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 0E477157A for ; Tue, 16 Oct 2018 23:36:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F2EAF295F3 for ; Tue, 16 Oct 2018 23:36:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E746F2980D; Tue, 16 Oct 2018 23:36: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 CFF19295F3 for ; Tue, 16 Oct 2018 23:36:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727266AbeJQH26 (ORCPT ); Wed, 17 Oct 2018 03:28:58 -0400 Received: from mail-it1-f202.google.com ([209.85.166.202]:37529 "EHLO mail-it1-f202.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727208AbeJQH25 (ORCPT ); Wed, 17 Oct 2018 03:28:57 -0400 Received: by mail-it1-f202.google.com with SMTP id y73-v6so234060ita.2 for ; Tue, 16 Oct 2018 16:36:12 -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=uez/GsuUMk6OTEc5V/EcmHFoQf8X5QynWGKks7S2L9E=; b=FKUPrOKvx2yu7LdFR+t4E+ojthPrZMkBA9ObXQtr1TEIeN/1yASVDcq5Lc7XZRwojw yipQRm769LHs9Z7wKsM7Oedjcjk8V/I5FUws+In5o0gRFMaVQ/r0nMXT0KrnhacdfDzc uYNWjCowV72d/zEGzRIp2t1S9qVikhS5KRTR7NSLeP6Q+zYVX44LXUjHMDnplA0ltHEj Q57qfkjmM3BbD3vtopNEvaOufXJBdh7kjRvIvbYEHh0DW5ufZ+dM880yW6FqJXlm5LtT t6A+3idHbRykK618jqutujSCJaBOpo/T23gfXGbTIgO4iYgiD1EVNrRIiRcg3yPHwynS UavQ== 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=uez/GsuUMk6OTEc5V/EcmHFoQf8X5QynWGKks7S2L9E=; b=IZcewM/oSIXeqsV22hk06I1s+zvcjqQ+lz2BICoXir/fjW2oY01oNpK8K/tpxdIRu4 JQvRA+L7GsrEliCJ45SiqKZFWyvefdDHRmwrG4oVejiYERPZ0zFFlvfc51nCWuNVEVuA j28wAZwSPBRGI4MnWEOZLKcmrzhfLclZceVqXrmAxb/1JTwUf2nzzC8zIT+f1xEnuEq3 INMHGJIwVuRK8TjeQQgupacJC44FYUdl55XSklXba+U2RE0s01IuSC+8bYP47eh7SceE etGdVLlTwBKZfFovxeDUT5blRbRPtebMOUSNUgIjWSdfRbmiZN/ImTQ1DsWtYkFTYF4b sRsw== X-Gm-Message-State: ABuFfoh8KAWqXVpKse2gQyh1UE9XO0VZmYvj9CQPyxUAS3L9m6dm0hjL jJxrvcHpoGzXl8tjFwGfuA+LkUgjRtmB9LG9IXdm6e1b4NZaWOSN8eL3+w7aKlTceOZMIEB50gM zk/xYkRXo52R1LRsZRyqLZHpERVCqME7B5QBsNEZ6WeRT5Jo2dj+KVpr2FkVD X-Google-Smtp-Source: ACcGV60Krfje9OSRbLxxlJewlyjEAinFZrxW0tHr+/jlCBhZ0P/RGZfHAPH8G+PTGjiAX9o5SPkgt0N3Sg/E X-Received: by 2002:a24:fe01:: with SMTP id w1-v6mr200481ith.0.1539732972258; Tue, 16 Oct 2018 16:36:12 -0700 (PDT) Date: Tue, 16 Oct 2018 16:35:38 -0700 In-Reply-To: <20181016233550.251311-1-sbeller@google.com> Message-Id: <20181016233550.251311-8-sbeller@google.com> Mime-Version: 1.0 References: <20181016233550.251311-1-sbeller@google.com> X-Mailer: git-send-email 2.19.0 Subject: [PATCH 07/19] commit: allow parse_commit* to handle arbitrary repositories From: Stefan Beller To: git@vger.kernel.org Cc: 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 +++++++++++++---- contrib/coccinelle/the_repository.cocci | 24 ++++++++++++++++++++++++ 3 files changed, 48 insertions(+), 11 deletions(-) diff --git a/commit.c b/commit.c index 5781f9bc67..fe942754e2 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 e2c99d9b04..58a0c5409b 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.cocci b/contrib/coccinelle/the_repository.cocci index 46f3a1b23a..b185fe0a1d 100644 --- a/contrib/coccinelle/the_repository.cocci +++ b/contrib/coccinelle/the_repository.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 16 23:35:39 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Beller X-Patchwork-Id: 10644331 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 48448157A for ; Tue, 16 Oct 2018 23:36:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 395F4295F3 for ; Tue, 16 Oct 2018 23:36:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2C5A92980D; Tue, 16 Oct 2018 23:36:17 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, USER_IN_DEF_DKIM_WL autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C1A5C295F3 for ; Tue, 16 Oct 2018 23:36:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727282AbeJQH3A (ORCPT ); Wed, 17 Oct 2018 03:29:00 -0400 Received: from mail-pg1-f201.google.com ([209.85.215.201]:38238 "EHLO mail-pg1-f201.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727208AbeJQH27 (ORCPT ); Wed, 17 Oct 2018 03:28:59 -0400 Received: by mail-pg1-f201.google.com with SMTP id e6-v6so18611164pge.5 for ; Tue, 16 Oct 2018 16:36:15 -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=lwChrbuEGJgYppzD2Ie5ZpCjtPrl0112xaB9bQtvhhc=; b=MUOuoOxbTZl1SBlLojhYH7Btd6ot0o0TSR2edAxp4bHGjm3aDuwqk8RMCQVapYG8K1 dak893kAfaLvYUyFggGhKW47OqYGuDjfyhvjr2kVTnYrYTDuj+7zITTI57diImdRKOd+ 4m/5Rs5XNNyx6nJoaUft32cp6Q+slYRF9h+EGvwyWoa9Py/PoNDvzH65cDZUjcZNBdUO WhCiv58JjTdfgJdM/ZUdEr2P/9Wyclvmxzn3ZlB8wHFl986zBurrkKe0h6BHleQa4qKV 8QpZb0Sgpda3vTI9Xnq88OdjKXDQJ1qSSey8I30px18yhEkt7ga6PTv0NPPF3Hj8s5pj WXoQ== 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=lwChrbuEGJgYppzD2Ie5ZpCjtPrl0112xaB9bQtvhhc=; b=hHSUKt2cO207Lh18KgLJ70LR/n8rVraOqLcCADXys9S5l5tdlqMrhmLjcIvGxUT2V/ efUGNgdGlFNbzXO8A688Q4PM8qoRMjJk0lCVtwMh8v/CTMhoM4GYLdee/mBVE3AiPBkm b9Ccmf8BYdZ+4x0oHn2/ueyoouNQBUimRRWpBoWmdYN8H8Sqhx9yPIq4FelpkkYwL1+G y9qvOO5davs6XCyPYAQwarVtAyF8qFl8V6EIzeScJgEEsWOdvVzS+Ep2joF8VxCQ9s5h SGLlX97/jZtAsvS0n2pPSGvFHSSKzZLOJDntR3YoyhwAWFHTvvoc3hWIz//Gwx+DO8Bc NfxA== X-Gm-Message-State: ABuFfohwplX5drIB9FKytgeOvYY470tI+EPJQUgBTSpnu0E8BFvk4ocL LE7Nud8GYHiO0iRChG3Enk/fX0ScSOhV5RD4qGlZ16drhxijK5Fb33DmEShJgu5tJ4kuCm8dOeC HTDCp6eJ765ZGmK545Jb+lQ1JVwhhgYm0vrBrPulhUckS74/ZuSVXZye46rOM X-Google-Smtp-Source: ACcGV63aaD/EkdUjUB2QrPKgJNRBEzxMH6XVY0J3oAxcCYhQ/KyRTOYTTZG4vR8u8HnW5pYN/KJpSl39OXB2 X-Received: by 2002:a62:1f41:: with SMTP id f62-v6mr12052529pff.59.1539732974576; Tue, 16 Oct 2018 16:36:14 -0700 (PDT) Date: Tue, 16 Oct 2018 16:35:39 -0700 In-Reply-To: <20181016233550.251311-1-sbeller@google.com> Message-Id: <20181016233550.251311-9-sbeller@google.com> Mime-Version: 1.0 References: <20181016233550.251311-1-sbeller@google.com> X-Mailer: git-send-email 2.19.0 Subject: [PATCH 08/19] commit-reach.c: allow paint_down_to_common to handle arbitrary repositories From: Stefan Beller To: git@vger.kernel.org Cc: 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 5a845440a9..2f7ae20bd4 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) { @@ -80,7 +81,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); @@ -113,7 +114,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); @@ -184,8 +185,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++) @@ -319,7 +320,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 16 23:35:40 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Beller X-Patchwork-Id: 10644333 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 56D291057 for ; Tue, 16 Oct 2018 23:36:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4900C295F3 for ; Tue, 16 Oct 2018 23:36:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3D8E12980D; Tue, 16 Oct 2018 23:36: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 E358C295F3 for ; Tue, 16 Oct 2018 23:36:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727306AbeJQH3C (ORCPT ); Wed, 17 Oct 2018 03:29:02 -0400 Received: from mail-pg1-f202.google.com ([209.85.215.202]:37086 "EHLO mail-pg1-f202.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727208AbeJQH3B (ORCPT ); Wed, 17 Oct 2018 03:29:01 -0400 Received: by mail-pg1-f202.google.com with SMTP id u43-v6so10873420pgn.4 for ; Tue, 16 Oct 2018 16:36:17 -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=pbYa7JpLVrLMQojmFQC8qEWdy/zc/7hAIZnqgBLNh1Q=; b=BNLzbv0hWvcm39u9b/UBZ0bPLPmDyUsYKpW0z/NEtOz2DUaq1P/pHE77jMw6B+EEYL DS2N6swqUR6dh2K4IOtWPzgM4q5VOhVJLvxZxqD2NJsoOW0dYQq8A44CJBbXM1r5VRNS rLhxGFUA+oCkn6sORYfYqpyt3ESwlO20LCprFcAHvvkLuiA9cmAyMzN/XgUMDZyQxrRU 2SRGo5nKiGpQfKVnQ8l+Q4u/+PEqRd79hFQSyQEYW+YEzCRn25wCTtb+UpKCDSXhfXox sABQXvpMbRwt16Nn/aYNqBCwKPjjBl8my5Lo4iKfRvkj1R7TIXEal2QLTnZCVIJkAAvM Y7mQ== 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=pbYa7JpLVrLMQojmFQC8qEWdy/zc/7hAIZnqgBLNh1Q=; b=ouY2Kr9paAEDq7ubkjfDZZiyKyxRcIYondKIq5uFeDIJCeObxq4O9G5beqo/X+Wmr2 WUE7xbljW5b0sI9wjkh2+ghlRFJSIucSdM5agi+hqsVAawEWnYM6miKdgPpEqQlISGof K6GMoGVzS/sUd7R46NUt91A/SQO8Fa1hOwEwyTCKIYHkQobR8MDka55UKlVR855GlRTi k2C+ARcIunZF4o7xw3DcWhfjr6Oa+edU2J7fk0rwX6LeC0CKN7n2PY9DJEPtwDJGgO94 +LE+oGtphdyfrF9kWDJapOdG9cSqQGK6VgdimbrUGQ0TmmLSlnoJ4WKrlGI4/ZPPGvjP MkqQ== X-Gm-Message-State: ABuFfog7bMYPIfcw76UwWMbevyhBpNkhMcEUvQIHkpAwBYRQY+bNGZ07 ZHhMNy2R1LrX8hXfMspOrC+NoMyZTYd52hURMqR5Lj90aEHAH+e9DdCf8gyYQYf3qYtAY+A7z/b IaIYK+Er+TDCLCjP5VKXF4uJU9pOCCzJlmKP6Qw5zBaXTqr3nWZEn781NISr7 X-Google-Smtp-Source: ACcGV62pHzv2Jy8oyVKqxYSwPSVVLmtTXRC+k8Z2F6wajiLC5XitiecA4dSaeeYazvYAB7Hy5CO8RZ/dHVsr X-Received: by 2002:a62:fd05:: with SMTP id p5-v6mr1792111pfh.25.1539732976770; Tue, 16 Oct 2018 16:36:16 -0700 (PDT) Date: Tue, 16 Oct 2018 16:35:40 -0700 In-Reply-To: <20181016233550.251311-1-sbeller@google.com> Message-Id: <20181016233550.251311-10-sbeller@google.com> Mime-Version: 1.0 References: <20181016233550.251311-1-sbeller@google.com> X-Mailer: git-send-email 2.19.0 Subject: [PATCH 09/19] commit-reach.c: allow merge_bases_many to handle arbitrary repositories From: Stefan Beller To: git@vger.kernel.org Cc: 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 2f7ae20bd4..aacd8cdc1e 100644 --- a/commit-reach.c +++ b/commit-reach.c @@ -92,7 +92,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; @@ -107,14 +109,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); @@ -221,7 +223,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 16 23:35:41 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Beller X-Patchwork-Id: 10644335 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 C1AFC157A for ; Tue, 16 Oct 2018 23:36:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B3A87295F3 for ; Tue, 16 Oct 2018 23:36:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A593E2980D; Tue, 16 Oct 2018 23:36:21 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, USER_IN_DEF_DKIM_WL autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 51059295F3 for ; Tue, 16 Oct 2018 23:36:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727323AbeJQH3E (ORCPT ); Wed, 17 Oct 2018 03:29:04 -0400 Received: from mail-pg1-f202.google.com ([209.85.215.202]:38239 "EHLO mail-pg1-f202.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727208AbeJQH3E (ORCPT ); Wed, 17 Oct 2018 03:29:04 -0400 Received: by mail-pg1-f202.google.com with SMTP id e6-v6so18611226pge.5 for ; Tue, 16 Oct 2018 16:36: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=J4QIGeazp/1Ko/Qmg1P0KNpmHyB7EfDvXKAT6i2oaa8=; b=WzZXlJ7ndXRwKEhHLgY819zL1ODACngTQlZO4QJWT34SyDop+DizsP/r8sjlsW4LKN kx4kSv1HH+mm/sgniLTjqeLEwCMQgMMbszH2JwRjc9uVLYLCfX1djYaxToTh7Z0CJbY8 +uq03S98LH1xE1r9AWs73Ga3oHjjV4/5wLyntv33wM0EA7SBnxMkfg9h/o4jCCPmQjJe iedukNor2zvPSbLoNvSoswl1OAv37IZq7Cm4ikNEQY9E/+BZ4NfwSDUZpKSFj9oQ8Vqm YBSuWedefNEwESKZWMZ252S2Q9pxhAMhz+lCe2yC8pr3QHn/z17qIIilwBgWLlDRkmRn kmig== 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=J4QIGeazp/1Ko/Qmg1P0KNpmHyB7EfDvXKAT6i2oaa8=; b=HzyzLYlFMkKZg/yJdn3jTiZ5urFp/rKF7ZMKb/N9hqjaiOhIJu7uLS33amzkCoz0LT Wg8DqQg3OaVOvdBJrKoSQzP/JbUC8Yz06Lou83eWWOK32l32A4EovxVu8Vnvi/R8gm5V gkTWfWG9GNqgpXnb2gjUy/XNnpEBZdqXIzeKhmEReRnz7McBoMtJgCswXz/lpNhG26/M ZYoZ95ppeCi23n62TwHGiHTRx4PhGrn71yNrlUdLufC4B6nrElcIp/FK0h9jArXHInsY Y2UeCfZgJt0ecllrrDjN4qryLvwM42T6V6p0Xu2be5p7Z6susULruEZqFNW9zM0mqx/2 1U0Q== X-Gm-Message-State: ABuFfoiqpKnqnCnYy5znlUq+gMxRD6Iqh1rQIbFVdxl4Qw06o5T48vXC DSRjznDf04jhMcm2DMu7DZNV4B9mWBksokqLfCXeuE8y7rg3EeVkJOcyjXzJ+JpGj1lGs4AUCst bp7eJZXvenfNsj974GXPWiyyKjRYI7drH88xQPEKDNjfwB1qPc8FnaqGsoxFA X-Google-Smtp-Source: ACcGV62NVbHvr8cw7ZucuFqER/4HgNdn37ZjiHLCFjVhMxcuWxPUnZEY6GJFB4GSh5+Mxw/1DkdPsfA0cUNw X-Received: by 2002:a63:ed47:: with SMTP id m7-v6mr11532335pgk.5.1539732979013; Tue, 16 Oct 2018 16:36:19 -0700 (PDT) Date: Tue, 16 Oct 2018 16:35:41 -0700 In-Reply-To: <20181016233550.251311-1-sbeller@google.com> Message-Id: <20181016233550.251311-11-sbeller@google.com> Mime-Version: 1.0 References: <20181016233550.251311-1-sbeller@google.com> X-Mailer: git-send-email 2.19.0 Subject: [PATCH 10/19] commit-reach.c: allow remove_redundant to handle arbitrary repositories From: Stefan Beller To: git@vger.kernel.org Cc: 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 aacd8cdc1e..bce4169f1f 100644 --- a/commit-reach.c +++ b/commit-reach.c @@ -153,7 +153,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 @@ -171,7 +171,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; @@ -187,7 +187,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; @@ -246,7 +246,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); @@ -367,7 +367,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 16 23:35:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Beller X-Patchwork-Id: 10644337 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 0CD1F157A for ; Tue, 16 Oct 2018 23:36:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F137A295F3 for ; Tue, 16 Oct 2018 23:36:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E5A642980D; Tue, 16 Oct 2018 23:36:23 +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 9392D295F3 for ; Tue, 16 Oct 2018 23:36:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727331AbeJQH3G (ORCPT ); Wed, 17 Oct 2018 03:29:06 -0400 Received: from mail-qk1-f201.google.com ([209.85.222.201]:57298 "EHLO mail-qk1-f201.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727208AbeJQH3G (ORCPT ); Wed, 17 Oct 2018 03:29:06 -0400 Received: by mail-qk1-f201.google.com with SMTP id l75-v6so25348569qke.23 for ; Tue, 16 Oct 2018 16:36: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=ITi3CUeG+Fw1uRxnQr+Xhmbstp7jF99+55WE3tvDj3Q=; b=J2TrsmYM11eEVTQUlUfq89s+PA4PXcAULdLtAe6E5N85gRbHd1C743erCj7UVI0hce hqOAhLgeJZ7DX4djixg1jLThBe/qfmGulU7l3d21rDMfR4mWa9pabRWnMfvW6ClY3jVs C/LcRJBSIl6Ah0XNFss+yeaxXWER8Wvsmie/nLJxs+4as+xVa4zy9CWmp3LGDmi+HnuU Bh3Ly0UVprf+l+evtzCGRWWrjjZnT4q21UHXylsgdkhmMxEbDghpWaGBx1/HXB+sgpyF XCGfqx5FeDSD5CaVjl2ndjvSDdZ7PJi7ZI7SiYKe7vYGEexXDHxG+82U+xzVIch2IG6L Az7w== 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=ITi3CUeG+Fw1uRxnQr+Xhmbstp7jF99+55WE3tvDj3Q=; b=sJXWr8w5ptfPaDM3fjXNR12xQWJCTItZstcpET+oiLF+3O2VxajPy2D83NHcKqfEiy YdUtv05K/Veu1xKvAqB7uTYPGNqRPww/Yr8R90xkZ0moyfR9winb9JKzWe8B+9Pot9Yi pEsoO4E+IAqydwGshNVpUrZPlXoC+Fx6sK5eyn5lRH5FadSB6ZuZJJy27kJrC9A7oXJd dfTS61NMB5ir2h1PvQk82IPVpXdZSlfW49vsgJpzDGO4NzOPszihLYt9Az4Xi42RTvbe diRZytfNC1p14bZIH1Vcc2IKpq7qhwwCHgCoLxJ6v9dxxRh1AgzowXNnuTvhuQ+1/IzT M5mw== X-Gm-Message-State: ABuFfogItZhK6QmG6HtLDZdYd5Nt9n2kVaIPjWJvBdwpJCnYG8UWMSxU ws6W9BY1yryL2nrrKKBlVZsJt+SXAvXqJPjDu59FkoFzR2oaxOaLrnPH1nJJNPfmXWwKVubFhdl SeMy0g58g+wwE1HTO8LSfqVma1uk8NGlgTkT08JvGoe5opn1FucdNYqRGzNk0 X-Google-Smtp-Source: ACcGV63R9wIqdoSrcd++Er2s7lrMrwpSsHc9PgLyHCyZL3Qf15L2wOB2inQYPVmztN11ZDBQHK/6NVy50PDu X-Received: by 2002:ac8:396b:: with SMTP id t40-v6mr19274220qtb.16.1539732981236; Tue, 16 Oct 2018 16:36:21 -0700 (PDT) Date: Tue, 16 Oct 2018 16:35:42 -0700 In-Reply-To: <20181016233550.251311-1-sbeller@google.com> Message-Id: <20181016233550.251311-12-sbeller@google.com> Mime-Version: 1.0 References: <20181016233550.251311-1-sbeller@google.com> X-Mailer: git-send-email 2.19.0 Subject: [PATCH 11/19] commit-reach.c: allow get_merge_bases_many_0 to handle arbitrary repositories From: Stefan Beller To: git@vger.kernel.org Cc: 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 bce4169f1f..df93274966 100644 --- a/commit-reach.c +++ b/commit-reach.c @@ -213,7 +213,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) @@ -223,7 +224,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; @@ -246,7 +247,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); @@ -258,19 +259,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 16 23:35:43 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Beller X-Patchwork-Id: 10644339 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 EFBCF1057 for ; Tue, 16 Oct 2018 23:36:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DEA93295F3 for ; Tue, 16 Oct 2018 23:36:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D1C462980D; Tue, 16 Oct 2018 23:36:26 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, USER_IN_DEF_DKIM_WL autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 669EE295F3 for ; Tue, 16 Oct 2018 23:36:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727336AbeJQH3J (ORCPT ); Wed, 17 Oct 2018 03:29:09 -0400 Received: from mail-vk1-f201.google.com ([209.85.221.201]:53515 "EHLO mail-vk1-f201.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727208AbeJQH3J (ORCPT ); Wed, 17 Oct 2018 03:29:09 -0400 Received: by mail-vk1-f201.google.com with SMTP id y199-v6so2800214vkd.20 for ; Tue, 16 Oct 2018 16:36: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=90I3ZaHEDfqV9PlVbEeEV15eRRK2DkNuwP+KtUDdzOI=; b=eopI4VH1m2267dXEoJVkrxEA5eyZR3dbTfUqb4Zcg57qwEUB1AYrNQbJZDcKSfNo/b JU+KZC+B4mJeqgzbewktJRVoCvmwb0LMN+m19u8VAZQtoFCLsEfrUlxoBQhU52nqdW7c pytKlQZ550MN8MFMi4bxVqyy6p2AvURbeC3pgRHVULqp4RCgAOjwt4OKi4jN/BVGOSwC 1YLA4OEECecA9zzCxXzRlBjTEh13PIgwSYE7/4nfSB6ttGaXgVcJ+4WLhJe8+6kY6+UK abipHTCrVoCFzfOGM2AAgZyRK+LG2QKINBahx6X1xPCZFCL9YeyDR3sNADxe06/LXoLj HXNA== 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=90I3ZaHEDfqV9PlVbEeEV15eRRK2DkNuwP+KtUDdzOI=; b=aJ1BnF52KNArwXv9shgBkDgtzPwMM9U/CUn26pJpJ7L3jTFt/FYMmzluMPZZ+6Jt7M FXkn0rERQCr29jUtUehyV2MlQ+XUG4ra2q/TCFl+55LrY3bE+9V2ITG5GwDYaxj7/Ghz /gkzj4bRQuVcJhMZn+1sYmYKywUYjz6JJX4sCLIZA6xtLks3mPMv5QVvNlbHebqYmp0W XedUrWK3W/UvS/MrTj1a+sbUkeyKB1flWsfx6Jtsi8e0uj8EKRxmhjZokCcfoxuNmowU +AU8vzRiIx5sbhzKTxziogdX7Wi24UJbPr2yIJ2R+iphfu4wNOJUmsCQ+NdnVoTWNchm tkmA== X-Gm-Message-State: ABuFfojCAlNP7n/I2zoBrfVRF4TMmM34SDoWR1u87P46N+JRPiEXFTQg 2yjfI4fBNHCLdHZ8OHIZYX5K4hsvwGPvKkR9qrxt+orp0UiXsSs/nyu/oYYeMM1oKi21U6/0GmY giCEX19RMJfnHk/JRX93F+bzCNFVeEb+AtfixlqQI5zxw1Tca9a8HCnTb7drm X-Google-Smtp-Source: ACcGV60tN8aqo8/VYUv0wPCDgzorazla0TRPlm1NdNBY2nUZdMJPjKch5VxxAQ6tjosQJiUUmX/71AHAcWi5 X-Received: by 2002:ab0:2916:: with SMTP id v22mr22302732uap.23.1539732983601; Tue, 16 Oct 2018 16:36:23 -0700 (PDT) Date: Tue, 16 Oct 2018 16:35:43 -0700 In-Reply-To: <20181016233550.251311-1-sbeller@google.com> Message-Id: <20181016233550.251311-13-sbeller@google.com> Mime-Version: 1.0 References: <20181016233550.251311-1-sbeller@google.com> X-Mailer: git-send-email 2.19.0 Subject: [PATCH 12/19] commit-reach: prepare get_merge_bases to handle arbitrary repositories From: Stefan Beller To: git@vger.kernel.org Cc: 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 +++++++++++++++--------- contrib/coccinelle/the_repository.cocci | 27 +++++++++++++++++++++++++ 3 files changed, 57 insertions(+), 20 deletions(-) diff --git a/commit-reach.c b/commit-reach.c index df93274966..aa3cde5c8a 100644 --- a/commit-reach.c +++ b/commit-reach.c @@ -255,23 +255,27 @@ static struct commit_list *get_merge_bases_many_0(struct repository *r, return result; } -struct commit_list *get_merge_bases_many(struct commit *one, - int n, - struct commit **twos) +struct commit_list *repo_get_merge_bases_many(struct repository *r, + struct commit *one, + int n, + struct commit **twos) { - return get_merge_bases_many_0(the_repository, one, n, twos, 1); + return get_merge_bases_many_0(r, one, n, twos, 1); } -struct commit_list *get_merge_bases_many_dirty(struct commit *one, - int n, - struct commit **twos) +struct commit_list *repo_get_merge_bases_many_dirty(struct repository *r, + struct commit *one, + int n, + struct commit **twos) { - return get_merge_bases_many_0(the_repository, one, n, twos, 0); + return get_merge_bases_many_0(r, one, n, twos, 0); } -struct commit_list *get_merge_bases(struct commit *one, struct commit *two) +struct commit_list *repo_get_merge_bases(struct repository *r, + struct commit *one, + struct commit *two) { - return get_merge_bases_many_0(the_repository, one, 1, &two, 1); + return get_merge_bases_many_0(r, one, 1, &two, 1); } /* diff --git a/commit-reach.h b/commit-reach.h index 7d313e2975..52667d64ac 100644 --- a/commit-reach.h +++ b/commit-reach.h @@ -8,17 +8,23 @@ struct commit_list; struct contains_cache; struct ref_filter; -struct commit_list *get_merge_bases_many(struct commit *one, - int n, - struct commit **twos); -struct commit_list *get_merge_bases_many_dirty(struct commit *one, - int n, - struct commit **twos); -struct commit_list *get_merge_bases(struct commit *one, struct commit *two); -struct commit_list *get_octopus_merge_bases(struct commit_list *in); - +struct commit_list *repo_get_merge_bases(struct repository *r, + struct commit *rev1, + struct commit *rev2); +struct commit_list *repo_get_merge_bases_many(struct repository *r, + struct commit *one, int n, + struct commit **twos); /* To be used only when object flags after this call no longer matter */ -struct commit_list *get_merge_bases_many_dirty(struct commit *one, int n, struct commit **twos); +struct commit_list *repo_get_merge_bases_many_dirty(struct repository *r, + struct commit *one, int n, + struct commit **twos); +#ifndef NO_THE_REPOSITORY_COMPATIBILITY_MACROS +#define get_merge_bases(r1, r2) repo_get_merge_bases(the_repository, r1, r2) +#define get_merge_bases_many(one, n, two) repo_get_merge_bases_many(the_repository, one, n, two) +#define get_merge_bases_many_dirty(one, n, twos) repo_get_merge_bases_many_dirty(the_repository, one, n, twos) +#endif + +struct commit_list *get_octopus_merge_bases(struct commit_list *in); int is_descendant_of(struct commit *commit, struct commit_list *with_commit); int in_merge_bases_many(struct commit *commit, int nr_reference, struct commit **reference); diff --git a/contrib/coccinelle/the_repository.cocci b/contrib/coccinelle/the_repository.cocci index b185fe0a1d..5e037fe428 100644 --- a/contrib/coccinelle/the_repository.cocci +++ b/contrib/coccinelle/the_repository.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 16 23:35:44 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Beller X-Patchwork-Id: 10644341 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 92B441057 for ; Tue, 16 Oct 2018 23:36:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 81E68295F3 for ; Tue, 16 Oct 2018 23:36:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 763EB2980D; Tue, 16 Oct 2018 23:36:28 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, USER_IN_DEF_DKIM_WL autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 107D8295F3 for ; Tue, 16 Oct 2018 23:36:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727348AbeJQH3L (ORCPT ); Wed, 17 Oct 2018 03:29:11 -0400 Received: from mail-qt1-f201.google.com ([209.85.160.201]:41139 "EHLO mail-qt1-f201.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727208AbeJQH3L (ORCPT ); Wed, 17 Oct 2018 03:29:11 -0400 Received: by mail-qt1-f201.google.com with SMTP id j60-v6so26161135qtb.8 for ; Tue, 16 Oct 2018 16:36:26 -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=lJ5XnWmMwZgP2dNtMbW8UO/ykc24nZuOEeoq/IQXo6U=; b=jKPPDtJ+gDybqw6SaM908zJXt8TE/o85ziZl1ATOSlx+xGh3JewcoJ+ClgYzv6I+Ap 2mDvfEVNWm9WD4VOEs+FB48h37jjOxgxvS9K0qT3s+bngjJ4PTlxK64mZgpVtXm+CKJl minyD5FSK/hjE3XmNs9nETr4h8Y834+A2HVNt26zvMKUrSeCw/OG3snuCmJLNl3lGWf0 elKidj1IqY0fWBNE27sQzyE7Z3bUWkz8WiPzSVKZ94KmPKdkKyS8qJQUgoZfTwmerwGd zzcqy17baQKdnc2y+TjzFislO9wAOqrbvSPfxiB1kpwmmArZLaocEuwMFaXRj9X4v3qP NSPg== 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=lJ5XnWmMwZgP2dNtMbW8UO/ykc24nZuOEeoq/IQXo6U=; b=jhk2L3VXMd0Ry8a8wO0YgyM8WKBnW7dp8u9suUjlzIPrSaIuNCEuCmX/GyIeD1a2wb afqYFWxl/45sTX6yyReIpNkBeEKt4o3YKkkVV9EBYWwqB0dhaChAarZ/kopGOAZZX8VP 3kKynW2OKYR9qsZVGuCAHUhG3pGu9vj5MUaQT5yEzj8Kqat0eInKIMXCoJx+4aW8hdEo 0YerSm+6h/WE1VQuYMLXC51hrmrvKnekxz2gyIg2Acpg7IQYksWmAbU+iYpeqW/MTvyx 12SpHFTF/Xa08VBAy9ZFLIlHgcKfIYKO/WnHbr1d5lDZhzoGqakfDCyhNohau8GUnurp 3gHA== X-Gm-Message-State: ABuFfogj4ojLMmiU9sHHF7JxzsdqwgeJd9/VBWsobW+J5lA5HwyJIoF6 pr82gx6QCy4YPvYprlcnvR4xzpKsmXa4icxp5cRL+8UO4qh4MpN+PR0l50P5sGJuL9BoE8EQw7O PChmUHAPAlHppTl9/CWNmIZhJyuIlxgoZz9shhAzIpYv9iTIRH/8oz7aksLBz X-Google-Smtp-Source: ACcGV62JmhhwUF+lhpskG5mjni36G3Hy1Ksyof9v8ADfGq7o9wc1MnO4dWsbBmufKoQN+LfznNMSD/P5y8sU X-Received: by 2002:a0c:88b2:: with SMTP id 47mr19355242qvn.58.1539732985803; Tue, 16 Oct 2018 16:36:25 -0700 (PDT) Date: Tue, 16 Oct 2018 16:35:44 -0700 In-Reply-To: <20181016233550.251311-1-sbeller@google.com> Message-Id: <20181016233550.251311-14-sbeller@google.com> Mime-Version: 1.0 References: <20181016233550.251311-1-sbeller@google.com> X-Mailer: git-send-email 2.19.0 Subject: [PATCH 13/19] commit-reach: prepare in_merge_bases[_many] to handle arbitrary repositories From: Stefan Beller To: git@vger.kernel.org Cc: 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.cocci | 16 ++++++++++++++++ 3 files changed, 35 insertions(+), 8 deletions(-) diff --git a/commit-reach.c b/commit-reach.c index aa3cde5c8a..1877f356e3 100644 --- a/commit-reach.c +++ b/commit-reach.c @@ -309,16 +309,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; @@ -327,7 +328,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) @@ -341,9 +342,11 @@ int in_merge_bases_many(struct commit *commit, int nr_reference, struct commit * /* * Is "commit" an ancestor of (i.e. reachable from) the "reference"? */ -int in_merge_bases(struct commit *commit, struct commit *reference) +int repo_in_merge_bases(struct repository *r, + struct commit *commit, + struct commit *reference) { - return in_merge_bases_many(commit, 1, &reference); + return repo_in_merge_bases_many(r, commit, 1, &reference); } struct commit_list *reduce_heads(struct commit_list *heads) diff --git a/commit-reach.h b/commit-reach.h index 52667d64ac..a0d4a29d25 100644 --- a/commit-reach.h +++ b/commit-reach.h @@ -27,8 +27,16 @@ struct commit_list *repo_get_merge_bases_many_dirty(struct repository *r, struct commit_list *get_octopus_merge_bases(struct commit_list *in); int is_descendant_of(struct commit *commit, struct commit_list *with_commit); -int in_merge_bases_many(struct commit *commit, int nr_reference, struct commit **reference); -int in_merge_bases(struct commit *commit, struct commit *reference); +int repo_in_merge_bases(struct repository *r, + struct commit *commit, + struct commit *reference); +int repo_in_merge_bases_many(struct repository *r, + struct commit *commit, + int nr_reference, struct commit **reference); +#ifndef NO_THE_REPOSITORY_COMPATIBILITY_MACROS +#define in_merge_bases(c1, c2) repo_in_merge_bases(the_repository, c1, c2) +#define in_merge_bases_many(c1, n, cs) repo_in_merge_bases_many(the_repository, c1, n, cs) +#endif /* * Takes a list of commits and returns a new list where those diff --git a/contrib/coccinelle/the_repository.cocci b/contrib/coccinelle/the_repository.cocci index 5e037fe428..8c6a71bf64 100644 --- a/contrib/coccinelle/the_repository.cocci +++ b/contrib/coccinelle/the_repository.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 16 23:35:45 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Beller X-Patchwork-Id: 10644343 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 9B7AB157A for ; Tue, 16 Oct 2018 23:36:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8BE96295F3 for ; Tue, 16 Oct 2018 23:36:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8045B2980D; Tue, 16 Oct 2018 23:36: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 28A62295F3 for ; Tue, 16 Oct 2018 23:36:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727352AbeJQH3N (ORCPT ); Wed, 17 Oct 2018 03:29:13 -0400 Received: from mail-io1-f73.google.com ([209.85.166.73]:33878 "EHLO mail-io1-f73.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727208AbeJQH3N (ORCPT ); Wed, 17 Oct 2018 03:29:13 -0400 Received: by mail-io1-f73.google.com with SMTP id y3-v6so23073218iob.1 for ; Tue, 16 Oct 2018 16:36:28 -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=3gHZxvmy6BQ5j1K5mVW5xHRXGJDY/6tRKrsUKBLQlXw=; b=dPpFAJ5JW1XVyO97lZ/mfmoAS4/kI+2de9hRw1+uHW4y7r84d9oCxUuLyIMkvhmBt1 C3C2V5VUXA/D1axjuaGxUMUNsxnNkqq3seWLMLdGVgFeHm7sproX22hVgFy4swsDFnuc KWgU08sNOCwHI11od8kVWoHdxaZlCbocrv9qv/UWF2Wyi5ssx42xSjaHkrt3cYWEDA9F FXelD5RT0kLHC9ASPinKZmZckuRlFIcvTgNy51QPx+VEHpZZ0iaGY87en7MbikTYyBXb IiEhO9wi6ErzlSMJG1qmAmL7jsCz9PVUCzppyKtZiCBokhGUdgniKZB7CPVC3qMIKMjE praA== 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=3gHZxvmy6BQ5j1K5mVW5xHRXGJDY/6tRKrsUKBLQlXw=; b=LkW2qnkVAdeRT3YJm66hR/MJXl7Jri5s8opmpT0gh/jx2KfHk6wGChBnrVEAFbLdk9 VvCSKqDH5cTA2FWg1FT+2oiTq1WugtAuhWbsjHxISl0M5bnjAGnXHzn3uJSn1ToxEzpx 5BepK1xA0YbG/Cx4ym9GGrhui1IHDvQhjHjCvgsPCnaUogdi8ilIHjhQY/u+Bn+IXPzb D03JFzS53OCJRXmqo/x3FISSaQUhC8Ijw1Pi+uABoJuA05p/dR4G46JPAz5NbCZGwhYn uCYVq9iMcY8xePH1C6DT6sEqeUzt/P4UjACTU29jgs9WxQ7i5YS3MWDfnL9eYG1Cc1Nb RyAQ== X-Gm-Message-State: ABuFfohuFC8tY3jrzHLAz7FB8qzRtya6j68sJtJgj4pyWa+TOJ5Rogtr ta4QrVECi5e9Jm4r55sD6VBOxk0sMHuAdELEauoHXUzDZ9DFvYgiBwIPvS93m0oEdlj/HI6RdK2 I0WFIbdz5gMSd5wUM/WI6cP3RJHjo2uywuLJ2aBkdrPSK0SwgO+0cefO/suCI X-Google-Smtp-Source: AJdET5dDAtKJoljfoD4+grGbMrsleJg1ckYW663Mxr8CExIeBYL4wwrmwyzHizzFkgxsebtYVnT/iWodNIAk X-Received: by 2002:a05:660c:b0c:: with SMTP id f12mr179746itk.22.1539732988016; Tue, 16 Oct 2018 16:36:28 -0700 (PDT) Date: Tue, 16 Oct 2018 16:35:45 -0700 In-Reply-To: <20181016233550.251311-1-sbeller@google.com> Message-Id: <20181016233550.251311-15-sbeller@google.com> Mime-Version: 1.0 References: <20181016233550.251311-1-sbeller@google.com> X-Mailer: git-send-email 2.19.0 Subject: [PATCH 14/19] commit: prepare get_commit_buffer to handle arbitrary repositories From: Stefan Beller To: git@vger.kernel.org Cc: 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.cocci | 8 ++++++++ 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/commit.c b/commit.c index fe942754e2..cc5321af8c 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 58a0c5409b..b8437f66e2 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.cocci b/contrib/coccinelle/the_repository.cocci index 8c6a71bf64..4018e6eaf7 100644 --- a/contrib/coccinelle/the_repository.cocci +++ b/contrib/coccinelle/the_repository.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 16 23:35:46 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Beller X-Patchwork-Id: 10644345 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 BC541157A for ; Tue, 16 Oct 2018 23:36:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AE8FD295F3 for ; Tue, 16 Oct 2018 23:36:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A2F3D2980D; Tue, 16 Oct 2018 23:36: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 4DC39295F3 for ; Tue, 16 Oct 2018 23:36:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727364AbeJQH3P (ORCPT ); Wed, 17 Oct 2018 03:29:15 -0400 Received: from mail-pl1-f201.google.com ([209.85.214.201]:50990 "EHLO mail-pl1-f201.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727208AbeJQH3P (ORCPT ); Wed, 17 Oct 2018 03:29:15 -0400 Received: by mail-pl1-f201.google.com with SMTP id ba5-v6so15666340plb.17 for ; Tue, 16 Oct 2018 16:36:30 -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=ReCRIleJDeibh9gTQRtBubKvPIUIX1xgVfM26n5rPI0=; b=IxAJF1cRDJ/GjMkdMfLpLn4G53ND4wsfEQLDJg1ArJAlyr5Fhj27Xw46tcvgE6+AH4 xj7sns+7Rz/mzaFb93tt48SFHqkh7ZfPxotSsukAJ6C8T+nUF1067SB1y62KSvovPK9z A9Xg1tc2Lk3jXRtHUFmNeGsfnb1w7SaIYk2ZmgzyLHPFccin+MoDkst4x3tdrsDBtHWF v4lNbAMVwUWar1RZEh3smoAm22VeA4ivs/AGUsDK5C+LBRb0HrFI04TGI9DZzCf218yq RHGaUELJ3rgk6hGtGr3+3xS/7WcraDvU0HZfOFZCoB4qyFq3CJNyEZAkdaX7Y9SuOvUX D8gA== 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=ReCRIleJDeibh9gTQRtBubKvPIUIX1xgVfM26n5rPI0=; b=sFMmoeZYNdJjqzyEKVoxdTkIAHhjJ6VVyhaMcXuxzWU4zrESky+PM+HQ6NqQA/u3OX 5O76f4Ttosa2dvPi0CBtIniiSEmmzBw5runeew4XmyaQ+bqY9RK/iY9KBc1p0cEFipVC FuJ4WmzT2KDcqahn8E1yQUTCU8yx0UCPeISX9W2Krn3Y+D8aWpy4vxCJMFKS5SCzRrr1 OooalHT5uGehjR//MyieByPw3ACuzWUVpDGcVVg/3igCnLgIty4eMvDa6youEsQfG634 1ryq7ZHxdxLZpDXjMVMbSwZxU+I60+NxfRVmsMLY5xXbS4MHZiiE41qWIyddxnThrDCn 7NDQ== X-Gm-Message-State: ABuFfojtlRotGpJwKM35c+kI/AL3NtirE3MEe1y359OX/cnNw9c2AnOx gIq5FnxLbb8+BXI9/pXfX6w2wRGM7banZVH3KiD+or6gI8Nux/13J3rfoHjzu3aRHYvXlW2w0bX xUgDHRlrDP6ejDuSwTI8DvZzs42zA6JleUR5TlMFyMZmyDT7pcQLWkoxg/U3A X-Google-Smtp-Source: ACcGV610k9WD8CD1uhHkgyzwUlQL3ncGL6m46Liyy32X7am04ZvzbEQE6HZLtLEEmsWwpuzi/iyAzE564/PL X-Received: by 2002:a63:d347:: with SMTP id u7-v6mr11584972pgi.30.1539732990240; Tue, 16 Oct 2018 16:36:30 -0700 (PDT) Date: Tue, 16 Oct 2018 16:35:46 -0700 In-Reply-To: <20181016233550.251311-1-sbeller@google.com> Message-Id: <20181016233550.251311-16-sbeller@google.com> Mime-Version: 1.0 References: <20181016233550.251311-1-sbeller@google.com> X-Mailer: git-send-email 2.19.0 Subject: [PATCH 15/19] commit: prepare repo_unuse_commit_buffer to handle arbitrary repositories From: Stefan Beller To: git@vger.kernel.org Cc: 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.cocci | 8 ++++++++ 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/commit.c b/commit.c index cc5321af8c..8e7b1138f7 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 b8437f66e2..f3ef497723 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.cocci b/contrib/coccinelle/the_repository.cocci index 4018e6eaf7..516f19ffee 100644 --- a/contrib/coccinelle/the_repository.cocci +++ b/contrib/coccinelle/the_repository.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 16 23:35:47 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Beller X-Patchwork-Id: 10644347 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 69D051057 for ; Tue, 16 Oct 2018 23:36:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 59955295F3 for ; Tue, 16 Oct 2018 23:36:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 494682980D; Tue, 16 Oct 2018 23:36:35 +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 DC082295F3 for ; Tue, 16 Oct 2018 23:36:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727370AbeJQH3S (ORCPT ); Wed, 17 Oct 2018 03:29:18 -0400 Received: from mail-io1-f74.google.com ([209.85.166.74]:47914 "EHLO mail-io1-f74.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727208AbeJQH3S (ORCPT ); Wed, 17 Oct 2018 03:29:18 -0400 Received: by mail-io1-f74.google.com with SMTP id c21-v6so23225276ioi.14 for ; Tue, 16 Oct 2018 16:36: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=kf7dkkDmp9teoinVZKskkWrxffP1vLtclk6rRR7i+F4=; b=sVp41HCKOlY3AvPnep5YKmTWsL50zWcFB1DW6Z9jp08T7RjAUD8me4OiHMpUPyrObm jTyGN7BMRplGQMCke78iIjKI/L0MWxGgJYiaJkUgF0ly9Fdm+049z/fbt+O2MHuVHDhE 70JsmcLJnXodf3Ql648k7Aps3uwIEvVtAuIqqi4T1xo0xpFJUSEEW0f+YeCM3gcjrrdn eeaoforwcnNriT7pa3u4PKoz/10iY5b8rYRoF3hRLt4YQ/pkgyJ0IcN+bNcfYeKTzCau 5Ay66BR92ivTaj5Xe96ybWyomWkQFCVdwMjolwvHRElUa8oyq6FkAJaDWROXqXEm6RpP 4L2w== 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=kf7dkkDmp9teoinVZKskkWrxffP1vLtclk6rRR7i+F4=; b=gYDu4sHvhOwNUOUS8zepzcloderE9/f80EqOY/6lGWAmga2+QjsU4TOlQcTXLcippV hCgTuqs+b9yKSSI9fp2ZKQ1vziX/npk5bo27AeTJViOl3LD+SClMBsA9BVdOcE5/h6p8 3DyTd+o1YtUx4k8YenCgH3sI3TVkU2qlxZk+boUDDpWDEjbGbDLXSwQsxsnVEZA2dX+W dq8qlYWfAozRGdruCSNbW8KNkpvV77dETORzpP9HXA/yM00PFgKzviGQAqbwQNwVMz4n 2nhzzKByCBkqqDVZPVCOqrOZXKyNhc9gALWqrHqGK1XIDqMbTuk9FS1uwQWjfI6tYU0n 3ubg== X-Gm-Message-State: ABuFfohCIRErE7WRXEJRLPNzSsDCv+LlQ+aVQCusysYHBH/0CA3MDhWs kWydKuPSkLpkXZU27i3+4XU5OXSvCPAAbIiJAy8oZf7RqJ61boJkqbt59TmeywYecOqyMhX5MAV oguYbFoXLVLlJ8arwBQxC7M63IjbQcK5GkRCor0V/hFbMenDE+1DnG845l5qs X-Google-Smtp-Source: ACcGV63M9jqzZkM2es6cxQxjQV9X3WfKVMSI6h5UW+CE8dIGpwKtZa6jatfGBlHlao/j96FoR7ZZEqT+cRnd X-Received: by 2002:a24:2153:: with SMTP id e80-v6mr18770229ita.1.1539732992549; Tue, 16 Oct 2018 16:36:32 -0700 (PDT) Date: Tue, 16 Oct 2018 16:35:47 -0700 In-Reply-To: <20181016233550.251311-1-sbeller@google.com> Message-Id: <20181016233550.251311-17-sbeller@google.com> Mime-Version: 1.0 References: <20181016233550.251311-1-sbeller@google.com> X-Mailer: git-send-email 2.19.0 Subject: [PATCH 16/19] commit: prepare logmsg_reencode to handle arbitrary repositories From: Stefan Beller To: git@vger.kernel.org Cc: 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.cocci | 9 +++++++++ pretty.c | 13 +++++++------ 3 files changed, 24 insertions(+), 6 deletions(-) diff --git a/commit.h b/commit.h index f3ef497723..b69a4b140d 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.cocci b/contrib/coccinelle/the_repository.cocci index 516f19ffee..f5b42cfc62 100644 --- a/contrib/coccinelle/the_repository.cocci +++ b/contrib/coccinelle/the_repository.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 98cf5228f9..26e44472bb 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 16 23:35:48 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Beller X-Patchwork-Id: 10644349 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 DF07B157A for ; Tue, 16 Oct 2018 23:36:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D0F8D295F3 for ; Tue, 16 Oct 2018 23:36:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C4E312980D; Tue, 16 Oct 2018 23:36: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 6471E295F3 for ; Tue, 16 Oct 2018 23:36:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727375AbeJQH3U (ORCPT ); Wed, 17 Oct 2018 03:29:20 -0400 Received: from mail-qt1-f201.google.com ([209.85.160.201]:56008 "EHLO mail-qt1-f201.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727208AbeJQH3U (ORCPT ); Wed, 17 Oct 2018 03:29:20 -0400 Received: by mail-qt1-f201.google.com with SMTP id 4-v6so25533046qtt.22 for ; Tue, 16 Oct 2018 16:36:35 -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=mf0127A88T9D12csagKn0A3wu6HACc8QzwWc1taLNPk=; b=P3A8S1o4cIFu7J1Gw0dYJmTpkreDwC5NAzzQ6QuBoI4WWMY6p2g8IFbFPOgfFEzDHf 4gfSQeblMPpW/inVXxKXh3Vf0MPjKBHuTK86rH9a4u/Jk0BKQNXta3Sh+G/kv45yqQVQ i6epcLdDCAgsrejz1eeNAiOtQlSjs6gcXPO5dck2HVO/yeyZbyooItgSJWO6kPQjip/x IgFMVVPtSrpV5ZxIJlnB9gvk46tVAo0LaXjRDz+M3nzQkDkygh+NR4qbbTaKeFfXcKxY BGwLP8/YCXLwkkdfNqVAzCSKgLnv+9QQpnAqGZL7NtXKbwk4Kdo90lZWWiwaWRFDeIRU x0HQ== 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=mf0127A88T9D12csagKn0A3wu6HACc8QzwWc1taLNPk=; b=MQ4lleJT5np6x/3Os4XUoAz4DEIxh1Xa2PJqEDH+0kJTBNxPgtO4xqWwi+GiBmrOix WKmm1RFCVm4UmRujWGP67kuCAgCtNlR9je04zbMeCJgy0q8+pObBzRDn6LpGWFnCgv66 IAaEOVAyu0DEuM8WXRGqfKtUD2WJ4UtHG7rf3jDKfMIimtcHz97DpaxHRVtg3/AwitZC sjdHrw3yeU0Woss6XUygdx/NGU0yTeqQp+6T3TGCItwHAh0ary7EMSCdcxiukyWVeVb4 nvtu9gDkuZduYImlbAwFHXt9sRVVN9zlw0jSsGxgFrLx7E8m5/1ooi+JejOal2ms0Eo9 VJLw== X-Gm-Message-State: ABuFfohN2C4r4pxF+FFLQmTcIe6XSXKs4qbppCtV90gFpck7jptUjTOK Pxawezo1MBF9CrEdux+Ehw/9zjl1LpqzK3rr1TBaBs4wzkO7L+Bw6je+FI+iKGRY+LbHDdzl5XF ZBXFAnglHY/EB6XkmrUDWgZoxirRaTD9PAfsJMFb4m5H0tYEZEzLL+L4/LMNr X-Google-Smtp-Source: ACcGV61of95dTBxubxDlDqOVanLUB8IlLKLgDoBI5DsjaxbEzz9BrsUj/ZfEIITm+rknjmuq6t7Cva3weKkN X-Received: by 2002:aed:3805:: with SMTP id j5-v6mr19915659qte.48.1539732994851; Tue, 16 Oct 2018 16:36:34 -0700 (PDT) Date: Tue, 16 Oct 2018 16:35:48 -0700 In-Reply-To: <20181016233550.251311-1-sbeller@google.com> Message-Id: <20181016233550.251311-18-sbeller@google.com> Mime-Version: 1.0 References: <20181016233550.251311-1-sbeller@google.com> X-Mailer: git-send-email 2.19.0 Subject: [PATCH 17/19] pretty: prepare format_commit_message to handle arbitrary repositories From: Stefan Beller To: git@vger.kernel.org Cc: 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.cocci | 10 ++++++++++ pretty.c | 15 ++++++++------- pretty.h | 7 ++++++- 3 files changed, 24 insertions(+), 8 deletions(-) diff --git a/contrib/coccinelle/the_repository.cocci b/contrib/coccinelle/the_repository.cocci index f5b42cfc62..2ee702ecf7 100644 --- a/contrib/coccinelle/the_repository.cocci +++ b/contrib/coccinelle/the_repository.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 26e44472bb..948f5346cf 100644 --- a/pretty.c +++ b/pretty.c @@ -1505,9 +1505,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; @@ -1521,9 +1522,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); @@ -1547,7 +1548,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 16 23:35:49 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Beller X-Patchwork-Id: 10644351 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 C1F34157A for ; Tue, 16 Oct 2018 23:36:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B3AF5295F3 for ; Tue, 16 Oct 2018 23:36:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A71672980D; Tue, 16 Oct 2018 23:36:40 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, USER_IN_DEF_DKIM_WL autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 178BF295F3 for ; Tue, 16 Oct 2018 23:36:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727382AbeJQH3X (ORCPT ); Wed, 17 Oct 2018 03:29:23 -0400 Received: from mail-qk1-f201.google.com ([209.85.222.201]:54721 "EHLO mail-qk1-f201.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727208AbeJQH3X (ORCPT ); Wed, 17 Oct 2018 03:29:23 -0400 Received: by mail-qk1-f201.google.com with SMTP id q20-v6so25530898qke.21 for ; Tue, 16 Oct 2018 16:36:37 -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=cqXoTb0n8I2f3M/ULsxlF5lrFrX1VIClbDcV5hntEm8=; b=Vg9BbEyHvP8ahNZewWX7ztCP45oGc9qk4fBXDymXDE4aclWqha06U8exxoMvqo1IXq 4XvW/NusM4+xMu395ZaPYo5ALlMPMG2I++iVjZvmooBL6RhIrZBRUerKmw0h+J18BaL8 ntoyp01sE+ZEqSVwBFzlYU7lI0aPJLZ2wpRfwgAyTQX+3BjMF5x8WOq/no5mbIDdaqGt /EtikjXFdzDeHZGp/nLqFKoP4kXE1qtWdiHZzEB7amKglswqOKhKK3BvTEs0V63Ta1Oc 6EKRjOvzdNCFrcm8qMHNgcf99L5NHLrXJrtbE2SD6gXqQGXKO0Z1DyVyYrUyzgUkqvX2 dTyQ== 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=cqXoTb0n8I2f3M/ULsxlF5lrFrX1VIClbDcV5hntEm8=; b=D8UkyhVRJTfDRK8VqtaCEtVwbt+SCSK1cEm5hTeSDCDGnx5lFvPLNJibPdDZAFp8PT 9hKx0J4T5FkZfQsLwNHnf7s8XC/d6wOLDCdgTPh9ljCZRyyKrW0VAEJhVBwGEnN7C3up 8OxyGobzHqyUrKK+OIx02LXXAoXi/reRRZWMhTKlFZzNB6skHvmqAhWyEbfrqBADhyFm Sz83R3i94GgbyWtEusPHcaCQBe+fdilUFy1yRrLDa6m1a23DN3rK40tHVYURFTowO6P4 Rokwu6EI+2GKfamYYNMophIRFmddi1uP0RgWJHyraNzcighb6j4+zlYurx+lPY2YlAve nTcw== X-Gm-Message-State: ABuFfohJ2wFx4F6oGW96cBfI5PkrkJnsa7/uzDQfbsrHEH/YXnaGXocO NHowFNiUcqbIGQ7r7AqD19cHJfG6vOHddU2/uLwwKzheXBr5p9dPTM8JX/wyR6aC5qoA9i3k5Cr Xy9ZpnReNXLPv5je/jlH84nRkoP71HIPQlTqOygvZpk2i7uVd6to2ysQia4Ft X-Google-Smtp-Source: ACcGV61LMac7sbzIHL/BdCWJ17+UqWWuCh72nVQrx3jYiBoVPO03TWHTbvFlFyg9idIwjIDlSf9fD30SLeQ/ X-Received: by 2002:ac8:22ce:: with SMTP id g14-v6mr19635407qta.49.1539732997393; Tue, 16 Oct 2018 16:36:37 -0700 (PDT) Date: Tue, 16 Oct 2018 16:35:49 -0700 In-Reply-To: <20181016233550.251311-1-sbeller@google.com> Message-Id: <20181016233550.251311-19-sbeller@google.com> Mime-Version: 1.0 References: <20181016233550.251311-1-sbeller@google.com> X-Mailer: git-send-email 2.19.0 Subject: [PATCH 18/19] submodule: use submodule repos for object lookup From: Stefan Beller To: git@vger.kernel.org Cc: 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 | 75 ++++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 60 insertions(+), 15 deletions(-) diff --git a/submodule.c b/submodule.c index 4ee69cc014..7305ae2e10 100644 --- a/submodule.c +++ b/submodule.c @@ -444,7 +444,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; @@ -455,7 +455,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); @@ -482,14 +483,46 @@ void prepare_submodule_repo_env(struct argv_array *out) DEFAULT_GIT_DIR_ENVIRONMENT); } -/* Helper function to display the submodule header line prior to the full - * summary output. If it can locate the submodule objects directory it will - * attempt to lookup both the left and right commits and put them into the - * left and right pointers. +/* + * Initialize '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 int open_submodule(struct repository *out, const char *path) +{ + struct strbuf sb = STRBUF_INIT; + + if (submodule_to_gitdir(&sb, path) || repo_init(out, sb.buf, NULL)) { + strbuf_release(&sb); + return -1; + } + + out->submodule_prefix = xstrdup(path); + out->submodule_prefix = xstrfmt("%s%s/", + the_repository->submodule_prefix ? + the_repository->submodule_prefix : + "", path); + + strbuf_release(&sb); + return 0; +} + +/* + * 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, +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) { @@ -508,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; @@ -518,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 @@ -529,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; @@ -563,16 +596,20 @@ 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 subrepo, *sub = &subrepo; + + if (open_submodule(&subrepo, path) < 0) + sub = NULL; 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 */ @@ -581,13 +618,15 @@ 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); } void show_submodule_inline_diff(struct diff_options *o, const char *path, @@ -599,9 +638,13 @@ 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 subrepo, *sub = &subrepo; + + if (open_submodule(&subrepo, path) < 0) + sub = NULL; 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)) || @@ -662,6 +705,8 @@ 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); } int should_update_submodules(void) From patchwork Tue Oct 16 23:35:50 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Beller X-Patchwork-Id: 10644353 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 5065F1057 for ; Tue, 16 Oct 2018 23:36:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 42677295F3 for ; Tue, 16 Oct 2018 23:36:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 370CD2980D; Tue, 16 Oct 2018 23:36:42 +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 E105A295F3 for ; Tue, 16 Oct 2018 23:36:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727393AbeJQH3Z (ORCPT ); Wed, 17 Oct 2018 03:29:25 -0400 Received: from mail-qt1-f202.google.com ([209.85.160.202]:42161 "EHLO mail-qt1-f202.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727208AbeJQH3Z (ORCPT ); Wed, 17 Oct 2018 03:29:25 -0400 Received: by mail-qt1-f202.google.com with SMTP id d52-v6so26775218qta.9 for ; Tue, 16 Oct 2018 16:36:39 -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=NWRQ5k7NvGE+k2jhE9BAIYBGNc5/3NVu7rXOJ/k2Itg=; b=AQafnxUrmuJRRdIj318mtVbhqvqfVK77wUZpe6EsU6BQ/F5o9SlnvaIxyu9G4lkI4o QsGz9tp3qz9l2UZPHDb/NGjiplMcFzcBHrgAlyrZDoGL9LfWxueO/sMTD/KULqJM58sF qvAehcAsNNVYCMySkfagO4xrQ355Y5IEMHW9JjZnjtyGs8ONYptNtvgWPvAs2D6XTtfB H2i2mY2hYotXwZ6SVzFZ42ttyRxzKbDbmDK7aN/SYjl5egazVyayRnUBRF7RhngiXZuO k2DR2MGU+9j4LrtuzMNafHBVCUlrYnJ2TiITAHj2rmAarUSljuZi6dTNbKVXAm47VJCW YQGQ== 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=NWRQ5k7NvGE+k2jhE9BAIYBGNc5/3NVu7rXOJ/k2Itg=; b=GCVjAMiEv8lcbMpZfjuVevuKUoQF8W3b/UIzdUaLO1rYT3v0wbvumW/hfYIrOkFPir QxypH9YGEHbgm3kE2T1Yk/VbrlsX3fdUEILKnjhGrP+FaF7gntxMqNBlXRKIV0m+AA58 1Ts9ITXuzMGX7j5Y+kpSgQ372iOxPZnZaXfT5vBxHWKQdY7vA4ZugcXiw12aIR5G0L2/ q1o+1YLu5ffvrgSQIjAvFl23EHECCACpJJwdzX+vyXBlMgyPbAb3Nc+oTX/OqEMhk6vh Rbr/22kguAImWZbXmkm7IFIEEXcAWToK4cOJcmQLwMQmA7muFazm20ovzk/RhKofdLhk wdRA== X-Gm-Message-State: ABuFfohz6V6KjHWvgbAnB+lPf57ObKpeGMap9i4/cSmc57weJqinlQZu xHdavl5kGITaCWzimZxafjaq+RmKgYro8ItVb5deyN268YkOz0ELvjlcXCfC3tUiYm2zek15oSk eZWAZND9Gx4golom7jMAXAuGJY2e36mgLO9JiWQhdi89OoAgDZsP/Gj29hB08 X-Google-Smtp-Source: ACcGV63xHzZCQclVvWaciSUjoZdLSrGx1SIhSNeasLB0pBmkno8rXFNwvBKa/vqLlYKghZ2fXmXR29U+SuP5 X-Received: by 2002:a0c:9e2e:: with SMTP id p46mr12563391qve.22.1539732999654; Tue, 16 Oct 2018 16:36:39 -0700 (PDT) Date: Tue, 16 Oct 2018 16:35:50 -0700 In-Reply-To: <20181016233550.251311-1-sbeller@google.com> Message-Id: <20181016233550.251311-20-sbeller@google.com> Mime-Version: 1.0 References: <20181016233550.251311-1-sbeller@google.com> X-Mailer: git-send-email 2.19.0 Subject: [PATCH 19/19] submodule: don't add submodule as odb for push From: Stefan Beller To: git@vger.kernel.org Cc: 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.) Signed-off-by: Stefan Beller --- submodule.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/submodule.c b/submodule.c index 7305ae2e10..e623e6bf7f 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");