From patchwork Wed Nov 14 00:12: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: 10681675 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 C5F8F18F0 for ; Wed, 14 Nov 2018 00:13:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B7DB22A778 for ; Wed, 14 Nov 2018 00:13:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AC0B929E99; Wed, 14 Nov 2018 00:13:36 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, USER_IN_DEF_DKIM_WL autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 50E3429E99 for ; Wed, 14 Nov 2018 00:13:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727318AbeKNKOR (ORCPT ); Wed, 14 Nov 2018 05:14:17 -0500 Received: from mail-vs1-f74.google.com ([209.85.217.74]:32864 "EHLO mail-vs1-f74.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726408AbeKNKOQ (ORCPT ); Wed, 14 Nov 2018 05:14:16 -0500 Received: by mail-vs1-f74.google.com with SMTP id t25so6275490vsk.0 for ; Tue, 13 Nov 2018 16:13:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=jwIa1zFDXQD9Y2fwo2/hJ0BhA1b0pg6o98pFDlcBpw0=; b=Jd99LbtE5PUc1nBCg/oKQGstCd+rO+JbNddXtfCF+1JogNltyIcM8ICRLCb+B+5Xkk 0hcj8aan058mOTz6i6fPkY/9Ss/gVS12AsU6zRizUxf7SFnKkWbnl+WhMSDI9PlyiDUV kreQ5zoLAlbv+rhWmmQU2hY7lYSL975++hRdnSJd+7rxO0EIl4Vru4Gw217PgZdgjEM6 UlguO0YJHs6iSeITBK9Z55a049CXvOrxatRDqe1Lvb84BYUR42gTwkoPkSZX9+T6Fk46 60dp0buTjI1ZBD018FK3JiDV/UPMU9/PIpTLTuWfgu/4If5VClCExv5tE8sklB8HI+3d z3Ug== 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=jwIa1zFDXQD9Y2fwo2/hJ0BhA1b0pg6o98pFDlcBpw0=; b=pXlr3imEIk9eSPalHLga/NzsvkHBUnRwfB8Ns0bcBc9KWzXDOyiM1Oi2YpTKKIzYav YBSZwoCySF4rH6sS7NI7Mr9yHxGUcuwXfDo+bZTmFqbLHyxABSgCvh74oveXpdw+IW79 4MSTDJQpkmO0jiZhDLAayDGo3/RQKL/lAgqciX5DTbP7lIID0LiTm/ImqGHNbatrXf9j Y0cLFnfXNJuw+m625R3h32fkpJfgUZF5wSCJWJfAMzaKmk33GtuybiG9vQT001SFcELR wJIlPegJuK3Cv84RT9n/dgmvGpNje4sPw3SP9oiEc7NkafpCFwklMaPAbBNZD52RXZqB jiDw== X-Gm-Message-State: AGRZ1gJIPq38Qgtaq9kRrEN+nQFcLidzEidq5iaY9imkjl8fwexqphgP bnOCdgGaXOc/Ef0+90GxDu58E79Ty7X/ X-Google-Smtp-Source: AJdET5cNmu8+HlcLd0SD9b+grSoi5qf2I/n3wLXvC6mdFQyNJqHyM3p8Eun8q7wUsxT3mC4gxiDp9/r6AHdu X-Received: by 2002:a1f:9d53:: with SMTP id g80mr6043887vke.3.1542154413357; Tue, 13 Nov 2018 16:13:33 -0800 (PST) Date: Tue, 13 Nov 2018 16:12:44 -0800 In-Reply-To: <20181114001306.138053-1-sbeller@google.com> Message-Id: <20181114001306.138053-2-sbeller@google.com> Mime-Version: 1.0 References: <20181114001306.138053-1-sbeller@google.com> X-Mailer: git-send-email 2.19.1.1215.g8438c0b245-goog Subject: [PATCH 01/23] sha1_file: allow read_object to read objects in arbitrary repositories From: Stefan Beller To: gitster@pobox.com, jonathantanmy@google.com Cc: git@vger.kernel.org, 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 Allow read_object (a file local functon in sha1_file) to handle arbitrary repositories by passing the repository down to oid_object_info_extended. Signed-off-by: Stefan Beller Signed-off-by: Junio C Hamano --- sha1-file.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/sha1-file.c b/sha1-file.c index dd0b6aa873..b8ce21cbaf 100644 --- a/sha1-file.c +++ b/sha1-file.c @@ -1361,7 +1361,9 @@ int oid_object_info(struct repository *r, return type; } -static void *read_object(const unsigned char *sha1, enum object_type *type, +static void *read_object(struct repository *r, + const unsigned char *sha1, + enum object_type *type, unsigned long *size) { struct object_id oid; @@ -1373,7 +1375,7 @@ static void *read_object(const unsigned char *sha1, enum object_type *type, hashcpy(oid.hash, sha1); - if (oid_object_info_extended(the_repository, &oid, &oi, 0) < 0) + if (oid_object_info_extended(r, &oid, &oi, 0) < 0) return NULL; return content; } @@ -1414,7 +1416,7 @@ void *read_object_file_extended(const struct object_id *oid, lookup_replace_object(the_repository, oid) : oid; errno = 0; - data = read_object(repl->hash, type, size); + data = read_object(the_repository, repl->hash, type, size); if (data) return data; @@ -1755,7 +1757,7 @@ int force_object_loose(const struct object_id *oid, time_t mtime) if (has_loose_object(oid)) return 0; - buf = read_object(oid->hash, &type, &len); + buf = read_object(the_repository, oid->hash, &type, &len); if (!buf) return error(_("cannot read sha1_file for %s"), oid_to_hex(oid)); hdrlen = xsnprintf(hdr, sizeof(hdr), "%s %lu", type_name(type), len) + 1; From patchwork Wed Nov 14 00:12: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: 10681677 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 34B1913BF for ; Wed, 14 Nov 2018 00:13:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 255AD299C3 for ; Wed, 14 Nov 2018 00:13:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 19EC42A778; Wed, 14 Nov 2018 00:13:39 +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 B1EC9299C3 for ; Wed, 14 Nov 2018 00:13:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728462AbeKNKOT (ORCPT ); Wed, 14 Nov 2018 05:14:19 -0500 Received: from mail-pf1-f202.google.com ([209.85.210.202]:49846 "EHLO mail-pf1-f202.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726408AbeKNKOT (ORCPT ); Wed, 14 Nov 2018 05:14:19 -0500 Received: by mail-pf1-f202.google.com with SMTP id x62-v6so11728253pfk.16 for ; Tue, 13 Nov 2018 16:13:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=02IgdK8uUOxL7M8ikqLAMdYUjR8Rbj8Lbzj+AnfQFE8=; b=g25bxDjys62g5Txy+d5LSFBja3cGzr9PKdtTfRVGEpoREDK9Yo0F5NTw+0Ulhb2ZL3 jxBx4A5tViNJOQsEWK1KYyX+guyeegPw1VnSJeensUVTxWppSBnBXvY+ICK22dDqs0r9 2Y0me6W3OMCvomGwtpWeilvydqwLQyIJPfWUrza5doCP9OuqFb4w2kgCvtHXEPkEJYhV cgIGEwUf9r0W/qwVjr/9W6jEbCBxXom6iv4bCIo6s03zlxFI29n5gHXuFFOiXKnJP2YR +m79viqJ1PQb9MhdqH42qxtq1HJ7/5piHM+GLphMvDn/gf20tKXy5k557cM4/hZsJY94 68UQ== 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=02IgdK8uUOxL7M8ikqLAMdYUjR8Rbj8Lbzj+AnfQFE8=; b=TTp83lo6YBrxCIdHQqD1+m/Lr4ELT7G4kjKY1exEPTMCF4HUTxwOvJGmwt0wAiHG4+ 4m11n5N1SNqs/3oJJzVoca0uaMAQctaQYkebvYM6YbBycaX9bmd4N663Zmekk+86J3Oq JkXs/lE4055woS6tNhAlqXwRntBLL3DOedA84/dQhOGIl8j7u93pDYthIU6NfmAKVmlg vvHvEKV2Ur0wafPmbRhB0ah34/WvpJBSqdBls5azdYKCkGZX2LpcKmncuxl6XkqCBpWD bRSNEbb3SkcUMKzF9Buoyc+rGQFL5PDu2arlf9pelnmC89UNpmsVxYQWG0PhqnT5+9k+ EeZw== X-Gm-Message-State: AGRZ1gLPPl4rrQAJAI1de5OZmqyU9rxNIy6SFUQ7RMde2tSCTNGz77j8 AqH8ucU3J6ScKIRmL8kRqjdIg2AkIXo4 X-Google-Smtp-Source: AJdET5c4S0jcbiYOGAHtym/nvBrw904qs8BqFEFDJTkluXvD7GuBKIavClG1ZdT47XPlbB2hMTmiw9sF/ePJ X-Received: by 2002:a63:608:: with SMTP id 8mr3195156pgg.139.1542154416511; Tue, 13 Nov 2018 16:13:36 -0800 (PST) Date: Tue, 13 Nov 2018 16:12:45 -0800 In-Reply-To: <20181114001306.138053-1-sbeller@google.com> Message-Id: <20181114001306.138053-3-sbeller@google.com> Mime-Version: 1.0 References: <20181114001306.138053-1-sbeller@google.com> X-Mailer: git-send-email 2.19.1.1215.g8438c0b245-goog Subject: [PATCH 02/23] packfile: allow has_packed_and_bad to handle arbitrary repositories From: Stefan Beller To: gitster@pobox.com, jonathantanmy@google.com Cc: git@vger.kernel.org, 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 has_packed_and_bad is not widely used, so just migrate it all at once. Signed-off-by: Stefan Beller Signed-off-by: Junio C Hamano --- packfile.c | 5 +++-- packfile.h | 2 +- sha1-file.c | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/packfile.c b/packfile.c index 841b36182f..bc2e0f5043 100644 --- a/packfile.c +++ b/packfile.c @@ -1131,12 +1131,13 @@ void mark_bad_packed_object(struct packed_git *p, const unsigned char *sha1) p->num_bad_objects++; } -const struct packed_git *has_packed_and_bad(const unsigned char *sha1) +const struct packed_git *has_packed_and_bad(struct repository *r, + const unsigned char *sha1) { struct packed_git *p; unsigned i; - for (p = the_repository->objects->packed_git; p; p = p->next) + for (p = r->objects->packed_git; p; p = p->next) for (i = 0; i < p->num_bad_objects; i++) if (hasheq(sha1, p->bad_object_sha1 + the_hash_algo->rawsz * i)) diff --git a/packfile.h b/packfile.h index 442625723d..7a62d72231 100644 --- a/packfile.h +++ b/packfile.h @@ -146,7 +146,7 @@ extern int packed_object_info(struct repository *r, off_t offset, struct object_info *); extern void mark_bad_packed_object(struct packed_git *p, const unsigned char *sha1); -extern const struct packed_git *has_packed_and_bad(const unsigned char *sha1); +extern const struct packed_git *has_packed_and_bad(struct repository *r, const unsigned char *sha1); /* * Iff a pack file in the given repository contains the object named by sha1, diff --git a/sha1-file.c b/sha1-file.c index b8ce21cbaf..856e000ee1 100644 --- a/sha1-file.c +++ b/sha1-file.c @@ -1432,7 +1432,7 @@ void *read_object_file_extended(const struct object_id *oid, die(_("loose object %s (stored in %s) is corrupt"), oid_to_hex(repl), path); - if ((p = has_packed_and_bad(repl->hash)) != NULL) + if ((p = has_packed_and_bad(the_repository, repl->hash)) != NULL) die(_("packed object %s (stored in %s) is corrupt"), oid_to_hex(repl), p->pack_name); From patchwork Wed Nov 14 00:12: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: 10681679 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 02DF21759 for ; Wed, 14 Nov 2018 00:13:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E7795299C3 for ; Wed, 14 Nov 2018 00:13:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DAA7A2A778; Wed, 14 Nov 2018 00:13:41 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, USER_IN_DEF_DKIM_WL autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 51E90299C3 for ; Wed, 14 Nov 2018 00:13:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728797AbeKNKOW (ORCPT ); Wed, 14 Nov 2018 05:14:22 -0500 Received: from mail-qk1-f202.google.com ([209.85.222.202]:55925 "EHLO mail-qk1-f202.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726408AbeKNKOW (ORCPT ); Wed, 14 Nov 2018 05:14:22 -0500 Received: by mail-qk1-f202.google.com with SMTP id 98so34124901qkp.22 for ; Tue, 13 Nov 2018 16:13:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=Ibc7hEFsjuir2b98MoZhtmpr7yqFPPDd1zPnA+ln3sg=; b=eeyCAr2Yepu3mCV7OIUgruNooJ3zUdvFdCnESMTP4p4RbkFuoc8rlvVdffIFz1cxFx uaGA0Xee8gfNqym6/xCTfc7HVgx1nBm4RWbHqswY2EJyJIHO74A6QS165izKgNFroJQP zfD5k9eE3JKui6SzG3KWmTFPnbPHQ/aenfliIPvJK7B/bK/deyhP6cNnO6tMGqqfbZRC 2t25zY1B4JFQor4vbU1MewsbUpDYNV9jn/vlQc6T01Q5uvIPJpAaWZqanAIUo7l4WeCY yRCmOFzgZ80UavmxeCqpS8YOIuqILZjDSWp0A7+b3+yfS3q+kmk619KFHk4DyOVDXTbw /rSQ== 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=Ibc7hEFsjuir2b98MoZhtmpr7yqFPPDd1zPnA+ln3sg=; b=O1KdZ8NltZJd4ncrgtMdyvTqNeQQwqvG3SzLLzgBhVng68+rtugtenC/z4M2eAMfdv s2ZKKUc2KoVzurP0YUt+DnQp2q7Z86j0+H9i7ihKsMM+YpYyPzU9XWI9Cl0Acmn5nPfY 1ALCHlueGGE+WQniDr5fdt/JQSv1UXEnEFAF43RMI3hd2ONlxJ6uL57mWQnBKKxeoFxD VkftR/70e2U4tQeH+c4AtxfeFyADhajwxFBdGEaF1STx3XAzaP5qMpb36mpOh6hAVyoY Yh80OsowtUTjVRU/ZL2QGca+SUrHNSow2jjUJxR0SV1AzZ4W1jGSCqQO3Cfz8FgW2Oke JVNQ== X-Gm-Message-State: AGRZ1gKhqteFxdhb+VuXSNEDYFZol/Co9oqbxZCUMb+raWOCFseoUylg FRWnGE0AyMwydUn3bpplrZy8baVl+kGD X-Google-Smtp-Source: AJdET5cFTV8iH7LXMPL8IVHW5g6xsb9fUXcjULcdL1wb1BeCUUwN7OSt4japmrXVx6DNge/8WcqkuuaSPLO3 X-Received: by 2002:ac8:26cb:: with SMTP id 11mr5106683qtp.34.1542154418916; Tue, 13 Nov 2018 16:13:38 -0800 (PST) Date: Tue, 13 Nov 2018 16:12:46 -0800 In-Reply-To: <20181114001306.138053-1-sbeller@google.com> Message-Id: <20181114001306.138053-4-sbeller@google.com> Mime-Version: 1.0 References: <20181114001306.138053-1-sbeller@google.com> X-Mailer: git-send-email 2.19.1.1215.g8438c0b245-goog Subject: [PATCH 03/23] object-store: allow read_object_file_extended to read from any repo From: Stefan Beller To: gitster@pobox.com, jonathantanmy@google.com Cc: git@vger.kernel.org, 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 read_object_file_extended is not widely used, so migrate it all at once. Signed-off-by: Stefan Beller Signed-off-by: Junio C Hamano --- object-store.h | 5 +++-- sha1-file.c | 11 ++++++----- streaming.c | 2 +- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/object-store.h b/object-store.h index 63b7605a3e..3d98a682b2 100644 --- a/object-store.h +++ b/object-store.h @@ -161,12 +161,13 @@ void sha1_file_name(struct repository *r, struct strbuf *buf, const unsigned cha void *map_sha1_file(struct repository *r, const unsigned char *sha1, unsigned long *size); -extern void *read_object_file_extended(const struct object_id *oid, +extern void *read_object_file_extended(struct repository *r, + const struct object_id *oid, enum object_type *type, unsigned long *size, int lookup_replace); static inline void *read_object_file(const struct object_id *oid, enum object_type *type, unsigned long *size) { - return read_object_file_extended(oid, type, size, 1); + return read_object_file_extended(the_repository, oid, type, size, 1); } /* Read and unpack an object file into memory, write memory to an object file */ diff --git a/sha1-file.c b/sha1-file.c index 856e000ee1..c5b704aec5 100644 --- a/sha1-file.c +++ b/sha1-file.c @@ -1403,7 +1403,8 @@ int pretend_object_file(void *buf, unsigned long len, enum object_type type, * deal with them should arrange to call read_object() and give error * messages themselves. */ -void *read_object_file_extended(const struct object_id *oid, +void *read_object_file_extended(struct repository *r, + const struct object_id *oid, enum object_type *type, unsigned long *size, int lookup_replace) @@ -1413,10 +1414,10 @@ void *read_object_file_extended(const struct object_id *oid, const char *path; struct stat st; const struct object_id *repl = lookup_replace ? - lookup_replace_object(the_repository, oid) : oid; + lookup_replace_object(r, oid) : oid; errno = 0; - data = read_object(the_repository, repl->hash, type, size); + data = read_object(r, repl->hash, type, size); if (data) return data; @@ -1428,11 +1429,11 @@ void *read_object_file_extended(const struct object_id *oid, die(_("replacement %s not found for %s"), oid_to_hex(repl), oid_to_hex(oid)); - if (!stat_sha1_file(the_repository, repl->hash, &st, &path)) + if (!stat_sha1_file(r, repl->hash, &st, &path)) die(_("loose object %s (stored in %s) is corrupt"), oid_to_hex(repl), path); - if ((p = has_packed_and_bad(the_repository, repl->hash)) != NULL) + if ((p = has_packed_and_bad(r, repl->hash)) != NULL) die(_("packed object %s (stored in %s) is corrupt"), oid_to_hex(repl), p->pack_name); diff --git a/streaming.c b/streaming.c index d1e6b2dce6..c843a1230f 100644 --- a/streaming.c +++ b/streaming.c @@ -490,7 +490,7 @@ static struct stream_vtbl incore_vtbl = { static open_method_decl(incore) { - st->u.incore.buf = read_object_file_extended(oid, type, &st->size, 0); + st->u.incore.buf = read_object_file_extended(the_repository, oid, type, &st->size, 0); st->u.incore.read_ptr = 0; st->vtbl = &incore_vtbl; From patchwork Wed Nov 14 00:12: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: 10681681 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 77DF91759 for ; Wed, 14 Nov 2018 00:13:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 697F7299C3 for ; Wed, 14 Nov 2018 00:13:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5DFDC2A778; Wed, 14 Nov 2018 00:13:44 +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 EFE58299C3 for ; Wed, 14 Nov 2018 00:13:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730665AbeKNKOZ (ORCPT ); Wed, 14 Nov 2018 05:14:25 -0500 Received: from mail-yw1-f73.google.com ([209.85.161.73]:40629 "EHLO mail-yw1-f73.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727203AbeKNKOY (ORCPT ); Wed, 14 Nov 2018 05:14:24 -0500 Received: by mail-yw1-f73.google.com with SMTP id k187-v6so11519826ywe.7 for ; Tue, 13 Nov 2018 16:13:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=pG0+SlIe+d9rkbh2INm+05H/ACD3hOmzDoWZGqrNL6o=; b=sPItMfyhDmdL5EeuShOKhuMEPCTLdxzViIk6ZD68TfCKDVCgJw82tny6Ic9q6WYH2e Eh/aKB/p8x4PcRwtre3D6Xz90oeMXIc16OrB8hp9Kp+fNR53LB2Vu7atix3T1O3BSP4D 3K0lKuRss2EE6GkYBsUdC7iVO8+shYw6UQWU0FME+bGp1yaWyIA6IEWKivO35FatpKM0 F/CiM+3RavEFs9YPrbTUtoYQnzd79uwzHm0LgkGirN6jZhyVp97ybfCvRbryxIXeOKc2 cDwgV7pRSo5jjwE3UiVt0CIZyu/B7O3NOjIptn18siWjRVwlZSZ4egJE6mQDTMS32EtP jcJg== 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=pG0+SlIe+d9rkbh2INm+05H/ACD3hOmzDoWZGqrNL6o=; b=CBEdRpR2t3I2EdeEdwKOtYI6zx2PCsDQB4jyyLk0AMCE4tdNkRSNkPyj3ijyykUo8m nLRVs2YHYeVMLSu8rimF7XsXSpbl0KZ2N6FW5WlbKIUKthal5gJiLSLxoCGuwJ+RCR7s m7IIh7JbXhl8vFA0LETOT33t5Wt6UYnRAG8mLVUc+Jhb3M4aP9YzKPXuTH8lvNGMINlZ SwPYW5x4b8dpj+WFnMG00OfdLiUvYKCkeSJ1NErG3u+/vIBDX5WPxl5fCrOZPHKmluwT IVUdE34gSh0hUDU2y05Zzn5eu1noQ6MzjFrsJQND6YJ3yFl2MHeqN0FE3HgaJr6jQnmw CqAg== X-Gm-Message-State: AGRZ1gJB5e0OnlCdw0CqnmaE+1nBtnmHOt8wh+rjj8W8+uPnKlHHlLGG T1qEUcl7zBpN0GDbFp1Re3+5lTKNW27W X-Google-Smtp-Source: AJdET5fJPQyWQF5JWlllEJhKqSGRopCvUaAbNHR1tWDzMeF7h2XNXFUJgQ5vePC6DIKT6yu7KgQpNWcyqLae X-Received: by 2002:a25:7d04:: with SMTP id y4-v6mr3380315ybc.16.1542154421475; Tue, 13 Nov 2018 16:13:41 -0800 (PST) Date: Tue, 13 Nov 2018 16:12:47 -0800 In-Reply-To: <20181114001306.138053-1-sbeller@google.com> Message-Id: <20181114001306.138053-5-sbeller@google.com> Mime-Version: 1.0 References: <20181114001306.138053-1-sbeller@google.com> X-Mailer: git-send-email 2.19.1.1215.g8438c0b245-goog Subject: [PATCH 04/23] object-store: prepare read_object_file to deal with any repo From: Stefan Beller To: gitster@pobox.com, jonathantanmy@google.com Cc: git@vger.kernel.org, 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 read_object_file is a widely used function (which is also regularly used in new code in flight between master..pu), changing its signature is painful is hard, as other series in flight rely on the original signature. It would burden the maintainer if we'd just change the signature. Introduce repo_read_object_file which takes the repository argument, and hide the original read_object_file as a macro behind NO_THE_REPOSITORY_COMPATIBILITY_MACROS, similar to e675765235 (diff.c: remove implicit dependency on the_index, 2018-09-21) Add a coccinelle patch to convert existing callers, but do not apply the resulting patch to keep the diff of this patch small. Signed-off-by: Stefan Beller --- contrib/coccinelle/the_repository.pending.cocci | 12 ++++++++++++ object-store.h | 10 ++++++++-- 2 files changed, 20 insertions(+), 2 deletions(-) create mode 100644 contrib/coccinelle/the_repository.pending.cocci diff --git a/contrib/coccinelle/the_repository.pending.cocci b/contrib/coccinelle/the_repository.pending.cocci new file mode 100644 index 0000000000..a7ac9e0c46 --- /dev/null +++ b/contrib/coccinelle/the_repository.pending.cocci @@ -0,0 +1,12 @@ +// This file is used for the ongoing refactoring of +// bringing the index or repository struct in all of +// our code base. + +@@ +expression E; +expression F; +expression G; +@@ +- read_object_file( ++ repo_read_object_file(the_repository, + E, F, G) diff --git a/object-store.h b/object-store.h index 3d98a682b2..00a64622e6 100644 --- a/object-store.h +++ b/object-store.h @@ -165,10 +165,16 @@ extern void *read_object_file_extended(struct repository *r, const struct object_id *oid, enum object_type *type, unsigned long *size, int lookup_replace); -static inline void *read_object_file(const struct object_id *oid, enum object_type *type, unsigned long *size) +static inline void *repo_read_object_file(struct repository *r, + const struct object_id *oid, + enum object_type *type, + unsigned long *size) { - return read_object_file_extended(the_repository, oid, type, size, 1); + return read_object_file_extended(r, oid, type, size, 1); } +#ifndef NO_THE_REPOSITORY_COMPATIBILITY_MACROS +#define read_object_file(oid, type, size) repo_read_object_file(the_repository, oid, type, size) +#endif /* Read and unpack an object file into memory, write memory to an object file */ int oid_object_info(struct repository *r, const struct object_id *, unsigned long *); From patchwork Wed Nov 14 00:12: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: 10681683 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 1B46713BF for ; Wed, 14 Nov 2018 00:13:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0CB8E2A778 for ; Wed, 14 Nov 2018 00:13:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0105F2B5F2; Wed, 14 Nov 2018 00:13:46 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, USER_IN_DEF_DKIM_WL autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 871D12A778 for ; Wed, 14 Nov 2018 00:13:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730969AbeKNKO1 (ORCPT ); Wed, 14 Nov 2018 05:14:27 -0500 Received: from mail-qk1-f201.google.com ([209.85.222.201]:46192 "EHLO mail-qk1-f201.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727203AbeKNKO1 (ORCPT ); Wed, 14 Nov 2018 05:14:27 -0500 Received: by mail-qk1-f201.google.com with SMTP id c84so34691295qkb.13 for ; Tue, 13 Nov 2018 16:13:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=+WQ6uWfFasA6UH8oQIvlYUgcW4lXi1IUNpab83BMHnE=; b=ICm5l0bRHPyOFayJXqU4e71YWVPnH2IBYPR/oM71qrZ+q1dl5YwQuVKSKgjQjEMYIw ZkKbfDWgLg/HTkai8NvXEVaT7CoWlKzMw17DG5KacfwUYZeao6U/zb/dycK4EmGoDZgF BTmT5EZNNd/y1ldJO6eE1ap+9CaiZ5vfdy8hA4zATbOZkJa1aXEssOYKAqdHbRu4FfC/ ANBF8nQwcl5piZGhUL/rlNgPIWj4h+OYazLt9WxjtHtSwnsxNP5lROeYU8h0N7cLgBMY VX/dGKy49l4TR5xQ/BgYp+f1S5p8CJyxftkFxDD6SGeBmN3JSL1O+782P7AnTtrV6kgw M6fw== 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=+WQ6uWfFasA6UH8oQIvlYUgcW4lXi1IUNpab83BMHnE=; b=X1QaX8WBt6NJJA1oGPz1zxdE6w8KhXKOr4P6Rru9Rt02OYmPIEOCz9Ad9AQUDkXMXK 0bQax8EWLw+7YA1lHiEwVl7IrTc5R22SVzv5nB/KvnpdMrNUHkodsj/au8PsCDmjo4AI MlcoBtvj0x0qR/RBiCXf1zgZz3bQ7KQfPzfbH5y31JS4+Q2bliNj4gSCBLmjFts3wyGp Zl/0TdDnMw4mo/jVwRuIfHlwjmyg3aIFYVNQ0DvEYwZK0AaKydZwCv4ngUPVeoWP1oLd 07MTkCnL85/ab+vB7eiYmGIoDSGimzZsCBWJWpyHNB+9yT8qrA042cCKh++n7cRYAVAQ 5FYQ== X-Gm-Message-State: AGRZ1gI6WdRV8QiLKUPQEdIALM32/ChpC8Erx+TR241oJ7mayopSsOmG 11LFSkbzYpf8KZfChMV5TvjUzW3Z09jP X-Google-Smtp-Source: AJdET5fqsizY9bdxrAz9NKQyOkhQwqvws5Ttg0aQASkpWlFt+GSmzQLN/x1tN4BmGi2Jl6H6SaJBKgqtyhoZ X-Received: by 2002:a37:9042:: with SMTP id s63mr4798414qkd.10.1542154423921; Tue, 13 Nov 2018 16:13:43 -0800 (PST) Date: Tue, 13 Nov 2018 16:12:48 -0800 In-Reply-To: <20181114001306.138053-1-sbeller@google.com> Message-Id: <20181114001306.138053-6-sbeller@google.com> Mime-Version: 1.0 References: <20181114001306.138053-1-sbeller@google.com> X-Mailer: git-send-email 2.19.1.1215.g8438c0b245-goog Subject: [PATCH 05/23] object-store: prepare has_{sha1, object}_file to handle any repo From: Stefan Beller To: gitster@pobox.com, jonathantanmy@google.com Cc: git@vger.kernel.org, Stefan Beller Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Stefan Beller --- .../coccinelle/the_repository.pending.cocci | 30 +++++++++++++++++++ object-store.h | 22 ++++++++++---- sha1-file.c | 15 ++++++---- 3 files changed, 56 insertions(+), 11 deletions(-) diff --git a/contrib/coccinelle/the_repository.pending.cocci b/contrib/coccinelle/the_repository.pending.cocci index a7ac9e0c46..46f3a1b23a 100644 --- a/contrib/coccinelle/the_repository.pending.cocci +++ b/contrib/coccinelle/the_repository.pending.cocci @@ -10,3 +10,33 @@ expression G; - read_object_file( + repo_read_object_file(the_repository, E, F, G) + +@@ +expression E; +@@ +- has_sha1_file( ++ repo_has_sha1_file(the_repository, + E) + +@@ +expression E; +expression F; +@@ +- has_sha1_file_with_flags( ++ repo_has_sha1_file_with_flags(the_repository, + E) + +@@ +expression E; +@@ +- has_object_file( ++ repo_has_object_file(the_repository, + E) + +@@ +expression E; +expression F; +@@ +- has_object_file_with_flags( ++ repo_has_object_file_with_flags(the_repository, + E) diff --git a/object-store.h b/object-store.h index 00a64622e6..2b5e6ff1ed 100644 --- a/object-store.h +++ b/object-store.h @@ -212,15 +212,27 @@ int read_loose_object(const char *path, * object_info. OBJECT_INFO_SKIP_CACHED is automatically set; pass * nonzero flags to also set other flags. */ -extern int has_sha1_file_with_flags(const unsigned char *sha1, int flags); -static inline int has_sha1_file(const unsigned char *sha1) +int repo_has_sha1_file_with_flags(struct repository *r, + const unsigned char *sha1, int flags); +static inline int repo_has_sha1_file(struct repository *r, + const unsigned char *sha1) { - return has_sha1_file_with_flags(sha1, 0); + return repo_has_sha1_file_with_flags(r, sha1, 0); } +#ifndef NO_THE_REPOSITORY_COMPATIBILITY_MACROS +#define has_sha1_file_with_flags(sha1, flags) repo_has_sha1_file_with_flags(the_repository, sha1, flags) +#define has_sha1_file(sha1) repo_has_sha1_file(the_repository, sha1) +#endif + /* Same as the above, except for struct object_id. */ -extern int has_object_file(const struct object_id *oid); -extern int has_object_file_with_flags(const struct object_id *oid, int flags); +int repo_has_object_file(struct repository *r, const struct object_id *oid); +int repo_has_object_file_with_flags(struct repository *r, + const struct object_id *oid, int flags); +#ifndef NO_THE_REPOSITORY_COMPATIBILITY_MACROS +#define has_object_file(oid) repo_has_object_file(the_repository, oid) +#define has_object_file_with_flags(oid, flags) repo_has_object_file_with_flags(the_repository, oid, flags) +#endif /* * Return true iff an alternate object database has a loose object diff --git a/sha1-file.c b/sha1-file.c index c5b704aec5..e77273ccfd 100644 --- a/sha1-file.c +++ b/sha1-file.c @@ -1768,24 +1768,27 @@ int force_object_loose(const struct object_id *oid, time_t mtime) return ret; } -int has_sha1_file_with_flags(const unsigned char *sha1, int flags) +int repo_has_sha1_file_with_flags(struct repository *r, + const unsigned char *sha1, int flags) { struct object_id oid; if (!startup_info->have_repository) return 0; hashcpy(oid.hash, sha1); - return oid_object_info_extended(the_repository, &oid, NULL, + return oid_object_info_extended(r, &oid, NULL, flags | OBJECT_INFO_SKIP_CACHED) >= 0; } -int has_object_file(const struct object_id *oid) +int repo_has_object_file(struct repository *r, + const struct object_id *oid) { - return has_sha1_file(oid->hash); + return repo_has_sha1_file(r, oid->hash); } -int has_object_file_with_flags(const struct object_id *oid, int flags) +int repo_has_object_file_with_flags(struct repository *r, + const struct object_id *oid, int flags) { - return has_sha1_file_with_flags(oid->hash, flags); + return repo_has_sha1_file_with_flags(r, oid->hash, flags); } static void check_tree(const void *buf, size_t size) From patchwork Wed Nov 14 00:12: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: 10681685 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 D232113BF for ; Wed, 14 Nov 2018 00:13:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C40F929E99 for ; Wed, 14 Nov 2018 00:13:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B87442B194; Wed, 14 Nov 2018 00:13:48 +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 6672F2A778 for ; Wed, 14 Nov 2018 00:13:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730979AbeKNKO3 (ORCPT ); Wed, 14 Nov 2018 05:14:29 -0500 Received: from mail-oi1-f201.google.com ([209.85.167.201]:42337 "EHLO mail-oi1-f201.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727203AbeKNKO3 (ORCPT ); Wed, 14 Nov 2018 05:14:29 -0500 Received: by mail-oi1-f201.google.com with SMTP id s22-v6so8159600oie.9 for ; Tue, 13 Nov 2018 16:13:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=pzSH75vF8Pt4fUApXiNMhUdAF4OotqFSFPjKUaEZ3b0=; b=Zxm/M8t+AOHCMmeu+o/T9ZIHuRcuIA1/BsoUqNq/mlLPuOfNg6EIikrzK0YTyD8juy kQcS/ZhmMsUb1hiYuGz8S4k+l/KxXP3NTTmT+l7CnEaLgVpknA8yFbuGNF1mxgaX7CHQ 8qcQpg8FhcXn1O16ckWdUeBjnABUUiQfEbDDPxci0phqQ+iqPWgQlPnxwqBJyzgDAUB8 Mjd6x5kPlZWkQ95JKIH+U52Su1YUYQBA8IJUiFctrKgSkPnjv8DmAF82Z2sj5b4vuBa4 HdrHzDCwzFFBtq8SgB3QVoGE3AXSJyY83Fg6ZE96U+/IF5VW7boncLiR7ijLTFJc4nsQ Kqcw== 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=pzSH75vF8Pt4fUApXiNMhUdAF4OotqFSFPjKUaEZ3b0=; b=rIXzck02Ey+nQJKM+yMvwTqGROCidhMZNvODfcsJCdn82iKHBAU98y8B+22ba00pk/ yo1P640HNCE08OLPXpaounuLyW4THXN696QJdwbdjblkTaVYu71xRWPVxqZCv16+icvj 9Dlby5bYpM7Pc2QjgJgfb110Rx0QLLRQc9NDnSuhp1vEBgfgl+6BS1olrwn5O45EQQPv xyhTjqQuK/7xcw6bmAnaVUeXy6Wtew6STuBUg8Bejx3GbKcUokUK2XICQRRVoORE4QmS t3X/ldnpWiNVET62Wkd5N1Agrdu3nTfBa4WbQ6yV3Ka/TggczDW0AuhWxwIQlgfAOole eafg== X-Gm-Message-State: AGRZ1gI/oLPTp3/vZzfVKQm5Xq03NFbbd+ZxrnDFNaNoK6RMsiUoRH0D kfmZJDynC6oR85DXtu2qrc6XpoHmSwQx X-Google-Smtp-Source: AJdET5dDATkWpnTf7M9Iel2/WkRfsLg6Ts0mFATGaKdf+wufAQm1J5AZAqKr4OcRjSZo71OyKNc6jVAQCb6y X-Received: by 2002:a9d:541e:: with SMTP id j30mr4974722oth.27.1542154426138; Tue, 13 Nov 2018 16:13:46 -0800 (PST) Date: Tue, 13 Nov 2018 16:12:49 -0800 In-Reply-To: <20181114001306.138053-1-sbeller@google.com> Message-Id: <20181114001306.138053-7-sbeller@google.com> Mime-Version: 1.0 References: <20181114001306.138053-1-sbeller@google.com> X-Mailer: git-send-email 2.19.1.1215.g8438c0b245-goog Subject: [PATCH 06/23] object: parse_object to honor its repository argument From: Stefan Beller To: gitster@pobox.com, jonathantanmy@google.com Cc: git@vger.kernel.org, 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 8e4b0b6047 (object.c: allow parse_object to handle arbitrary repositories, 2018-06-28), we forgot to pass the repository down to the read_object_file. Signed-off-by: Stefan Beller Signed-off-by: Junio C Hamano --- object.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/object.c b/object.c index e54160550c..003f870484 100644 --- a/object.c +++ b/object.c @@ -259,8 +259,8 @@ struct object *parse_object(struct repository *r, const struct object_id *oid) if (obj && obj->parsed) return obj; - if ((obj && obj->type == OBJ_BLOB && has_object_file(oid)) || - (!obj && has_object_file(oid) && + if ((obj && obj->type == OBJ_BLOB && repo_has_object_file(r, oid)) || + (!obj && repo_has_object_file(r, oid) && oid_object_info(r, oid, NULL) == OBJ_BLOB)) { if (check_object_signature(repl, NULL, 0, NULL) < 0) { error(_("sha1 mismatch %s"), oid_to_hex(oid)); @@ -270,7 +270,7 @@ struct object *parse_object(struct repository *r, const struct object_id *oid) return lookup_object(r, oid->hash); } - buffer = read_object_file(oid, &type, &size); + buffer = repo_read_object_file(r, oid, &type, &size); if (buffer) { if (check_object_signature(repl, buffer, size, type_name(type)) < 0) { free(buffer); From patchwork Wed Nov 14 00:12: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: 10681687 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 866431759 for ; Wed, 14 Nov 2018 00:13:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 76318299C3 for ; Wed, 14 Nov 2018 00:13:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6ABBD2A778; Wed, 14 Nov 2018 00:13:52 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, USER_IN_DEF_DKIM_WL autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ED0E2299C3 for ; Wed, 14 Nov 2018 00:13:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731032AbeKNKOd (ORCPT ); Wed, 14 Nov 2018 05:14:33 -0500 Received: from mail-io1-f74.google.com ([209.85.166.74]:55532 "EHLO mail-io1-f74.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727203AbeKNKOc (ORCPT ); Wed, 14 Nov 2018 05:14:32 -0500 Received: by mail-io1-f74.google.com with SMTP id y14-v6so14170613ioa.22 for ; Tue, 13 Nov 2018 16:13:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=ECmjKTbfHCMgEIfWVFX+LBSDVRiz5doRtWK7UIw84qM=; b=YOfqFJhKw1tt5ER7Upri6wQwwPFJ/C4eVe/p+qDP+TPQDkHZRpKrDnbq1Y0aRmBIy0 tNNThHeOrqQKyDM4+QbcO+QcsSFe6TN2KWndiGJY89r6yoWa09uihh4RT19XsDWv5zKU D/wlpwoKPjJVfvFuN5WYulQQePWtY1xYNtm6nlk8E1z5o2mr0Uhj2ePs13AE5/igOc0G W0MlP0CRI5rC3tGM218t6vQGVtqNltkjo7xzVwvAAiWhyP5bFWxNey9zP+8DoibwKcKS aUT96Pm8sz6HVlHBoNcN2Qp3Vpv47lEJXNW1ivFq3CIqfxy4nEz4M8OL9k+wiUeVuYP9 mcUQ== 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=ECmjKTbfHCMgEIfWVFX+LBSDVRiz5doRtWK7UIw84qM=; b=NUmwkz4r6uDVqLcUpZyJizsqDR5CxqhFEdXy+MN8U5JxaxnICyoSqB4qkFymsB/td4 GeZQrjWW8YxlP/8reNOz4xTzrIs4jw8hH1dHtE9RFFiIaRUiijhUxW7FUd+o+qP36Knu Y87Nd6VKwGSKR86tiKEl02S65UZiFZBXlqaMxaiu81R7nwmU4vMiOHksY2lTlJAQp8vK pslYWsCkcvFR/I3PkOeLIDd3PROw1+bt2TidNDmV4k560Af8lTOXwz8QdZqU9se0AztT xGSGQiitkNUqzZ2DHiVjavVHB73jcZkgR4MUTcLdsZuULOcgNrO/SIOWQNrWdVqiTwJQ GWbw== X-Gm-Message-State: AA+aEWbQ6oTTxmi+TEEytAcvlMtg+oAFR3On1EOoFsdFFzXIdYAMAbV7 9nqFVnw2Mno96h73KyLXlDTQyW3TWQMP X-Google-Smtp-Source: AJdET5dMgtDuO4FGPT27Mq4q2FuqMujQwWnFNuru+fbdHF445jT1rFwg3NgCc5j4hnnUKpCFe1xjUKDaaJqo X-Received: by 2002:a24:1882:: with SMTP id 124mr86669itr.0.1542154429449; Tue, 13 Nov 2018 16:13:49 -0800 (PST) Date: Tue, 13 Nov 2018 16:12:50 -0800 In-Reply-To: <20181114001306.138053-1-sbeller@google.com> Message-Id: <20181114001306.138053-8-sbeller@google.com> Mime-Version: 1.0 References: <20181114001306.138053-1-sbeller@google.com> X-Mailer: git-send-email 2.19.1.1215.g8438c0b245-goog Subject: [PATCH 07/23] commit: allow parse_commit* to handle any repo From: Stefan Beller To: gitster@pobox.com, jonathantanmy@google.com Cc: git@vger.kernel.org, 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 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 --- commit.c | 18 ++++++++------ commit.h | 17 +++++++++---- .../coccinelle/the_repository.pending.cocci | 24 +++++++++++++++++++ 3 files changed, 48 insertions(+), 11 deletions(-) diff --git a/commit.c b/commit.c index dc8a39d52a..7a931d7fd4 100644 --- a/commit.c +++ b/commit.c @@ -443,7 +443,10 @@ int parse_commit_buffer(struct repository *r, struct commit *item, const void *b return 0; } -int parse_commit_internal(struct commit *item, int quiet_on_missing, int use_commit_graph) +int repo_parse_commit_internal(struct repository *r, + struct commit *item, + int quiet_on_missing, + int use_commit_graph) { enum object_type type; void *buffer; @@ -454,9 +457,9 @@ int parse_commit_internal(struct commit *item, int quiet_on_missing, int use_com return -1; if (item->object.parsed) return 0; - if (use_commit_graph && parse_commit_in_graph(the_repository, item)) + if (use_commit_graph && parse_commit_in_graph(r, item)) return 0; - buffer = read_object_file(&item->object.oid, &type, &size); + buffer = repo_read_object_file(r, &item->object.oid, &type, &size); if (!buffer) return quiet_on_missing ? -1 : error("Could not read %s", @@ -467,18 +470,19 @@ int parse_commit_internal(struct commit *item, int quiet_on_missing, int use_com oid_to_hex(&item->object.oid)); } - ret = parse_commit_buffer(the_repository, item, buffer, size, 0); + ret = parse_commit_buffer(r, item, buffer, size, 0); if (save_commit_buffer && !ret) { - set_commit_buffer(the_repository, item, buffer, size); + set_commit_buffer(r, item, buffer, size); return 0; } free(buffer); return ret; } -int parse_commit_gently(struct commit *item, int quiet_on_missing) +int repo_parse_commit_gently(struct repository *r, + struct commit *item, int quiet_on_missing) { - return parse_commit_internal(item, quiet_on_missing, 1); + return repo_parse_commit_internal(r, item, quiet_on_missing, 1); } void parse_commit_or_die(struct commit *item) diff --git a/commit.h b/commit.h index 1d260d62f5..08935f9a19 100644 --- a/commit.h +++ b/commit.h @@ -79,12 +79,21 @@ struct commit *lookup_commit_reference_by_name(const char *name); struct commit *lookup_commit_or_die(const struct object_id *oid, const char *ref_name); int parse_commit_buffer(struct repository *r, struct commit *item, const void *buffer, unsigned long size, int check_graph); -int parse_commit_internal(struct commit *item, int quiet_on_missing, int use_commit_graph); -int parse_commit_gently(struct commit *item, int quiet_on_missing); -static inline int parse_commit(struct commit *item) +int repo_parse_commit_internal(struct repository *r, struct commit *item, + int quiet_on_missing, int use_commit_graph); +int repo_parse_commit_gently(struct repository *r, + struct commit *item, + int quiet_on_missing); +static inline int repo_parse_commit(struct repository *r, struct commit *item) { - return parse_commit_gently(item, 0); + return repo_parse_commit_gently(r, item, 0); } +#ifndef NO_THE_REPOSITORY_COMPATIBILITY_MACROS +#define parse_commit_internal(item, quiet, use) repo_parse_commit_internal(the_repository, item, quiet, use) +#define parse_commit_gently(item, quiet) repo_parse_commit_gently(the_repository, item, quiet) +#define parse_commit(item) repo_parse_commit(the_repository, item) +#endif + void parse_commit_or_die(struct commit *item); struct buffer_slab; diff --git a/contrib/coccinelle/the_repository.pending.cocci b/contrib/coccinelle/the_repository.pending.cocci index 46f3a1b23a..b185fe0a1d 100644 --- a/contrib/coccinelle/the_repository.pending.cocci +++ b/contrib/coccinelle/the_repository.pending.cocci @@ -40,3 +40,27 @@ expression F; - has_object_file_with_flags( + repo_has_object_file_with_flags(the_repository, E) + +@@ +expression E; +expression F; +expression G; +@@ +- parse_commit_internal( ++ repo_parse_commit_internal(the_repository, + E, F, G) + +@@ +expression E; +expression F; +@@ +- parse_commit_gently( ++ repo_parse_commit_gently(the_repository, + E, F) + +@@ +expression E; +@@ +- parse_commit( ++ repo_parse_commit(the_repository, + E) From patchwork Wed Nov 14 00:12:51 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Beller X-Patchwork-Id: 10681689 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 3FC181759 for ; Wed, 14 Nov 2018 00:13:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 31939299C3 for ; Wed, 14 Nov 2018 00:13:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 261DA2A778; Wed, 14 Nov 2018 00:13:55 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, USER_IN_DEF_DKIM_WL autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B848B299C3 for ; Wed, 14 Nov 2018 00:13:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731066AbeKNKOg (ORCPT ); Wed, 14 Nov 2018 05:14:36 -0500 Received: from mail-vk1-f202.google.com ([209.85.221.202]:43852 "EHLO mail-vk1-f202.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727203AbeKNKOf (ORCPT ); Wed, 14 Nov 2018 05:14:35 -0500 Received: by mail-vk1-f202.google.com with SMTP id 62-v6so2360725vkl.10 for ; Tue, 13 Nov 2018 16:13:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=zGDdMPSddeFULDcISmWptCyX0A+0rR5eFWVgQhXPVTY=; b=MGNMONqvdBbMjLJWXYSMVhg9G0c+lnDCfpIt+DczVKWsJsq2TVNa8GlJsooYjg5jXi xseBzCt8kC/Fp/9gey5kEDfcu9KAasMZ3c2I46cqSPZNCyEP+7cWxZjbm/tZS66thHgz j4dv50flDd8EXZTb/5iBceM7hduAsKx2CG95uUW+OOvc54Owg1YddOMKvpx3SpW7lkow DfuUs+Z/tKFQ8h/2py8CEDVX+dP6nk0bdEIiN4w261qpGxOEXDfcsxDnvTBqkEGweBd2 W1EQMKO4QYdjbPtguN0VSYkWJYCUQG4FiAmPXi7mxOaJaqeXyviWu74fpUJMrMCbLdBx 53ow== 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=zGDdMPSddeFULDcISmWptCyX0A+0rR5eFWVgQhXPVTY=; b=XcQT50BsybGcA0FfCMF3oATjGmCPkV4fUMssTDjpMh336q8SPkHPLzuDw7ieRQIrVQ qvwON6/YYP3ZNKsBdPuKt9J1fgpEpg2bfqSLM5AmmNskg0QxiSIhjGP+5pcMqHF7BBlT wOhqW8vLws1DwLdx5Sdmlu4jdXP9Kjc1QDGVwJ/AM8iWCOx90OvzpQtaRDBWEIjsGMuI SDAqLztorqSBPbgL+WzebZXQfDB9rrDhOsccW7BSNvx2SxOc3VXo0sDOOZPPgx66kyiy tvcSkdKF1D6Igfwi0ObbOqAezgusC7shxy22Ay5ac23TsOwDLi/aSQUJbyGjBXe3JT6p 4FuQ== X-Gm-Message-State: AGRZ1gKBrUz/fhcCmeLq//mo7JCtvFhv/bozQqjv1xLv1YpAkW2bUV4I Ez+A0vC6cU7yQt1s0HaVTU4SQH++GIuT X-Google-Smtp-Source: AJdET5dfrKub9KpUSpc7HfPXDLrHjZTDSHWqqoKXF98AhrLmfcApNezLVUIq2Wsl9xXD1O0I5Ee6gYGN6IyJ X-Received: by 2002:a1f:2c4c:: with SMTP id s73mr6042848vks.7.1542154432211; Tue, 13 Nov 2018 16:13:52 -0800 (PST) Date: Tue, 13 Nov 2018 16:12:51 -0800 In-Reply-To: <20181114001306.138053-1-sbeller@google.com> Message-Id: <20181114001306.138053-9-sbeller@google.com> Mime-Version: 1.0 References: <20181114001306.138053-1-sbeller@google.com> X-Mailer: git-send-email 2.19.1.1215.g8438c0b245-goog Subject: [PATCH 08/23] commit-reach.c: allow paint_down_to_common to handle any repo From: Stefan Beller To: gitster@pobox.com, jonathantanmy@google.com Cc: git@vger.kernel.org, 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 9f79ce0a22..67c2e43d5e 100644 --- a/commit-reach.c +++ b/commit-reach.c @@ -30,7 +30,8 @@ static int queue_has_nonstale(struct prio_queue *queue) } /* all input commits in one and twos[] must have been parsed! */ -static struct commit_list *paint_down_to_common(struct commit *one, int n, +static struct commit_list *paint_down_to_common(struct repository *r, + struct commit *one, int n, struct commit **twos, int min_generation) { @@ -83,7 +84,7 @@ static struct commit_list *paint_down_to_common(struct commit *one, int n, parents = parents->next; if ((p->object.flags & flags) == flags) continue; - if (parse_commit(p)) + if (repo_parse_commit(r, p)) return NULL; p->object.flags |= flags; prio_queue_put(&queue, p); @@ -116,7 +117,7 @@ static struct commit_list *merge_bases_many(struct commit *one, int n, struct co return NULL; } - list = paint_down_to_common(one, n, twos, 0); + list = paint_down_to_common(the_repository, one, n, twos, 0); while (list) { struct commit *commit = pop_commit(&list); @@ -187,8 +188,8 @@ static int remove_redundant(struct commit **array, int cnt) if (array[j]->generation < min_generation) min_generation = array[j]->generation; } - common = paint_down_to_common(array[i], filled, work, - min_generation); + common = paint_down_to_common(the_repository, array[i], filled, + work, min_generation); if (array[i]->object.flags & PARENT2) redundant[i] = 1; for (j = 0; j < filled; j++) @@ -322,7 +323,9 @@ int in_merge_bases_many(struct commit *commit, int nr_reference, struct commit * if (commit->generation > min_generation) return ret; - bases = paint_down_to_common(commit, nr_reference, reference, commit->generation); + bases = paint_down_to_common(the_repository, commit, + nr_reference, reference, + commit->generation); if (commit->object.flags & PARENT2) ret = 1; clear_commit_marks(commit, all_flags); From patchwork Wed Nov 14 00:12:52 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Beller X-Patchwork-Id: 10681691 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 0765013BF for ; Wed, 14 Nov 2018 00:13:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ED514299C3 for ; Wed, 14 Nov 2018 00:13:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E1E5A2A778; Wed, 14 Nov 2018 00:13:56 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, USER_IN_DEF_DKIM_WL autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 90DB6299C3 for ; Wed, 14 Nov 2018 00:13:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731105AbeKNKOh (ORCPT ); Wed, 14 Nov 2018 05:14:37 -0500 Received: from mail-io1-f74.google.com ([209.85.166.74]:39146 "EHLO mail-io1-f74.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727203AbeKNKOh (ORCPT ); Wed, 14 Nov 2018 05:14:37 -0500 Received: by mail-io1-f74.google.com with SMTP id o8-v6so14299783iom.6 for ; Tue, 13 Nov 2018 16:13:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=ts1RZHynoVLLBhU1ZWwveKYofM8UY+3XzaNWeJsLK78=; b=hg1aljS3/sfNWMRtB63wFJaZeo0a/bpWCGKWesAYVmpUa2j9itc99y6Jg9s6o44hSW X6XX7f2zc0AMQCwLDigT3jZKzglAvkddiovnwTw1sxggxdrW7+ISCqWW8AVANqil18DV bpNWnfLESqG9ravn/kPLgNpc4QDrvLQlcUqadymjh/YdViez0D+o0ZF1erKrMWXkTlh8 op7Aiqv/jBSpPclW8Deoy4NZ6CY1RMYAd0Q6UOrtns0b0/xwBJ21Ehsr8W35sWwua+TB RxPg5Ep1K2AVQF58/iVB3NPRdSU8S9EQj78/OxJNY0/NvESPWdBsJkDbmhldOAiHmM+l oe+A== 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=ts1RZHynoVLLBhU1ZWwveKYofM8UY+3XzaNWeJsLK78=; b=QiC0KN/CGLOVoulpVVpRWEitxh1Z1aedFQGz7UrL/lM+gaf/GLsSHyoVXR7aB1t7vq EZxBk0Iz7x2B3rMS3/WTX0Y8zd6QEGt0F0mGSh2ZHJET6GH/d58bTh2SBZZ+AiMB/rgJ 1/6b0I7GaqF+ijD5p+fjSZ5zwM64Ej8ZCV+cQGPLqLTLvnb9ZSpUnm+fmzYOaaR1x+Qf g+qf2kkP4dGyKYWaoKrgyKj93EC6SPZXv8dL53HytFL7y27tjXhJxphHl7XpdJDg3D3i pLPypW6ZuspCiP1TJ6gISmpGYgSNhkIreHy0rfDW9fs5QdLFdpOShA4QPErdZXnP2vbU rFfA== X-Gm-Message-State: AGRZ1gKT11zUMF3OLNx4yOPaSwTQXeoUfSLUn9iIIUVlKJsYwY7keK5U xEo0klx+NsYvihTPs8iTSSKnnmeWqfXM X-Google-Smtp-Source: AFSGD/V6QWCVr/yidMMv+J0lLYFKQk2TR7P1GTLw75O6NxlzoGP2JcrDE0tY6xFWCYQwlE/wHcsDcZ4arlVD X-Received: by 2002:a24:5e81:: with SMTP id h123-v6mr57630itb.33.1542154434380; Tue, 13 Nov 2018 16:13:54 -0800 (PST) Date: Tue, 13 Nov 2018 16:12:52 -0800 In-Reply-To: <20181114001306.138053-1-sbeller@google.com> Message-Id: <20181114001306.138053-10-sbeller@google.com> Mime-Version: 1.0 References: <20181114001306.138053-1-sbeller@google.com> X-Mailer: git-send-email 2.19.1.1215.g8438c0b245-goog Subject: [PATCH 09/23] commit-reach.c: allow merge_bases_many to handle any repo From: Stefan Beller To: gitster@pobox.com, jonathantanmy@google.com Cc: git@vger.kernel.org, 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 67c2e43d5e..a53b31e6a2 100644 --- a/commit-reach.c +++ b/commit-reach.c @@ -95,7 +95,9 @@ static struct commit_list *paint_down_to_common(struct repository *r, return result; } -static struct commit_list *merge_bases_many(struct commit *one, int n, struct commit **twos) +static struct commit_list *merge_bases_many(struct repository *r, + struct commit *one, int n, + struct commit **twos) { struct commit_list *list = NULL; struct commit_list *result = NULL; @@ -110,14 +112,14 @@ static struct commit_list *merge_bases_many(struct commit *one, int n, struct co return commit_list_insert(one, &result); } - if (parse_commit(one)) + if (repo_parse_commit(r, one)) return NULL; for (i = 0; i < n; i++) { - if (parse_commit(twos[i])) + if (repo_parse_commit(r, twos[i])) return NULL; } - list = paint_down_to_common(the_repository, one, n, twos, 0); + list = paint_down_to_common(r, one, n, twos, 0); while (list) { struct commit *commit = pop_commit(&list); @@ -224,7 +226,7 @@ static struct commit_list *get_merge_bases_many_0(struct commit *one, struct commit_list *result; int cnt, i; - result = merge_bases_many(one, n, twos); + result = merge_bases_many(the_repository, one, n, twos); for (i = 0; i < n; i++) { if (one == twos[i]) return result; From patchwork Wed Nov 14 00:12:53 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Beller X-Patchwork-Id: 10681693 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 1FE031759 for ; Wed, 14 Nov 2018 00:13:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1199C299C3 for ; Wed, 14 Nov 2018 00:13:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 062762A778; Wed, 14 Nov 2018 00:13:59 +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 A1DB2299C3 for ; Wed, 14 Nov 2018 00:13:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731132AbeKNKOj (ORCPT ); Wed, 14 Nov 2018 05:14:39 -0500 Received: from mail-it1-f201.google.com ([209.85.166.201]:39427 "EHLO mail-it1-f201.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727203AbeKNKOj (ORCPT ); Wed, 14 Nov 2018 05:14:39 -0500 Received: by mail-it1-f201.google.com with SMTP id l15-v6so16326393ita.4 for ; Tue, 13 Nov 2018 16:13:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=J6zxwZwbL1Z82LBVdSj3y0+cy288hJlU7+cbFX77ISY=; b=JvRO2LFb+aJl+2X73JLQ+YGHrjX9MEKDfTSIvRq45lO6q3NOhy2xPfpyeHnDBfcl3A co57rebVqY1t/XiSQMnZLhPUB5LIMB8poIbEnz0OP7LNldX3+2FFwP1Ial3wE3FVozax cx3D8d3YzTNKZd1ioLeHoKFhVx0PwbI+k+3RNt1UaFIDgQFLktBWT8IL86fV39xsmUWQ s9I//QmNlOGWW3IekZFw1P3LpVX/MDZlCje3ixQodlWyiPayO6Cn8fEU2dBMKOYlWT2t j+NolNmeVP7UnlTm3AJR5Ay7Vgi65iMqvUolaAINyxxXVKlG6ZleKap9gVTDIZMT9PxW UuvQ== 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=J6zxwZwbL1Z82LBVdSj3y0+cy288hJlU7+cbFX77ISY=; b=dDeagoVX1PWRoDXY5j+3llFORHp+iI6AeU0+jneQvzXG2sYAynBqfEgvdv8Il6aALi aotYrfobdkzs9ErnIiAAgzBviWtcpLlC/zUpXDSoJjwSVc94XkcYM1kxdexM9KWaUr+J hvjm0w3nu5usjIhDNIk7hibxdJ9R3si2A6jcuS3n0kf1HW+K5O16TIrzQINwLL3ElVIi K6gdf7iQPL94D2ZLjst5BSEyBkZqJeGptY6smhDYRV+qurrnrYm0feoQwHcNHgedU8Yh DIckyYBkbqTDnqb+Jfmw7dBfgSfYpAQ35L00XIEsELcW0XSlXlsidDm2FSEjEa26FHcr /YVQ== X-Gm-Message-State: AA+aEWayCoSPzlVHrapJscVC//IiD9WI4NiClcim+S0yQC2hzEmYfIPM anHI7FnL+kuNJWOZysV/yWFHhKL8qqqD X-Google-Smtp-Source: AJdET5etvJ2a+Olq2fRP3pqje6BSVmmvJMfwyJ9uPk5SuUE8Ecq/7iCKawtf9hu3vtrAMuiO3nv7qylJVVoU X-Received: by 2002:a24:1741:: with SMTP id 62-v6mr73507ith.1.1542154436486; Tue, 13 Nov 2018 16:13:56 -0800 (PST) Date: Tue, 13 Nov 2018 16:12:53 -0800 In-Reply-To: <20181114001306.138053-1-sbeller@google.com> Message-Id: <20181114001306.138053-11-sbeller@google.com> Mime-Version: 1.0 References: <20181114001306.138053-1-sbeller@google.com> X-Mailer: git-send-email 2.19.1.1215.g8438c0b245-goog Subject: [PATCH 10/23] commit-reach.c: allow remove_redundant to handle any repo From: Stefan Beller To: gitster@pobox.com, jonathantanmy@google.com Cc: git@vger.kernel.org, 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 a53b31e6a2..81015830cb 100644 --- a/commit-reach.c +++ b/commit-reach.c @@ -156,7 +156,7 @@ struct commit_list *get_octopus_merge_bases(struct commit_list *in) return ret; } -static int remove_redundant(struct commit **array, int cnt) +static int remove_redundant(struct repository *r, struct commit **array, int cnt) { /* * Some commit in the array may be an ancestor of @@ -174,7 +174,7 @@ static int remove_redundant(struct commit **array, int cnt) ALLOC_ARRAY(filled_index, cnt - 1); for (i = 0; i < cnt; i++) - parse_commit(array[i]); + repo_parse_commit(r, array[i]); for (i = 0; i < cnt; i++) { struct commit_list *common; uint32_t min_generation = array[i]->generation; @@ -190,7 +190,7 @@ static int remove_redundant(struct commit **array, int cnt) if (array[j]->generation < min_generation) min_generation = array[j]->generation; } - common = paint_down_to_common(the_repository, array[i], filled, + common = paint_down_to_common(r, array[i], filled, work, min_generation); if (array[i]->object.flags & PARENT2) redundant[i] = 1; @@ -249,7 +249,7 @@ static struct commit_list *get_merge_bases_many_0(struct commit *one, clear_commit_marks(one, all_flags); clear_commit_marks_many(n, twos, all_flags); - cnt = remove_redundant(rslt, cnt); + cnt = remove_redundant(the_repository, rslt, cnt); result = NULL; for (i = 0; i < cnt; i++) commit_list_insert_by_date(rslt[i], &result); @@ -370,7 +370,7 @@ struct commit_list *reduce_heads(struct commit_list *heads) p->item->object.flags &= ~STALE; } } - num_head = remove_redundant(array, num_head); + num_head = remove_redundant(the_repository, array, num_head); for (i = 0; i < num_head; i++) tail = &commit_list_insert(array[i], tail)->next; free(array); From patchwork Wed Nov 14 00:12:54 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Beller X-Patchwork-Id: 10681695 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 10FF31759 for ; Wed, 14 Nov 2018 00:14:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 01FF22B194 for ; Wed, 14 Nov 2018 00:14:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EAB4D2B5FD; Wed, 14 Nov 2018 00:14: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 5CBC22B194 for ; Wed, 14 Nov 2018 00:14:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731161AbeKNKOm (ORCPT ); Wed, 14 Nov 2018 05:14:42 -0500 Received: from mail-ua1-f73.google.com ([209.85.222.73]:49102 "EHLO mail-ua1-f73.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727203AbeKNKOm (ORCPT ); Wed, 14 Nov 2018 05:14:42 -0500 Received: by mail-ua1-f73.google.com with SMTP id v10so3579428uaj.15 for ; Tue, 13 Nov 2018 16:13:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=gP+CBAlQmPNn/yqMaToN/OK84ai7EoqZvg7PiVDbZCg=; b=Td28SZtw7va5hZYOtxYr4t848EOjTVprwVuwz5OiFMk0Vr/vDmhf8MIaZ/aWWHHX88 PwqqpKlyIagbZzJg00lE/bb69oD7BA6v3RX7wjxUrj4svHwKBQEdz/Qxqxbmmx8bhH1I GEsqBPB6XYb4SqbinGo/ooEeixzrXmCzXaQZJqkPJVzusfZP09PWsssRRzyXYZBFcw6u veogSmoP6onRFveNTCl1LPDkGR7QVd9IUZTDC0mnPohFTGQqSBREACMdJzrI6x4vx0rV fAp0DWUHZT1yPRZ5qZJV/Odl5IWQOSwA3lGvgrKIvDr4fu/HmSP4Yu1DeNeJ3FV3/xlV 1FJg== 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=gP+CBAlQmPNn/yqMaToN/OK84ai7EoqZvg7PiVDbZCg=; b=iMZrtYrY2uzY/+dJdxiNixOGQ2jVNRqD4Wj7S+UFfOYgaKJmGJHbQtlgSK1WhMU3Zl HAMe7XWUeR1zqRvcikKz/tT3OOx6OlQSBk+JpDbJis23oYEX8agDKPfFW1T6PYFlpXgn tWcRotADQuIX2MXy7glRaPuQdsgUCR9e7g3xsWFDaOlbunmi/rjpZGSx+KFqLDq6jobi 8s89EWTKxuA+e1i3NARRSAbWgRR891k+h5n+/nAEUcPKO+XbIq46mIgPn8e+jEHBMvGs ciGdvK/YFAomg1pPNfItDEjM1oyXghwR+fPT/kTos+v9zxhvJXmuq2pHzOb6CIXXpjIL 0FeA== X-Gm-Message-State: AGRZ1gK0NeEcchSq89zdcoLSEFY6qe+cCXo/2FNuifwmWJwdpXpytaf3 LhAqscn6WP3tcnah1lOMfXeTaqVZkwIW X-Google-Smtp-Source: AJdET5czgAH+hJ3N/Cee2Y4HxQa6W64LF+2EChyNml+fJUX8MBb511qvswHu+3iiga25CctRRUG5WOc0vs+i X-Received: by 2002:ab0:47c8:: with SMTP id w8mr3337822uac.24.1542154438903; Tue, 13 Nov 2018 16:13:58 -0800 (PST) Date: Tue, 13 Nov 2018 16:12:54 -0800 In-Reply-To: <20181114001306.138053-1-sbeller@google.com> Message-Id: <20181114001306.138053-12-sbeller@google.com> Mime-Version: 1.0 References: <20181114001306.138053-1-sbeller@google.com> X-Mailer: git-send-email 2.19.1.1215.g8438c0b245-goog Subject: [PATCH 11/23] commit-reach.c: allow get_merge_bases_many_0 to handle any repo From: Stefan Beller To: gitster@pobox.com, jonathantanmy@google.com Cc: git@vger.kernel.org, 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 81015830cb..b3b1f62aba 100644 --- a/commit-reach.c +++ b/commit-reach.c @@ -216,7 +216,8 @@ static int remove_redundant(struct repository *r, struct commit **array, int cnt return filled; } -static struct commit_list *get_merge_bases_many_0(struct commit *one, +static struct commit_list *get_merge_bases_many_0(struct repository *r, + struct commit *one, int n, struct commit **twos, int cleanup) @@ -226,7 +227,7 @@ static struct commit_list *get_merge_bases_many_0(struct commit *one, struct commit_list *result; int cnt, i; - result = merge_bases_many(the_repository, one, n, twos); + result = merge_bases_many(r, one, n, twos); for (i = 0; i < n; i++) { if (one == twos[i]) return result; @@ -249,7 +250,7 @@ static struct commit_list *get_merge_bases_many_0(struct commit *one, clear_commit_marks(one, all_flags); clear_commit_marks_many(n, twos, all_flags); - cnt = remove_redundant(the_repository, rslt, cnt); + cnt = remove_redundant(r, rslt, cnt); result = NULL; for (i = 0; i < cnt; i++) commit_list_insert_by_date(rslt[i], &result); @@ -261,19 +262,19 @@ struct commit_list *get_merge_bases_many(struct commit *one, int n, struct commit **twos) { - return get_merge_bases_many_0(one, n, twos, 1); + return get_merge_bases_many_0(the_repository, one, n, twos, 1); } struct commit_list *get_merge_bases_many_dirty(struct commit *one, int n, struct commit **twos) { - return get_merge_bases_many_0(one, n, twos, 0); + return get_merge_bases_many_0(the_repository, one, n, twos, 0); } struct commit_list *get_merge_bases(struct commit *one, struct commit *two) { - return get_merge_bases_many_0(one, 1, &two, 1); + return get_merge_bases_many_0(the_repository, one, 1, &two, 1); } /* From patchwork Wed Nov 14 00:12:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Beller X-Patchwork-Id: 10681697 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 EAE2413BF for ; Wed, 14 Nov 2018 00:14:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DBF952B194 for ; Wed, 14 Nov 2018 00:14:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D090B2B5F7; Wed, 14 Nov 2018 00:14: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 61BF82B194 for ; Wed, 14 Nov 2018 00:14:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731192AbeKNKOo (ORCPT ); Wed, 14 Nov 2018 05:14:44 -0500 Received: from mail-pl1-f201.google.com ([209.85.214.201]:52465 "EHLO mail-pl1-f201.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731191AbeKNKOo (ORCPT ); Wed, 14 Nov 2018 05:14:44 -0500 Received: by mail-pl1-f201.google.com with SMTP id 33-v6so10796258pld.19 for ; Tue, 13 Nov 2018 16:14:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=27BOe5wD3fr53AYTQS7q4HuK2T7gbBlT87unv87+w2c=; b=NIp9v5cz/gI6069Qvsp4t874ba10xKRGGf08aSYDoIPODEJNn2UWerzZp5tYS+oxaJ r2oKgf0YOJcTmod+dxPafIsqYrHlwO/7JnZ/GF1W2GEZZT7QH2qaObIpRMzny2HAuoKU sC6g9Nb0dYazEusRc2G3QWxa/SD8fG/ccdEa4EHwKmIHulQb5XPr51UyTItc3x+G/LyV fy8TmqSfLnvIpoAiHhBQ0Mf8qipwIKEA2wsu4swG7TbJE1ftt9GHvqSx7IP2mLMVCWol ylBoj4PZ7P8SmIduxUcqTHVCtafQ8IqU71KhMJXy9BZQCTYuVgmhBfPqUZMQS4ogc8WG SjfQ== 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=27BOe5wD3fr53AYTQS7q4HuK2T7gbBlT87unv87+w2c=; b=ivExksYPcilf1xFAb6TjyiD2BALq7vlRyTlZCA48kebnnRYg1P0pMOAsIE9sUMtZ/P GDXT4IFwxsYlpBHa2rZ0JbjsofiF1ER5yQcgcSXtr3vaUJ4c0HYaqklyFJ5jlOuWm4kL kTibZnaI1pJd1ob+Ig5wVop+LpfRd6RZY2DLGVOOoFSGKh247vCiYQsLhn/InvX7mc08 jiq24BX+yZBU/PVifuvIPqeL1aKJdoE86fIh0ocAqowJ6YB620jx9B/8DUT2WsmQ4ws9 mtjUt2GZp8EY5O7eez8rF3Qi0VA4IJ5GiWNC1ga8piU4Ee+86UvGbo2xRH0uHsB/YLWP Fnrg== X-Gm-Message-State: AGRZ1gIgzZy+oYmTUCh+7eak7fDTmHl2/LDc+9JB34XbaUWBwrCU2X2C DSES5Uno59DLzVptwnl+z7OErmieqayB X-Google-Smtp-Source: AJdET5cC5tEh5LCAaGHW8t6PRUpcBeQ8uMn05Zfjh5urKZedbGyTT/T5bm9lbqxf4cJ529X7eFjvE545T7VT X-Received: by 2002:a62:d5c2:: with SMTP id d185mr1876866pfg.123.1542154441210; Tue, 13 Nov 2018 16:14:01 -0800 (PST) Date: Tue, 13 Nov 2018 16:12:55 -0800 In-Reply-To: <20181114001306.138053-1-sbeller@google.com> Message-Id: <20181114001306.138053-13-sbeller@google.com> Mime-Version: 1.0 References: <20181114001306.138053-1-sbeller@google.com> X-Mailer: git-send-email 2.19.1.1215.g8438c0b245-goog Subject: [PATCH 12/23] commit-reach: prepare get_merge_bases to handle any repo From: Stefan Beller To: gitster@pobox.com, jonathantanmy@google.com Cc: git@vger.kernel.org, Stefan Beller Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Similarly to previous patches, the get_merge_base functions are used often in the code base, which makes migrating them hard. Implement the new functions, prefixed with 'repo_' and hide the old functions behind a wrapper macro. Signed-off-by: Stefan Beller --- commit-reach.c | 24 ++++++++++------- commit-reach.h | 26 ++++++++++++------- .../coccinelle/the_repository.pending.cocci | 26 +++++++++++++++++++ 3 files changed, 56 insertions(+), 20 deletions(-) diff --git a/commit-reach.c b/commit-reach.c index b3b1f62aba..657a4e9b5a 100644 --- a/commit-reach.c +++ b/commit-reach.c @@ -258,23 +258,27 @@ static struct commit_list *get_merge_bases_many_0(struct repository *r, return result; } -struct commit_list *get_merge_bases_many(struct commit *one, - int n, - struct commit **twos) +struct commit_list *repo_get_merge_bases_many(struct repository *r, + struct commit *one, + int n, + struct commit **twos) { - return get_merge_bases_many_0(the_repository, one, n, twos, 1); + return get_merge_bases_many_0(r, one, n, twos, 1); } -struct commit_list *get_merge_bases_many_dirty(struct commit *one, - int n, - struct commit **twos) +struct commit_list *repo_get_merge_bases_many_dirty(struct repository *r, + struct commit *one, + int n, + struct commit **twos) { - return get_merge_bases_many_0(the_repository, one, n, twos, 0); + return get_merge_bases_many_0(r, one, n, twos, 0); } -struct commit_list *get_merge_bases(struct commit *one, struct commit *two) +struct commit_list *repo_get_merge_bases(struct repository *r, + struct commit *one, + struct commit *two) { - return get_merge_bases_many_0(the_repository, one, 1, &two, 1); + return get_merge_bases_many_0(r, one, 1, &two, 1); } /* diff --git a/commit-reach.h b/commit-reach.h index 7d313e2975..52667d64ac 100644 --- a/commit-reach.h +++ b/commit-reach.h @@ -8,17 +8,23 @@ struct commit_list; struct contains_cache; struct ref_filter; -struct commit_list *get_merge_bases_many(struct commit *one, - int n, - struct commit **twos); -struct commit_list *get_merge_bases_many_dirty(struct commit *one, - int n, - struct commit **twos); -struct commit_list *get_merge_bases(struct commit *one, struct commit *two); -struct commit_list *get_octopus_merge_bases(struct commit_list *in); - +struct commit_list *repo_get_merge_bases(struct repository *r, + struct commit *rev1, + struct commit *rev2); +struct commit_list *repo_get_merge_bases_many(struct repository *r, + struct commit *one, int n, + struct commit **twos); /* To be used only when object flags after this call no longer matter */ -struct commit_list *get_merge_bases_many_dirty(struct commit *one, int n, struct commit **twos); +struct commit_list *repo_get_merge_bases_many_dirty(struct repository *r, + struct commit *one, int n, + struct commit **twos); +#ifndef NO_THE_REPOSITORY_COMPATIBILITY_MACROS +#define get_merge_bases(r1, r2) repo_get_merge_bases(the_repository, r1, r2) +#define get_merge_bases_many(one, n, two) repo_get_merge_bases_many(the_repository, one, n, two) +#define get_merge_bases_many_dirty(one, n, twos) repo_get_merge_bases_many_dirty(the_repository, one, n, twos) +#endif + +struct commit_list *get_octopus_merge_bases(struct commit_list *in); int is_descendant_of(struct commit *commit, struct commit_list *with_commit); int in_merge_bases_many(struct commit *commit, int nr_reference, struct commit **reference); diff --git a/contrib/coccinelle/the_repository.pending.cocci b/contrib/coccinelle/the_repository.pending.cocci index b185fe0a1d..f6c2915a4e 100644 --- a/contrib/coccinelle/the_repository.pending.cocci +++ b/contrib/coccinelle/the_repository.pending.cocci @@ -64,3 +64,29 @@ expression E; - parse_commit( + repo_parse_commit(the_repository, E) + +@@ +expression E; +expression F; +@@ +- get_merge_bases( ++ repo_get_merge_bases(the_repository, + E, F); + +@@ +expression E; +expression F; +expression G; +@@ +- get_merge_bases_many( ++ repo_get_merge_bases_many(the_repository, + E, F, G); + +@@ +expression E; +expression F; +expression G; +@@ +- get_merge_bases_many_dirty( ++ repo_get_merge_bases_many_dirty(the_repository, + E, F, G); From patchwork Wed Nov 14 00:12:56 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Beller X-Patchwork-Id: 10681699 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 738D913BF for ; Wed, 14 Nov 2018 00:14:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 64D6D2B194 for ; Wed, 14 Nov 2018 00:14:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 596412B5F7; Wed, 14 Nov 2018 00:14:07 +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 E6DDF2B194 for ; Wed, 14 Nov 2018 00:14:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731260AbeKNKOs (ORCPT ); Wed, 14 Nov 2018 05:14:48 -0500 Received: from mail-io1-f73.google.com ([209.85.166.73]:56932 "EHLO mail-io1-f73.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731191AbeKNKOr (ORCPT ); Wed, 14 Nov 2018 05:14:47 -0500 Received: by mail-io1-f73.google.com with SMTP id m1so1791176ioh.23 for ; Tue, 13 Nov 2018 16:14:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=9o9YDsgGUmPN52/oPMXRqdZNvbgLfyrW9jXywrxCI+o=; b=ud1ybqWzCOTZlOlfpOCOQI9oXsAa2rOZ9uk4wOox6vMAwx9K2BYAlmMZDseGs/LWpz AA6A4UoWo3Tv2OklCQiLPYlxT2R0vmUuvPZCI7EMKLVLIO+qP+2NhAem3PAVUpzH3Mj1 2p8AmsTXBm9KedS9+yIdTHCiWpLV+/kQzlh+vvdi5PdhuewBfMKVmqOShknF9q0TbVZV lhEVmI9XXqjJfKVx2sXeVPwIwrDWVY2Mrt4WcP7VuOK3EcxjSSoh8Vz8/ol8d8xiDFY5 6nPjCcGfyj50x0pQoviHTBnwLBsjETR+qUgn/LvLZBw69/YZ1YADdt8VqNUhte7oVntz 6KLA== 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=9o9YDsgGUmPN52/oPMXRqdZNvbgLfyrW9jXywrxCI+o=; b=OV30149SBKrh8jxRGLI9BYwUKo6BED9lVJtcaRcwvAH/O3FX21K5KwIyruj+f2T5c+ meqIV2yeDjSk3EYIBmsTbgRD2dnze316NOBuLA1Ec2OvEckM2UEjzU7wIq3KYRp4BynK 9XK4hv8Ms0uoMW+DwQAb+ogMc17vUXeln1ZFtEgZvlVXuRDQgQi7Yr9kO+4p+qO3ksYr Nq6wdbxPzYNdWV7DkMumfyMN8m+VZUQFLU8wRe7zn9Mx/I4tvYvkKSHEX4HvBulwk1dA sKp9CHqULJbani8O4VjjnvN1MXvihUiJjOIMT162gQRLHpbF3eQMasQyh05Htxbk6exQ 9CUw== X-Gm-Message-State: AGRZ1gIXKrqJdpRGLqpOmUXnEuZVIScs8dhGkvpIsG/+PjkfsyPWg9Hb yCyj3uDKou/cPGhVfVA4K9lnEc34WTi1 X-Google-Smtp-Source: AJdET5eb14m6AudoQRKUFMxsk+cnVfxuTAgCGy5GxpWU8bx/RdxF8T812r/8NvKB6xh1/0sl1CQ3QSF75HIR X-Received: by 2002:a24:1644:: with SMTP id a65mr72806ita.40.1542154444226; Tue, 13 Nov 2018 16:14:04 -0800 (PST) Date: Tue, 13 Nov 2018 16:12:56 -0800 In-Reply-To: <20181114001306.138053-1-sbeller@google.com> Message-Id: <20181114001306.138053-14-sbeller@google.com> Mime-Version: 1.0 References: <20181114001306.138053-1-sbeller@google.com> X-Mailer: git-send-email 2.19.1.1215.g8438c0b245-goog Subject: [PATCH 13/23] commit-reach: prepare in_merge_bases[_many] to handle any repo From: Stefan Beller To: gitster@pobox.com, jonathantanmy@google.com Cc: git@vger.kernel.org, Stefan Beller Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Stefan Beller --- commit-reach.c | 15 +++++++++------ commit-reach.h | 12 ++++++++++-- contrib/coccinelle/the_repository.pending.cocci | 17 +++++++++++++++++ 3 files changed, 36 insertions(+), 8 deletions(-) diff --git a/commit-reach.c b/commit-reach.c index 657a4e9b5a..8715008fef 100644 --- a/commit-reach.c +++ b/commit-reach.c @@ -312,16 +312,17 @@ int is_descendant_of(struct commit *commit, struct commit_list *with_commit) /* * Is "commit" an ancestor of one of the "references"? */ -int in_merge_bases_many(struct commit *commit, int nr_reference, struct commit **reference) +int repo_in_merge_bases_many(struct repository *r, struct commit *commit, + int nr_reference, struct commit **reference) { struct commit_list *bases; int ret = 0, i; uint32_t min_generation = GENERATION_NUMBER_INFINITY; - if (parse_commit(commit)) + if (repo_parse_commit(r, commit)) return ret; for (i = 0; i < nr_reference; i++) { - if (parse_commit(reference[i])) + if (repo_parse_commit(r, reference[i])) return ret; if (reference[i]->generation < min_generation) min_generation = reference[i]->generation; @@ -330,7 +331,7 @@ int in_merge_bases_many(struct commit *commit, int nr_reference, struct commit * if (commit->generation > min_generation) return ret; - bases = paint_down_to_common(the_repository, commit, + bases = paint_down_to_common(r, commit, nr_reference, reference, commit->generation); if (commit->object.flags & PARENT2) @@ -344,9 +345,11 @@ int in_merge_bases_many(struct commit *commit, int nr_reference, struct commit * /* * Is "commit" an ancestor of (i.e. reachable from) the "reference"? */ -int in_merge_bases(struct commit *commit, struct commit *reference) +int repo_in_merge_bases(struct repository *r, + struct commit *commit, + struct commit *reference) { - return in_merge_bases_many(commit, 1, &reference); + return repo_in_merge_bases_many(r, commit, 1, &reference); } struct commit_list *reduce_heads(struct commit_list *heads) diff --git a/commit-reach.h b/commit-reach.h index 52667d64ac..a0d4a29d25 100644 --- a/commit-reach.h +++ b/commit-reach.h @@ -27,8 +27,16 @@ struct commit_list *repo_get_merge_bases_many_dirty(struct repository *r, struct commit_list *get_octopus_merge_bases(struct commit_list *in); int is_descendant_of(struct commit *commit, struct commit_list *with_commit); -int in_merge_bases_many(struct commit *commit, int nr_reference, struct commit **reference); -int in_merge_bases(struct commit *commit, struct commit *reference); +int repo_in_merge_bases(struct repository *r, + struct commit *commit, + struct commit *reference); +int repo_in_merge_bases_many(struct repository *r, + struct commit *commit, + int nr_reference, struct commit **reference); +#ifndef NO_THE_REPOSITORY_COMPATIBILITY_MACROS +#define in_merge_bases(c1, c2) repo_in_merge_bases(the_repository, c1, c2) +#define in_merge_bases_many(c1, n, cs) repo_in_merge_bases_many(the_repository, c1, n, cs) +#endif /* * Takes a list of commits and returns a new list where those diff --git a/contrib/coccinelle/the_repository.pending.cocci b/contrib/coccinelle/the_repository.pending.cocci index f6c2915a4e..8c6a71bf64 100644 --- a/contrib/coccinelle/the_repository.pending.cocci +++ b/contrib/coccinelle/the_repository.pending.cocci @@ -90,3 +90,20 @@ expression G; - get_merge_bases_many_dirty( + repo_get_merge_bases_many_dirty(the_repository, E, F, G); + +@@ +expression E; +expression F; +@@ +- in_merge_bases( ++ repo_in_merge_bases(the_repository, + E, F); + +@@ +expression E; +expression F; +expression G; +@@ +- in_merge_bases_many( ++ repo_in_merge_bases_many(the_repository, + E, F, G); From patchwork Wed Nov 14 00:12:57 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Beller X-Patchwork-Id: 10681701 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 2F1231759 for ; Wed, 14 Nov 2018 00:14:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 20B952B194 for ; Wed, 14 Nov 2018 00:14:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 154C32B5F7; Wed, 14 Nov 2018 00:14: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 A7BF02B194 for ; Wed, 14 Nov 2018 00:14:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731278AbeKNKOv (ORCPT ); Wed, 14 Nov 2018 05:14:51 -0500 Received: from mail-yw1-f73.google.com ([209.85.161.73]:33938 "EHLO mail-yw1-f73.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731191AbeKNKOu (ORCPT ); Wed, 14 Nov 2018 05:14:50 -0500 Received: by mail-yw1-f73.google.com with SMTP id j186-v6so4467737ywj.1 for ; Tue, 13 Nov 2018 16:14:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=4oPSJiLpae3XBaLljvdnmh4s6/Kyu2e/v7ySXbNXtWk=; b=DCYBE/Z34seTqq23LqD8foGaMwG304YE7Msc939seto1SZL9lisx1P6vOrp9DGIQBD hlrCxnQEKU7pWnUPbPzYFsDR7LpD7iULQSYrmhVIA+qu2rHAQiPZDkcqub6nm+M7c1yE QnYjQzVUFm2rqIr+RG1vBklljH2G5RXi7vAQ+EBIPess6nQijoPwjK0TW3MJQMIuQf2M sabYQj8AsQtWhP8zd1x8Z0CKgdjIrwcVS+/nyCIvolSqUvMyn9TwtpTvCUXHNhkTxyA6 QSJ30DWv1K4YmJ3spfOdkw3BqN8hvaCzM0m3UXtKsmJ3rRDOU/z6uIIDCjqOAzZPce7C B+vA== 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=4oPSJiLpae3XBaLljvdnmh4s6/Kyu2e/v7ySXbNXtWk=; b=Xt66CDmRVOOgAG4hPhFb0y/BY2JoKWo6AVEFBrxJthXYMVDsroL22+NVa5CJMCybq/ rmBkXyjUTItRLTN0a9TBUHoF70k/slSR21iWGrjf0IcwClUPcdzc7oARuORgy0UauPWN OorOYtdW5WVe9zMkAU3zB9ZgsAhiHyQ6UFdDwZzoVD/t1IvY/drLqU6QZwqlLYRN/Qrj ePhG0J0t6MT6/2m2LPaHwbkh4UClXFbFtMwpMCXufGEhmJ7vRRdMfTkz9RoA4ExfejkB ogJPDuX5bdx5II7tMmdjmKXgFLfBd0le0Yl4iygaBG1yrpxHxQ7gr9xHgao4s2cGjBI5 h9pw== X-Gm-Message-State: AGRZ1gIvDPzK0pJNzkhEUnSkt/bmxbYG3/Z59aJJfIaWWOgmeWjmEF9n zGABy3DOXqN4LK+9MnjGRnzJCZoTKTC7 X-Google-Smtp-Source: AJdET5fkUR4OdES77XtTiAdZs7NmlhySv+GiV1rZULAmI+g0I2XR1QZTs5cH3gEAp5Kf7mHT8W5zeXflgI32 X-Received: by 2002:a81:77d4:: with SMTP id s203-v6mr3639440ywc.7.1542154447335; Tue, 13 Nov 2018 16:14:07 -0800 (PST) Date: Tue, 13 Nov 2018 16:12:57 -0800 In-Reply-To: <20181114001306.138053-1-sbeller@google.com> Message-Id: <20181114001306.138053-15-sbeller@google.com> Mime-Version: 1.0 References: <20181114001306.138053-1-sbeller@google.com> X-Mailer: git-send-email 2.19.1.1215.g8438c0b245-goog Subject: [PATCH 14/23] commit: prepare get_commit_buffer to handle any repo From: Stefan Beller To: gitster@pobox.com, jonathantanmy@google.com Cc: git@vger.kernel.org, Stefan Beller Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Stefan Beller --- commit.c | 8 +++++--- commit.h | 7 ++++++- contrib/coccinelle/the_repository.pending.cocci | 8 ++++++++ 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/commit.c b/commit.c index 7a931d7fd4..4034def16c 100644 --- a/commit.c +++ b/commit.c @@ -297,13 +297,15 @@ const void *get_cached_commit_buffer(struct repository *r, const struct commit * return v->buffer; } -const void *get_commit_buffer(const struct commit *commit, unsigned long *sizep) +const void *repo_get_commit_buffer(struct repository *r, + const struct commit *commit, + unsigned long *sizep) { - const void *ret = get_cached_commit_buffer(the_repository, commit, sizep); + const void *ret = get_cached_commit_buffer(r, commit, sizep); if (!ret) { enum object_type type; unsigned long size; - ret = read_object_file(&commit->object.oid, &type, &size); + ret = repo_read_object_file(r, &commit->object.oid, &type, &size); if (!ret) die("cannot read commit object %s", oid_to_hex(&commit->object.oid)); diff --git a/commit.h b/commit.h index 08935f9a19..591a77a5bb 100644 --- a/commit.h +++ b/commit.h @@ -117,7 +117,12 @@ const void *get_cached_commit_buffer(struct repository *, const struct commit *, * from disk. The resulting memory should not be modified, and must be given * to unuse_commit_buffer when the caller is done. */ -const void *get_commit_buffer(const struct commit *, unsigned long *size); +const void *repo_get_commit_buffer(struct repository *r, + const struct commit *, + unsigned long *size); +#ifndef NO_THE_REPOSITORY_COMPATIBILITY_MACROS +#define get_commit_buffer(c, s) repo_get_commit_buffer(the_repository, c, s) +#endif /* * Tell the commit subsytem that we are done with a particular commit buffer. diff --git a/contrib/coccinelle/the_repository.pending.cocci b/contrib/coccinelle/the_repository.pending.cocci index 8c6a71bf64..4018e6eaf7 100644 --- a/contrib/coccinelle/the_repository.pending.cocci +++ b/contrib/coccinelle/the_repository.pending.cocci @@ -107,3 +107,11 @@ expression G; - in_merge_bases_many( + repo_in_merge_bases_many(the_repository, E, F, G); + +@@ +expression E; +expression F; +@@ +- get_commit_buffer( ++ repo_get_commit_buffer(the_repository, + E, F); From patchwork Wed Nov 14 00:12:58 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Beller X-Patchwork-Id: 10681703 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 187A61759 for ; Wed, 14 Nov 2018 00:14:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 09FC22B194 for ; Wed, 14 Nov 2018 00:14:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F2B882B5F7; Wed, 14 Nov 2018 00:14: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 9F78E2B194 for ; Wed, 14 Nov 2018 00:14:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731321AbeKNKOy (ORCPT ); Wed, 14 Nov 2018 05:14:54 -0500 Received: from mail-it1-f202.google.com ([209.85.166.202]:35603 "EHLO mail-it1-f202.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731191AbeKNKOx (ORCPT ); Wed, 14 Nov 2018 05:14:53 -0500 Received: by mail-it1-f202.google.com with SMTP id e19-v6so12984513itc.0 for ; Tue, 13 Nov 2018 16:14:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=darsJglboYFXdBV0PtDEBbxKvHxm+QT0RA6oYl1qQTo=; b=wL45PdnCIzGChZsSPBW1QtS7igfQSAr22w64u8fJGdtFamUNLYpQq96TULnmRLstPT 3aJVVeVv8ic07WIaW4ba0ba8jS3u5s6lZVylmZfV/sblO4w9mPQHW3i7lSLCuuo3iAaP J/TiXfNnO5WxJDSWwx5+AFNZ9W3HHJy3QtJSXW9vsq2b8KnyAELTNhYAPd5YdiELE6Y3 ACFhgOrN5/v/+jQ4rUQFU4OrC+pFkCeKrVNmMHXJHwe7Ed1MTwUijwW5Tz6alhpub4SZ dRLTMxUkIdSJWKXmjqy3sZB5e3AM6HgZ5OlxCtgjooXT2pnXxCQeH85hRZFerIZp3px1 Qq0w== 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=darsJglboYFXdBV0PtDEBbxKvHxm+QT0RA6oYl1qQTo=; b=VWmh7nctSpM8nPjcIM3ryZ9MxegeoUB4AErvvKoqH6ys1YWV+wKIeYX5zfS+Ex28PV 28YvlFd38ETogexyLj/5LBaS3g7FjzJbyG3uCJHQGRu+/0oNIyvVEB2jLuxo0fj5MlzG gUQ9VgMRd6izgr4nZd6vfICFhzlwWKORaC9Jggsd2voBhLk4yJl5mncq0nUN+mWQLj5u W521nSo0dPvi8Jz5R8dnozmB6xYcUc1u/karYRZEiFKMSt/oBcILwqBY0l3cMkyHZz1e KU+keKDjIDH3mMnJz9HtRkcImjOOcQXOHMo6mu5/7wWHSJXMUjVVX0Yyqiwry5NUNzYk 0/Rw== X-Gm-Message-State: AGRZ1gJk8LsKGe5Hl3IDkMsvaorVQCBaMX//rfrdRaoxt0M6E9W90gOW slY1vAAwBMGJ7IVgv/5gti8G/f1ffrvR X-Google-Smtp-Source: AJdET5fd05/NL1Po+jP4G21NUHoIMH++ho5ND9FeqI5FcJKYH72lG9tbVHRtO043LJxEstTTVa68jo46R8X0 X-Received: by 2002:a24:9085:: with SMTP id x127-v6mr65542itd.17.1542154450611; Tue, 13 Nov 2018 16:14:10 -0800 (PST) Date: Tue, 13 Nov 2018 16:12:58 -0800 In-Reply-To: <20181114001306.138053-1-sbeller@google.com> Message-Id: <20181114001306.138053-16-sbeller@google.com> Mime-Version: 1.0 References: <20181114001306.138053-1-sbeller@google.com> X-Mailer: git-send-email 2.19.1.1215.g8438c0b245-goog Subject: [PATCH 15/23] commit: prepare repo_unuse_commit_buffer to handle any repo From: Stefan Beller To: gitster@pobox.com, jonathantanmy@google.com Cc: git@vger.kernel.org, Stefan Beller Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Stefan Beller --- commit.c | 6 ++++-- commit.h | 7 ++++++- contrib/coccinelle/the_repository.pending.cocci | 8 ++++++++ 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/commit.c b/commit.c index 4034def16c..7d2f3a9a93 100644 --- a/commit.c +++ b/commit.c @@ -318,10 +318,12 @@ const void *repo_get_commit_buffer(struct repository *r, return ret; } -void unuse_commit_buffer(const struct commit *commit, const void *buffer) +void repo_unuse_commit_buffer(struct repository *r, + const struct commit *commit, + const void *buffer) { struct commit_buffer *v = buffer_slab_peek( - the_repository->parsed_objects->buffer_slab, commit); + r->parsed_objects->buffer_slab, commit); if (!(v && v->buffer == buffer)) free((void *)buffer); } diff --git a/commit.h b/commit.h index 591a77a5bb..57375e3239 100644 --- a/commit.h +++ b/commit.h @@ -130,7 +130,12 @@ const void *repo_get_commit_buffer(struct repository *r, * from an earlier call to get_commit_buffer. The buffer may or may not be * freed by this call; callers should not access the memory afterwards. */ -void unuse_commit_buffer(const struct commit *, const void *buffer); +void repo_unuse_commit_buffer(struct repository *r, + const struct commit *, + const void *buffer); +#ifndef NO_THE_REPOSITORY_COMPATIBILITY_MACROS +#define unuse_commit_buffer(c, b) repo_unuse_commit_buffer(the_repository, c, b) +#endif /* * Free any cached object buffer associated with the commit. diff --git a/contrib/coccinelle/the_repository.pending.cocci b/contrib/coccinelle/the_repository.pending.cocci index 4018e6eaf7..516f19ffee 100644 --- a/contrib/coccinelle/the_repository.pending.cocci +++ b/contrib/coccinelle/the_repository.pending.cocci @@ -115,3 +115,11 @@ expression F; - get_commit_buffer( + repo_get_commit_buffer(the_repository, E, F); + +@@ +expression E; +expression F; +@@ +- unuse_commit_buffer( ++ repo_unuse_commit_buffer(the_repository, + E, F); From patchwork Wed Nov 14 00:12:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Beller X-Patchwork-Id: 10681705 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 A633513BF for ; Wed, 14 Nov 2018 00:14:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 97DC72B194 for ; Wed, 14 Nov 2018 00:14:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8C6AA2B5F7; Wed, 14 Nov 2018 00:14: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 214132B194 for ; Wed, 14 Nov 2018 00:14:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731337AbeKNKO4 (ORCPT ); Wed, 14 Nov 2018 05:14:56 -0500 Received: from mail-pf1-f202.google.com ([209.85.210.202]:44190 "EHLO mail-pf1-f202.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731191AbeKNKO4 (ORCPT ); Wed, 14 Nov 2018 05:14:56 -0500 Received: by mail-pf1-f202.google.com with SMTP id 129-v6so11702776pfx.11 for ; Tue, 13 Nov 2018 16:14:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=D2k+iH8QhVa1BNqc2yyTHw7BYpFZyZ6tcgdp5lnz6LM=; b=hxqXG7qbhiUkj9EA7ZRNRK0PElPLfBGKQPwF9EBxe2ucTx82NXiDu+trLvUXVTNrQl LRxpmeUKgU+yDgjb9zCoRjxg6fZV2TXQ/rt0QUwmb/9/6VNP6+EpbB8q6Rs40GOV0ZjI dStuaZFcZH3sfk4Lt4qOJkTZqYMyfRa9GLBZaG7NEjEF7ZKLBJqsOyQiPL5jeTO/Zt3A 7hlC3zaBiDORq3pmF/u9TQgJS7w9FU8fq88wHWrvNiE+/ZhmrGBez3/ZWHyLjkQkfrKn 0vQMQKnRDIRK7Xjy+wr7O4jSKDhSDFoMGbuQDf0JtQlukyb8L1RfobRR1guEQqdtq3mB IPoA== 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=D2k+iH8QhVa1BNqc2yyTHw7BYpFZyZ6tcgdp5lnz6LM=; b=WSz0tH7hnHeV4+6wek0al6j5r2H+B5UADc+EANtxpjvl5jVlEihkx1Qg3jkmeM/9RJ 7pX0ApzqBCBFOvBcmq5zMwsVhNM9EaYCZgXJnEpVL9gCECvCaf4B63rVOy3mAHee1W7O BZ2W/KQ7Q/RuWRvMJNWFKIcG8y/efrgYn5zDlkUr69Et0E8uX49FVDTzAf7vN4i7LAIw Hp1yb2JtNnlaUxnt216frH2VLeNYnziDKfYHyNNz1tuCRDtP4Q29NWckjo+d8U5AVhNs 2UvmnpJwSEN2B+W/SaW8429FuCsnEA2Eei6Q1uC2qFt1z3DvvTNN2SAyzo3nNw9AuhFW 6ozw== X-Gm-Message-State: AGRZ1gJSohSNEKYYyRuxnHOQbfJEsrw4E8OnXkN90S2x9Pu/hkAZ8HS4 vgtBpY+hps8iPjqDMDLE6rME1vQXyGV6 X-Google-Smtp-Source: AJdET5c0Ut3zSVaLBz2PjqqycKjB28crg/HDarR54lTYF4ydrE+3fKYkaAM2k7CEt03ehqg+zgX+ADmRT6Z9 X-Received: by 2002:a62:e053:: with SMTP id f80mr93443pfh.106.1542154452993; Tue, 13 Nov 2018 16:14:12 -0800 (PST) Date: Tue, 13 Nov 2018 16:12:59 -0800 In-Reply-To: <20181114001306.138053-1-sbeller@google.com> Message-Id: <20181114001306.138053-17-sbeller@google.com> Mime-Version: 1.0 References: <20181114001306.138053-1-sbeller@google.com> X-Mailer: git-send-email 2.19.1.1215.g8438c0b245-goog Subject: [PATCH 16/23] commit: prepare logmsg_reencode to handle arbitrary repositories From: Stefan Beller To: gitster@pobox.com, jonathantanmy@google.com Cc: git@vger.kernel.org, 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 Signed-off-by: Junio C Hamano --- commit.h | 8 ++++++++ contrib/coccinelle/the_repository.pending.cocci | 9 +++++++++ pretty.c | 13 +++++++------ 3 files changed, 24 insertions(+), 6 deletions(-) diff --git a/commit.h b/commit.h index 57375e3239..2e6b799b26 100644 --- a/commit.h +++ b/commit.h @@ -180,6 +180,14 @@ extern int has_non_ascii(const char *text); extern const char *logmsg_reencode(const struct commit *commit, char **commit_encoding, const char *output_encoding); +const char *repo_logmsg_reencode(struct repository *r, + const struct commit *commit, + char **commit_encoding, + const char *output_encoding); +#ifndef NO_THE_REPOSITORY_COMPATIBILITY_MACROS +#define logmsg_reencode(c, enc, out) repo_logmsg_reencode(the_repository, c, enc, out) +#endif + extern const char *skip_blank_lines(const char *msg); /** Removes the first commit from a list sorted by date, and adds all diff --git a/contrib/coccinelle/the_repository.pending.cocci b/contrib/coccinelle/the_repository.pending.cocci index 516f19ffee..f5b42cfc62 100644 --- a/contrib/coccinelle/the_repository.pending.cocci +++ b/contrib/coccinelle/the_repository.pending.cocci @@ -123,3 +123,12 @@ expression F; - unuse_commit_buffer( + repo_unuse_commit_buffer(the_repository, E, F); + +@@ +expression E; +expression F; +expression G; +@@ +- logmsg_reencode( ++ repo_logmsg_reencode(the_repository, + E, F, G); diff --git a/pretty.c b/pretty.c index 8ca29e9281..b359b68750 100644 --- a/pretty.c +++ b/pretty.c @@ -595,14 +595,15 @@ static char *replace_encoding_header(char *buf, const char *encoding) return strbuf_detach(&tmp, NULL); } -const char *logmsg_reencode(const struct commit *commit, - char **commit_encoding, - const char *output_encoding) +const char *repo_logmsg_reencode(struct repository *r, + const struct commit *commit, + char **commit_encoding, + const char *output_encoding) { static const char *utf8 = "UTF-8"; const char *use_encoding; char *encoding; - const char *msg = get_commit_buffer(commit, NULL); + const char *msg = repo_get_commit_buffer(r, commit, NULL); char *out; if (!output_encoding || !*output_encoding) { @@ -630,7 +631,7 @@ const char *logmsg_reencode(const struct commit *commit, * the cached copy from get_commit_buffer, we need to duplicate it * to avoid munging the cached copy. */ - if (msg == get_cached_commit_buffer(the_repository, commit, NULL)) + if (msg == get_cached_commit_buffer(r, commit, NULL)) out = xstrdup(msg); else out = (char *)msg; @@ -644,7 +645,7 @@ const char *logmsg_reencode(const struct commit *commit, */ out = reencode_string(msg, output_encoding, use_encoding); if (out) - unuse_commit_buffer(commit, msg); + repo_unuse_commit_buffer(r, commit, msg); } /* From patchwork Wed Nov 14 00:13:00 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Beller X-Patchwork-Id: 10681707 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 C3DD01759 for ; Wed, 14 Nov 2018 00:14:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B56732B194 for ; Wed, 14 Nov 2018 00:14:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AA3472B5F7; Wed, 14 Nov 2018 00:14: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 46F792B194 for ; Wed, 14 Nov 2018 00:14:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731359AbeKNKO6 (ORCPT ); Wed, 14 Nov 2018 05:14:58 -0500 Received: from mail-it1-f201.google.com ([209.85.166.201]:53584 "EHLO mail-it1-f201.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731191AbeKNKO6 (ORCPT ); Wed, 14 Nov 2018 05:14:58 -0500 Received: by mail-it1-f201.google.com with SMTP id l200-v6so18007642ita.3 for ; Tue, 13 Nov 2018 16:14:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=/M0cdu6WCZ+2pkx59FGxTEKlnilI57MH75dOTIlVSq0=; b=lNYwvd6l/WSK6wAaX5prHkCkQcjNOJCAP9n6yMnPrBhk3dhKO3KzlvCMRd5BGgYWJ9 WfMNAT0mHeU/kHgqI0KGEhD9fPzIxdbSi7IUNjCMhDsqzN1kWxkP1/6KCU6eFYt0IsEx gAVncHcXiEb5/NDq5si+OYyH24xJ5pKEMuuzy9AroLItG/hGYvMf/PaL/jDwZjrYrPXy T0KFXct9PSqTlTHFEZWhZm7AwPxOOrV88dhvA2Ssa+g/NYG6pVmfQlGLPz1fmA6RdcXv pHbgaxH9SnqawVu1YsWfKCV8yLsTSECxCnbOaLo1rRiyHYHC02t/Q/66bSlu5z20rDV4 p24Q== 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=/M0cdu6WCZ+2pkx59FGxTEKlnilI57MH75dOTIlVSq0=; b=mGINLh3M5+J+21sEbZzN9n0rgMsmEg8XNVUSrQnDwKvzOW+HhIzuc8Smu6zUx61L27 JkW5TWx2Ko5Ge+EmBYP5c5vHZE+INEd8nqK2FUAi4wvhpKsBpwYqMtg90bkwRxPDE6Bx 2BliU6sCUefgWUdflBc7pgg2ahtwMBcd5cAFUfe3TJxy0qLEqWvKxuRXg10XG56lnjeH v+0jcJU9DziHZFmaNIlC9mBblOdkTvSQjrOOjhTJ4HuokWbkLDy2SXo7gEygTD/rx9Zt 9vrBPWSEZ5pcJhSPREE4J3a6+oXm/pRBvQYH8+tKtA3h2rS4vxCZw7pnKHNgeBPe/23p poBg== X-Gm-Message-State: AGRZ1gLK7bCZaNZql00tw5siX+bHjm8itRb3LuLif6+He2o8yolbUyP+ KySDN/MmAnjDPxR5MJfcdcRZfTVomDzQ X-Google-Smtp-Source: AJdET5dx0VhHfJIHu5qYKoVzDuJKdmcwNBNP0l+VLLJrLp+bwEw7sQmuosXZb/v/9dyVBSKAEPGDG5BYx89F X-Received: by 2002:a24:59d1:: with SMTP id p200-v6mr84467itb.10.1542154455319; Tue, 13 Nov 2018 16:14:15 -0800 (PST) Date: Tue, 13 Nov 2018 16:13:00 -0800 In-Reply-To: <20181114001306.138053-1-sbeller@google.com> Message-Id: <20181114001306.138053-18-sbeller@google.com> Mime-Version: 1.0 References: <20181114001306.138053-1-sbeller@google.com> X-Mailer: git-send-email 2.19.1.1215.g8438c0b245-goog Subject: [PATCH 17/23] pretty: prepare format_commit_message to handle arbitrary repositories From: Stefan Beller To: gitster@pobox.com, jonathantanmy@google.com Cc: git@vger.kernel.org, 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 Signed-off-by: Junio C Hamano --- contrib/coccinelle/the_repository.pending.cocci | 10 ++++++++++ pretty.c | 15 ++++++++------- pretty.h | 7 ++++++- 3 files changed, 24 insertions(+), 8 deletions(-) diff --git a/contrib/coccinelle/the_repository.pending.cocci b/contrib/coccinelle/the_repository.pending.cocci index f5b42cfc62..2ee702ecf7 100644 --- a/contrib/coccinelle/the_repository.pending.cocci +++ b/contrib/coccinelle/the_repository.pending.cocci @@ -132,3 +132,13 @@ expression G; - logmsg_reencode( + repo_logmsg_reencode(the_repository, E, F, G); + +@@ +expression E; +expression F; +expression G; +expression H; +@@ +- format_commit_message( ++ repo_format_commit_message(the_repository, + E, F, G, H); diff --git a/pretty.c b/pretty.c index b359b68750..3240495308 100644 --- a/pretty.c +++ b/pretty.c @@ -1508,9 +1508,10 @@ void userformat_find_requirements(const char *fmt, struct userformat_want *w) strbuf_release(&dummy); } -void format_commit_message(const struct commit *commit, - const char *format, struct strbuf *sb, - const struct pretty_print_context *pretty_ctx) +void repo_format_commit_message(struct repository *r, + const struct commit *commit, + const char *format, struct strbuf *sb, + const struct pretty_print_context *pretty_ctx) { struct format_commit_context context; const char *output_enc = pretty_ctx->output_encoding; @@ -1524,9 +1525,9 @@ void format_commit_message(const struct commit *commit, * convert a commit message to UTF-8 first * as far as 'format_commit_item' assumes it in UTF-8 */ - context.message = logmsg_reencode(commit, - &context.commit_encoding, - utf8); + context.message = repo_logmsg_reencode(r, commit, + &context.commit_encoding, + utf8); strbuf_expand(sb, format, format_commit_item, &context); rewrap_message_tail(sb, &context, 0, 0, 0); @@ -1550,7 +1551,7 @@ void format_commit_message(const struct commit *commit, } free(context.commit_encoding); - unuse_commit_buffer(commit, context.message); + repo_unuse_commit_buffer(r, commit, context.message); } static void pp_header(struct pretty_print_context *pp, diff --git a/pretty.h b/pretty.h index 7359d318a9..e6625269cf 100644 --- a/pretty.h +++ b/pretty.h @@ -103,9 +103,14 @@ void pp_remainder(struct pretty_print_context *pp, const char **msg_p, * Put the result to "sb". * Please use this function for custom formats. */ -void format_commit_message(const struct commit *commit, +void repo_format_commit_message(struct repository *r, + const struct commit *commit, const char *format, struct strbuf *sb, const struct pretty_print_context *context); +#ifndef NO_THE_REPOSITORY_COMPATIBILITY_MACROS +#define format_commit_message(c, f, s, con) \ + repo_format_commit_message(the_repository, c, f, s, con) +#endif /* * Parse given arguments from "arg", check it for correctness and From patchwork Wed Nov 14 00:13:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Beller X-Patchwork-Id: 10681709 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 BA0F31759 for ; Wed, 14 Nov 2018 00:14:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AB6E62B194 for ; Wed, 14 Nov 2018 00:14:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9FF982B5F7; Wed, 14 Nov 2018 00:14:20 +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 1DE662B194 for ; Wed, 14 Nov 2018 00:14:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731384AbeKNKPB (ORCPT ); Wed, 14 Nov 2018 05:15:01 -0500 Received: from mail-yb1-f201.google.com ([209.85.219.201]:56214 "EHLO mail-yb1-f201.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731191AbeKNKPB (ORCPT ); Wed, 14 Nov 2018 05:15:01 -0500 Received: by mail-yb1-f201.google.com with SMTP id y125-v6so3831154ybe.22 for ; Tue, 13 Nov 2018 16:14:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=/OtJ1IIPFcty7vJipL34AStQVGkZLwdq+ROwHdxDi30=; b=CbFX6bOu97+N2ArWPAPN1tGcPycTgLr0J/Yr2ZZaOelSkCBvVwYNuezojVwUQfzK1b HxF3aA/pIAOs9n51xgPv5618NV02zmz0AHhRm83ki0WyG11YPX8DfuGocyEPMdrykd+B or7gyRcNZ66ye1Pj4LrDvTpL5gadqgjK0lTXtX4K2XfSmYfc4w5kUF2EyUXvNmMALFZG H2ZnKM4NpGf56CW5aX6yQRDKHn9sF7Bs8Ojx/bMg7pIgGbSns3BoTbwNDEUlhDHGzYmn jpHEx1vaoTo6jfi+z8kFvEyc5YeoWaPFEhn0eh+ReyrQpBh/C1L1V+zgl6SS/E050C0X UE+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=/OtJ1IIPFcty7vJipL34AStQVGkZLwdq+ROwHdxDi30=; b=AbEM6iTr5BLHlfdW8k6SrsaidRL2bc4MFEqcMny58uWeEV89kcbnoeQtpV8R9gH5S/ YK+KFtj4Xk6RnGh3kV3jAdcumYlh08okJRxsehPPNYNQrG+n2cRl9phXcrpir7AukPz/ CbN0oys/UOq6HXd5giqUsfcHEmMgqN7i6XaVHzu+RDlEI9himG/dzmoOuPERrpb54vwV 8iATcN5NU6McSNDR+5Wn0n5Cq4xzopZxyc9WbTPCzcU/S52oXSPRuKAEuuYyI+eN37Ym MtLz1PyDt1IDPoMtIKTAsSblp2MBnjA06xN5Z5yII8LRLVqucp1rdhgUijWr+R2xC2dR 4eyw== X-Gm-Message-State: AGRZ1gJgpr1NEoRsQKjGjg5SRzS74czhnhkBLew/A0YB9pdmmMaerv/w s+xQLNtO5Pk/RbJSS73K7C7Yf/FQ3mRP X-Google-Smtp-Source: AJdET5cg62SGhX5yiWDRCuCs8CQ8WhlNPEHdKDFe6K1E7F4yCNoSS7dMHLmLdiwf181iYmERGi2XTYynqEkP X-Received: by 2002:a25:80ce:: with SMTP id c14-v6mr3741904ybm.53.1542154457666; Tue, 13 Nov 2018 16:14:17 -0800 (PST) Date: Tue, 13 Nov 2018 16:13:01 -0800 In-Reply-To: <20181114001306.138053-1-sbeller@google.com> Message-Id: <20181114001306.138053-19-sbeller@google.com> Mime-Version: 1.0 References: <20181114001306.138053-1-sbeller@google.com> X-Mailer: git-send-email 2.19.1.1215.g8438c0b245-goog Subject: [PATCH 18/23] submodule: use submodule repos for object lookup From: Stefan Beller To: gitster@pobox.com, jonathantanmy@google.com Cc: git@vger.kernel.org, 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 Signed-off-by: Stefan Beller --- submodule.c | 73 ++++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 58 insertions(+), 15 deletions(-) diff --git a/submodule.c b/submodule.c index d9d3046689..262f03f118 100644 --- a/submodule.c +++ b/submodule.c @@ -443,7 +443,7 @@ static int prepare_submodule_summary(struct rev_info *rev, const char *path, return prepare_revision_walk(rev); } -static void print_submodule_summary(struct rev_info *rev, struct diff_options *o) +static void print_submodule_summary(struct repository *r, struct rev_info *rev, struct diff_options *o) { static const char format[] = " %m %s"; struct strbuf sb = STRBUF_INIT; @@ -454,7 +454,8 @@ static void print_submodule_summary(struct rev_info *rev, struct diff_options *o ctx.date_mode = rev->date_mode; ctx.output_encoding = get_log_output_encoding(); strbuf_setlen(&sb, 0); - format_commit_message(commit, format, &sb, &ctx); + repo_format_commit_message(r, commit, format, &sb, + &ctx); strbuf_addch(&sb, '\n'); if (commit->object.flags & SYMMETRIC_LEFT) diff_emit_submodule_del(o, sb.buf); @@ -481,14 +482,44 @@ void prepare_submodule_repo_env(struct argv_array *out) DEFAULT_GIT_DIR_ENVIRONMENT); } -/* Helper function to display the submodule header line prior to the full - * summary output. If it can locate the submodule objects directory it will - * attempt to lookup both the left and right commits and put them into the - * left and right pointers. +/* + * Initialize 'out' based on the provided submodule path. + * + * Unlike repo_submodule_init, this tolerates submodules not present + * in .gitmodules. This function exists only to preserve historical behavior, + * + * Returns 0 on success, -1 when the submodule is not present. */ -static void show_submodule_header(struct diff_options *o, const char *path, +static struct repository *open_submodule(const char *path) +{ + struct strbuf sb = STRBUF_INIT; + struct repository *out = xmalloc(sizeof(*out)); + + if (submodule_to_gitdir(&sb, path) || repo_init(out, sb.buf, NULL)) { + strbuf_release(&sb); + free(out); + return NULL; + } + + out->submodule_prefix = xstrdup(path); + + strbuf_release(&sb); + return out; +} + +/* + * Helper function to display the submodule header line prior to the full + * summary output. + * + * If it can locate the submodule git directory it will create a repository + * handle for the submodule and lookup both the left and right commits and + * put them into the left and right pointers. + */ +static void show_submodule_header(struct diff_options *o, + const char *path, struct object_id *one, struct object_id *two, unsigned dirty_submodule, + struct repository *sub, struct commit **left, struct commit **right, struct commit_list **merge_bases) { @@ -507,7 +538,7 @@ static void show_submodule_header(struct diff_options *o, const char *path, else if (is_null_oid(two)) message = "(submodule deleted)"; - if (add_submodule_odb(path)) { + if (!sub) { if (!message) message = "(commits not present)"; goto output_header; @@ -517,8 +548,8 @@ static void show_submodule_header(struct diff_options *o, const char *path, * Attempt to lookup the commit references, and determine if this is * a fast forward or fast backwards update. */ - *left = lookup_commit_reference(the_repository, one); - *right = lookup_commit_reference(the_repository, two); + *left = lookup_commit_reference(sub, one); + *right = lookup_commit_reference(sub, two); /* * Warn about missing commits in the submodule project, but only if @@ -528,7 +559,7 @@ static void show_submodule_header(struct diff_options *o, const char *path, (!is_null_oid(two) && !*right)) message = "(commits not present)"; - *merge_bases = get_merge_bases(*left, *right); + *merge_bases = repo_get_merge_bases(sub, *left, *right); if (*merge_bases) { if ((*merge_bases)->item == *left) fast_forward = 1; @@ -562,16 +593,18 @@ void show_submodule_summary(struct diff_options *o, const char *path, struct rev_info rev; struct commit *left = NULL, *right = NULL; struct commit_list *merge_bases = NULL; + struct repository *sub; + sub = open_submodule(path); show_submodule_header(o, path, one, two, dirty_submodule, - &left, &right, &merge_bases); + sub, &left, &right, &merge_bases); /* * If we don't have both a left and a right pointer, there is no * reason to try and display a summary. The header line should contain * all the information the user needs. */ - if (!left || !right) + if (!left || !right || !sub) goto out; /* Treat revision walker failure the same as missing commits */ @@ -580,13 +613,17 @@ void show_submodule_summary(struct diff_options *o, const char *path, goto out; } - print_submodule_summary(&rev, o); + print_submodule_summary(sub, &rev, o); out: if (merge_bases) free_commit_list(merge_bases); clear_commit_marks(left, ~0); clear_commit_marks(right, ~0); + if (sub) { + repo_clear(sub); + free(sub); + } } void show_submodule_inline_diff(struct diff_options *o, const char *path, @@ -598,9 +635,11 @@ void show_submodule_inline_diff(struct diff_options *o, const char *path, struct commit_list *merge_bases = NULL; struct child_process cp = CHILD_PROCESS_INIT; struct strbuf sb = STRBUF_INIT; + struct repository *sub; + sub = open_submodule(path); show_submodule_header(o, path, one, two, dirty_submodule, - &left, &right, &merge_bases); + sub, &left, &right, &merge_bases); /* We need a valid left and right commit to display a difference */ if (!(left || is_null_oid(one)) || @@ -661,6 +700,10 @@ void show_submodule_inline_diff(struct diff_options *o, const char *path, clear_commit_marks(left, ~0); if (right) clear_commit_marks(right, ~0); + if (sub) { + repo_clear(sub); + free(sub); + } } int should_update_submodules(void) From patchwork Wed Nov 14 00:13:02 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Beller X-Patchwork-Id: 10681711 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 548C613BF for ; Wed, 14 Nov 2018 00:14:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 451C52B194 for ; Wed, 14 Nov 2018 00:14:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 39A4A2B5F7; Wed, 14 Nov 2018 00:14:22 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, USER_IN_DEF_DKIM_WL autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DBAE82B194 for ; Wed, 14 Nov 2018 00:14:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731468AbeKNKPD (ORCPT ); Wed, 14 Nov 2018 05:15:03 -0500 Received: from mail-ot1-f74.google.com ([209.85.210.74]:36964 "EHLO mail-ot1-f74.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731191AbeKNKPD (ORCPT ); Wed, 14 Nov 2018 05:15:03 -0500 Received: by mail-ot1-f74.google.com with SMTP id q6so9989832otk.4 for ; Tue, 13 Nov 2018 16:14:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=c0Dtnac/GkIoitoSsGrP8UZTLgBS/bMDjrrAtpnCaZw=; b=D2cmM5YdAQdTzxIEG8DB+iSQnUNZr3RDRpby4W/x1tdbYGQaL5KuUOAzEtYA71wWaX 4BfVl3f4+MaF0FMDuEa/+48gKKHCAVHWoCc1dzf8BjsbSpcKKFcXAWHLR4D/864Ojbrd HEkAs12xvWScmjCVi2U9XjzHk218UE8KCn3HOTEmcr0/5eWkgoG2qjhIKz7LnBE88K6v ykLw8SlkWMQ+niV7fo3zb2cVo0+KXtqFkEtEIljCiULi2sNro+i9qyzLld5YkJkIC40s MSMlSbnQ5NxVQJeIAM4fka40I0xuFD+E64DrGaLqRtcequ7Sdzku/1YDRcFG7DoMOAcx jl1g== 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=c0Dtnac/GkIoitoSsGrP8UZTLgBS/bMDjrrAtpnCaZw=; b=BNKWREuHOH/T1p4KTljJP7q3AMSnF4qkSneVp65H6Nz1PI3XUXBFizQUHxummjHC8G RaTWkSdijYobFcWhDf2B8ycPMng34SyEGTkeKKQLVjRKA6NBYVM8fEWcnINLHdJpXx7Q w1AL1KjPhmQklk1JPbr7lhOZmsUsh/tc2puX+7BKVgHM+WI3SMMZX3NZi+6E3Wsxa2CE ruhfG7dsktGarVo1O7NAjknZm7B+xIDLWI/7geUHnsHv/LCMc6iyHOJ91cyCjqxDg8hI YCYyB8hfYPG7QCa1ZpMpeW397Ko6GRwEF1qJYCp5rD1wZdAx8YIFnKfP4KhYQAumq2/0 sOcg== X-Gm-Message-State: AGRZ1gKWIXFLj8CIy5eIkA87ba3Aw5EdVdi2DCaGgJ6W4ncmW/W+t8jV jjQl5AEKbCV1zXdaZOIeGzZvu34LxcM6 X-Google-Smtp-Source: AJdET5fZPBcQR3/HSVb7rpAe84g/nfnmv9nRvWc1Si+9wwBhqnGRhLg9zrNneAtgOt1F3r/UWj0YGfuaMfUA X-Received: by 2002:a9d:1516:: with SMTP id u22mr5327657otf.49.1542154459844; Tue, 13 Nov 2018 16:14:19 -0800 (PST) Date: Tue, 13 Nov 2018 16:13:02 -0800 In-Reply-To: <20181114001306.138053-1-sbeller@google.com> Message-Id: <20181114001306.138053-20-sbeller@google.com> Mime-Version: 1.0 References: <20181114001306.138053-1-sbeller@google.com> X-Mailer: git-send-email 2.19.1.1215.g8438c0b245-goog Subject: [PATCH 19/23] submodule: don't add submodule as odb for push From: Stefan Beller To: gitster@pobox.com, jonathantanmy@google.com Cc: git@vger.kernel.org, Stefan Beller Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP In push_submodule(), because we do not actually need access to objects in the submodule, do not invoke add_submodule_odb(). (for_each_remote_ref_submodule() does not require access to those objects, and the actual push is done by spawning another process, which handles object access by itself.) This code of push_submodule() is exercised in t5531 and continues to work, showing that the submodule odbc is not needed. Signed-off-by: Stefan Beller --- submodule.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/submodule.c b/submodule.c index 262f03f118..5818088df2 100644 --- a/submodule.c +++ b/submodule.c @@ -1021,9 +1021,6 @@ static int push_submodule(const char *path, const struct string_list *push_options, int dry_run) { - if (add_submodule_odb(path)) - return 1; - if (for_each_remote_ref_submodule(path, has_remote, NULL) > 0) { struct child_process cp = CHILD_PROCESS_INIT; argv_array_push(&cp.args, "push"); From patchwork Wed Nov 14 00:13:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Beller X-Patchwork-Id: 10681713 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 746F21759 for ; Wed, 14 Nov 2018 00:14:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 665062B194 for ; Wed, 14 Nov 2018 00:14:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5AD402B5F7; Wed, 14 Nov 2018 00:14:24 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, USER_IN_DEF_DKIM_WL autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D33122B194 for ; Wed, 14 Nov 2018 00:14:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731480AbeKNKPF (ORCPT ); Wed, 14 Nov 2018 05:15:05 -0500 Received: from mail-pl1-f201.google.com ([209.85.214.201]:41020 "EHLO mail-pl1-f201.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731191AbeKNKPE (ORCPT ); Wed, 14 Nov 2018 05:15:04 -0500 Received: by mail-pl1-f201.google.com with SMTP id y2so3237505plr.8 for ; Tue, 13 Nov 2018 16:14:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=WNR/f8TluUPmY8S0v4gmPLNTzwVeC3S7nPTCn/rqhYE=; b=AIMAYG676oYa/tcQKGgLhROpUZxQIzS0Yl+IVP26pjKB1EyLxUYBtEG4kbNWzVnLGP HmBHqtTcvi328g3KNnO/lf4AoNw9qJecVkh1c8VoxlNoMu8IR/c5+FGqjZka3T67lNE7 JyikqA7YSD0TLnirUhKwL33Di3ipThMBxOF27qFKMm+IOnZO4W7JRjQvf3GRpGF2hEjt refOV9DONpCHXa7XGUOTyvqkdD0vpo+wLt7uZVf9xSeLRpXwymVyqqlZGyMBWxl7plsB Uy4znsApn2sddPKlBZ3nW4hwc2nTnITqszv4vOfhtfZUc4NTkkKPNG+hiVLKUwn02pMj CrLA== 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=WNR/f8TluUPmY8S0v4gmPLNTzwVeC3S7nPTCn/rqhYE=; b=g0QR5bAAmxrODC/AQBmOPI6GC3dX9Bv7IV1MpqJq++9JwATY9QIQKZ7XDq/+ifZQAk df/M2JudhnNUictCQuHT2mJVuqCH5+PvNANMSHIl0N6tjcdylf4dxP9uHa8qoNifYGh3 TIZ0qXjrzPcjSXIj1VHk2wCkajeLw/TMutoZeexnpTuTrK+w5IHvA3Q3nUAJzeUcGqhb UZBMPDB6qIndCNDOEtMUZKs1f357KbnX0A5Lx6R41jvZaiDUn5gslgCotHbqbEhIoJCv ShGW7de/DXv1shhV9XUTt5SsPr0D6HoRtOMrdWLNulovBtXDYIoZfLh1aIFfLl+9PnJB CmUg== X-Gm-Message-State: AGRZ1gKMDIZUZ6uyQOgMqdn3pFHGjWmHfXoHFZOajSxXfMu33BOxcoOD LnNegrOAzQZezOA6lHKDumSQwUI4Nm8O X-Google-Smtp-Source: AJdET5cDi3zZ1EdV1QNuRur9qOIhjENx2NXBnIEiulkKZQ3h9Ib+RMMeRWQHHmmrYYDLTfioDu7OY753+dwG X-Received: by 2002:a17:902:d212:: with SMTP id t18mr279714ply.97.1542154461973; Tue, 13 Nov 2018 16:14:21 -0800 (PST) Date: Tue, 13 Nov 2018 16:13:03 -0800 In-Reply-To: <20181114001306.138053-1-sbeller@google.com> Message-Id: <20181114001306.138053-21-sbeller@google.com> Mime-Version: 1.0 References: <20181114001306.138053-1-sbeller@google.com> X-Mailer: git-send-email 2.19.1.1215.g8438c0b245-goog Subject: [PATCH 20/23] commit-graph: convert remaining functions to handle any repo From: Stefan Beller To: gitster@pobox.com, jonathantanmy@google.com Cc: git@vger.kernel.org, Stefan Beller Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Convert all functions to handle arbitrary repositories in commit-graph.c that are used by functions taking a repository argument already. Notable exclusion is write_commit_graph and its local functions as that only works on the_repository. Signed-off-by: Stefan Beller --- commit-graph.c | 40 ++++++++++++++++++++++++---------------- 1 file changed, 24 insertions(+), 16 deletions(-) diff --git a/commit-graph.c b/commit-graph.c index 40c855f185..f78a8e96b5 100644 --- a/commit-graph.c +++ b/commit-graph.c @@ -292,7 +292,8 @@ static int bsearch_graph(struct commit_graph *g, struct object_id *oid, uint32_t g->chunk_oid_lookup, g->hash_len, pos); } -static struct commit_list **insert_parent_or_die(struct commit_graph *g, +static struct commit_list **insert_parent_or_die(struct repository *r, + struct commit_graph *g, uint64_t pos, struct commit_list **pptr) { @@ -303,7 +304,7 @@ static struct commit_list **insert_parent_or_die(struct commit_graph *g, die("invalid parent position %"PRIu64, pos); hashcpy(oid.hash, g->chunk_oid_lookup + g->hash_len * pos); - c = lookup_commit(the_repository, &oid); + c = lookup_commit(r, &oid); if (!c) die(_("could not find commit %s"), oid_to_hex(&oid)); c->graph_pos = pos; @@ -317,7 +318,9 @@ static void fill_commit_graph_info(struct commit *item, struct commit_graph *g, item->generation = get_be32(commit_data + g->hash_len + 8) >> 2; } -static int fill_commit_in_graph(struct commit *item, struct commit_graph *g, uint32_t pos) +static int fill_commit_in_graph(struct repository *r, + struct commit *item, + struct commit_graph *g, uint32_t pos) { uint32_t edge_value; uint32_t *parent_data_ptr; @@ -341,13 +344,13 @@ static int fill_commit_in_graph(struct commit *item, struct commit_graph *g, uin edge_value = get_be32(commit_data + g->hash_len); if (edge_value == GRAPH_PARENT_NONE) return 1; - pptr = insert_parent_or_die(g, edge_value, pptr); + pptr = insert_parent_or_die(r, g, edge_value, pptr); edge_value = get_be32(commit_data + g->hash_len + 4); if (edge_value == GRAPH_PARENT_NONE) return 1; if (!(edge_value & GRAPH_OCTOPUS_EDGES_NEEDED)) { - pptr = insert_parent_or_die(g, edge_value, pptr); + pptr = insert_parent_or_die(r, g, edge_value, pptr); return 1; } @@ -355,7 +358,7 @@ static int fill_commit_in_graph(struct commit *item, struct commit_graph *g, uin 4 * (uint64_t)(edge_value & GRAPH_EDGE_LAST_MASK)); do { edge_value = get_be32(parent_data_ptr); - pptr = insert_parent_or_die(g, + pptr = insert_parent_or_die(r, g, edge_value & GRAPH_EDGE_LAST_MASK, pptr); parent_data_ptr++; @@ -374,7 +377,9 @@ static int find_commit_in_graph(struct commit *item, struct commit_graph *g, uin } } -static int parse_commit_in_graph_one(struct commit_graph *g, struct commit *item) +static int parse_commit_in_graph_one(struct repository *r, + struct commit_graph *g, + struct commit *item) { uint32_t pos; @@ -382,7 +387,7 @@ static int parse_commit_in_graph_one(struct commit_graph *g, struct commit *item return 1; if (find_commit_in_graph(item, g, &pos)) - return fill_commit_in_graph(item, g, pos); + return fill_commit_in_graph(r, item, g, pos); return 0; } @@ -391,7 +396,7 @@ int parse_commit_in_graph(struct repository *r, struct commit *item) { if (!prepare_commit_graph(r)) return 0; - return parse_commit_in_graph_one(r->objects->commit_graph, item); + return parse_commit_in_graph_one(r, r->objects->commit_graph, item); } void load_commit_graph_info(struct repository *r, struct commit *item) @@ -403,19 +408,22 @@ void load_commit_graph_info(struct repository *r, struct commit *item) fill_commit_graph_info(item, r->objects->commit_graph, pos); } -static struct tree *load_tree_for_commit(struct commit_graph *g, struct commit *c) +static struct tree *load_tree_for_commit(struct repository *r, + struct commit_graph *g, + struct commit *c) { struct object_id oid; const unsigned char *commit_data = g->chunk_commit_data + GRAPH_DATA_WIDTH * (c->graph_pos); hashcpy(oid.hash, commit_data); - c->maybe_tree = lookup_tree(the_repository, &oid); + c->maybe_tree = lookup_tree(r, &oid); return c->maybe_tree; } -static struct tree *get_commit_tree_in_graph_one(struct commit_graph *g, +static struct tree *get_commit_tree_in_graph_one(struct repository *r, + struct commit_graph *g, const struct commit *c) { if (c->maybe_tree) @@ -423,12 +431,12 @@ static struct tree *get_commit_tree_in_graph_one(struct commit_graph *g, if (c->graph_pos == COMMIT_NOT_FROM_GRAPH) BUG("get_commit_tree_in_graph_one called from non-commit-graph commit"); - return load_tree_for_commit(g, (struct commit *)c); + return load_tree_for_commit(r, g, (struct commit *)c); } struct tree *get_commit_tree_in_graph(struct repository *r, const struct commit *c) { - return get_commit_tree_in_graph_one(r->objects->commit_graph, c); + return get_commit_tree_in_graph_one(r, r->objects->commit_graph, c); } static void write_graph_chunk_fanout(struct hashfile *f, @@ -1025,7 +1033,7 @@ int verify_commit_graph(struct repository *r, struct commit_graph *g) } graph_commit = lookup_commit(r, &cur_oid); - if (!parse_commit_in_graph_one(g, graph_commit)) + if (!parse_commit_in_graph_one(r, g, graph_commit)) graph_report("failed to parse %s from commit-graph", oid_to_hex(&cur_oid)); } @@ -1061,7 +1069,7 @@ int verify_commit_graph(struct repository *r, struct commit_graph *g) continue; } - if (!oideq(&get_commit_tree_in_graph_one(g, graph_commit)->object.oid, + if (!oideq(&get_commit_tree_in_graph_one(r, g, graph_commit)->object.oid, get_commit_tree_oid(odb_commit))) graph_report("root tree OID for commit %s in commit-graph is %s != %s", oid_to_hex(&cur_oid), From patchwork Wed Nov 14 00:13:04 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Beller X-Patchwork-Id: 10681715 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 E55A01759 for ; Wed, 14 Nov 2018 00:14:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D5A532B194 for ; Wed, 14 Nov 2018 00:14:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C79BB2B5F7; Wed, 14 Nov 2018 00:14:27 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, USER_IN_DEF_DKIM_WL autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4C2032B194 for ; Wed, 14 Nov 2018 00:14:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731496AbeKNKPI (ORCPT ); Wed, 14 Nov 2018 05:15:08 -0500 Received: from mail-vs1-f74.google.com ([209.85.217.74]:52211 "EHLO mail-vs1-f74.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731191AbeKNKPI (ORCPT ); Wed, 14 Nov 2018 05:15:08 -0500 Received: by mail-vs1-f74.google.com with SMTP id p1so6114663vsc.18 for ; Tue, 13 Nov 2018 16:14:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=ebO+gFh8SHzWJ9UK7UTM5Sy+lR6HWdI3pHOvZKqKZLM=; b=iEGjR0yXeUXFcgV+Ph7hrVQaYcKmjQlmUuhYpQErX3caq2CWrCejdI2E5a4KC1JAM4 6f/dybPOx6CtHzl5Ay1hQz8UGbBPYK3j8w6mZCqUmA/rW+xE+FJKBvbrFergW3oMXqmp vi6Ip/AzH9f9oG4LogYTeLIxGoFNI6GUiArtryxB5JGyrvADIkUExiEqy5O6H6c/LK/D 5lsVOO6xiro7MG/JjMDTmpv/AfNvVhRRkeeEc3WQQQF28SoknKTqGE/ZcBNBLXYQXC1/ tkCm5dP+yD1R9IwM1HuOdH+Fy85iyZvzWrZbJcCQ04xUlAGUYmMJKSRAa9dmYdB4q8Jm l94g== 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=ebO+gFh8SHzWJ9UK7UTM5Sy+lR6HWdI3pHOvZKqKZLM=; b=WIdOo/hvF7E7ow8Gv40HegFmK54Kyn+KvhZOUe4qmpd2LMhhO8aqftjHJeKoA7aum4 r5fJuwKw5iTTskUjS4rtn88dp344EvdFKhuM1KQSDFpupd/zdaABjMoqNCCSkh9EgMie IPV0dbFec640VqBMHdC6BolYPuElPVnKGMQTDXiNJFitcHnJmWEg7DmBzd7yaWa0nqg7 r3t3y7Mrh4bLoDVekkJIBsta2BRHOL7jdTD4zpjEZKM0jokadu5+tAAWihmPtJpVurgN UDNim1HjxnlFcQl9DB7qp3/mbnN+Js3vfZ+LisTqbSlDcRgN6chbjMZFeqheYJbfSXZt dEBw== X-Gm-Message-State: AGRZ1gKqzYfM2ElOWp+unEVveOjHq56kC/752D4PNC1xKILdewg41CXp FARYBzmbtcfTmqeq9lZa+hsgfdzkEktG X-Google-Smtp-Source: AJdET5fnbfmQToZL+3VspVfEaMd0/fPFScUAdaRkYCiqCPf71YhJy+muUpTOg/unSq0KJgXS7UDl6N/AVtmO X-Received: by 2002:a1f:fc0b:: with SMTP id a11mr6036802vki.23.1542154464602; Tue, 13 Nov 2018 16:14:24 -0800 (PST) Date: Tue, 13 Nov 2018 16:13:04 -0800 In-Reply-To: <20181114001306.138053-1-sbeller@google.com> Message-Id: <20181114001306.138053-22-sbeller@google.com> Mime-Version: 1.0 References: <20181114001306.138053-1-sbeller@google.com> X-Mailer: git-send-email 2.19.1.1215.g8438c0b245-goog Subject: [PATCH 21/23] commit: prepare free_commit_buffer and release_commit_memory for any repo From: Stefan Beller To: gitster@pobox.com, jonathantanmy@google.com Cc: git@vger.kernel.org, Stefan Beller Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Pass the object pool to free_commit_buffer and release_commit_memory, such that we can eliminate access to 'the_repository'. Also remove the TODO in release_commit_memory, as commit->util was removed in 9d2c97016f (commit.h: delete 'util' field in struct commit, 2018-05-19) Signed-off-by: Stefan Beller --- builtin/fsck.c | 3 ++- builtin/log.c | 6 ++++-- builtin/rev-list.c | 3 ++- commit.c | 9 ++++----- commit.h | 4 ++-- object.c | 2 +- 6 files changed, 15 insertions(+), 12 deletions(-) diff --git a/builtin/fsck.c b/builtin/fsck.c index 06eb421720..c476ac6983 100644 --- a/builtin/fsck.c +++ b/builtin/fsck.c @@ -382,7 +382,8 @@ static int fsck_obj(struct object *obj, void *buffer, unsigned long size) if (obj->type == OBJ_TREE) free_tree_buffer((struct tree *)obj); if (obj->type == OBJ_COMMIT) - free_commit_buffer((struct commit *)obj); + free_commit_buffer(the_repository->parsed_objects, + (struct commit *)obj); return err; } diff --git a/builtin/log.c b/builtin/log.c index 061d4fd864..64c2649c7c 100644 --- a/builtin/log.c +++ b/builtin/log.c @@ -395,7 +395,8 @@ static int cmd_log_walk(struct rev_info *rev) * We may show a given commit multiple times when * walking the reflogs. */ - free_commit_buffer(commit); + free_commit_buffer(the_repository->parsed_objects, + commit); free_commit_list(commit->parents); commit->parents = NULL; } @@ -1922,7 +1923,8 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix) open_next_file(rev.numbered_files ? NULL : commit, NULL, &rev, quiet)) die(_("Failed to create output files")); shown = log_tree_commit(&rev, commit); - free_commit_buffer(commit); + free_commit_buffer(the_repository->parsed_objects, + commit); /* We put one extra blank line between formatted * patches and this flag is used by log-tree code diff --git a/builtin/rev-list.c b/builtin/rev-list.c index cc1b70522f..2b301fa315 100644 --- a/builtin/rev-list.c +++ b/builtin/rev-list.c @@ -196,7 +196,8 @@ static void finish_commit(struct commit *commit, void *data) free_commit_list(commit->parents); commit->parents = NULL; } - free_commit_buffer(commit); + free_commit_buffer(the_repository->parsed_objects, + commit); } static inline void finish_object__ma(struct object *obj) diff --git a/commit.c b/commit.c index 7d2f3a9a93..4fe74aa4bc 100644 --- a/commit.c +++ b/commit.c @@ -328,10 +328,10 @@ void repo_unuse_commit_buffer(struct repository *r, free((void *)buffer); } -void free_commit_buffer(struct commit *commit) +void free_commit_buffer(struct parsed_object_pool *pool, struct commit *commit) { struct commit_buffer *v = buffer_slab_peek( - the_repository->parsed_objects->buffer_slab, commit); + pool->buffer_slab, commit); if (v) { FREE_AND_NULL(v->buffer); v->size = 0; @@ -354,13 +354,12 @@ struct object_id *get_commit_tree_oid(const struct commit *commit) return &get_commit_tree(commit)->object.oid; } -void release_commit_memory(struct commit *c) +void release_commit_memory(struct parsed_object_pool *pool, struct commit *c) { c->maybe_tree = NULL; c->index = 0; - free_commit_buffer(c); + free_commit_buffer(pool, c); free_commit_list(c->parents); - /* TODO: what about commit->util? */ c->object.parsed = 0; } diff --git a/commit.h b/commit.h index 2e6b799b26..d2779a23f6 100644 --- a/commit.h +++ b/commit.h @@ -140,7 +140,7 @@ void repo_unuse_commit_buffer(struct repository *r, /* * Free any cached object buffer associated with the commit. */ -void free_commit_buffer(struct commit *); +void free_commit_buffer(struct parsed_object_pool *pool, struct commit *); struct tree *get_commit_tree(const struct commit *); struct object_id *get_commit_tree_oid(const struct commit *); @@ -149,7 +149,7 @@ struct object_id *get_commit_tree_oid(const struct commit *); * Release memory related to a commit, including the parent list and * any cached object buffer. */ -void release_commit_memory(struct commit *c); +void release_commit_memory(struct parsed_object_pool *pool, struct commit *c); /* * Disassociate any cached object buffer from the commit, but do not free it. diff --git a/object.c b/object.c index 003f870484..c4170d2d0c 100644 --- a/object.c +++ b/object.c @@ -540,7 +540,7 @@ void parsed_object_pool_clear(struct parsed_object_pool *o) if (obj->type == OBJ_TREE) free_tree_buffer((struct tree*)obj); else if (obj->type == OBJ_COMMIT) - release_commit_memory((struct commit*)obj); + release_commit_memory(o, (struct commit*)obj); else if (obj->type == OBJ_TAG) release_tag_memory((struct tag*)obj); } From patchwork Wed Nov 14 00:13:05 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Beller X-Patchwork-Id: 10681717 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 5BD9C13BF for ; Wed, 14 Nov 2018 00:14:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4C7BD2B194 for ; Wed, 14 Nov 2018 00:14:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 40A512B5F7; Wed, 14 Nov 2018 00:14: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 EF4F32B194 for ; Wed, 14 Nov 2018 00:14:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731508AbeKNKPL (ORCPT ); Wed, 14 Nov 2018 05:15:11 -0500 Received: from mail-io1-f74.google.com ([209.85.166.74]:51670 "EHLO mail-io1-f74.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731191AbeKNKPL (ORCPT ); Wed, 14 Nov 2018 05:15:11 -0500 Received: by mail-io1-f74.google.com with SMTP id k9-v6so14164006ioj.18 for ; Tue, 13 Nov 2018 16:14:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=mTUD9ulPYZvydj8DDSVkvbToWUsxJo0+2EWrNpzfDXU=; b=HuAjvZ6poCgfO/jLAzRvy/0l4hvccC61RxYcrjyGvlHb/jXbs/zLSkgpbkIwL+oOkb Z/YZCfjf5Fmib83TM8rG9NAp5fEcZOqVwKFpp+6lskwzn0jOBexx1c0MLiJzfaazszfY AP4pMu0M5Vyad0M6F4JpxXnevoyoCamrtpSXOU72d8+06NQCIUkB43qxu9n9KUZVBPaU qWy+sjnOJkjnwR9EtkZKvzxPS1kGRfJ17ztN0y0/Cg/22WboZ/YcUPNJWjRF4YxJubwS rxf/gMadKscNbY6VVCutfUyUU7+s3KPc3jntCqzn5LdLPuQSWFVjdpimYYMR2bpTrI+Y Aa/A== 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=mTUD9ulPYZvydj8DDSVkvbToWUsxJo0+2EWrNpzfDXU=; b=kFFuHJIbf9Beyqh/1vNKNLkiFJfK7D8TZGsyUIeNSBLDHBs02c46/8YNoHMtg/ZmEb k7zrG1i3A5SVxuOFOaRfg/lqA8nrpzxgnm6MydXJjYogDoqwwhDmH2dXy/VAZRlgyFRG 5GxszWe2kdamqKo0YhYRFJl+ph5lELzvWZE8yPfvp+KhvN1ChGAbDKZ61mCxNq0YcwZM vDEGrkPzwvrU722cQOW98atvLIe6NKoGJwTdu+kx9Gyi2+531akEYH2ivQhMwdynnrRB fB8h8smlNNuqa2SEU0bEUZSi/vi5tvjA82HWmNqlnfATU+mbXd0uzk3XMcCsWJuN9odM C07g== X-Gm-Message-State: AGRZ1gJbQ1kHW1+aJUt5NnfgNRyEdLYCLoUndkEjtotdd2erkA/52U49 NOV7RYvlWdvKRzDxguOjHeuZzhkQZCFQ X-Google-Smtp-Source: AJdET5fSoIv8rQQk/p1vbxmALI5/RdFzDggXSI4FU1Lg9Wi+tKpIRjgckG2v6FZ/Ze9KPkblCTDKGSYj5rwy X-Received: by 2002:a24:8342:: with SMTP id d63mr77676ite.26.1542154467951; Tue, 13 Nov 2018 16:14:27 -0800 (PST) Date: Tue, 13 Nov 2018 16:13:05 -0800 In-Reply-To: <20181114001306.138053-1-sbeller@google.com> Message-Id: <20181114001306.138053-23-sbeller@google.com> Mime-Version: 1.0 References: <20181114001306.138053-1-sbeller@google.com> X-Mailer: git-send-email 2.19.1.1215.g8438c0b245-goog Subject: [PATCH 22/23] path.h: make REPO_GIT_PATH_FUNC repository agnostic From: Stefan Beller To: gitster@pobox.com, jonathantanmy@google.com Cc: git@vger.kernel.org, Stefan Beller Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP git_pathdup uses the_repository internally, but the macro REPO_GIT_PATH_FUNC is specifically made for arbitrary repositories. Switch to repo_git_path which works on arbitrary repositories. Signed-off-by: Stefan Beller --- path.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/path.h b/path.h index b654ea8ff5..651e6157fc 100644 --- a/path.h +++ b/path.h @@ -165,7 +165,7 @@ extern void report_linked_checkout_garbage(void); const char *git_path_##var(struct repository *r) \ { \ if (!r->cached_paths.var) \ - r->cached_paths.var = git_pathdup(filename); \ + r->cached_paths.var = repo_git_path(r, filename); \ return r->cached_paths.var; \ } From patchwork Wed Nov 14 00:13:06 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Beller X-Patchwork-Id: 10681719 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 985C613BF for ; Wed, 14 Nov 2018 00:14:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8A32D2B194 for ; Wed, 14 Nov 2018 00:14:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7E47C2B5F7; Wed, 14 Nov 2018 00:14:33 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, USER_IN_DEF_DKIM_WL autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6F19F2B194 for ; Wed, 14 Nov 2018 00:14:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731519AbeKNKPN (ORCPT ); Wed, 14 Nov 2018 05:15:13 -0500 Received: from mail-pg1-f201.google.com ([209.85.215.201]:50073 "EHLO mail-pg1-f201.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731191AbeKNKPN (ORCPT ); Wed, 14 Nov 2018 05:15:13 -0500 Received: by mail-pg1-f201.google.com with SMTP id a18so9387620pga.16 for ; Tue, 13 Nov 2018 16:14:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=AmC1N4f2Hpm9iBV4CqRjLMB11EbW2gsbN4jjEH7W/SE=; b=TkF4OUHslID8Zd7fXWz/cgphOIx7qN4QQB5gtBdEDkEcoMhnoQSsE3jS+bdCjh71NY FXPXFr/Jtc7YqAc3Z7fdduIWOE7nFgVgAyTRH5+tT1ArmzaJA5xsV7jC/7f7CF6M9YtB 11DNvxgeruct1tD9M9hiqgM5VTG9OXWXnPwFMw23TyPaRtxuGJdFbrOmTYJXh0OG5BAh 78IfAeuwkoydT3oNOkl5RmLk2ohTg4xrKXbY2u5JLt6+bxfqXgA0SHF7GC5fRZqJfzNr aGNY1rluWZMENXrFUrpMwuLndngMkDu6ghBYBqpL1xMenfM4PTIkjNQkZRz+hlVnOP7A RXLQ== 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=AmC1N4f2Hpm9iBV4CqRjLMB11EbW2gsbN4jjEH7W/SE=; b=WtIwSzmSFN1lQAwFPhzLDPZ3QI+qczzPEl/kLfwjUk52c2a3NdPBCCIlfdmDVsVwQg Y+vtOMwHApjbqP8y1TB6eUoTPnQY1XGqdUpyE9f6htU0eYyPQbXbWq1aVK1Cj0/Y+Bt2 oY613uSJM03ptPD1gZWh5LjSKR6NOVUmfFbfeGjbIhT1tyUsdmFLoe47K/ehk9LcM4wF 2B0FRQnh5K1oO8oQQmvzoWWvZOJj0FYcNmvq236aW76iUmM24QBHhRYoTojrtdgfdiy6 l9MGlAldshYvbNHIV1jb3HzZ66YfrrQO6Ti47NlxBJPBPrsmQ1mzvNKV0Qnmc7a0FTBB 3B8w== X-Gm-Message-State: AGRZ1gKqqkfdnkptvc7hLgDPo6ocZP2SyEnlUxVYYJd9FqLoVYpky/rs 5SnNRRxmFwHY0ngnTCnllgtfNHaCNerT X-Google-Smtp-Source: AJdET5fPNrZTB+FDDd8PxVciyOmqq68epDvmoqLgbsVvT++1gwoTshufYp4mhs/kcBRaYnWCX4uuzeY1BzWJ X-Received: by 2002:a17:902:ac1:: with SMTP id 59-v6mr506773plp.66.1542154470019; Tue, 13 Nov 2018 16:14:30 -0800 (PST) Date: Tue, 13 Nov 2018 16:13:06 -0800 In-Reply-To: <20181114001306.138053-1-sbeller@google.com> Message-Id: <20181114001306.138053-24-sbeller@google.com> Mime-Version: 1.0 References: <20181114001306.138053-1-sbeller@google.com> X-Mailer: git-send-email 2.19.1.1215.g8438c0b245-goog Subject: [PATCH 23/23] t/helper/test-repository: celebrate independence from the_repository From: Stefan Beller To: gitster@pobox.com, jonathantanmy@google.com Cc: git@vger.kernel.org, Stefan Beller Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP dade47c06c (commit-graph: add repo arg to graph readers, 2018-07-11) brought more independence from the_repository to the commit graph, however it was not completely independent of the_repository, as the previous patches show. To ensure we're not accessing the_repository by accident, we'd ideally assign NULL to the_repository to trigger a segfault on access. We currently have a temporary hack in cache.h, which relies on the_hash_algo (which is a short form of the_repository->hash_algo) to be set, so we cannot do that. The next best thing is to set all fields of the_repository to 0, so any accidental access is more likely to be found. Signed-off-by: Stefan Beller --- cache.h | 2 ++ t/helper/test-repository.c | 10 ++++++++++ 2 files changed, 12 insertions(+) diff --git a/cache.h b/cache.h index 59c8a93046..8864d7ec15 100644 --- a/cache.h +++ b/cache.h @@ -1033,6 +1033,8 @@ static inline int hashcmp(const unsigned char *sha1, const unsigned char *sha2) * * This will need to be extended or ripped out when we learn about * hashes of different sizes. + * + * When ripping this out, see TODO in test-repository.c. */ if (the_hash_algo->rawsz != 20) BUG("hash size not yet supported by hashcmp"); diff --git a/t/helper/test-repository.c b/t/helper/test-repository.c index 6a84a53efb..f7f8618445 100644 --- a/t/helper/test-repository.c +++ b/t/helper/test-repository.c @@ -17,6 +17,11 @@ static void test_parse_commit_in_graph(const char *gitdir, const char *worktree, setup_git_env(gitdir); + memset(the_repository, 0, sizeof(*the_repository)); + + /* TODO: Needed for temporary hack in hashcmp, see 183a638b7da. */ + repo_set_hash_algo(the_repository, GIT_HASH_SHA1); + if (repo_init(&r, gitdir, worktree)) die("Couldn't init repo"); @@ -43,6 +48,11 @@ static void test_get_commit_tree_in_graph(const char *gitdir, setup_git_env(gitdir); + memset(the_repository, 0, sizeof(*the_repository)); + + /* TODO: Needed for temporary hack in hashcmp, see 183a638b7da. */ + repo_set_hash_algo(the_repository, GIT_HASH_SHA1); + if (repo_init(&r, gitdir, worktree)) die("Couldn't init repo");