From patchwork Thu Oct 11 21:17:36 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Beller X-Patchwork-Id: 10637471 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 5910D15E2 for ; Thu, 11 Oct 2018 21:18:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 479582BECE for ; Thu, 11 Oct 2018 21:18:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3B87A2BED4; Thu, 11 Oct 2018 21:18: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 DE05E2BD3C for ; Thu, 11 Oct 2018 21:18:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726798AbeJLErF (ORCPT ); Fri, 12 Oct 2018 00:47:05 -0400 Received: from mail-pg1-f201.google.com ([209.85.215.201]:47925 "EHLO mail-pg1-f201.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726210AbeJLErF (ORCPT ); Fri, 12 Oct 2018 00:47:05 -0400 Received: by mail-pg1-f201.google.com with SMTP id o18-v6so7559717pgv.14 for ; Thu, 11 Oct 2018 14:18:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=c4g6PS10JROHZRLjL5kGuzM/VPwtNxbm0jJv8njRjUM=; b=DLbEPM4ib7vHXYrCuEYVDXkJ707iRsBzU2mBA01xo2mVuf3ztB4kYTBwpk0MgZFHbg CmUSlz9jb8ePJDmU8zUpRsfYzfiFpx7rehgxAKwLrTW7bnOjHo+oqeWBm5vYk762SK+X 5WqjvN/dIvsgZyC6EGdYg67sR4uH0+Ji1sR+Ctt1FEVZbD1pYO2znM3+a3UThz9wUTZ/ hbUMz407Ll1plcf5UPNR4446mBD5kL8sANSW0WsWLzVwQ3W/et4PQQ1EVAxYn5tDHp9j zHODUay3Mt4szOC7rgL91L1GAlrb00hIj8n99piLzQW8c4r/MKu3pmWvCNTF6e8Ap/3e ZTIA== 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=c4g6PS10JROHZRLjL5kGuzM/VPwtNxbm0jJv8njRjUM=; b=tMg3sJq4Xeg76sc9MQT/9G7yB40mcgYWZrTEomFadclL0QnTI5EHn2WoICAqYJNi/I Vvm2fiO3S3p7obugnYgM0gJ6u/hqwZUkDZrVT+HNA6MdK+OzligSfgO38qFXQnrTQRYU O2ipfxWZJw8UoXGvoWeRe/rsSxwCQIY/2QBExaXPQZ+Cp/3P5/7WACcgJOaM2Wz+tsoV eFIDJpzjpJ58hwdrG21HO7Gj+iBzuTczpk0lgW+Wt48XCOIuhmhd2A6p2DPZ10ZHMt6y dgJcwRTLxnV1VDBAcBUmLxQlvUNqO9JJDq3D4c8BfDDaNhBFsj3+Y17fsBgxUVFoVd+4 rgbw== X-Gm-Message-State: ABuFfojUGf71ocr/LLrxF8XqwUw2BKiCJWKwi5PzMLiay85YFSQLO9Nv iQF2MlLSzHidDsa9ql3xuEUXOX7E2yN+SqRANB4hAL+B81QiDMcIqPTUwlzxZKngiuQFzF3LfFp cFLATg5GStEhjK76tmIHOM9MQRLEra4VmFa3nLKvKbzYi72XzQyjqfAPhqbnq X-Google-Smtp-Source: ACcGV61AKldR8kvoO+ejMF3PESwzRGm7gUZSNAYPmON/Zzs5WmgY3zB2yGx3+vqaMs7+Zez0d3qQcR2cmGp7 X-Received: by 2002:a65:4888:: with SMTP id n8-v6mr1647789pgs.15.1539292680154; Thu, 11 Oct 2018 14:18:00 -0700 (PDT) Date: Thu, 11 Oct 2018 14:17:36 -0700 In-Reply-To: <20181011211754.31369-1-sbeller@google.com> Message-Id: <20181011211754.31369-2-sbeller@google.com> Mime-Version: 1.0 References: <20181011211754.31369-1-sbeller@google.com> X-Mailer: git-send-email 2.19.0 Subject: [PATCH 01/19] sha1_file: allow read_object to read objects in arbitrary repositories From: Stefan Beller To: git@vger.kernel.org Cc: jonathantanmy@google.com, Stefan Beller 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 --- sha1-file.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/sha1-file.c b/sha1-file.c index 308d5e20e2..647068a836 100644 --- a/sha1-file.c +++ b/sha1-file.c @@ -1361,7 +1361,9 @@ int oid_object_info(struct repository *r, return type; } -static void *read_object(const unsigned char *sha1, enum object_type *type, +static void *read_object(struct repository *r, + const unsigned char *sha1, + enum object_type *type, unsigned long *size) { struct object_id oid; @@ -1373,7 +1375,7 @@ static void *read_object(const unsigned char *sha1, enum object_type *type, hashcpy(oid.hash, sha1); - if (oid_object_info_extended(the_repository, &oid, &oi, 0) < 0) + if (oid_object_info_extended(r, &oid, &oi, 0) < 0) return NULL; return content; } @@ -1414,7 +1416,7 @@ void *read_object_file_extended(const struct object_id *oid, lookup_replace_object(the_repository, oid) : oid; errno = 0; - data = read_object(repl->hash, type, size); + data = read_object(the_repository, repl->hash, type, size); if (data) return data; @@ -1755,7 +1757,7 @@ int force_object_loose(const struct object_id *oid, time_t mtime) if (has_loose_object(oid)) return 0; - buf = read_object(oid->hash, &type, &len); + buf = read_object(the_repository, oid->hash, &type, &len); if (!buf) return error(_("cannot read sha1_file for %s"), oid_to_hex(oid)); hdrlen = xsnprintf(hdr, sizeof(hdr), "%s %lu", type_name(type), len) + 1; From patchwork Thu Oct 11 21:17:37 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Beller X-Patchwork-Id: 10637473 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 8317A15E2 for ; Thu, 11 Oct 2018 21:18:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 714AB2BD3C for ; Thu, 11 Oct 2018 21:18:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 65BF82BED4; Thu, 11 Oct 2018 21:18:05 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, USER_IN_DEF_DKIM_WL autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0F3452BD3C for ; Thu, 11 Oct 2018 21:18:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726890AbeJLErH (ORCPT ); Fri, 12 Oct 2018 00:47:07 -0400 Received: from mail-oi1-f201.google.com ([209.85.167.201]:38067 "EHLO mail-oi1-f201.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726210AbeJLErH (ORCPT ); Fri, 12 Oct 2018 00:47:07 -0400 Received: by mail-oi1-f201.google.com with SMTP id j186-v6so6977084oih.5 for ; Thu, 11 Oct 2018 14:18:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=LpMC4FYyUEce8MrzoPqSOFz2HJiapPWB+LYSLNRAk58=; b=fi4UJVIfp1m38x8QW8UpuHfIf9FkkclZimiQYfZ4MIaO2jWWXrwaWFHadDsStxqing V8cc8Ki8q7EYvhwIADp3CyNJ543tnkbuk9XWt9VAjYJ9M3jL63WtC8ItbhhiQrBvBsnp 3wbVewVs5XnBF6uXaOUAuqKtusCLzJgLEA1AbkKWYITUTQqfFWtI1tZwxuUlkeRPes8V 7K2ClrWO6tkhe8oEiH2Ce5eXz0wDIu0JPrdfkCAbTv6bPNg9xM0fj4mfolDLu6AicKBq Rkx+rQ4nylj05tRqkosAnt9MtrG8t6Wb0U0x27CDBi5RJubio43WJIyiVwYFS1BMQ/Tc ngtg== 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=LpMC4FYyUEce8MrzoPqSOFz2HJiapPWB+LYSLNRAk58=; b=YbmkZ3hwSpO15tGb4hybMipmcG2lj/znXydftqbqe520trg5TgJM+O5uTXjLlehtA4 whaOrMVARiik729u0KwLMSzrq34WygVgSy4h4FNMIWOhF9w2WaKxWxwcjBzgA0+UFXo1 N7kMniNAPrDjIRE6k494xkJyqgpcmNpNn7zSTiaoGZ95RiBEMZLPvqjROWNb+AX9cfR3 HXUAcFFO12m6SvTKOuXp4bLVGY6NkV7RjC2qOr+vVS5Olt2n+yvrIbAbCDI3QPZODDxA L67m7SffpRQCJcCGjp7tuTa9AzMxvj+SkE86GeDs9BRFKQo5EDhHWdzuZTHlgZJVOqXF CorA== X-Gm-Message-State: ABuFfoj4mQvOEAxl/xXpCN1JRwOPmfAWRGYIYpvHShBx37Dw1tuXOOKU jrvsh6NxwFy44oIs8EHnaQtKYx2s8oBaBfPSdkbugKsd+MoEOEOp59HDYdSp3I/4cWn+nXDl4IE E5HCnhdH/5OMRLv8A27GGxx1rhY2+UaZWeYmJ4Wt+cE0+xX7J7uw3IRZQAcNK X-Google-Smtp-Source: ACcGV61mGi339FXiUPiyKM3LhAY0tEnFBsM0aVnkJJNhi/EIukr3cyzs+cQjSYT00R5yxuZJI8WbdUDwZjST X-Received: by 2002:a9d:2cae:: with SMTP id p43mr2787394otb.0.1539292682670; Thu, 11 Oct 2018 14:18:02 -0700 (PDT) Date: Thu, 11 Oct 2018 14:17:37 -0700 In-Reply-To: <20181011211754.31369-1-sbeller@google.com> Message-Id: <20181011211754.31369-3-sbeller@google.com> Mime-Version: 1.0 References: <20181011211754.31369-1-sbeller@google.com> X-Mailer: git-send-email 2.19.0 Subject: [PATCH 02/19] packfile: allow has_packed_and_bad to handle arbitrary repositories From: Stefan Beller To: git@vger.kernel.org Cc: jonathantanmy@google.com, Stefan Beller 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 --- packfile.c | 5 +++-- packfile.h | 2 +- sha1-file.c | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/packfile.c b/packfile.c index ebcb5742ec..40085fe160 100644 --- a/packfile.c +++ b/packfile.c @@ -1024,12 +1024,13 @@ void mark_bad_packed_object(struct packed_git *p, const unsigned char *sha1) p->num_bad_objects++; } -const struct packed_git *has_packed_and_bad(const unsigned char *sha1) +const struct packed_git *has_packed_and_bad(struct repository *r, + const unsigned char *sha1) { struct packed_git *p; unsigned i; - for (p = the_repository->objects->packed_git; p; p = p->next) + for (p = r->objects->packed_git; p; p = p->next) for (i = 0; i < p->num_bad_objects; i++) if (!hashcmp(sha1, p->bad_object_sha1 + the_hash_algo->rawsz * i)) diff --git a/packfile.h b/packfile.h index 630f35cf31..1d2d170bf8 100644 --- a/packfile.h +++ b/packfile.h @@ -136,7 +136,7 @@ extern int packed_object_info(struct repository *r, off_t offset, struct object_info *); extern void mark_bad_packed_object(struct packed_git *p, const unsigned char *sha1); -extern const struct packed_git *has_packed_and_bad(const unsigned char *sha1); +extern const struct packed_git *has_packed_and_bad(struct repository *r, const unsigned char *sha1); /* * Iff a pack file in the given repository contains the object named by sha1, diff --git a/sha1-file.c b/sha1-file.c index 647068a836..13b3c5cb79 100644 --- a/sha1-file.c +++ b/sha1-file.c @@ -1432,7 +1432,7 @@ void *read_object_file_extended(const struct object_id *oid, die(_("loose object %s (stored in %s) is corrupt"), oid_to_hex(repl), path); - if ((p = has_packed_and_bad(repl->hash)) != NULL) + if ((p = has_packed_and_bad(the_repository, repl->hash)) != NULL) die(_("packed object %s (stored in %s) is corrupt"), oid_to_hex(repl), p->pack_name); From patchwork Thu Oct 11 21:17:38 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Beller X-Patchwork-Id: 10637475 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 DDEE7933 for ; Thu, 11 Oct 2018 21:18:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CC54F2BD3C for ; Thu, 11 Oct 2018 21:18:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C07F22BED4; Thu, 11 Oct 2018 21:18: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 5E2222BD3C for ; Thu, 11 Oct 2018 21:18:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726903AbeJLErK (ORCPT ); Fri, 12 Oct 2018 00:47:10 -0400 Received: from mail-yw1-f74.google.com ([209.85.161.74]:41857 "EHLO mail-yw1-f74.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726210AbeJLErK (ORCPT ); Fri, 12 Oct 2018 00:47:10 -0400 Received: by mail-yw1-f74.google.com with SMTP id d23-v6so5843366ywd.8 for ; Thu, 11 Oct 2018 14:18:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=oKupGglTaz+JkyOCnYUv6My7t1bqxgM24KPHQka9dE8=; b=SOUqOmD/mPShBPKPC8wzV/vVOOA3YBY8ju/Y8YpJSwq9gbRefR0z4BJJC3SYUHecIs 7SXrlcP9f0VfxlGCfS6Es456s4tb2KWfg/xaVv1V+pQbr3SaLwZp9O8i5cEJZp8oQ1Kz qhDRepj5KJEHVKwv7/F3CPsSgcDyMEqkge1vJ7tZRdg8efjIQy5gT5B7Qijjnl5UG+rM kVnsOmeyyTu0Es7UR4g6e9rQSBVIyMuWHj/9kjyf36pzD1utwsukXzeY/d7Y6S+3kKf2 pS4RxItwmKn4zztL5mlXs9gPMb4aLa/fQBwdklCtAErFvHAyhQvsJY+AlAIwDT8F1aO3 xEVQ== 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=oKupGglTaz+JkyOCnYUv6My7t1bqxgM24KPHQka9dE8=; b=T9bOGZJB8KBff91zcrBQVsq4ijvvD3n8rLtmwPEHSGY2e/eQkl3Qc90OCdX3XImhmF W0s5IqPJNjHRYHW02BnXNwZvPplRaqNinpSCcxBlu4/4wXTEnVP6JeEKiptzIMTDkwqn zb6xCOKfcNGqYn+gigxbB95LWSnx8vvbxBmn0OwI2/b7gc7YpbtxoD2acWuhjsVCNx1T VTf5SwOdKkO8fx/gjaUkJpxaZMOQdqLh9aGy7s9J8biICYHEsGPOepf9wGr33MDnCgmv 2xUdOpe5Q/Y/bJfCs9VPlseyntwlIyzVZh6S5fkiyeEAQTsJlRoeDeV4yScSAJ37rmg5 C7aQ== X-Gm-Message-State: ABuFfohglppg+p6oDz08gIB9737uzSXuq0r4YOBni7IugzXzNBv1TLoT eNWj9Md15vNSJUdtcsm9SjDhByiv/jdiUOB1D1KftXPk9rltv8c5Fg5g3vhW0wkAdoiPhs8Ixk3 WMAnqTG78jlzGATkiftIZcs7eoxkUUBrdoKB28Dx5171jE6R+MT+qn1oJjT1i X-Google-Smtp-Source: ACcGV60nwDdJLwAI5Of1d9rnBMOoSrkaEciPtpn12aizaYJwsy6oCW8iZS1q0N4nmbCvSGL02CLH9wMA7E8Y X-Received: by 2002:a25:8545:: with SMTP id f5-v6mr1966724ybn.74.1539292684914; Thu, 11 Oct 2018 14:18:04 -0700 (PDT) Date: Thu, 11 Oct 2018 14:17:38 -0700 In-Reply-To: <20181011211754.31369-1-sbeller@google.com> Message-Id: <20181011211754.31369-4-sbeller@google.com> Mime-Version: 1.0 References: <20181011211754.31369-1-sbeller@google.com> X-Mailer: git-send-email 2.19.0 Subject: [PATCH 03/19] object-store: allow read_object_file_extended to read from arbitrary repositories From: Stefan Beller To: git@vger.kernel.org Cc: jonathantanmy@google.com, Stefan Beller 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 --- object-store.h | 5 +++-- sha1-file.c | 11 ++++++----- streaming.c | 2 +- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/object-store.h b/object-store.h index 67e66227d9..6bb0ccbf05 100644 --- a/object-store.h +++ b/object-store.h @@ -146,12 +146,13 @@ void sha1_file_name(struct repository *r, struct strbuf *buf, const unsigned cha void *map_sha1_file(struct repository *r, const unsigned char *sha1, unsigned long *size); -extern void *read_object_file_extended(const struct object_id *oid, +extern void *read_object_file_extended(struct repository *r, + const struct object_id *oid, enum object_type *type, unsigned long *size, int lookup_replace); static inline void *read_object_file(const struct object_id *oid, enum object_type *type, unsigned long *size) { - return read_object_file_extended(oid, type, size, 1); + return read_object_file_extended(the_repository, oid, type, size, 1); } /* Read and unpack an object file into memory, write memory to an object file */ diff --git a/sha1-file.c b/sha1-file.c index 13b3c5cb79..ce47524679 100644 --- a/sha1-file.c +++ b/sha1-file.c @@ -1403,7 +1403,8 @@ int pretend_object_file(void *buf, unsigned long len, enum object_type type, * deal with them should arrange to call read_object() and give error * messages themselves. */ -void *read_object_file_extended(const struct object_id *oid, +void *read_object_file_extended(struct repository *r, + const struct object_id *oid, enum object_type *type, unsigned long *size, int lookup_replace) @@ -1413,10 +1414,10 @@ void *read_object_file_extended(const struct object_id *oid, const char *path; struct stat st; const struct object_id *repl = lookup_replace ? - lookup_replace_object(the_repository, oid) : oid; + lookup_replace_object(r, oid) : oid; errno = 0; - data = read_object(the_repository, repl->hash, type, size); + data = read_object(r, repl->hash, type, size); if (data) return data; @@ -1428,11 +1429,11 @@ void *read_object_file_extended(const struct object_id *oid, die(_("replacement %s not found for %s"), oid_to_hex(repl), oid_to_hex(oid)); - if (!stat_sha1_file(the_repository, repl->hash, &st, &path)) + if (!stat_sha1_file(r, repl->hash, &st, &path)) die(_("loose object %s (stored in %s) is corrupt"), oid_to_hex(repl), path); - if ((p = has_packed_and_bad(the_repository, repl->hash)) != NULL) + if ((p = has_packed_and_bad(r, repl->hash)) != NULL) die(_("packed object %s (stored in %s) is corrupt"), oid_to_hex(repl), p->pack_name); diff --git a/streaming.c b/streaming.c index d1e6b2dce6..c843a1230f 100644 --- a/streaming.c +++ b/streaming.c @@ -490,7 +490,7 @@ static struct stream_vtbl incore_vtbl = { static open_method_decl(incore) { - st->u.incore.buf = read_object_file_extended(oid, type, &st->size, 0); + st->u.incore.buf = read_object_file_extended(the_repository, oid, type, &st->size, 0); st->u.incore.read_ptr = 0; st->vtbl = &incore_vtbl; From patchwork Thu Oct 11 21:17:39 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Beller X-Patchwork-Id: 10637477 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 605D4933 for ; Thu, 11 Oct 2018 21:18:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4CAF92BD3C for ; Thu, 11 Oct 2018 21:18:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 40C082BED4; Thu, 11 Oct 2018 21:18: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 D96B82BD3C for ; Thu, 11 Oct 2018 21:18:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726918AbeJLErM (ORCPT ); Fri, 12 Oct 2018 00:47:12 -0400 Received: from mail-qk1-f202.google.com ([209.85.222.202]:52402 "EHLO mail-qk1-f202.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726210AbeJLErM (ORCPT ); Fri, 12 Oct 2018 00:47:12 -0400 Received: by mail-qk1-f202.google.com with SMTP id 17-v6so9702307qkj.19 for ; Thu, 11 Oct 2018 14:18:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=umgBTvwMnUjpWiVyhoBw62KfXXSxT6/FuuGkq2vDQ8o=; b=L2yZ9WMm7fBRXorRHokgU2EKDzAePU2P8ckfmDKEr6O5C/jv1cbFsig5TD307yjsOL YCcQUqHOZoS2M6cpqrQERtwnDQdUqJKQGMKmUY9+hR416Gd79cBZNxk2SR0Q1HIVQSKJ U1vE2bYaHLuxF8O2pwZDc8xXCjivI3uSTi0+JlcdDFkue/Kdd0yxC9c5a2vls47Ot6aM cCYqtudum9DZvj6wxSTAlsCphSpa65islVshEOg3DD4xCh5AuF4zhBRnp6HjsynvX8Ed NXoWeWnQwD1aqzOEtj6X0Key1ocF7PqzYqgxh7iK0JSVHyUF4aRI+OZulMVKY6Cc6obf ARYA== 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=umgBTvwMnUjpWiVyhoBw62KfXXSxT6/FuuGkq2vDQ8o=; b=b0wvRkkB4lUF0qUbeYi7JzA0Udv8iP3+umFDMfGf/sP7QWBsAJspN0oJa82RunXAcE 3fMhpvGjmFmfPkgPK9lAnofvGrrkn6PV82MJa72a0o7yFTmKL047zy7b6dHnWNRWyL7U J4Sg/t+Kz4SQQ6kEn4XHIgyTacMhwC+KMPIJMWx3wTmxzTbcQAHjLg1DMUKBM8Jtpkhu 2dcfCeua9tUdVc/CpRCRfJptWdAzDp9tNQXY5uyvb7MY1xosNDKI0Tfg16+Ramr/PZaO YR8UqJkkYhakOlnaUw0pcnGbU2EgRVF/codmiSu7jLhJokTVbi+1B903OhIsy9jFAR8w qGyg== X-Gm-Message-State: ABuFfojcXwciVj75WCHG+dXiQdUTtqVeQBmusqpHR+QlWNg+obFpzYph ag6gj3TZVHmUfrf6zULZ9zKOOdHnkif+aOU7lQQau4bELkkQ9T0rR4GpY5K4bwo0oDYQkFRb3J0 tJyyt+oHrr3qCesslV/s5d8Y7NRoeyoBWg1y+HPaMa/8RfjRTeXozO4Pu6jTU X-Google-Smtp-Source: ACcGV62IHlpV9CbypdB1DxRRzoEBvG+CoPIUZprvcG+FpwzdswtGbZayGjb03UL1iMccyDzoXtlapCU3aHBq X-Received: by 2002:ac8:227a:: with SMTP id p55-v6mr2821695qtp.19.1539292687429; Thu, 11 Oct 2018 14:18:07 -0700 (PDT) Date: Thu, 11 Oct 2018 14:17:39 -0700 In-Reply-To: <20181011211754.31369-1-sbeller@google.com> Message-Id: <20181011211754.31369-5-sbeller@google.com> Mime-Version: 1.0 References: <20181011211754.31369-1-sbeller@google.com> X-Mailer: git-send-email 2.19.0 Subject: [PATCH 04/19] object-store: prepare read_object_file to deal with arbitrary repositories From: Stefan Beller To: git@vger.kernel.org Cc: jonathantanmy@google.com, Stefan Beller 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, which we planned for in e675765235 (diff.c: remove implicit dependency on the_index, 2018-09-21) Add a coccinelle patch to convert existing callers, but do not apply the resulting patch from 'make coccicheck' to keep the diff of this patch small. Signed-off-by: Stefan Beller --- contrib/coccinelle/the_repository.cocci | 13 +++++++++++++ object-store.h | 10 ++++++++-- 2 files changed, 21 insertions(+), 2 deletions(-) create mode 100644 contrib/coccinelle/the_repository.cocci diff --git a/contrib/coccinelle/the_repository.cocci b/contrib/coccinelle/the_repository.cocci new file mode 100644 index 0000000000..3c7fa70502 --- /dev/null +++ b/contrib/coccinelle/the_repository.cocci @@ -0,0 +1,13 @@ +// This file is used for the ongoing refactoring of +// bringing the index or repository struct in all of +// our code base. + +@@ +expression E; +expression F; +expression G; +@@ +- read_object_file( ++ repo_read_object_file(the_repository, + E, F, G) + diff --git a/object-store.h b/object-store.h index 6bb0ccbf05..41ceebca48 100644 --- a/object-store.h +++ b/object-store.h @@ -150,10 +150,16 @@ extern void *read_object_file_extended(struct repository *r, const struct object_id *oid, enum object_type *type, unsigned long *size, int lookup_replace); -static inline void *read_object_file(const struct object_id *oid, enum object_type *type, unsigned long *size) +static inline void *repo_read_object_file(struct repository *r, + const struct object_id *oid, + enum object_type *type, + unsigned long *size) { - return read_object_file_extended(the_repository, oid, type, size, 1); + return read_object_file_extended(r, oid, type, size, 1); } +#ifndef NO_THE_REPOSITORY_COMPATIBILITY_MACROS +#define read_object_file(oid, type, size) repo_read_object_file(the_repository, oid, type, size) +#endif /* Read and unpack an object file into memory, write memory to an object file */ int oid_object_info(struct repository *r, const struct object_id *, unsigned long *); From patchwork Thu Oct 11 21:17:40 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Beller X-Patchwork-Id: 10637479 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 C892115E2 for ; Thu, 11 Oct 2018 21:18:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B0A5C290B8 for ; Thu, 11 Oct 2018 21:18:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9C8692B9F4; Thu, 11 Oct 2018 21:18: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 43991290B8 for ; Thu, 11 Oct 2018 21:18:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726942AbeJLErP (ORCPT ); Fri, 12 Oct 2018 00:47:15 -0400 Received: from mail-vs1-f74.google.com ([209.85.217.74]:52849 "EHLO mail-vs1-f74.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726210AbeJLErO (ORCPT ); Fri, 12 Oct 2018 00:47:14 -0400 Received: by mail-vs1-f74.google.com with SMTP id k1so4030309vso.19 for ; Thu, 11 Oct 2018 14:18:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=FMO/AN4rsMfciY8hDo0JqYkdDtNh7BtAY6W9lRsDdxc=; b=Pzd4RXAEgXBbuRLRmtqgknGygygJCj9xbS/9MbFo+uTRKpKPZbkz9ZZqWYXYvm15l8 F63yzGXSaws3AeF09qBaiGkPxNfV8GXKWp3oZ7Z4b5+H03hi5cShaWMPKbJP19rRnMNN nFZKEWNM3PLCowp/nsDPlyLGy24qBz1MtUXzzLdZW1MO4lUKFZDOe0bmqylNqGuEYIah WVVHKa2GsMv9knn1++EooS0cHGzZ7EYaMzM8j7yZMWDTj9OJ/MGz2nzX+LVs1V4+qrYB aBgislW5iokylBYdDvOUKZIq4QWz/EtxP/DFvPO9n/0tVLSGxgkXdotpzApG5lS/T6c/ 2Fng== 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=FMO/AN4rsMfciY8hDo0JqYkdDtNh7BtAY6W9lRsDdxc=; b=WEDCCwXvfnLM8T1eMEquZgrwCVUev2W1vbD1/lm2ByK4JvFbTfvQsaw26TrEc+ozgk 8ONFHjHecKXG2sfPOwecPadqNi+kzSr7BqNA2qdhXpNUCwqjJJqs4aJCh4Gx7gDjd1Op 2pT743HMgLcMyQNWUPT5EBpMqdun+l1Y1wFAvvIchXPWN7rexRUDi2fDGt/cJVXDYEKd 8sBtzpBFQGCKltsxkN4VXpS54oO/6oUk+Q/ixTtTc2/VeF0c9hLRnSTkeumCWpg2URS9 lPJfhTWM+9cXrsC9cJKdQCwfooy/3n49UGoyZmdKcCIF0u1cL8Ntbvern95fGF7h+nVj LBQQ== X-Gm-Message-State: ABuFfohCy2ZQ/Kb/XAcud6tkqFlR/2590q+CzqVygCzwmDmPW0VW5NjY rjXN8oRv0nvenrr6I9Zpocy1pek8wQJcC7bsUYQujouqhx9jo+Ol40u/0+VCdkbCL38EBQyGCHE 53mbgg0L5ei0jqIDYITEo7pWrCimzh6LHkxLXRh5ewYFuHdleDHQjSg/VUTLw X-Google-Smtp-Source: ACcGV62cvmYT0hTyXbNVOMzYHFgvmYRCPp9NVQpMQOLa1JVFSmEwb5UVC+NEz5z2o7necgwYfuDltU1Mzh4E X-Received: by 2002:ab0:446:: with SMTP id 64mr3230772uav.0.1539292689923; Thu, 11 Oct 2018 14:18:09 -0700 (PDT) Date: Thu, 11 Oct 2018 14:17:40 -0700 In-Reply-To: <20181011211754.31369-1-sbeller@google.com> Message-Id: <20181011211754.31369-6-sbeller@google.com> Mime-Version: 1.0 References: <20181011211754.31369-1-sbeller@google.com> X-Mailer: git-send-email 2.19.0 Subject: [PATCH 05/19] object: parse_object to honor its repository argument From: Stefan Beller To: git@vger.kernel.org Cc: jonathantanmy@google.com, Stefan Beller Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP In 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 --- object.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/object.c b/object.c index 51c4594515..61f49d8b99 100644 --- a/object.c +++ b/object.c @@ -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 Thu Oct 11 21:17:41 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Beller X-Patchwork-Id: 10637481 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 29A0215E2 for ; Thu, 11 Oct 2018 21:18:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 173892BA31 for ; Thu, 11 Oct 2018 21:18:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0B8CB2BA3E; Thu, 11 Oct 2018 21:18: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 91DA12BA31 for ; Thu, 11 Oct 2018 21:18:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726976AbeJLErR (ORCPT ); Fri, 12 Oct 2018 00:47:17 -0400 Received: from mail-yw1-f73.google.com ([209.85.161.73]:33161 "EHLO mail-yw1-f73.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726210AbeJLErR (ORCPT ); Fri, 12 Oct 2018 00:47:17 -0400 Received: by mail-yw1-f73.google.com with SMTP id f66-v6so5948276ywa.0 for ; Thu, 11 Oct 2018 14:18:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=iJcZMy+50JNMtgZH1blblTTpqWu/hOpcr38q8O7pAPI=; b=hkQGyxMUQ+S+Ykynw22AElByOxUT3/AoupVaoB1c90Ey42awCUmzGOhD3GKtZnXoan sPbwY1RuDykXVsNYRiPc6IkSjbscPm7dbXUGvDTT5W2zfw5Ufho4f1n+jLay+8VfMBYH M+zrOmtKTd6Jt8gjHTNiUkmKNkmIyIHhJZc5g8sihWJ4Aw9diID2dnYfkfnFOjAMfl7u E8ElKWS1LghpGETSAyT1afvFDz2k+HXXSvxb5LUafibsz+oSYvdv2aPcm7KJHJ7tSW9z Efhau1cOAvIufa0kfdX4TGhMtpvRh3UWjizpMWvGLJTyTaMWnfyiRqMNNSpsmKRjzhGC ZGWg== 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=iJcZMy+50JNMtgZH1blblTTpqWu/hOpcr38q8O7pAPI=; b=QzTa2/ovoMKuiqqbH/KuSxn7bsthmm52FsgJg3hHSaIFs0kp7h0lnOk8YnsfX1RXPz wW9ndiLheQF+fXgJXxSgalYorIJ1TbYh46KLk4ByZenPmacpKr7MzCeVKcCc8Dz59Bu9 HVujcL2jRaokv6h8RZvxfQvolGxc+vzXpJ0rV2q4rNROLz2gAbfHgQkMQtYT63K3mmOO YzOWMLqQUwy+jMGneaaXW0wxT6K4/NECyb5TZTSSuB4XfM2mo8RQouoa3BYJueUjm2Jd zROjSsbM0db/B5WYqSrfTCBi29L8CIDu3i7zFPrSiMYAl81TRoe/IyEB3AltgCQLgyps mrlg== X-Gm-Message-State: ABuFfog1sjBcFXPmUNnlRUlTT1WCm3jLa6J4kTlkcvfT8Ewx1gEQZWxN TilH+kqaJvELVvMCX81SEsnxg617hSX0LPQ5u6adImphoI1dU8pd3qLImTsqPjs3i8fhpt4tFps KK1sep34/82qSyLWOytfwd9UvXtNpfMvmeg1nRMz91/2HphOFFMBmV/c6A5Ih X-Google-Smtp-Source: ACcGV62ubtSfmLnHuXtjN9PRufQTPluI9uyyDFnDoorzvJLURVVsmCGAbUwSbm7A/nCoX1lzCfLWug8wpZlN X-Received: by 2002:a25:dbd1:: with SMTP id g200-v6mr1789104ybf.90.1539292692310; Thu, 11 Oct 2018 14:18:12 -0700 (PDT) Date: Thu, 11 Oct 2018 14:17:41 -0700 In-Reply-To: <20181011211754.31369-1-sbeller@google.com> Message-Id: <20181011211754.31369-7-sbeller@google.com> Mime-Version: 1.0 References: <20181011211754.31369-1-sbeller@google.com> X-Mailer: git-send-email 2.19.0 Subject: [PATCH 06/19] commit: allow parse_commit* to handle arbitrary repositories From: Stefan Beller To: git@vger.kernel.org Cc: jonathantanmy@google.com, Stefan Beller Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 +++++++++++++---- contrib/coccinelle/the_repository.cocci | 24 ++++++++++++++++++++++++ 3 files changed, 48 insertions(+), 11 deletions(-) diff --git a/commit.c b/commit.c index 449c1f4920..c6aeedc3d8 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 da0db36eba..b8d1f6728f 100644 --- a/commit.h +++ b/commit.h @@ -79,12 +79,21 @@ struct commit *lookup_commit_reference_by_name(const char *name); struct commit *lookup_commit_or_die(const struct object_id *oid, const char *ref_name); int parse_commit_buffer(struct repository *r, struct commit *item, const void *buffer, unsigned long size, int check_graph); -int parse_commit_internal(struct commit *item, int quiet_on_missing, int use_commit_graph); -int parse_commit_gently(struct commit *item, int quiet_on_missing); -static inline int parse_commit(struct commit *item) +int repo_parse_commit_internal(struct repository *r, struct commit *item, + int quiet_on_missing, int use_commit_graph); +int repo_parse_commit_gently(struct repository *r, + struct commit *item, + int quiet_on_missing); +static inline int repo_parse_commit(struct repository *r, struct commit *item) { - return parse_commit_gently(item, 0); + return repo_parse_commit_gently(r, item, 0); } +#ifndef NO_THE_REPOSITORY_COMPATIBILITY_MACROS +#define parse_commit_internal(item, quiet, use) repo_parse_commit_internal(the_repository, item, quiet, use) +#define parse_commit_gently(item, quiet) repo_parse_commit_gently(the_repository, item, quiet) +#define parse_commit(item) repo_parse_commit(the_repository, item) +#endif + void parse_commit_or_die(struct commit *item); struct buffer_slab; diff --git a/contrib/coccinelle/the_repository.cocci b/contrib/coccinelle/the_repository.cocci index 3c7fa70502..7189a7293a 100644 --- a/contrib/coccinelle/the_repository.cocci +++ b/contrib/coccinelle/the_repository.cocci @@ -11,3 +11,27 @@ expression G; + repo_read_object_file(the_repository, E, F, G) +@@ +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 Thu Oct 11 21:17:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Beller X-Patchwork-Id: 10637483 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 D3269933 for ; Thu, 11 Oct 2018 21:18:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C0A852BA31 for ; Thu, 11 Oct 2018 21:18:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B51162BA3E; Thu, 11 Oct 2018 21:18: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 A753D2BA31 for ; Thu, 11 Oct 2018 21:18:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726983AbeJLErT (ORCPT ); Fri, 12 Oct 2018 00:47:19 -0400 Received: from mail-io1-f73.google.com ([209.85.166.73]:50531 "EHLO mail-io1-f73.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726210AbeJLErT (ORCPT ); Fri, 12 Oct 2018 00:47:19 -0400 Received: by mail-io1-f73.google.com with SMTP id f5-v6so9020542ioq.17 for ; Thu, 11 Oct 2018 14:18:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=pVgUHI2uKlC/a+Ea8m1gk0SMIcfQSxo1rEe+FM4vawU=; b=b7mELdsDBhZ8uFde8FYFSY8my1v7d02zXYJVAxsYTWb5/ZyTxiX9YD9LybZY+vIVFN G04TjyUpuI/FHVVMJdBTTdT2kKf/9QG+UEbTnkDxOWsNHPgLZjL54fHskhus/smYynR8 +x59rG4OvRV1lhrw1ZH+3NaN/BedkwRubH0tNyoMqGGTfBa09KDZL4xdBRl80VKVaUh+ SzfaLdkXFfbg5SW3jUnsZ4iOX2LrwKT5tYl9v/H1GwIkY6JxbzkccfJRQ4S0fLKYb1iR yvb6mBrWRcj+PJgZ6NKPtyW8vZQvqU73Ko+NYaadLL+SrwcEe5EfmUX4mC9q9LAnQvX4 VMYg== 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=pVgUHI2uKlC/a+Ea8m1gk0SMIcfQSxo1rEe+FM4vawU=; b=Ma9kyAl3686+ZbRNGCAL6HjBptS/kISAxYuo7AKo3CTNnE7lLvr/UvvFSJsifS+Cvo okNrBYsfiestqNljkTP72yCSTZBqa4/BgxjoJ/p89cwAatnoke7uzROke6TnSL9zDiPI TfbomUDLRgqTxhabOf+hMKekzYsS85bTQ0n+Je1G1cM/7aNgguMTIr6jLUebcNA57q1x jATV8lB0yIu6y9BKlLffUmduPk4MZN+nBl3Jyiu+RijK3FIFUarWvzx+PJksTTxCvUmZ 548lHjY9RojITYoYg0Gq7khL96/fqXtqaBzOrqabbBhIxpZXMc8JJuIra5c73fn2BhnI syow== X-Gm-Message-State: ABuFfohBppFjTz7QmSG78lWzesyUUPwuyYAsVnsQVl4uAylTAnuHHjeT rsDNKl6jf0ZlYBaRF8EYwumuc1Rn7QBEHvRwzT2r47p9K4EVNxvKXOTKJw3Tt/EN91Pte9SXs4/ A+Z0qupcNscFQ6nuwmjfsizJ7jPAk7D2S1fMl5WLcc2eO1TMflcr05ClZgt2R X-Google-Smtp-Source: ACcGV61V/gS/jzbJj8beCQZe+fSbHTgRVUkttC14ZoNcGuZEnB2fYDUhADZMghg1Glso7UoMzsselxDnmy2i X-Received: by 2002:a24:c7:: with SMTP id 190-v6mr5912770ita.2.1539292694649; Thu, 11 Oct 2018 14:18:14 -0700 (PDT) Date: Thu, 11 Oct 2018 14:17:42 -0700 In-Reply-To: <20181011211754.31369-1-sbeller@google.com> Message-Id: <20181011211754.31369-8-sbeller@google.com> Mime-Version: 1.0 References: <20181011211754.31369-1-sbeller@google.com> X-Mailer: git-send-email 2.19.0 Subject: [PATCH 07/19] commit.c: allow paint_down_to_common to handle arbitrary repositories From: Stefan Beller To: git@vger.kernel.org Cc: jonathantanmy@google.com, Stefan Beller Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP As the function is file local and not widely used, migrate it all at once. Signed-off-by: Stefan Beller --- commit.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/commit.c b/commit.c index c6aeedc3d8..f493a82f72 100644 --- a/commit.c +++ b/commit.c @@ -869,7 +869,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) { @@ -922,7 +923,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); @@ -955,7 +956,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); @@ -1026,8 +1027,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++) @@ -1151,7 +1152,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 Thu Oct 11 21:17:43 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Beller X-Patchwork-Id: 10637485 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 32EAD15E2 for ; Thu, 11 Oct 2018 21:18:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 20BC92BA31 for ; Thu, 11 Oct 2018 21:18:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 13FFE2BB7D; Thu, 11 Oct 2018 21:18:19 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, USER_IN_DEF_DKIM_WL autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B7C4A2BA31 for ; Thu, 11 Oct 2018 21:18:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726990AbeJLErV (ORCPT ); Fri, 12 Oct 2018 00:47:21 -0400 Received: from mail-it1-f201.google.com ([209.85.166.201]:53805 "EHLO mail-it1-f201.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726210AbeJLErV (ORCPT ); Fri, 12 Oct 2018 00:47:21 -0400 Received: by mail-it1-f201.google.com with SMTP id f79-v6so10751141ita.3 for ; Thu, 11 Oct 2018 14:18:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=fHEBkMvfNkG1LKHhcqjHWe+nIt3HXD1NXOI5mSoxsRY=; b=P2EP8yQOIkUuf4H3mnURhqyrUbrwwOqN2E+hKM2/65450RZ6djzEBXIzm56uanXvYC u4F/vmstuDq19PesAbnO2b4zuBDmnBTZYe3N3HsI7KWXQVL9ZFQAn4XWFy8PTytcMntE rCDSOKR6hHGSbfkhnrxF6rSiFmqhqC48X+7x9EFtKB6U29W+f70eBZihsaF8lAHhJl8f Fl0K+SgEQyYrFA9XRoHtWoclsaj2/AQCboFir553N5VxALv42ID7+9ZCidz2pKBthx38 FMCG72iKfXQtTF2CY18k15T/k66DxOigYbhf8QZmLflvmrMkMCaLeWGyqw/r+/T/1QTJ Cl/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=fHEBkMvfNkG1LKHhcqjHWe+nIt3HXD1NXOI5mSoxsRY=; b=iaJ6V0hIAY6LBur32T9oWhz1FHV+cXD5ukvMKuwOamiRYRrP8AxweZlQlks3lrmBcG pDaQozToQU+0l2garzb/tMyDl1Cb/WT/8QkHM37k2T+SnFr7dAiTV/HqBoT8gbEiWwZX VjWlOjYskrJD4KsH1NS5ATKxp7MUAJy2eVdtwifceDpcRuGi8hM0w9gsEjxPZ5ccq6Fw ZNSgTQBv0fuihzVCzXP7U7JVfvzeBAH09r63AZzkH0XBjOzFyw1SjZlO8yVXwsQWvpBV 1aw/4Ml1i4rrBoQqSsl9VpwLOES29MFLzG/O6XwDmAHXlVDt/V/WBPhtxLaoRIaVuKV+ HNfg== X-Gm-Message-State: ABuFfoiBhWLXKW00wKXWIwtGNVuGgQyywsnh9vLsp6FdvW+a1UmX6DuH H9/JHtaFxVugtN6JkWcNon5pxvIdgEBIKc4Gpmpq0X2MKNDMoE5NWymoUfsHK+Joj2NoX0kNdFp GF8uIuwzOH67B2D1UC2xuaEnwb0PBl/2WoqYztCltoSw0BRD8SWUuV89atGs2 X-Google-Smtp-Source: ACcGV60BdckSChMTYgTH8jwMrzacQya+dbN2ShF7gpo9khw+Q8TJv2xBiJ3gd4hSLMT1XpYQH0DndSlDOCgT X-Received: by 2002:a24:2752:: with SMTP id g79-v6mr2820543ita.4.1539292696804; Thu, 11 Oct 2018 14:18:16 -0700 (PDT) Date: Thu, 11 Oct 2018 14:17:43 -0700 In-Reply-To: <20181011211754.31369-1-sbeller@google.com> Message-Id: <20181011211754.31369-9-sbeller@google.com> Mime-Version: 1.0 References: <20181011211754.31369-1-sbeller@google.com> X-Mailer: git-send-email 2.19.0 Subject: [PATCH 08/19] commit.c: allow merge_bases_many to handle arbitrary repositories From: Stefan Beller To: git@vger.kernel.org Cc: jonathantanmy@google.com, Stefan Beller Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Stefan Beller --- commit.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/commit.c b/commit.c index f493a82f72..5e8791f0c1 100644 --- a/commit.c +++ b/commit.c @@ -934,7 +934,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; @@ -949,14 +951,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); @@ -1063,7 +1065,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 Thu Oct 11 21:17: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: 10637487 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 808B015E2 for ; Thu, 11 Oct 2018 21:18:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6BACD2BA31 for ; Thu, 11 Oct 2018 21:18:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5FDC72BB7D; Thu, 11 Oct 2018 21:18:21 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, USER_IN_DEF_DKIM_WL autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0BA432BA31 for ; Thu, 11 Oct 2018 21:18:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727006AbeJLErY (ORCPT ); Fri, 12 Oct 2018 00:47:24 -0400 Received: from mail-it1-f201.google.com ([209.85.166.201]:54939 "EHLO mail-it1-f201.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726210AbeJLErX (ORCPT ); Fri, 12 Oct 2018 00:47:23 -0400 Received: by mail-it1-f201.google.com with SMTP id v13-v6so10754786itc.4 for ; Thu, 11 Oct 2018 14:18:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=t479P2RXlsIOLR/pHltHu7p4oqKg24wEF8UxWF3OPSQ=; b=dw1LCw7X5j3I2TuscMeIDF4wgiDZ16TV0gajr7+nGFnhvwJjGLfugq8UNRyOJJbE2y lUgUR/2lkXWHycp8zrPY8RHJv1JeibjmRoEXHqt+iMRd2CT4fqqSGhie4C8+e0IiA+8f YpNGdZTTIJ40rmAh0llKcXXKpQ4zfaVCeiWYrsd9ZufZd7EU7s8Adon+kkG8W/SGhAHd GDNi9nXoCHfd4bGHjMt28izMEc/CKDr4fhny992wr8+rEsw5fS7OP674geOHW1k/hnza JoMXWxhnHFw8zbyxwZj7fs/F4EgQG5iMCp7UN9APsqqXz9y3nByHeqHCNwGGgPPaqtZR YGNg== 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=t479P2RXlsIOLR/pHltHu7p4oqKg24wEF8UxWF3OPSQ=; b=WAGWHecMF/KDMxXpmSt8/ZYFzrmoEU4idpktconDANIf2RiNHlKYo6qfZdk9ZQzqpU VtBSNI+jfilmDgLkbKqxRvEOeRhhYa6P6PaZxKCzGMnWdkdEGR3xzyWijy7q3HoH6s5f oaMdtfmf/Y8hdHkZe5k+zXk/i3MglQRoZr4W0jIFcmo22iny8o4QSdygRcwTHk2I45Ak 8cGpvSrq9bCETfqqWs0anhUqa7DatlRn5qc2WlYO4v/SeqyhQmVXXRLjW0pxHCb/Z0Ha F4xS8X/AjuHrtszqGIw9uf6qvcV1EnNghVdvjn4bAHqD9Cb7rifYFK8pBIdWgLzKJhGC EhCg== X-Gm-Message-State: ABuFfogv9X2vqdGAIy0jUGSTyOQfVVyGsmL7MIxDP0Mix+hENZphRqaK 6KCJk/prVV61LwXcOlu/L+0gk+gFydutbcQcQk/u62K9hNNVCYTo4BNsS4zLXanlFNDPbJeiX5J TvuIWReQo8WVds9GbnrmeCoJA1EyRhBjOJWAm2ME3UG9nJBSHWITOdP4pcCno X-Google-Smtp-Source: ACcGV61t0jgV58cjQTH6yX23fL+l6s0EeVAxNLn9TRMZbH7nBTZYZiVEsQ/qzvdlrwang5xHQDwVpfijKb2n X-Received: by 2002:a24:be05:: with SMTP id i5-v6mr2998848itf.17.1539292699100; Thu, 11 Oct 2018 14:18:19 -0700 (PDT) Date: Thu, 11 Oct 2018 14:17:44 -0700 In-Reply-To: <20181011211754.31369-1-sbeller@google.com> Message-Id: <20181011211754.31369-10-sbeller@google.com> Mime-Version: 1.0 References: <20181011211754.31369-1-sbeller@google.com> X-Mailer: git-send-email 2.19.0 Subject: [PATCH 09/19] commit.c: allow remove_redundant to handle arbitrary repositories From: Stefan Beller To: git@vger.kernel.org Cc: jonathantanmy@google.com, Stefan Beller Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Stefan Beller --- commit.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/commit.c b/commit.c index 5e8791f0c1..f8a8844a72 100644 --- a/commit.c +++ b/commit.c @@ -995,7 +995,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 @@ -1013,7 +1013,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; @@ -1029,7 +1029,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; @@ -1088,7 +1088,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); @@ -1199,7 +1199,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 Thu Oct 11 21:17: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: 10637489 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 5BE24933 for ; Thu, 11 Oct 2018 21:18:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4AB722BA31 for ; Thu, 11 Oct 2018 21:18:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3C19C2BB7D; Thu, 11 Oct 2018 21:18:23 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, USER_IN_DEF_DKIM_WL autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D95222BA31 for ; Thu, 11 Oct 2018 21:18:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727029AbeJLErZ (ORCPT ); Fri, 12 Oct 2018 00:47:25 -0400 Received: from mail-pl1-f202.google.com ([209.85.214.202]:51813 "EHLO mail-pl1-f202.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726210AbeJLErZ (ORCPT ); Fri, 12 Oct 2018 00:47:25 -0400 Received: by mail-pl1-f202.google.com with SMTP id d63-v6so7728149pld.18 for ; Thu, 11 Oct 2018 14:18:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=Uh53UNCboTiCuOX27IF+eo5LEhSR8CWc2x/1rp7lP7o=; b=pEHWNJH3akZbuPo1YY4frDRl6/yWRTzLZkMjULlngmms3j90VKhKI6dfg04kgmEajO ABFbW7mwL5vvNwJDGA3wBX0dIip9hGdC1HhcsZfLJ3z4Bth0BBqYxbVrruUjwJ/UndD8 JMGwVbaxKCUN+dAoq5uZxf16vyVFUApPEsJna895pBYWS3+WbdTfymaAih00pgKTLman u1kt+trmWdSDp/ZjpyndHX1lNGUdeB7KeehBHGiUejmgEOB/od27G/askC1VwFwhBJpy Pa9mwEiXFruatHnMKxaZD6MoUR8EmC6sDrLThU/X4AkjAFiIxbXWQNWY0PFZNW2n4+NN Q6PQ== 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=Uh53UNCboTiCuOX27IF+eo5LEhSR8CWc2x/1rp7lP7o=; b=sSb8o4tO5BfwQ7p6KSEEMwYYt2XJkPoosc4IldUHWR/h+s7IL6B0GSOXKyUauCmTOB +m06YDuOdmXWcKhAzV6L+oSzzEX/cH6SwNVfe0ocHQrjbzFXNhJu0cp451hPebkm21sC CUBWVWwUD/5qtTtVq3yoawJbuRi3SwhmBxKcTsayGYKzDnZAmJjD7ElOiqBZB/4IMTAY IsAdytcIFocnHyDG6zsAv3NIt6s81iZnqF/C2x+oJu6170Ip6akL7N9+r5G4CYhlbxEx uUTdPIgVO/9uHz4fhTznMv1+yNR19kGrfSodwghcRgBqBD3wQrX/zzVqZw0eFqgSqRju 8pfg== X-Gm-Message-State: ABuFfoibUbmc8gsWmHE0N168DemNcLBWx3qSPBYQ2pcmVz8QNOK5y5Op QlLj4ioYxlJFhwbqsvVkPmUYR5wQzzY95Wv8lyrsViLUX7W+CeZWvQ5bxMiOJPebe4txK4vlTrz giVs99xGVuCVbiTwtEva4FgWV2MOGqBbFsTRdnHXRF/OJZAVB+SvgEWI2AA0f X-Google-Smtp-Source: ACcGV61sUtK6EKk+3oyZG3HslK/4bdRcNldxDTqp4p7k1F5jkAh6p6H84GwOUorsKnD//7jusBikzuxJAVJ9 X-Received: by 2002:a63:1413:: with SMTP id u19-v6mr1648423pgl.80.1539292700941; Thu, 11 Oct 2018 14:18:20 -0700 (PDT) Date: Thu, 11 Oct 2018 14:17:45 -0700 In-Reply-To: <20181011211754.31369-1-sbeller@google.com> Message-Id: <20181011211754.31369-11-sbeller@google.com> Mime-Version: 1.0 References: <20181011211754.31369-1-sbeller@google.com> X-Mailer: git-send-email 2.19.0 Subject: [PATCH 10/19] commit: allow get_merge_bases_many_0 to handle arbitrary repositories From: Stefan Beller To: git@vger.kernel.org Cc: jonathantanmy@google.com, Stefan Beller Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Stefan Beller --- commit.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/commit.c b/commit.c index f8a8844a72..b36c2aa0bf 100644 --- a/commit.c +++ b/commit.c @@ -1055,7 +1055,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) @@ -1065,7 +1066,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; @@ -1088,7 +1089,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); @@ -1100,19 +1101,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 Thu Oct 11 21:17: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: 10637491 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 0E189933 for ; Thu, 11 Oct 2018 21:18:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EFC312BA31 for ; Thu, 11 Oct 2018 21:18:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E42632BB7D; Thu, 11 Oct 2018 21:18:25 +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 795012BA31 for ; Thu, 11 Oct 2018 21:18:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727034AbeJLEr2 (ORCPT ); Fri, 12 Oct 2018 00:47:28 -0400 Received: from mail-it1-f202.google.com ([209.85.166.202]:53200 "EHLO mail-it1-f202.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726210AbeJLEr2 (ORCPT ); Fri, 12 Oct 2018 00:47:28 -0400 Received: by mail-it1-f202.google.com with SMTP id n132-v6so10773196itn.2 for ; Thu, 11 Oct 2018 14:18:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=qKtvbI845QpG4mt5HUfjxux6SgHT7h+YObU2uyY4Oao=; b=QcoHEgTzG18BAB/ILwSG3AtLmt5wy/a/MUSrRskVBmjt9vqNlk55nUgyvgWFoq+B8o rlIaOZy1YsF/KlqtobMlpnpCJr+BDN4sU225EG11n1jdSgUbALThA9GMZKYdBO1YlLJB vpkYrmGvYxOArPbLNRx46Qlf3OSRzPMXKGGyRH+BM7FtP2IYSaiSWSRWXWPJWgKLfnK6 UfEHIkeSdpZNv11I1Kx6b4rTFntN/DLS+0qkzxB8JTjvJG7uFg5ARgx8t6k4IxqAKy5y IttdVQ9WF/eG95NaUjJk4r6FgjZfAhIumKIp0LqcbtvR63p7xt3JZlHvcbgfJaMZmnj5 Zc9A== 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=qKtvbI845QpG4mt5HUfjxux6SgHT7h+YObU2uyY4Oao=; b=n3a5lahO1+pSuPn+mNtojOjmNZJxiysBoFl89E0Nivxl11Cd5dSbEr1lCqQfQFigvf 6eKejxWkfVwJo36F8gcxJSRia4siOZFiepZH5AeBbf8Ztx7fTUioHN6NRhyrVyZR5x5/ wEr6dZjgz9Dh23jkEz97WS2D+IQrEmuksZat6id44citSlnUDptLS6ZE6uW9LlYUGvmS vRpKnFi74mrIBOHUwKH+3QiITE/Cs+Zh9AghK4yVDuunfQ3u1gx2aht6bhsigoYOi4KZ cs3UoIGzLBGaUavfF2E8RzVkj300P2nZq8JWpBUEGcJpa9E4npHE8uYuVeqPXUDI6JLD C/IA== X-Gm-Message-State: ABuFfojFnra189j7Ef/dp8hDHN/Sd4ioYL+/10GsED1ihI5ciQjLFxSB +tuZWy53lsHI69u5oG0p0EDYQH7fPjMN01z0e7ADh31vM2/X5ID0yEYpsKDz00LbOhPmAM0MSMr 07LH4uJal4to9aDqu2+zzliq+vfa3RG5Wj+mUqrbf5JZCJAlVOtNwSJoOTR5s X-Google-Smtp-Source: ACcGV61v4ajc8A7LjeQ0lMPkDpGsPVCnYqSBzoa1FO8faxBS5VgLlq+gAnHp5Y1Wx4t94ui1c9gU/t6jjsTX X-Received: by 2002:a24:4243:: with SMTP id i64-v6mr3017520itb.8.1539292703128; Thu, 11 Oct 2018 14:18:23 -0700 (PDT) Date: Thu, 11 Oct 2018 14:17:46 -0700 In-Reply-To: <20181011211754.31369-1-sbeller@google.com> Message-Id: <20181011211754.31369-12-sbeller@google.com> Mime-Version: 1.0 References: <20181011211754.31369-1-sbeller@google.com> X-Mailer: git-send-email 2.19.0 Subject: [PATCH 11/19] commit: prepare get_merge_bases to handle arbitrary repositories From: Stefan Beller To: git@vger.kernel.org Cc: jonathantanmy@google.com, Stefan Beller Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Similarly to previous patches, the get_merge_base functions are used often in the code base, which makes migrating them hard. Implement the new functions, prefixed with 'repo_' and hide the old functions behind a wrapper macro. Signed-off-by: Stefan Beller --- commit.c | 24 +++++++++++++---------- commit.h | 20 ++++++++++++++----- contrib/coccinelle/the_repository.cocci | 26 +++++++++++++++++++++++++ 3 files changed, 55 insertions(+), 15 deletions(-) diff --git a/commit.c b/commit.c index b36c2aa0bf..2733bef019 100644 --- a/commit.c +++ b/commit.c @@ -1097,23 +1097,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.h b/commit.h index b8d1f6728f..f311911785 100644 --- a/commit.h +++ b/commit.h @@ -213,12 +213,22 @@ struct commit_graft *read_graft_line(struct strbuf *line); int register_commit_graft(struct repository *r, struct commit_graft *, int); struct commit_graft *lookup_commit_graft(struct repository *r, const struct object_id *oid); -extern struct commit_list *get_merge_bases(struct commit *rev1, struct commit *rev2); -extern struct commit_list *get_merge_bases_many(struct commit *one, int n, struct commit **twos); -extern 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 */ -extern 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 +extern struct commit_list *get_octopus_merge_bases(struct commit_list *in); /* largest positive number a signed 32-bit integer can contain */ #define INFINITE_DEPTH 0x7fffffff diff --git a/contrib/coccinelle/the_repository.cocci b/contrib/coccinelle/the_repository.cocci index 7189a7293a..7814f8fa1c 100644 --- a/contrib/coccinelle/the_repository.cocci +++ b/contrib/coccinelle/the_repository.cocci @@ -35,3 +35,29 @@ expression E; + 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 Thu Oct 11 21:17: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: 10637493 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 095D215E2 for ; Thu, 11 Oct 2018 21:18:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EB9C82BA31 for ; Thu, 11 Oct 2018 21:18:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DFC542BB91; Thu, 11 Oct 2018 21:18: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 7C06C2BA31 for ; Thu, 11 Oct 2018 21:18:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727056AbeJLEra (ORCPT ); Fri, 12 Oct 2018 00:47:30 -0400 Received: from mail-qk1-f201.google.com ([209.85.222.201]:42486 "EHLO mail-qk1-f201.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726210AbeJLEra (ORCPT ); Fri, 12 Oct 2018 00:47:30 -0400 Received: by mail-qk1-f201.google.com with SMTP id m63-v6so9733788qkb.9 for ; Thu, 11 Oct 2018 14:18:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=5aC63YeB6DWEdN/wauV+06XE10cArJdD5GEiqddH5Q0=; b=ELpqd+r8vh+WqAnb9EQ9fJXGzqzuTcb2il07okEg2eIT23JDRZsivgBHBHkXU6Z9M9 E65ekx8WRJqnx6NF7h0N5TZc+Z4N2AZY/0vpSQ/b60dKjt4LuyHp0LVH3fCqwCp2E8Tp T1EQ7OVhCNMtNKCY8hyQeDr0F+t/zkeOtuPU9BHHlnD6Z3ApRoEr4nP8ptN0gJbA2NT5 16jFho9cvUd0+3YZNBIkhHMgBTH0cczrLHXwIvEvTNo/h3YzC634USQuxwTTMfh/bsnG ww02f4r44dUyVmNz5QT9g1tKvAHuxOoGPYC0L3Rme7B0q4R1i9i97yEEe8NINoDqBPJI LN0g== 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=5aC63YeB6DWEdN/wauV+06XE10cArJdD5GEiqddH5Q0=; b=GHv2QS01GH9e2p8h9npRHTsA2+7+Z58fh77Hq7pAR9EGumRQ9gBgQoiRLHuhYc3L+t IuCeBEMJ7KnlUC6VJ8MvoOggMEf0+QjXnVhFo3IgcdYMxRG8artwkVYxrtkbNv0PxSVy k9MxgO5f0eh8Cu1qXLfbS9HX4EJ8y4JSPgsJWWxztCBt74Jzci86uPaxaE2Pbk9WyeRJ AWfDjq6S1s3K9YzOLnLcxAnL4sFUVn5hM0rQ8ZTVFB8wT4DOkcvTHsJSfsoJfyuk5uuq sMSRSVTojacCo8TnM36jl6msYCAnk8jd4q2/+at4w87VjiphfyTIrb927CCyFGoMzCGD 0EbA== X-Gm-Message-State: ABuFfogWlxt7a06zSa0Uu8MJjhd1AjuGqYAxfbXOSl/cleRKEWtgC9L2 CpTC9toQj4WwKIdjH05MYLhhrmiB2IONtBlAk3+YD//NCEQ66vRHMBr4umswTOypat5tSQXfHXi T0lSxHSJ6bvJ79TSUE4MsccZjOZbxtnDR8ktHCDsCHhn89T7GADgfCiqVeOCN X-Google-Smtp-Source: ACcGV63agpdsCk/WOiteWvKBWaaQ9IhrFNcpA5hwZ84uw43F4jyIpv32JfDh6Qp9+N8EdcBaGDSIvtoh2E9H X-Received: by 2002:a0c:acbc:: with SMTP id m57-v6mr2802669qvc.19.1539292705356; Thu, 11 Oct 2018 14:18:25 -0700 (PDT) Date: Thu, 11 Oct 2018 14:17:47 -0700 In-Reply-To: <20181011211754.31369-1-sbeller@google.com> Message-Id: <20181011211754.31369-13-sbeller@google.com> Mime-Version: 1.0 References: <20181011211754.31369-1-sbeller@google.com> X-Mailer: git-send-email 2.19.0 Subject: [PATCH 12/19] commit: prepare get_commit_buffer to handle arbitrary repositories From: Stefan Beller To: git@vger.kernel.org Cc: jonathantanmy@google.com, Stefan Beller Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Stefan Beller --- commit.c | 8 +++++--- commit.h | 7 ++++++- contrib/coccinelle/the_repository.cocci | 7 +++++++ 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/commit.c b/commit.c index 2733bef019..31f2ca4c78 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 f311911785..89b245be03 100644 --- a/commit.h +++ b/commit.h @@ -117,7 +117,12 @@ const void *get_cached_commit_buffer(struct repository *, const struct commit *, * from disk. The resulting memory should not be modified, and must be given * to unuse_commit_buffer when the caller is done. */ -const void *get_commit_buffer(const struct commit *, unsigned long *size); +const void *repo_get_commit_buffer(struct repository *r, + const struct commit *, + unsigned long *size); +#ifndef NO_THE_REPOSITORY_COMPATIBILITY_MACROS +#define get_commit_buffer(c, s) repo_get_commit_buffer(the_repository, c, s) +#endif /* * Tell the commit subsytem that we are done with a particular commit buffer. diff --git a/contrib/coccinelle/the_repository.cocci b/contrib/coccinelle/the_repository.cocci index 7814f8fa1c..6dad83f17b 100644 --- a/contrib/coccinelle/the_repository.cocci +++ b/contrib/coccinelle/the_repository.cocci @@ -61,3 +61,10 @@ expression G; + repo_get_merge_bases_many_dirty(the_repository, E, F, G); +@@ +expression E; +expression F; +@@ +- get_commit_buffer( ++ repo_get_commit_buffer(the_repository, + E, F); From patchwork Thu Oct 11 21:17: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: 10637495 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 E131315E2 for ; Thu, 11 Oct 2018 21:18:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CDD182BA31 for ; Thu, 11 Oct 2018 21:18:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C22CF2BB91; Thu, 11 Oct 2018 21:18: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 5C7602BA31 for ; Thu, 11 Oct 2018 21:18:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727065AbeJLErd (ORCPT ); Fri, 12 Oct 2018 00:47:33 -0400 Received: from mail-qt1-f202.google.com ([209.85.160.202]:35803 "EHLO mail-qt1-f202.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726210AbeJLErd (ORCPT ); Fri, 12 Oct 2018 00:47:33 -0400 Received: by mail-qt1-f202.google.com with SMTP id s56-v6so10176207qtk.2 for ; Thu, 11 Oct 2018 14:18:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=j2UQPbnp+o3nIkW55IhRqzszp3nTW+ZIzCMHc5yYDvo=; b=ZFgmCy3rcpzrp3QuF+eHzJFSu6yc1NsPeTe9+QpxPJ5o8H/unegJ9Wi8rUC0TQWLUQ mM7oSz2jpIOBqdryLHMYh7ynRKQ+bvgKpsojLydpsbpwj1h7bc9PFJp2gs+iDXthzJkj GKyVW7XKJwZdfEMaS1aB0gL9XSl9SgsMEiJjdC5f3T4XWT2GRbfuQggQvQD1GbhcwIdG 3nZD8+3BC5g2QV3acsyNLzPDNdmjaItA1gm6QE+V71trno7alP+g5N7Gc+cl1CC5mXcO 0KomHB97l0LtIQjeoMZK+2saEJ8nJZvDJI7Oi3XO6CuK4AwzcqpQrZIo47f0/mtzhctz D1wQ== 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=j2UQPbnp+o3nIkW55IhRqzszp3nTW+ZIzCMHc5yYDvo=; b=AxHf0yRoYgcwjfFzd8XcyyTQL5q2wZijo3ont7zo9N3gEhzKTXDcc30GLH8GjWpPD/ J+sESkLb7Eep1fAZxpvVKJQ4JbK+c94heEdrvOLEtpM0IzY1Y3lmhVNjcETcVukj/zJH pp5eN1Nf/XfKCns2VkZ59hKJGrftFGpdi3DvVFVXY3vAB002+O+bc42pYsRxyu4GNcg4 9dGnKMRtrkRYIsWC4wDU47QwQ8F+58xqjLFizb8ZBYarEbs1GuCWIK4me199hNxm7CT6 m2AjY8fmOo70AlHNVhmBSyiAI1psIeefmiOR6UDtl1O8SqG191j8bFVc87+wyTrtZq4g 78QA== X-Gm-Message-State: ABuFfogqD95YdNmrrwjVfw8jhaQbjDCC5fSq9B98Cms+MwATvPnK6sHU umPe5Fh8uJHKUZd3cTOGXGn79XmAfKHw+xzvYV5l81lKs4x1T4ZTUAhO72ENM0NmIqRqTJSfMku X1xDt5VlF8kHe/8eIpPL8aNeBbUcW8SN27jxvHhuN+0pii4WVIUx+GUZb0tXF X-Google-Smtp-Source: ACcGV62gQhP29mo+uYr94Rlfpbf1a3oPockqlAwERW4kwnUT+YA+ZsIxJTGJ/7JAMR1sjfV57h/ZEzfV7Efo X-Received: by 2002:aed:3906:: with SMTP id l6-v6mr2715105qte.24.1539292707880; Thu, 11 Oct 2018 14:18:27 -0700 (PDT) Date: Thu, 11 Oct 2018 14:17:48 -0700 In-Reply-To: <20181011211754.31369-1-sbeller@google.com> Message-Id: <20181011211754.31369-14-sbeller@google.com> Mime-Version: 1.0 References: <20181011211754.31369-1-sbeller@google.com> X-Mailer: git-send-email 2.19.0 Subject: [PATCH 13/19] commit: prepare in_merge_bases[_many] to handle arbitrary repositories From: Stefan Beller To: git@vger.kernel.org Cc: jonathantanmy@google.com, Stefan Beller Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Stefan Beller --- commit.c | 15 +++++++++------ commit.h | 8 ++++++-- contrib/coccinelle/the_repository.cocci | 17 +++++++++++++++++ 3 files changed, 32 insertions(+), 8 deletions(-) diff --git a/commit.c b/commit.c index 31f2ca4c78..eca9a475c7 100644 --- a/commit.c +++ b/commit.c @@ -1143,16 +1143,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; @@ -1161,7 +1162,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) @@ -1175,9 +1176,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.h b/commit.h index 89b245be03..fead381651 100644 --- a/commit.h +++ b/commit.h @@ -283,8 +283,12 @@ extern void prune_shallow(int show_only); extern struct trace_key trace_shallow; int is_descendant_of(struct commit *, struct commit_list *); -int in_merge_bases(struct commit *, struct commit *); -int in_merge_bases_many(struct commit *, int, struct commit **); +int repo_in_merge_bases(struct repository *r, struct commit *, struct commit *); +int repo_in_merge_bases_many(struct repository *r, struct commit *, int, struct commit **); +#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 extern int interactive_add(int argc, const char **argv, const char *prefix, int patch); extern int run_add_interactive(const char *revision, const char *patch_mode, diff --git a/contrib/coccinelle/the_repository.cocci b/contrib/coccinelle/the_repository.cocci index 6dad83f17b..ec579682f6 100644 --- a/contrib/coccinelle/the_repository.cocci +++ b/contrib/coccinelle/the_repository.cocci @@ -68,3 +68,20 @@ expression F; - get_commit_buffer( + repo_get_commit_buffer(the_repository, E, F); + +@@ +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 Thu Oct 11 21:17: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: 10637497 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 81D77933 for ; Thu, 11 Oct 2018 21:18:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6F1282BA31 for ; Thu, 11 Oct 2018 21:18:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 62EB02BB91; Thu, 11 Oct 2018 21:18: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 115042BA31 for ; Thu, 11 Oct 2018 21:18:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727074AbeJLErg (ORCPT ); Fri, 12 Oct 2018 00:47:36 -0400 Received: from mail-vk1-f202.google.com ([209.85.221.202]:45325 "EHLO mail-vk1-f202.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726210AbeJLErf (ORCPT ); Fri, 12 Oct 2018 00:47:35 -0400 Received: by mail-vk1-f202.google.com with SMTP id l5-v6so3898219vkd.12 for ; Thu, 11 Oct 2018 14:18:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=0FW3TH6n5gGc2SzHQ9YWmVLQYSXqLZZRv4D2QCbVZjM=; b=qoS9tBeHvSRR4s7EfsUp0Ntq8gMHq5hEYDusPIHf26mlURPpplb9tYn8IqidUoKt+n RD6rh3JfHm+nhH9jtmrzxX+iiQYwiArlXITQ/+kij7XjLh61eGMlUpI24Xr8giDBkVyV u6p2Ni8X3Yh76I7A/pQiXQu+Jj1jkje+xD2lRS2+5GeR7jXzLnkyC4mSLbGX90sq5vLs r2EH4NhBwKNGZiUzJA11vua/y4nHcLDgWFnyiygJLgBXOo7IbQMpYFqxGaOW7+QeXCaQ Y3yl3hc74YLhtA9RPkr5tP2AP7JZYsYAhdLNEnnnRfklOF728yXeecy2czcOgLaqsaJC lmuA== 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=0FW3TH6n5gGc2SzHQ9YWmVLQYSXqLZZRv4D2QCbVZjM=; b=iezYnt3uso6AQiTky0e4i//urQPklDc4/i7zBzlba/Taunf/YGjB3AE7Sa0ruT7lUB qqUiWNz0Mr3RWYyKO6Ou7j5c6Xd4ubxE1QDdL42NoVgorV6/8OP2BF+jIXyVw5HG5zwi BSxGrpHRPxQKl2LWkyJSq95o7CUHkqQbAjCdjkdVCXYwe8mMclgauTW2Gjw9fKLowZ90 zQFv08joGvaZTjd0iKRuJiYsrRRz4vXD7cSuFdIv5WRDHYHXdxuNEY6JR4IWzCBhK6eE nsrngVk8yfMk9lwy3CLrZMtQaN8YJRkAgZPejCCqUQoG4jSqeZFnTm0giI3y0KgvJ2M6 KzUQ== X-Gm-Message-State: ABuFfog7MQvlJfqs2Zb54S7GMukPINPdPpvPhUroBgSLbayk4FcC9SIC USJPIURyUypnzu2ViDEYs0ABAWnGSQ16lBIQzm5jhRN4oeAFdqL5D8nuXzDjDUI00OA40HHzVRf X0TIQ6uetfOFDrC/vzkVEMuM7l+mEGYH8lUgtzQr6HR5LyUG08D1MXZiwpNke X-Google-Smtp-Source: ACcGV635KDO093nGgLYAAXA60/KBpReW0+bT6p9+/FnA7JOXUhqJE5crr0qokLzhGbEciC9OlmcIzSqUGOaA X-Received: by 2002:a67:3d41:: with SMTP id k62mr3277020vsa.2.1539292710291; Thu, 11 Oct 2018 14:18:30 -0700 (PDT) Date: Thu, 11 Oct 2018 14:17:49 -0700 In-Reply-To: <20181011211754.31369-1-sbeller@google.com> Message-Id: <20181011211754.31369-15-sbeller@google.com> Mime-Version: 1.0 References: <20181011211754.31369-1-sbeller@google.com> X-Mailer: git-send-email 2.19.0 Subject: [PATCH 14/19] commit: prepare repo_unuse_commit_buffer to handle arbitrary repositories From: Stefan Beller To: git@vger.kernel.org Cc: jonathantanmy@google.com, Stefan Beller Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Stefan Beller --- commit.c | 6 ++++-- commit.h | 7 ++++++- contrib/coccinelle/the_repository.cocci | 8 ++++++++ 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/commit.c b/commit.c index eca9a475c7..526b33758d 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 fead381651..0976bf2562 100644 --- a/commit.h +++ b/commit.h @@ -130,7 +130,12 @@ const void *repo_get_commit_buffer(struct repository *r, * from an earlier call to get_commit_buffer. The buffer may or may not be * freed by this call; callers should not access the memory afterwards. */ -void unuse_commit_buffer(const struct commit *, const void *buffer); +void repo_unuse_commit_buffer(struct repository *r, + const struct commit *, + const void *buffer); +#ifndef NO_THE_REPOSITORY_COMPATIBILITY_MACROS +#define unuse_commit_buffer(c, b) repo_unuse_commit_buffer(the_repository, c, b) +#endif /* * Free any cached object buffer associated with the commit. diff --git a/contrib/coccinelle/the_repository.cocci b/contrib/coccinelle/the_repository.cocci index ec579682f6..8c07185195 100644 --- a/contrib/coccinelle/the_repository.cocci +++ b/contrib/coccinelle/the_repository.cocci @@ -69,6 +69,14 @@ expression F; + repo_get_commit_buffer(the_repository, E, F); +@@ +expression E; +expression F; +@@ +- unuse_commit_buffer( ++ repo_unuse_commit_buffer(the_repository, + E, F); + @@ expression E; expression F; From patchwork Thu Oct 11 21:17: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: 10637499 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 A2FC515E2 for ; Thu, 11 Oct 2018 21:18:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 900D42BA31 for ; Thu, 11 Oct 2018 21:18:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 842872BB91; Thu, 11 Oct 2018 21:18:35 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, USER_IN_DEF_DKIM_WL autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 269712BA31 for ; Thu, 11 Oct 2018 21:18:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727094AbeJLEri (ORCPT ); Fri, 12 Oct 2018 00:47:38 -0400 Received: from mail-yb1-f201.google.com ([209.85.219.201]:43070 "EHLO mail-yb1-f201.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726210AbeJLErh (ORCPT ); Fri, 12 Oct 2018 00:47:37 -0400 Received: by mail-yb1-f201.google.com with SMTP id c6-v6so5099296ybm.10 for ; Thu, 11 Oct 2018 14:18:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=g/RZAUtkjwNelc7ZyGAmenZWdtG7DXhqBOZRTLYCfOQ=; b=YtSHRco4CODNQlJLulzPN5yfRnbI7xsVg2jOzq4dQP1TZFAc6kcOKy0iI1KoYQEJY4 /Z26dXlvgA0JNnDsSHVi2hutkzzr4lOG906zT0/Gg5Yeu2QkIMpPJYi18zez5IjdGVsE odLFHdBYww0Hy1papQf/ZzCLn+kAlkcHE2qdLwlzoqhmnkiLEzr23LaXV3XbXREsllgc A5RMf5BS43aQjyVci4J60cM1Z20YmLXmQGSKOQSNDn4BG855Z4Rca8VQi+vySATHJl+S 7cAfGHlwMk/ozBwPVDba6fXKHypfUfSI1/06c0rcq4amjSG/wTfQPeEL+7WlkbC5hRG+ MMWg== 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=g/RZAUtkjwNelc7ZyGAmenZWdtG7DXhqBOZRTLYCfOQ=; b=S5GlPrGuxX2MfmNnqoNzbb61sPCrz0g9ToPxutxMHHBIm0M+deDxT3++PPh6sH8uYu 8/+fqtfYPapqGj9IfVcW+hsy2DYSoVYsb2/OXf6tk8rq7fmzLvaAA2UoBAjBgflAkeA/ yqhtAtfe88bUmjdIAZP1CR7bcNS2uDV5edP1XOBgj94aAHLPs9ZSjWNaUX5CDCSWNDkY 1pZRqUX2ilLZY0cKBb7vn8hhzkymN0gm8m0bHRIc3E17VPqyjgHhpkbjWFVVUl6EkTgC 5LlfrbyVk0uXdJkfFQJOCF29YRSJ/tVTFyKMvsZ5imEslEs194tCkrvKsHun1Ui2U76q bXQA== X-Gm-Message-State: ABuFfohhclrOcf/BJJJ0q7zPGvzpykWTn7yHBMTg8Ip4yUsTjBBrmlkj 8NPVagQ3LOLWhuD4ruj2DMm3f6c7HTzIDFwDCsv+WkfoPQdkNUuoM948IPHwo7FWwvkjoGgEJFj Hec8+gXCthS2S59K77SJ/OlT5pC/S1sP54kMrHvuBdJnfBRXRHIjizNbO4TiP X-Google-Smtp-Source: ACcGV62Ln4Cnr9OBUKFkCxC0PD7itUPJUOQHpZFX/g36EqseSfZhjviWffSYuLVJMa1WQoZgrifLR4yDUmQ2 X-Received: by 2002:a25:9888:: with SMTP id l8-v6mr1849469ybo.37.1539292712715; Thu, 11 Oct 2018 14:18:32 -0700 (PDT) Date: Thu, 11 Oct 2018 14:17:50 -0700 In-Reply-To: <20181011211754.31369-1-sbeller@google.com> Message-Id: <20181011211754.31369-16-sbeller@google.com> Mime-Version: 1.0 References: <20181011211754.31369-1-sbeller@google.com> X-Mailer: git-send-email 2.19.0 Subject: [PATCH 15/19] commit: prepare logmsg_reencode to handle arbitrary repositories From: Stefan Beller To: git@vger.kernel.org Cc: jonathantanmy@google.com, Stefan Beller Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Stefan Beller --- commit.h | 8 ++++++++ contrib/coccinelle/the_repository.cocci | 9 +++++++++ pretty.c | 13 +++++++------ 3 files changed, 24 insertions(+), 6 deletions(-) diff --git a/commit.h b/commit.h index 0976bf2562..61b05ddd91 100644 --- a/commit.h +++ b/commit.h @@ -180,6 +180,14 @@ extern int has_non_ascii(const char *text); extern const char *logmsg_reencode(const struct commit *commit, char **commit_encoding, const char *output_encoding); +const char *repo_logmsg_reencode(struct repository *r, + const struct commit *commit, + char **commit_encoding, + const char *output_encoding); +#ifndef NO_THE_REPOSITORY_COMPATIBILITY_MACROS +#define logmsg_reencode(c, enc, out) repo_logmsg_reencode(the_repository, c, enc, out) +#endif + extern const char *skip_blank_lines(const char *msg); /** Removes the first commit from a list sorted by date, and adds all diff --git a/contrib/coccinelle/the_repository.cocci b/contrib/coccinelle/the_repository.cocci index 8c07185195..c81708bb73 100644 --- a/contrib/coccinelle/the_repository.cocci +++ b/contrib/coccinelle/the_repository.cocci @@ -93,3 +93,12 @@ expression G; - in_merge_bases_many( + repo_in_merge_bases_many(the_repository, E, F, G); + +@@ +expression E; +expression F; +expression G; +@@ +- logmsg_reencode( ++ repo_logmsg_reencode(the_repository, + E, F, G); diff --git a/pretty.c b/pretty.c index 98cf5228f9..26e44472bb 100644 --- a/pretty.c +++ b/pretty.c @@ -595,14 +595,15 @@ static char *replace_encoding_header(char *buf, const char *encoding) return strbuf_detach(&tmp, NULL); } -const char *logmsg_reencode(const struct commit *commit, - char **commit_encoding, - const char *output_encoding) +const char *repo_logmsg_reencode(struct repository *r, + const struct commit *commit, + char **commit_encoding, + const char *output_encoding) { static const char *utf8 = "UTF-8"; const char *use_encoding; char *encoding; - const char *msg = get_commit_buffer(commit, NULL); + const char *msg = repo_get_commit_buffer(r, commit, NULL); char *out; if (!output_encoding || !*output_encoding) { @@ -630,7 +631,7 @@ const char *logmsg_reencode(const struct commit *commit, * the cached copy from get_commit_buffer, we need to duplicate it * to avoid munging the cached copy. */ - if (msg == get_cached_commit_buffer(the_repository, commit, NULL)) + if (msg == get_cached_commit_buffer(r, commit, NULL)) out = xstrdup(msg); else out = (char *)msg; @@ -644,7 +645,7 @@ const char *logmsg_reencode(const struct commit *commit, */ out = reencode_string(msg, output_encoding, use_encoding); if (out) - unuse_commit_buffer(commit, msg); + repo_unuse_commit_buffer(r, commit, msg); } /* From patchwork Thu Oct 11 21:17: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: 10637501 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 65FFC15E2 for ; Thu, 11 Oct 2018 21:18:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 53C052BA31 for ; Thu, 11 Oct 2018 21:18:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 47D1C2BB91; Thu, 11 Oct 2018 21:18:37 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, USER_IN_DEF_DKIM_WL autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DC9842BA31 for ; Thu, 11 Oct 2018 21:18:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727103AbeJLErj (ORCPT ); Fri, 12 Oct 2018 00:47:39 -0400 Received: from mail-it1-f201.google.com ([209.85.166.201]:43201 "EHLO mail-it1-f201.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726210AbeJLErj (ORCPT ); Fri, 12 Oct 2018 00:47:39 -0400 Received: by mail-it1-f201.google.com with SMTP id w137-v6so11240981itc.8 for ; Thu, 11 Oct 2018 14:18:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=0NzGU7Eh3pz6deiN1D8iqAyLoQSeY8LiS6PVmKcunfw=; b=e6VkJUs6tw03onNoIkg4RQB6/zlTzavTVmUxnqCsF635DEFZoiY/A0qBk9qDVPcvmf wGryeZJrqQEIBWlQQlUPW0LRP2ICXT0G+AljAK8ieuxF3HVZkR0GavbIRQscZQabFNTh eUIreqz9KpWs0k5TcHnHwuz/IgZZrv35dC+JUSe+kztckhI2pMY9llgowU2VAsa3+6yK wclFutjDjAsQHSFTa4Be74YEu663hdPgTI9KlVaWB6H2M1I5MFu6DYeJl49wa2MX35/n b2XzBNP8IlwgF1hchx417eP5uWwLlP2oPqxHz+z08j8+0GWGtam1PWidTVpGa5c+qLLy YWUA== 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=0NzGU7Eh3pz6deiN1D8iqAyLoQSeY8LiS6PVmKcunfw=; b=N/i9wm181PgbTUH62gL0gNB7pN+08wPe+UfKDbii60dAVHVFiKcTh4xBLcgEeYX3ZU Mh0BfkK3foQVbU6tRlLmSQVK2ItkWvV3TjlzPIn3fVKMtj5IuNq21N25cXMEKerZN/xD osHeOsnlAKNqtDsAzxqapI32/fOOTGt/oR/Vk5QBgtHMjar8DT1Xpra4KjtWe+FbJb52 LTXEKn3qUVmbiDOPpLHs1rcA8vINm2y8/NVO8SsoI1Vwipp8nEIiM4QFtalshw+2b9vX gf4VjmUesKCgNHoWv+sDhkafm7spQQjWKozQ8wfrArH0WhKZ9pCBnSIAmcDxRdJsVz65 YSEA== X-Gm-Message-State: ABuFfoj24mH3355rGxkrzborqAAhUJHF12Wg63blF4wdeURAEYV0KzwV y4vQwkCjxEl2Jh8+J6smrPsRYe41wVdScA8T6o+wmoPU07F394Fgmm8c652zEiHZv0Q5QrWY8hM 8B4cvPYtTdloHaCei86wg5A3N0IdPG6aU4ANz67sGl/jwfLUt9uQmkL7A/uIv X-Google-Smtp-Source: ACcGV61qfaUhBtHHFzD9n26ma3LcY3wLp8odCdd9H0+7IjjbFQak8n4M0/4CwzwKFx6avrYtJBDcQGgVJ+KU X-Received: by 2002:a24:e48b:: with SMTP id o133-v6mr5825205ith.0.1539292714901; Thu, 11 Oct 2018 14:18:34 -0700 (PDT) Date: Thu, 11 Oct 2018 14:17:51 -0700 In-Reply-To: <20181011211754.31369-1-sbeller@google.com> Message-Id: <20181011211754.31369-17-sbeller@google.com> Mime-Version: 1.0 References: <20181011211754.31369-1-sbeller@google.com> X-Mailer: git-send-email 2.19.0 Subject: [PATCH 16/19] pretty: prepare format_commit_message to handle arbitrary repositories From: Stefan Beller To: git@vger.kernel.org Cc: jonathantanmy@google.com, Stefan Beller Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Stefan Beller --- contrib/coccinelle/the_repository.cocci | 10 ++++++++++ pretty.c | 15 ++++++++------- pretty.h | 7 ++++++- 3 files changed, 24 insertions(+), 8 deletions(-) diff --git a/contrib/coccinelle/the_repository.cocci b/contrib/coccinelle/the_repository.cocci index c81708bb73..c86decd418 100644 --- a/contrib/coccinelle/the_repository.cocci +++ b/contrib/coccinelle/the_repository.cocci @@ -102,3 +102,13 @@ expression G; - logmsg_reencode( + repo_logmsg_reencode(the_repository, E, F, G); + +@@ +expression E; +expression F; +expression G; +expression H; +@@ +- format_commit_message( ++ repo_format_commit_message(the_repository, + E, F, G, H); diff --git a/pretty.c b/pretty.c index 26e44472bb..948f5346cf 100644 --- a/pretty.c +++ b/pretty.c @@ -1505,9 +1505,10 @@ void userformat_find_requirements(const char *fmt, struct userformat_want *w) strbuf_release(&dummy); } -void format_commit_message(const struct commit *commit, - const char *format, struct strbuf *sb, - const struct pretty_print_context *pretty_ctx) +void repo_format_commit_message(struct repository *r, + const struct commit *commit, + const char *format, struct strbuf *sb, + const struct pretty_print_context *pretty_ctx) { struct format_commit_context context; const char *output_enc = pretty_ctx->output_encoding; @@ -1521,9 +1522,9 @@ void format_commit_message(const struct commit *commit, * convert a commit message to UTF-8 first * as far as 'format_commit_item' assumes it in UTF-8 */ - context.message = logmsg_reencode(commit, - &context.commit_encoding, - utf8); + context.message = repo_logmsg_reencode(r, commit, + &context.commit_encoding, + utf8); strbuf_expand(sb, format, format_commit_item, &context); rewrap_message_tail(sb, &context, 0, 0, 0); @@ -1547,7 +1548,7 @@ void format_commit_message(const struct commit *commit, } free(context.commit_encoding); - unuse_commit_buffer(commit, context.message); + repo_unuse_commit_buffer(r, commit, context.message); } static void pp_header(struct pretty_print_context *pp, diff --git a/pretty.h b/pretty.h index 7359d318a9..e6625269cf 100644 --- a/pretty.h +++ b/pretty.h @@ -103,9 +103,14 @@ void pp_remainder(struct pretty_print_context *pp, const char **msg_p, * Put the result to "sb". * Please use this function for custom formats. */ -void format_commit_message(const struct commit *commit, +void repo_format_commit_message(struct repository *r, + const struct commit *commit, const char *format, struct strbuf *sb, const struct pretty_print_context *context); +#ifndef NO_THE_REPOSITORY_COMPATIBILITY_MACROS +#define format_commit_message(c, f, s, con) \ + repo_format_commit_message(the_repository, c, f, s, con) +#endif /* * Parse given arguments from "arg", check it for correctness and From patchwork Thu Oct 11 21:17: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: 10637503 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 DC8B6933 for ; Thu, 11 Oct 2018 21:18:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C9EAB2BA31 for ; Thu, 11 Oct 2018 21:18:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BE4982BB91; Thu, 11 Oct 2018 21:18: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 4BE9B2BA31 for ; Thu, 11 Oct 2018 21:18:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727127AbeJLErm (ORCPT ); Fri, 12 Oct 2018 00:47:42 -0400 Received: from mail-it1-f202.google.com ([209.85.166.202]:51985 "EHLO mail-it1-f202.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726210AbeJLErm (ORCPT ); Fri, 12 Oct 2018 00:47:42 -0400 Received: by mail-it1-f202.google.com with SMTP id u2-v6so10776737ith.1 for ; Thu, 11 Oct 2018 14:18:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=0L9yyL6/ctK0N33OCpWLxP2yvQk/1Xh40CMdkyPYXPo=; b=Kv657acac5/YBgPaTBULJ4HD6IZ2kBaFsm6ypzJYPMMNFqAuGDWmqiBtXGhZblF9Vb My0AFY9hBMuuL+W6Al0s6QaC7xWnOkYcI/dwtDl8ssqaIAVmLJb3EoOOBpY3QreJHe5u Q/QeUb9moba12kDJ8cd04d7Wuv+RQTNuyAH+ZqU7ZJ1ivPXptRix0KYPlxcdGE2W9Iro TFgJlw4NeT9MBUYpFGhxwkFDSuNix/x+41yLafQo+XpHDOSM8QuawtpNNs0oLgUzvTkd vWtPX0G8N+oEX+tb2/XQJEN/MtJEPo2zU+1RsjT9toYTF1pRRaOD9Y/2hBMWQIzStJ9R hZ0w== 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=0L9yyL6/ctK0N33OCpWLxP2yvQk/1Xh40CMdkyPYXPo=; b=Tw6/ZdgWKNOLXxmjy83tCu2MfeiRGMvxVWiPOQK8jxE9Vu9CFwRYDqOetWeYvYiPXB WpAtOnaPP1Gci+AYHThI9TXg9u4xodPh3egu/iHgldt2kVlMjn9cEkQ/T8GZ09sNgyVK cr35ANEK2psfEvp/E89v59+YIDBVzpl58RjBt3ppBX3gD5t+OOSa7gZln3E0OliNBSn0 6K//EhItbfLtb+d9mStHyRkgBIvuL+NBRWHVNuphOxMB3Mnecs9LXxQL+4nN4IedVl7Y u08mT1gzS7+BG+NafvwiqSkjU3WKS/inPX16zIopiaQF6oJgaATSv7Sl5C/rgmrAMS++ wxtg== X-Gm-Message-State: ABuFfoiZ/OwA18ECBWPcpgLGi3+v4iRPQQtHsTTIVq2pQnqWnLP/pRiP 8m6EH41q1rvX70cjqXr0S3Jo9MBHEbdUalv69AySm9rSX9OTU1WikeVHK6HFVj0Xxq2B1DnVwFN wdEJYMxomLtE4ztR71/I/nP2Zn/kIp8vc3DeS1U3E8xdBEJpGcQ+6j/6i526J X-Google-Smtp-Source: ACcGV63JbmH07lpLl2nbIXUNLEc68PpAAKSIJWNfiLxEmBcerVAbWpGPNQ6gyTur3jOFgs++s5g13UhJ+CTy X-Received: by 2002:a24:dd45:: with SMTP id t66-v6mr5904923itf.5.1539292717023; Thu, 11 Oct 2018 14:18:37 -0700 (PDT) Date: Thu, 11 Oct 2018 14:17:52 -0700 In-Reply-To: <20181011211754.31369-1-sbeller@google.com> Message-Id: <20181011211754.31369-18-sbeller@google.com> Mime-Version: 1.0 References: <20181011211754.31369-1-sbeller@google.com> X-Mailer: git-send-email 2.19.0 Subject: [PATCH 17/19] submodule: use submodule repos for object lookup From: Stefan Beller To: git@vger.kernel.org Cc: jonathantanmy@google.com, Stefan Beller Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This converts the 'show_submodule_header' function to use the repository API properly, such that the submodule objects are not added to the main object store. Signed-off-by: Stefan Beller --- submodule.c | 48 ++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 38 insertions(+), 10 deletions(-) diff --git a/submodule.c b/submodule.c index 442229bb49..5e1a6c0b7c 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,12 +482,37 @@ void prepare_submodule_repo_env(struct argv_array *out) DEFAULT_GIT_DIR_ENVIRONMENT); } +/* + * Initialize 'out' based on the provided submodule path. + * + * Unlike repo_submodule_init, this tolerates submodules not present + * in .gitmodules. NEEDSWORK: The repo_submodule_init behavior is + * preferrable. This function exists only to preserve historical behavior. + * + * Returns 0 on success, -1 when the submodule is not present. + */ +static int open_submodule(struct repository *out, const char *path) +{ + struct strbuf sb = STRBUF_INIT; + + if (submodule_to_gitdir(&sb, path) || repo_init(out, sb.buf, NULL)) { + strbuf_release(&sb); + return -1; + } + + out->submodule_prefix = xstrdup(path); + + strbuf_release(&sb); + return 0; +} + /* Helper function to display the submodule header line prior to the full * summary output. If it can locate the submodule objects directory it will * attempt to lookup both the left and right commits and put them into the * left and right pointers. */ -static void show_submodule_header(struct diff_options *o, const char *path, +static void show_submodule_header(struct diff_options *o, struct repository *sub, + const char *path, struct object_id *one, struct object_id *two, unsigned dirty_submodule, struct commit **left, struct commit **right, @@ -507,7 +533,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 (open_submodule(sub, path) < 0) { if (!message) message = "(commits not present)"; goto output_header; @@ -517,8 +543,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 +554,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,8 +588,9 @@ 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; - show_submodule_header(o, path, one, two, dirty_submodule, + show_submodule_header(o, &sub, path, one, two, dirty_submodule, &left, &right, &merge_bases); /* @@ -580,7 +607,7 @@ 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) @@ -598,8 +625,9 @@ 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; - show_submodule_header(o, path, one, two, dirty_submodule, + show_submodule_header(o, &sub, path, one, two, dirty_submodule, &left, &right, &merge_bases); /* We need a valid left and right commit to display a difference */ From patchwork Thu Oct 11 21:17: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: 10637505 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 9B27015E2 for ; Thu, 11 Oct 2018 21:18:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 84D672BBE8 for ; Thu, 11 Oct 2018 21:18:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 77B582BB91; Thu, 11 Oct 2018 21:18: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 2FFF32BA31 for ; Thu, 11 Oct 2018 21:18:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727148AbeJLEro (ORCPT ); Fri, 12 Oct 2018 00:47:44 -0400 Received: from mail-io1-f74.google.com ([209.85.166.74]:54948 "EHLO mail-io1-f74.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726210AbeJLEro (ORCPT ); Fri, 12 Oct 2018 00:47:44 -0400 Received: by mail-io1-f74.google.com with SMTP id l24-v6so9145894iok.21 for ; Thu, 11 Oct 2018 14:18:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=UUZ6Va/mNKFe/YVnUcUO+5XlmtcsDZnNJk0zm8ELkRw=; b=Isa5cz0hNDaxj1oP780s/A3Oqfu7rl6/c0pmq8YNTIdyJKZSjnePHuCmY1kSM0K1G2 WAVzQ0+sjiyUZJ+AvEGtcRKnYymspX9mHaTqm1/Gzh6NSoTVH4ExBIqwOoX2wTqlegO0 N47AqRfImA+129InyOKrprfenHyi05Ts2O+NAFO+EAXzt+HZZIZVYs7cQQC1aLH5CE3N aMysqZXv8mt03xJ09tjnBY1lrHffP/no+N2QJ15hZWZPg3dsBI1DarVlMOTx79cqj7rP u8ArOw+WMsvNm39NKkObh/x2c3MOHyWNrQcnkgXvDEjRGYH2HUwlB18uevzPIon/byVG VWtQ== 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=UUZ6Va/mNKFe/YVnUcUO+5XlmtcsDZnNJk0zm8ELkRw=; b=C8dbVlkegyD1y40g03FtrSJWB+SzXmzWBU0VkSFgH0o/SCjyDkIZ1TXBiVhNsvbhAC Hsqo0/4aO8X3P7IQ5ueqAD7i2ZxpiZPmwzCm+dTimpYzHZOEakkGxzbiAnAeJA2XH6s5 X689udMcBv6L3SuGF76TkczEFxDtZqHagGvC6zDwsy5IhoRsQZIlQOKw3tQXs1oS0EwF RaVL/EtuK345+b9oadmOKZBuRpTdn5AyoS2lrh+flte+b9mNKfjKM2siFYgL+9W7mKTb h0U0KdgbxDV8KInFDXC96vDfLN8TXZwruev2HTuXwoMrm2XFQ+8BmYHNdgQteCJPCNBC vtmw== X-Gm-Message-State: ABuFfoiOfhVxdcl55jxINVNXrymYstUT6nHm6Qp0ZwGX6MT9n33XI3hd 23NhrwX7HhqKXukCjOSb54FSr3VMlPIlBSWQw55GVeaq71+HKta/YSSf8LLbM6T1/QURr7A6e8Z PsW0VZ3M+itBLZBkAHpEQrd+fs2UyfsoBpnIQ5oWlWOOhjXddKhpt/FdPZamw X-Google-Smtp-Source: ACcGV60meAc0xKicrSSHGPHuorsHrniDmCgK9zx4XDOBxq4PIjCyIX+7lUfB9DMwBP3vf+EKTNLhr/rRx1Zh X-Received: by 2002:a24:3d14:: with SMTP id n20-v6mr2868284itn.13.1539292719249; Thu, 11 Oct 2018 14:18:39 -0700 (PDT) Date: Thu, 11 Oct 2018 14:17:53 -0700 In-Reply-To: <20181011211754.31369-1-sbeller@google.com> Message-Id: <20181011211754.31369-19-sbeller@google.com> Mime-Version: 1.0 References: <20181011211754.31369-1-sbeller@google.com> X-Mailer: git-send-email 2.19.0 Subject: [PATCH 18/19] submodule: don't add submodule as odb for push From: Stefan Beller To: git@vger.kernel.org Cc: jonathantanmy@google.com, Stefan Beller Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The submodule was added as an alternative in eb21c732d6 (push: teach --recurse-submodules the on-demand option, 2012-03-29), but was not explained, why. In similar code, submodule_has_commits, the submodule is added as an alternative to perform a quick check if we need to dive into the submodule. However in push_submodule (a) for_each_remote_ref_submodule will also provide the quick check and (b) after that we don't need to have submodule objects around, as all further code is to spawn a separate process. Signed-off-by: Stefan Beller --- submodule.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/submodule.c b/submodule.c index 5e1a6c0b7c..f70d75ef45 100644 --- a/submodule.c +++ b/submodule.c @@ -1006,9 +1006,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 Thu Oct 11 21:17: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: 10637507 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 4925115E2 for ; Thu, 11 Oct 2018 21:18:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2E9B02BF9C for ; Thu, 11 Oct 2018 21:18:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 219822BFA0; Thu, 11 Oct 2018 21:18:50 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, USER_IN_DEF_DKIM_WL autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4BBEF2BF9C for ; Thu, 11 Oct 2018 21:18:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727152AbeJLErt (ORCPT ); Fri, 12 Oct 2018 00:47:49 -0400 Received: from mail-qt1-f202.google.com ([209.85.160.202]:55656 "EHLO mail-qt1-f202.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726210AbeJLErt (ORCPT ); Fri, 12 Oct 2018 00:47:49 -0400 Received: by mail-qt1-f202.google.com with SMTP id 4-v6so9286006qtt.22 for ; Thu, 11 Oct 2018 14:18:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=7xs/hp9VGMjMZxOyV1udCN5bqAgb15X42pid8k9ZFpU=; b=TxpHRuIcfV6Z/3ce/tHchBgMmaBBDnghZEpagzQaK1tRPmSBQmYEZqKXnJaAMdjqa7 cY/eEH9JT64Z04jwhvo7BBLpsmg37XYltflxjeJHtwGYFOOBHmY6OuPi0z40LMgejm7U orT5ABmUSsZo0Y+GLwPJERGsF19sKmP390BEVi3Ekj0ia1tjbcNDc8N8RZpg7x4hVoo4 VBlYHvJR1biq+OjDwdJSyh6VNxbB+Rf193K9yTQsNbxLxeNbG2td2hRq0yamDsqw46Aq 6g0tO1QN/Fgbow3D49fThMq+NSuY/cwWUjDJecNYf4ggaMKLQw7gDOSCvNO4MEvlqwiV RRgg== 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=7xs/hp9VGMjMZxOyV1udCN5bqAgb15X42pid8k9ZFpU=; b=RDdUVf2CWfr707wUXxPaEeowAbbERTA7aULI0risZHcHVNTk2144smlDQCBnhIre7a enjrylAv0iZcG9gNlma5SPK8Q8hQYxq0jPnu6pBczqQK2sfIk7hWpAWbgghL5wQAGy6+ vB6FOUGVi09pol+rCWn58mYT7rCQi16IkdtDbOq4+NZz/5NK1QycVrfqL9W2OKZRTmDb rJKiYPi8wqA2nlow5CDdT1BtlVXlW9xJ//4XYKzgGn0ba8LacIg4kt2kkluyxl0oHZkU YA4MXgcgPjK2NjRoFEZx7Sk3xBJO1gwSei3drjJgVuwMthgrFDz1J5BnYh0e167K4aBJ FMZg== X-Gm-Message-State: ABuFfojRsTGmB8XtfdEOBtXz0ebmK2D8gl9L1rsgLMut3I1B0U9KlV4M BkeUbugxQB1LQv4a5TKQ+oPYprVHlzl2kGNKuBZ2yhYSz49JMPzOOBac+ckKBv7wHkHwhxl9YXz ceYFgJJMz7OtUrNi6oz2lXpg2pnKxe5nRhm+Og+ETxrjL+DBEiRioEbAoT7yk X-Google-Smtp-Source: ACcGV63IykOOtNQ3Gb9hvrJ382xSynpc2BxQgTH/x6fvu/DgAFfmTz5cmokZj5p6ftZ+/OF39CoOTAAyf4h2 X-Received: by 2002:a37:19c9:: with SMTP id 70-v6mr2765264qkz.56.1539292721637; Thu, 11 Oct 2018 14:18:41 -0700 (PDT) Date: Thu, 11 Oct 2018 14:17:54 -0700 In-Reply-To: <20181011211754.31369-1-sbeller@google.com> Message-Id: <20181011211754.31369-20-sbeller@google.com> Mime-Version: 1.0 References: <20181011211754.31369-1-sbeller@google.com> X-Mailer: git-send-email 2.19.0 Subject: [PATCH 19/19] Apply semantic patches from previous patches From: Stefan Beller To: git@vger.kernel.org Cc: jonathantanmy@google.com, Stefan Beller Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Previous commits added some cocci rules, but did not patch the whole tree, as to not dilute the focus for reviewing the previous patches. This patch is generated by 'make coccicheck' and applying the resulting diff, which was white space damaged (>8 spaces after a tab) in blame.c, which has been fixed. Signed-off-by: Stefan Beller --- apply.c | 6 ++-- archive.c | 5 +-- bisect.c | 5 +-- blame.c | 15 +++++---- builtin/am.c | 2 +- builtin/blame.c | 4 +-- builtin/cat-file.c | 21 +++++++----- builtin/checkout.c | 4 +-- builtin/commit.c | 13 +++++--- builtin/describe.c | 4 +-- builtin/difftool.c | 3 +- builtin/fast-export.c | 7 ++-- builtin/fmt-merge-msg.c | 8 +++-- builtin/grep.c | 2 +- builtin/index-pack.c | 8 +++-- builtin/log.c | 4 +-- builtin/merge-base.c | 2 +- builtin/merge-tree.c | 9 ++++-- builtin/mktag.c | 3 +- builtin/name-rev.c | 2 +- builtin/notes.c | 12 ++++--- builtin/pack-objects.c | 22 +++++++++---- builtin/reflog.c | 5 +-- builtin/replace.c | 2 +- builtin/shortlog.c | 5 +-- builtin/show-branch.c | 4 +-- builtin/tag.c | 4 +-- builtin/unpack-file.c | 2 +- builtin/unpack-objects.c | 3 +- builtin/verify-commit.c | 2 +- bundle.c | 2 +- combine-diff.c | 2 +- commit-graph.c | 8 ++--- commit.c | 15 +++++---- config.c | 2 +- diff.c | 3 +- dir.c | 2 +- entry.c | 3 +- fast-import.c | 7 ++-- fsck.c | 9 +++--- grep.c | 3 +- http-push.c | 3 +- log-tree.c | 3 +- mailmap.c | 2 +- match-trees.c | 4 +-- merge-blobs.c | 6 ++-- merge-recursive.c | 13 ++++---- negotiator/default.c | 6 ++-- negotiator/skipping.c | 2 +- notes-cache.c | 5 +-- notes-merge.c | 4 +-- notes-utils.c | 2 +- notes.c | 10 +++--- pretty.c | 5 +-- read-cache.c | 5 +-- remote-testsvn.c | 4 +-- remote.c | 2 +- rerere.c | 5 +-- revision.c | 12 +++---- sequencer.c | 55 +++++++++++++++++++------------- sha1-file.c | 3 +- sha1-name.c | 9 +++--- shallow.c | 4 +-- submodule-config.c | 3 +- t/helper/test-revision-walking.c | 3 +- tag.c | 5 +-- tree-walk.c | 6 ++-- tree.c | 5 +-- walker.c | 2 +- xdiff-interface.c | 2 +- 70 files changed, 254 insertions(+), 180 deletions(-) diff --git a/apply.c b/apply.c index fdae1d423b..5ac284b7e8 100644 --- a/apply.c +++ b/apply.c @@ -3187,7 +3187,8 @@ static int apply_binary(struct apply_state *state, unsigned long size; char *result; - result = read_object_file(&oid, &type, &size); + result = repo_read_object_file(the_repository, &oid, &type, + &size); if (!result) return error(_("the necessary postimage %s for " "'%s' cannot be read"), @@ -3249,7 +3250,8 @@ static int read_blob_object(struct strbuf *buf, const struct object_id *oid, uns unsigned long sz; char *result; - result = read_object_file(oid, &type, &sz); + result = repo_read_object_file(the_repository, oid, &type, + &sz); if (!result) return -1; /* XXX read_sha1_file NUL-terminates */ diff --git a/archive.c b/archive.c index 994495af05..70e5eed535 100644 --- a/archive.c +++ b/archive.c @@ -55,7 +55,8 @@ static void format_subst(const struct commit *commit, strbuf_add(&fmt, b + 8, c - b - 8); strbuf_add(buf, src, b - src); - format_commit_message(commit, fmt.buf, buf, &ctx); + repo_format_commit_message(the_repository, commit, fmt.buf, + buf, &ctx); len -= c + 1 - src; src = c + 1; } @@ -73,7 +74,7 @@ void *object_file_to_archive(const struct archiver_args *args, const struct commit *commit = args->convert ? args->commit : NULL; path += args->baselen; - buffer = read_object_file(oid, type, sizep); + buffer = repo_read_object_file(the_repository, oid, type, sizep); if (buffer && S_ISREG(mode)) { struct strbuf buf = STRBUF_INIT; size_t size = 0; diff --git a/bisect.c b/bisect.c index 6ae5e5b49e..ae92367738 100644 --- a/bisect.c +++ b/bisect.c @@ -136,8 +136,9 @@ static void show_list(const char *debug, int counted, int nr, unsigned flags = commit->object.flags; enum object_type type; unsigned long size; - char *buf = read_object_file(&commit->object.oid, &type, - &size); + char *buf = repo_read_object_file(the_repository, + &commit->object.oid, &type, + &size); const char *subject_start; int subject_len; diff --git a/blame.c b/blame.c index c229a10c0e..fc2764d036 100644 --- a/blame.c +++ b/blame.c @@ -322,8 +322,9 @@ static void fill_origin_blob(struct diff_options *opt, &o->blob_oid, 1, &file->ptr, &file_size)) ; else - file->ptr = read_object_file(&o->blob_oid, &type, - &file_size); + file->ptr = repo_read_object_file(the_repository, + &o->blob_oid, &type, + &file_size); file->size = file_size; if (!file->ptr) @@ -1455,7 +1456,7 @@ static void pass_blame(struct blame_scoreboard *sb, struct blame_origin *origin, if (sg_origin[i]) continue; - if (parse_commit(p)) + if (repo_parse_commit(the_repository, p)) continue; porigin = find(sb->repo, p, origin); if (!porigin) @@ -1594,7 +1595,7 @@ void assign_blame(struct blame_scoreboard *sb, int opt) * so hold onto it in the meantime. */ blame_origin_incref(suspect); - parse_commit(commit); + repo_parse_commit(the_repository, commit); if (sb->reverse || (!(commit->object.flags & UNINTERESTING) && !(revs->max_age != -1 && commit->date < revs->max_age))) @@ -1864,8 +1865,10 @@ void setup_scoreboard(struct blame_scoreboard *sb, &sb->final_buf_size)) ; else - sb->final_buf = read_object_file(&o->blob_oid, &type, - &sb->final_buf_size); + sb->final_buf = repo_read_object_file(the_repository, + &o->blob_oid, + &type, + &sb->final_buf_size); if (!sb->final_buf) die(_("cannot read blob %s for path %s"), diff --git a/builtin/am.c b/builtin/am.c index 601570dbef..3c992a93fb 100644 --- a/builtin/am.c +++ b/builtin/am.c @@ -1360,7 +1360,7 @@ static void get_commit_info(struct am_state *state, struct commit *commit) die(_("unable to parse commit %s"), oid_to_hex(&commit->object.oid)); state->msg = xstrdup(msg + 2); state->msg_len = strlen(state->msg); - unuse_commit_buffer(commit, buffer); + repo_unuse_commit_buffer(the_repository, commit, buffer); } /** diff --git a/builtin/blame.c b/builtin/blame.c index a443af9ee9..dcd300c0d3 100644 --- a/builtin/blame.c +++ b/builtin/blame.c @@ -197,7 +197,7 @@ static void get_commit_info(struct commit *commit, &ret->author_time, &ret->author_tz); if (!detailed) { - unuse_commit_buffer(commit, message); + repo_unuse_commit_buffer(the_repository, commit, message); return; } @@ -211,7 +211,7 @@ static void get_commit_info(struct commit *commit, else strbuf_addf(&ret->summary, "(%s)", oid_to_hex(&commit->object.oid)); - unuse_commit_buffer(commit, message); + repo_unuse_commit_buffer(the_repository, commit, message); } /* diff --git a/builtin/cat-file.c b/builtin/cat-file.c index 8d97c84725..afad7b1c84 100644 --- a/builtin/cat-file.c +++ b/builtin/cat-file.c @@ -34,7 +34,7 @@ static int filter_object(const char *path, unsigned mode, { enum object_type type; - *buf = read_object_file(oid, &type, size); + *buf = repo_read_object_file(the_repository, oid, &type, size); if (!*buf) return error(_("cannot read object %s '%s'"), oid_to_hex(oid), path); @@ -133,7 +133,8 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name, if (type == OBJ_BLOB) return stream_blob_to_fd(1, &oid, NULL, 0); - buf = read_object_file(&oid, &type, &size); + buf = repo_read_object_file(the_repository, &oid, &type, + &size); if (!buf) die("Cannot read object %s", obj_name); @@ -144,8 +145,10 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name, if (type_from_string(exp_type) == OBJ_BLOB) { struct object_id blob_oid; if (oid_object_info(the_repository, &oid, NULL) == OBJ_TAG) { - char *buffer = read_object_file(&oid, &type, - &size); + char *buffer = repo_read_object_file(the_repository, + &oid, + &type, + &size); const char *target; if (!skip_prefix(buffer, "object ", &target) || get_oid_hex(target, &blob_oid)) @@ -309,9 +312,10 @@ static void print_object_or_die(struct batch_options *opt, struct expand_data *d if (!textconv_object(the_repository, data->rest, 0100644, oid, 1, &contents, &size)) - contents = read_object_file(oid, - &type, - &size); + contents = repo_read_object_file(the_repository, + oid, + &type, + &size); if (!contents) die("could not convert '%s' %s", oid_to_hex(oid), data->rest); @@ -327,7 +331,8 @@ static void print_object_or_die(struct batch_options *opt, struct expand_data *d unsigned long size; void *contents; - contents = read_object_file(oid, &type, &size); + contents = repo_read_object_file(the_repository, oid, &type, + &size); if (!contents) die("object %s disappeared", oid_to_hex(oid)); if (type != data->type) diff --git a/builtin/checkout.c b/builtin/checkout.c index ae28478ff8..0be05e0665 100644 --- a/builtin/checkout.c +++ b/builtin/checkout.c @@ -404,7 +404,7 @@ static void describe_detached_head(const char *msg, struct commit *commit) { struct strbuf sb = STRBUF_INIT; - if (!parse_commit(commit)) + if (!repo_parse_commit(the_repository, commit)) pp_commit_easy(CMIT_FMT_ONELINE, commit, &sb); if (print_sha1_ellipsis()) { fprintf(stderr, "%s %s... %s\n", msg, @@ -732,7 +732,7 @@ static void describe_one_orphan(struct strbuf *sb, struct commit *commit) strbuf_addstr(sb, " "); strbuf_add_unique_abbrev(sb, &commit->object.oid, DEFAULT_ABBREV); strbuf_addch(sb, ' '); - if (!parse_commit(commit)) + if (!repo_parse_commit(the_repository, commit)) pp_commit_easy(CMIT_FMT_ONELINE, commit, sb); strbuf_addch(sb, '\n'); } diff --git a/builtin/commit.c b/builtin/commit.c index 9d8ce6cb3b..4c07dc5681 100644 --- a/builtin/commit.c +++ b/builtin/commit.c @@ -680,8 +680,9 @@ static int prepare_to_commit(const char *index_file, const char *prefix, if (!c) die(_("could not lookup commit %s"), squash_message); ctx.output_encoding = get_commit_output_encoding(); - format_commit_message(c, "squash! %s\n\n", &sb, - &ctx); + repo_format_commit_message(the_repository, c, + "squash! %s\n\n", &sb, + &ctx); } } @@ -713,8 +714,9 @@ static int prepare_to_commit(const char *index_file, const char *prefix, if (!commit) die(_("could not lookup commit %s"), fixup_message); ctx.output_encoding = get_commit_output_encoding(); - format_commit_message(commit, "fixup! %s\n\n", - &sb, &ctx); + repo_format_commit_message(the_repository, commit, + "fixup! %s\n\n", + &sb, &ctx); if (have_option_m) strbuf_addbuf(&sb, &message); hook_arg1 = "message"; @@ -997,7 +999,8 @@ static const char *find_author_by_nickname(const char *name) struct pretty_print_context ctx = {0}; ctx.date_mode.type = DATE_NORMAL; strbuf_release(&buf); - format_commit_message(commit, "%aN <%aE>", &buf, &ctx); + repo_format_commit_message(the_repository, commit, + "%aN <%aE>", &buf, &ctx); clear_mailmap(&mailmap); return strbuf_detach(&buf, NULL); } diff --git a/builtin/describe.c b/builtin/describe.c index 1fde0563fe..290218c0d9 100644 --- a/builtin/describe.c +++ b/builtin/describe.c @@ -254,7 +254,7 @@ static unsigned long finish_depth_computation( best->depth++; while (parents) { struct commit *p = parents->item; - parse_commit(p); + repo_parse_commit(the_repository, p); if (!(p->object.flags & SEEN)) commit_list_insert_by_date(p, list); p->object.flags |= c->object.flags; @@ -381,7 +381,7 @@ static void describe_commit(struct object_id *oid, struct strbuf *dst) } while (parents) { struct commit *p = parents->item; - parse_commit(p); + repo_parse_commit(the_repository, p); if (!(p->object.flags & SEEN)) commit_list_insert_by_date(p, &list); p->object.flags |= c->object.flags; diff --git a/builtin/difftool.c b/builtin/difftool.c index e7023e3adf..23720d4d64 100644 --- a/builtin/difftool.c +++ b/builtin/difftool.c @@ -307,7 +307,8 @@ static char *get_symlink(const struct object_id *oid, const char *path) } else { enum object_type type; unsigned long size; - data = read_object_file(oid, &type, &size); + data = repo_read_object_file(the_repository, oid, &type, + &size); if (!data) die(_("could not read object %s for symlink %s"), oid_to_hex(oid), path); diff --git a/builtin/fast-export.c b/builtin/fast-export.c index 9bd4a95a47..9e65697524 100644 --- a/builtin/fast-export.c +++ b/builtin/fast-export.c @@ -239,7 +239,7 @@ static void export_blob(const struct object_id *oid) object = (struct object *)lookup_blob(the_repository, oid); eaten = 0; } else { - buf = read_object_file(oid, &type, &size); + buf = repo_read_object_file(the_repository, oid, &type, &size); if (!buf) die("could not read blob %s", oid_to_hex(oid)); if (check_object_signature(oid, buf, size, type_name(type)) < 0) @@ -617,7 +617,7 @@ static void handle_commit(struct commit *commit, struct rev_info *rev, ? strlen(message) : 0), reencoded ? reencoded : message ? message : ""); free(reencoded); - unuse_commit_buffer(commit, commit_buffer); + repo_unuse_commit_buffer(the_repository, commit, commit_buffer); for (i = 0, p = commit->parents; p; p = p->next) { int mark = get_object_mark(&p->item->object); @@ -689,7 +689,8 @@ static void handle_tag(const char *name, struct tag *tag) return; } - buf = read_object_file(&tag->object.oid, &type, &size); + buf = repo_read_object_file(the_repository, &tag->object.oid, &type, + &size); if (!buf) die("could not read tag %s", oid_to_hex(&tag->object.oid)); message = memmem(buf, size, "\n\n", 2); diff --git a/builtin/fmt-merge-msg.c b/builtin/fmt-merge-msg.c index 1adc84ed87..4248e3982d 100644 --- a/builtin/fmt-merge-msg.c +++ b/builtin/fmt-merge-msg.c @@ -264,7 +264,7 @@ static void record_person(int which, struct string_list *people, { const char *buffer = get_commit_buffer(commit, NULL); record_person_from_buf(which, people, buffer); - unuse_commit_buffer(commit, buffer); + repo_unuse_commit_buffer(the_repository, commit, buffer); } static int cmp_string_list_util_as_integral(const void *a_, const void *b_) @@ -375,7 +375,8 @@ static void shortlog(const char *name, if (subjects.nr > limit) continue; - format_commit_message(commit, "%s", &sb, &ctx); + repo_format_commit_message(the_repository, commit, "%s", &sb, + &ctx); strbuf_ltrim(&sb); if (!sb.len) @@ -493,7 +494,8 @@ static void fmt_merge_msg_sigs(struct strbuf *out) struct object_id *oid = origins.items[i].util; enum object_type type; unsigned long size, len; - char *buf = read_object_file(oid, &type, &size); + char *buf = repo_read_object_file(the_repository, oid, &type, + &size); struct strbuf sig = STRBUF_INIT; if (!buf || type != OBJ_TAG) diff --git a/builtin/grep.c b/builtin/grep.c index 0c3527242e..06f7711330 100644 --- a/builtin/grep.c +++ b/builtin/grep.c @@ -308,7 +308,7 @@ static void *lock_and_read_oid_file(const struct object_id *oid, enum object_typ void *data; grep_read_lock(); - data = read_object_file(oid, type, size); + data = repo_read_object_file(the_repository, oid, type, size); grep_read_unlock(); return data; } diff --git a/builtin/index-pack.c b/builtin/index-pack.c index 9582ead950..887c44e111 100644 --- a/builtin/index-pack.c +++ b/builtin/index-pack.c @@ -817,7 +817,8 @@ static void sha1_object(const void *data, struct object_entry *obj_entry, die(_("cannot read existing object info %s"), oid_to_hex(oid)); if (has_type != type || has_size != size) die(_("SHA1 COLLISION FOUND WITH %s !"), oid_to_hex(oid)); - has_data = read_object_file(oid, &has_type, &has_size); + has_data = repo_read_object_file(the_repository, oid, + &has_type, &has_size); read_unlock(); if (!data) data = new_data = get_data_from_pack(obj_entry); @@ -1379,8 +1380,9 @@ static void fix_unresolved_deltas(struct hashfile *f) if (objects[d->obj_no].real_type != OBJ_REF_DELTA) continue; - base_obj->data = read_object_file(&d->oid, &type, - &base_obj->size); + base_obj->data = repo_read_object_file(the_repository, + &d->oid, &type, + &base_obj->size); if (!base_obj->data) continue; diff --git a/builtin/log.c b/builtin/log.c index 717d20e115..d4709ec63d 100644 --- a/builtin/log.c +++ b/builtin/log.c @@ -525,7 +525,7 @@ static int show_tag_object(const struct object_id *oid, struct rev_info *rev) { unsigned long size; enum object_type type; - char *buf = read_object_file(oid, &type, &size); + char *buf = repo_read_object_file(the_repository, oid, &type, &size); int offset = 0; if (!buf) @@ -1032,7 +1032,7 @@ static void make_cover_letter(struct rev_info *rev, int use_stdout, const char *buf = get_commit_buffer(list[i], NULL); if (has_non_ascii(buf)) need_8bit_cte = 1; - unuse_commit_buffer(list[i], buf); + repo_unuse_commit_buffer(the_repository, list[i], buf); } if (!branch_name) diff --git a/builtin/merge-base.c b/builtin/merge-base.c index 08d91b1f0c..82567bf79c 100644 --- a/builtin/merge-base.c +++ b/builtin/merge-base.c @@ -127,7 +127,7 @@ static void add_one_commit(struct object_id *oid, struct rev_collect *revs) commit = lookup_commit(the_repository, oid); if (!commit || (commit->object.flags & TMP_MARK) || - parse_commit(commit)) + repo_parse_commit(the_repository, commit)) return; ALLOC_GROW(revs->commit, revs->nr + 1, revs->alloc); diff --git a/builtin/merge-tree.c b/builtin/merge-tree.c index f32941fdab..99403f70f4 100644 --- a/builtin/merge-tree.c +++ b/builtin/merge-tree.c @@ -62,7 +62,9 @@ static void *result(struct merge_list *entry, unsigned long *size) const char *path = entry->path; if (!entry->stage) - return read_object_file(&entry->blob->object.oid, &type, size); + return repo_read_object_file(the_repository, + &entry->blob->object.oid, &type, + size); base = NULL; if (entry->stage == 1) { base = entry->blob; @@ -84,8 +86,9 @@ static void *origin(struct merge_list *entry, unsigned long *size) enum object_type type; while (entry) { if (entry->stage == 2) - return read_object_file(&entry->blob->object.oid, - &type, size); + return repo_read_object_file(the_repository, + &entry->blob->object.oid, + &type, size); entry = entry->link; } return NULL; diff --git a/builtin/mktag.c b/builtin/mktag.c index 6fb7dc8578..be4366b03f 100644 --- a/builtin/mktag.c +++ b/builtin/mktag.c @@ -25,7 +25,8 @@ static int verify_object(const struct object_id *oid, const char *expected_type) int ret = -1; enum object_type type; unsigned long size; - void *buffer = read_object_file(oid, &type, &size); + void *buffer = repo_read_object_file(the_repository, oid, &type, + &size); const struct object_id *repl = lookup_replace_object(the_repository, oid); if (buffer) { diff --git a/builtin/name-rev.c b/builtin/name-rev.c index f1cb45c227..41f2de37e4 100644 --- a/builtin/name-rev.c +++ b/builtin/name-rev.c @@ -87,7 +87,7 @@ static void name_rev(struct commit *commit, int parent_number = 1; char *to_free = NULL; - parse_commit(commit); + repo_parse_commit(the_repository, commit); if (commit->date < cutoff) return; diff --git a/builtin/notes.c b/builtin/notes.c index c05cd004ab..7ce3e50b45 100644 --- a/builtin/notes.c +++ b/builtin/notes.c @@ -124,7 +124,7 @@ static void copy_obj_to_fd(int fd, const struct object_id *oid) { unsigned long size; enum object_type type; - char *buf = read_object_file(oid, &type, &size); + char *buf = repo_read_object_file(the_repository, oid, &type, &size); if (buf) { if (size) write_or_die(fd, buf, size); @@ -255,7 +255,7 @@ static int parse_reuse_arg(const struct option *opt, const char *arg, int unset) if (get_oid(arg, &object)) die(_("failed to resolve '%s' as a valid ref."), arg); - if (!(buf = read_object_file(&object, &type, &len))) { + if (!(buf = repo_read_object_file(the_repository, &object, &type, &len))) { free(buf); die(_("failed to read object '%s'."), arg); } @@ -610,7 +610,8 @@ static int append_edit(int argc, const char **argv, const char *prefix) /* Append buf to previous note contents */ unsigned long size; enum object_type type; - char *prev_buf = read_object_file(note, &type, &size); + char *prev_buf = repo_read_object_file(the_repository, note, + &type, &size); strbuf_grow(&d.buf, size + 1); if (d.buf.len && prev_buf && size) @@ -714,7 +715,7 @@ static int merge_commit(struct notes_merge_options *o) die(_("failed to read ref NOTES_MERGE_PARTIAL")); else if (!(partial = lookup_commit_reference(the_repository, &oid))) die(_("could not find commit from NOTES_MERGE_PARTIAL.")); - else if (parse_commit(partial)) + else if (repo_parse_commit(the_repository, partial)) die(_("could not parse commit from NOTES_MERGE_PARTIAL.")); if (partial->parents) @@ -735,7 +736,8 @@ static int merge_commit(struct notes_merge_options *o) /* Reuse existing commit message in reflog message */ memset(&pretty_ctx, 0, sizeof(pretty_ctx)); - format_commit_message(partial, "%s", &msg, &pretty_ctx); + repo_format_commit_message(the_repository, partial, "%s", &msg, + &pretty_ctx); strbuf_trim(&msg); strbuf_insert(&msg, 0, "notes: ", 7); update_ref(msg.buf, o->local_ref, &oid, diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c index 3383ba43d0..2d55b64433 100644 --- a/builtin/pack-objects.c +++ b/builtin/pack-objects.c @@ -138,11 +138,13 @@ static void *get_delta(struct object_entry *entry) void *buf, *base_buf, *delta_buf; enum object_type type; - buf = read_object_file(&entry->idx.oid, &type, &size); + buf = repo_read_object_file(the_repository, &entry->idx.oid, &type, + &size); if (!buf) die(_("unable to read %s"), oid_to_hex(&entry->idx.oid)); - base_buf = read_object_file(&DELTA(entry)->idx.oid, &type, - &base_size); + base_buf = repo_read_object_file(the_repository, + &DELTA(entry)->idx.oid, &type, + &base_size); if (!base_buf) die("unable to read %s", oid_to_hex(&DELTA(entry)->idx.oid)); @@ -292,7 +294,9 @@ static unsigned long write_no_reuse_object(struct hashfile *f, struct object_ent (st = open_istream(&entry->idx.oid, &type, &size, NULL)) != NULL) buf = NULL; else { - buf = read_object_file(&entry->idx.oid, &type, &size); + buf = repo_read_object_file(the_repository, + &entry->idx.oid, &type, + &size); if (!buf) die(_("unable to read %s"), oid_to_hex(&entry->idx.oid)); @@ -1218,7 +1222,7 @@ static struct pbase_tree_cache *pbase_tree_get(const struct object_id *oid) /* Did not find one. Either we got a bogus request or * we need to read and perhaps cache. */ - data = read_object_file(oid, &type, &size); + data = repo_read_object_file(the_repository, oid, &type, &size); if (!data) return NULL; if (type != OBJ_TREE) { @@ -1989,7 +1993,9 @@ static int try_delta(struct unpacked *trg, struct unpacked *src, /* Load data if not already done */ if (!trg->data) { read_lock(); - trg->data = read_object_file(&trg_entry->idx.oid, &type, &sz); + trg->data = repo_read_object_file(the_repository, + &trg_entry->idx.oid, &type, + &sz); read_unlock(); if (!trg->data) die(_("object %s cannot be read"), @@ -2002,7 +2008,9 @@ static int try_delta(struct unpacked *trg, struct unpacked *src, } if (!src->data) { read_lock(); - src->data = read_object_file(&src_entry->idx.oid, &type, &sz); + src->data = repo_read_object_file(the_repository, + &src_entry->idx.oid, &type, + &sz); read_unlock(); if (!src->data) { if (src_entry->preferred_base) { diff --git a/builtin/reflog.c b/builtin/reflog.c index b5941c1ff3..53a7f0c8e5 100644 --- a/builtin/reflog.c +++ b/builtin/reflog.c @@ -77,7 +77,8 @@ static int tree_is_complete(const struct object_id *oid) if (!tree->buffer) { enum object_type type; unsigned long size; - void *data = read_object_file(oid, &type, &size); + void *data = repo_read_object_file(the_repository, oid, &type, + &size); if (!data) { tree->object.flags |= INCOMPLETE; return 0; @@ -235,7 +236,7 @@ static void mark_reachable(struct expire_reflog_policy_cb *cb) struct commit *commit = pop_commit(&pending); if (commit->object.flags & REACHABLE) continue; - if (parse_commit(commit)) + if (repo_parse_commit(the_repository, commit)) continue; commit->object.flags |= REACHABLE; if (commit->date < expire_limit) { diff --git a/builtin/replace.c b/builtin/replace.c index e0b16ad44b..48b44dba3e 100644 --- a/builtin/replace.c +++ b/builtin/replace.c @@ -449,7 +449,7 @@ static int create_graft(int argc, const char **argv, int force, int gentle) buffer = get_commit_buffer(commit, &size); strbuf_add(&buf, buffer, size); - unuse_commit_buffer(commit, buffer); + repo_unuse_commit_buffer(the_repository, commit, buffer); if (replace_parents(&buf, argc - 1, &argv[1]) < 0) { strbuf_release(&buf); diff --git a/builtin/shortlog.c b/builtin/shortlog.c index 88f88e97b2..d46df5af34 100644 --- a/builtin/shortlog.c +++ b/builtin/shortlog.c @@ -170,12 +170,13 @@ void shortlog_add_commit(struct shortlog *log, struct commit *commit) (log->email ? "%cN <%cE>" : "%cN") : (log->email ? "%aN <%aE>" : "%aN"); - format_commit_message(commit, fmt, &author, &ctx); + repo_format_commit_message(the_repository, commit, fmt, &author, &ctx); if (!log->summary) { if (log->user_format) pretty_print_commit(&ctx, commit, &oneline); else - format_commit_message(commit, "%s", &oneline, &ctx); + repo_format_commit_message(the_repository, commit, + "%s", &oneline, &ctx); } insert_one_record(log, author.buf, oneline.len ? oneline.buf : ""); diff --git a/builtin/show-branch.c b/builtin/show-branch.c index 363cf8509a..d7e8d6f15c 100644 --- a/builtin/show-branch.c +++ b/builtin/show-branch.c @@ -238,7 +238,7 @@ static void join_revs(struct commit_list **list_p, parents = parents->next; if ((this_flag & flags) == flags) continue; - parse_commit(p); + repo_parse_commit(the_repository, p); if (mark_seen(p, seen_p) && !still_interesting) extra--; p->object.flags |= flags; @@ -835,7 +835,7 @@ int cmd_show_branch(int ac, const char **av, const char *prefix) if (!commit) die(_("cannot find commit %s (%s)"), ref_name[num_rev], oid_to_hex(&revkey)); - parse_commit(commit); + repo_parse_commit(the_repository, commit); mark_seen(commit, &seen); /* rev#0 uses bit REV_SHIFT, rev#1 uses bit REV_SHIFT+1, diff --git a/builtin/tag.c b/builtin/tag.c index 9a19ffb49f..3aa1ea7f15 100644 --- a/builtin/tag.c +++ b/builtin/tag.c @@ -169,7 +169,7 @@ static void write_tag_body(int fd, const struct object_id *oid) enum object_type type; char *buf, *sp; - buf = read_object_file(oid, &type, &size); + buf = repo_read_object_file(the_repository, oid, &type, &size); if (!buf) return; /* skip header */ @@ -305,7 +305,7 @@ static void create_reflog_msg(const struct object_id *oid, struct strbuf *sb) strbuf_addstr(sb, "object of unknown type"); break; case OBJ_COMMIT: - if ((buf = read_object_file(oid, &type, &size)) != NULL) { + if ((buf = repo_read_object_file(the_repository, oid, &type, &size)) != NULL) { subject_len = find_commit_subject(buf, &subject_start); strbuf_insert(sb, sb->len, subject_start, subject_len); } else { diff --git a/builtin/unpack-file.c b/builtin/unpack-file.c index 58652229f2..df4a47bae7 100644 --- a/builtin/unpack-file.c +++ b/builtin/unpack-file.c @@ -10,7 +10,7 @@ static char *create_temp_file(struct object_id *oid) unsigned long size; int fd; - buf = read_object_file(oid, &type, &size); + buf = repo_read_object_file(the_repository, oid, &type, &size); if (!buf || type != OBJ_BLOB) die("unable to read blob object %s", oid_to_hex(oid)); diff --git a/builtin/unpack-objects.c b/builtin/unpack-objects.c index 30d9413b4b..1e2bc1be3a 100644 --- a/builtin/unpack-objects.c +++ b/builtin/unpack-objects.c @@ -425,7 +425,8 @@ static void unpack_delta_entry(enum object_type type, unsigned long delta_size, if (resolve_against_held(nr, &base_oid, delta_data, delta_size)) return; - base = read_object_file(&base_oid, &type, &base_size); + base = repo_read_object_file(the_repository, &base_oid, &type, + &base_size); if (!base) { error("failed to read delta-pack base object %s", oid_to_hex(&base_oid)); diff --git a/builtin/verify-commit.c b/builtin/verify-commit.c index 7772c07ed7..3caa6cf8e9 100644 --- a/builtin/verify-commit.c +++ b/builtin/verify-commit.c @@ -47,7 +47,7 @@ static int verify_commit(const char *name, unsigned flags) if (get_oid(name, &oid)) return error("commit '%s' not found.", name); - buf = read_object_file(&oid, &type, &size); + buf = repo_read_object_file(the_repository, &oid, &type, &size); if (!buf) return error("%s: unable to read file.", name); if (type != OBJ_COMMIT) diff --git a/bundle.c b/bundle.c index a5a71d059e..8080cf1ed1 100644 --- a/bundle.c +++ b/bundle.c @@ -224,7 +224,7 @@ static int is_tag_in_date_range(struct object *tag, struct rev_info *revs) if (revs->max_age == -1 && revs->min_age == -1) goto out; - buf = read_object_file(&tag->oid, &type, &size); + buf = repo_read_object_file(the_repository, &tag->oid, &type, &size); if (!buf) goto out; line = memmem(buf, size, "\ntagger ", 8); diff --git a/combine-diff.c b/combine-diff.c index 41ab5b01de..5593052ae9 100644 --- a/combine-diff.c +++ b/combine-diff.c @@ -308,7 +308,7 @@ static char *grab_blob(struct repository *r, *size = fill_textconv(r, textconv, df, &blob); free_filespec(df); } else { - blob = read_object_file(oid, &type, size); + blob = repo_read_object_file(the_repository, oid, &type, size); if (type != OBJ_BLOB) die("object '%s' is not a blob!", oid_to_hex(oid)); } diff --git a/commit-graph.c b/commit-graph.c index 8a1bec7b8a..fd2f5380e1 100644 --- a/commit-graph.c +++ b/commit-graph.c @@ -435,7 +435,7 @@ static void write_graph_chunk_data(struct hashfile *f, int hash_len, int edge_value; uint32_t packedDate[2]; - parse_commit(*list); + repo_parse_commit(the_repository, *list); hashwrite(f, get_commit_tree_oid(*list)->hash, hash_len); parent = (*list)->parents; @@ -606,7 +606,7 @@ static void close_reachable(struct packed_oid_list *oids) for (i = 0; i < oids->nr; i++) { commit = lookup_commit(the_repository, &oids->list[i]); - if (commit && !parse_commit(commit)) + if (commit && !repo_parse_commit(the_repository, commit)) add_missing_parents(oids, commit); } @@ -783,7 +783,7 @@ void write_commit_graph(const char *obj_dir, continue; commits.list[commits.nr] = lookup_commit(the_repository, &oids.list[i]); - parse_commit(commits.list[commits.nr]); + repo_parse_commit(the_repository, commits.list[commits.nr]); for (parent = commits.list[commits.nr]->parents; parent; parent = parent->next) @@ -954,7 +954,7 @@ int verify_commit_graph(struct repository *r, struct commit_graph *g) graph_commit = lookup_commit(r, &cur_oid); odb_commit = (struct commit *)create_object(r, cur_oid.hash, alloc_commit_node(r)); - if (parse_commit_internal(odb_commit, 0, 0)) { + if (repo_parse_commit_internal(the_repository, odb_commit, 0, 0)) { graph_report("failed to parse %s from object database", oid_to_hex(&cur_oid)); continue; diff --git a/commit.c b/commit.c index 526b33758d..e86241b802 100644 --- a/commit.c +++ b/commit.c @@ -70,7 +70,7 @@ struct commit *lookup_commit_reference_by_name(const char *name) if (get_oid_committish(name, &oid)) return NULL; commit = lookup_commit_reference(the_repository, &oid); - if (parse_commit(commit)) + if (repo_parse_commit(the_repository, commit)) return NULL; return commit; } @@ -491,7 +491,7 @@ int repo_parse_commit_gently(struct repository *r, void parse_commit_or_die(struct commit *item) { - if (parse_commit(item)) + if (repo_parse_commit(the_repository, item)) die("unable to parse commit %s", item ? oid_to_hex(&item->object.oid) : "(null)"); } @@ -596,7 +596,7 @@ struct commit *pop_most_recent_commit(struct commit_list **list, while (parents) { struct commit *commit = parents->item; - if (!parse_commit(commit) && !(commit->object.flags & mark)) { + if (!repo_parse_commit(the_repository, commit) && !(commit->object.flags & mark)) { commit->object.flags |= mark; commit_list_insert_by_date(commit, list); } @@ -689,7 +689,7 @@ static void record_author_date(struct author_date_slab *author_date, *(author_date_slab_at(author_date, commit)) = date; fail_exit: - unuse_commit_buffer(commit, buffer); + repo_unuse_commit_buffer(the_repository, commit, buffer); } static int compare_commits_by_author_date(const void *a_, const void *b_, @@ -1302,7 +1302,7 @@ int parse_signed_commit(const struct commit *commit, } line = next; } - unuse_commit_buffer(commit, buffer); + repo_unuse_commit_buffer(the_repository, commit, buffer); return saw_signature; } @@ -1351,7 +1351,8 @@ static void handle_signed_tag(struct commit *parent, struct commit_extra_header desc = merge_remote_util(parent); if (!desc || !desc->obj) return; - buf = read_object_file(&desc->obj->oid, &type, &size); + buf = repo_read_object_file(the_repository, &desc->obj->oid, &type, + &size); if (!buf || type != OBJ_TAG) goto free_return; len = parse_signature(buf, size); @@ -1429,7 +1430,7 @@ struct commit_extra_header *read_commit_extra_headers(struct commit *commit, unsigned long size; const char *buffer = get_commit_buffer(commit, &size); extra = read_commit_extra_header_lines(buffer, size, exclude); - unuse_commit_buffer(commit, buffer); + repo_unuse_commit_buffer(the_repository, commit, buffer); return extra; } diff --git a/config.c b/config.c index 3461993f0a..e2b72403a6 100644 --- a/config.c +++ b/config.c @@ -1605,7 +1605,7 @@ int git_config_from_blob_oid(config_fn_t fn, unsigned long size; int ret; - buf = read_object_file(oid, &type, &size); + buf = repo_read_object_file(the_repository, oid, &type, &size); if (!buf) return error(_("unable to load config blob object '%s'"), name); if (type != OBJ_BLOB) { diff --git a/diff.c b/diff.c index c5b5e7ac41..ab16d6dcad 100644 --- a/diff.c +++ b/diff.c @@ -3939,7 +3939,8 @@ int diff_populate_filespec(struct repository *r, return 0; } } - s->data = read_object_file(&s->oid, &type, &s->size); + s->data = repo_read_object_file(the_repository, &s->oid, + &type, &s->size); if (!s->data) die("unable to read %s", oid_to_hex(&s->oid)); s->should_free = 1; diff --git a/dir.c b/dir.c index aceb0d4869..8722b1e5d5 100644 --- a/dir.c +++ b/dir.c @@ -245,7 +245,7 @@ static int do_read_blob(const struct object_id *oid, struct oid_stat *oid_stat, *size_out = 0; *data_out = NULL; - data = read_object_file(oid, &type, &sz); + data = repo_read_object_file(the_repository, oid, &type, &sz); if (!data || type != OBJ_BLOB) { free(data); return -1; diff --git a/entry.c b/entry.c index 2a2ab6c839..45723fc958 100644 --- a/entry.c +++ b/entry.c @@ -86,7 +86,8 @@ static int create_file(const char *path, unsigned int mode) static void *read_blob_entry(const struct cache_entry *ce, unsigned long *size) { enum object_type type; - void *blob_data = read_object_file(&ce->oid, &type, size); + void *blob_data = repo_read_object_file(the_repository, &ce->oid, + &type, size); if (blob_data) { if (type == OBJ_BLOB) diff --git a/fast-import.c b/fast-import.c index 89bb0c9db3..879b1fbf56 100644 --- a/fast-import.c +++ b/fast-import.c @@ -1371,7 +1371,7 @@ static void load_tree(struct tree_entry *root) die("Can't load tree %s", oid_to_hex(oid)); } else { enum object_type type; - buf = read_object_file(oid, &type, &size); + buf = repo_read_object_file(the_repository, oid, &type, &size); if (!buf || type != OBJ_TREE) die("Can't load tree %s", oid_to_hex(oid)); } @@ -2931,7 +2931,7 @@ static void cat_blob(struct object_entry *oe, struct object_id *oid) char *buf; if (!oe || oe->pack_id == MAX_PACK_ID) { - buf = read_object_file(oid, &type, &size); + buf = repo_read_object_file(the_repository, oid, &type, &size); } else { type = oe->type; buf = gfi_unpack_entry(oe, &size); @@ -3037,7 +3037,8 @@ static struct object_entry *dereference(struct object_entry *oe, buf = gfi_unpack_entry(oe, &size); } else { enum object_type unused; - buf = read_object_file(oid, &unused, &size); + buf = repo_read_object_file(the_repository, oid, &unused, + &size); } if (!buf) die("Can't load object %s", oid_to_hex(oid)); diff --git a/fsck.c b/fsck.c index a0cee0be59..0d3e8886e2 100644 --- a/fsck.c +++ b/fsck.c @@ -447,7 +447,7 @@ static int fsck_walk_commit(struct commit *commit, void *data, struct fsck_optio int result; const char *name; - if (parse_commit(commit)) + if (repo_parse_commit(the_repository, commit)) return -1; name = get_object_name(options, &commit->object); @@ -859,7 +859,7 @@ static int fsck_commit(struct commit *commit, const char *data, const char *buffer = data ? data : get_commit_buffer(commit, &size); int ret = fsck_commit_buffer(commit, buffer, size, options); if (!data) - unuse_commit_buffer(commit, buffer); + repo_unuse_commit_buffer(the_repository, commit, buffer); return ret; } @@ -879,7 +879,8 @@ static int fsck_tag_buffer(struct tag *tag, const char *data, enum object_type type; buffer = to_free = - read_object_file(&tag->object.oid, &type, &size); + repo_read_object_file(the_repository, + &tag->object.oid, &type, &size); if (!buffer) return report(options, &tag->object, FSCK_MSG_MISSING_TAG_OBJECT, @@ -1091,7 +1092,7 @@ int fsck_finish(struct fsck_options *options) continue; } - buf = read_object_file(oid, &type, &size); + buf = repo_read_object_file(the_repository, oid, &type, &size); if (!buf) { if (is_promisor_object(&blob->object.oid)) continue; diff --git a/grep.c b/grep.c index f6bd89e40b..216c38a0d5 100644 --- a/grep.c +++ b/grep.c @@ -2112,7 +2112,8 @@ static int grep_source_load_oid(struct grep_source *gs) enum object_type type; grep_read_lock(); - gs->buf = read_object_file(gs->identifier, &type, &gs->size); + gs->buf = repo_read_object_file(the_repository, gs->identifier, &type, + &gs->size); grep_read_unlock(); if (!gs->buf) diff --git a/http-push.c b/http-push.c index df504ab6a3..c6206838ed 100644 --- a/http-push.c +++ b/http-push.c @@ -364,7 +364,8 @@ static void start_put(struct transfer_request *request) ssize_t size; git_zstream stream; - unpacked = read_object_file(&request->obj->oid, &type, &len); + unpacked = repo_read_object_file(the_repository, &request->obj->oid, + &type, &len); hdrlen = xsnprintf(hdr, sizeof(hdr), "%s %lu", type_name(type), len) + 1; /* Set it up */ diff --git a/log-tree.c b/log-tree.c index 7443e5fcc7..360dd0b4e6 100644 --- a/log-tree.c +++ b/log-tree.c @@ -332,7 +332,8 @@ void fmt_output_commit(struct strbuf *filename, struct pretty_print_context ctx = {0}; struct strbuf subject = STRBUF_INIT; - format_commit_message(commit, "%f", &subject, &ctx); + repo_format_commit_message(the_repository, commit, "%f", &subject, + &ctx); fmt_output_subject(filename, subject.buf, info); strbuf_release(&subject); } diff --git a/mailmap.c b/mailmap.c index 962fd86d6d..f3ffea0e17 100644 --- a/mailmap.c +++ b/mailmap.c @@ -225,7 +225,7 @@ static int read_mailmap_blob(struct string_list *map, if (get_oid(name, &oid) < 0) return 0; - buf = read_object_file(&oid, &type, &size); + buf = repo_read_object_file(the_repository, &oid, &type, &size); if (!buf) return error("unable to read mailmap object at %s", name); if (type != OBJ_BLOB) diff --git a/match-trees.c b/match-trees.c index 37653308d3..3fb649ad08 100644 --- a/match-trees.c +++ b/match-trees.c @@ -55,7 +55,7 @@ static void *fill_tree_desc_strict(struct tree_desc *desc, enum object_type type; unsigned long size; - buffer = read_object_file(hash, &type, &size); + buffer = repo_read_object_file(the_repository, hash, &type, &size); if (!buffer) die("unable to read tree (%s)", oid_to_hex(hash)); if (type != OBJ_TREE) @@ -190,7 +190,7 @@ static int splice_tree(const struct object_id *oid1, const char *prefix, if (*subpath) subpath++; - buf = read_object_file(oid1, &type, &sz); + buf = repo_read_object_file(the_repository, oid1, &type, &sz); if (!buf) die("cannot read tree %s", oid_to_hex(oid1)); init_tree_desc(&desc, buf, sz); diff --git a/merge-blobs.c b/merge-blobs.c index ee0a0e90c9..757e338715 100644 --- a/merge-blobs.c +++ b/merge-blobs.c @@ -12,7 +12,8 @@ static int fill_mmfile_blob(mmfile_t *f, struct blob *obj) unsigned long size; enum object_type type; - buf = read_object_file(&obj->object.oid, &type, &size); + buf = repo_read_object_file(the_repository, &obj->object.oid, &type, + &size); if (!buf) return -1; if (type != OBJ_BLOB) { @@ -75,7 +76,8 @@ void *merge_blobs(struct index_state *istate, const char *path, return NULL; if (!our) our = their; - return read_object_file(&our->object.oid, &type, size); + return repo_read_object_file(the_repository, &our->object.oid, + &type, size); } if (fill_mmfile_blob(&f1, our) < 0) diff --git a/merge-recursive.c b/merge-recursive.c index 82e9f1d24a..646e265625 100644 --- a/merge-recursive.c +++ b/merge-recursive.c @@ -299,7 +299,7 @@ static void output_commit_title(struct merge_options *o, struct commit *commit) strbuf_add_unique_abbrev(&o->obuf, &commit->object.oid, DEFAULT_ABBREV); strbuf_addch(&o->obuf, ' '); - if (parse_commit(commit) != 0) + if (repo_parse_commit(the_repository, commit) != 0) strbuf_addstr(&o->obuf, _("(bad commit)\n")); else { const char *title; @@ -307,7 +307,7 @@ static void output_commit_title(struct merge_options *o, struct commit *commit) int len = find_commit_subject(msg, &title); if (len) strbuf_addf(&o->obuf, "%.*s\n", len, title); - unuse_commit_buffer(commit, msg); + repo_unuse_commit_buffer(the_repository, commit, msg); } } flush_output(o); @@ -957,7 +957,7 @@ static int update_file_flags(struct merge_options *o, goto update_index; } - buf = read_object_file(oid, &type, &size); + buf = repo_read_object_file(the_repository, oid, &type, &size); if (!buf) return err(o, _("cannot read object %s '%s'"), oid_to_hex(oid), path); if (type != OBJ_BLOB) { @@ -1160,7 +1160,8 @@ static void print_commit(struct commit *commit) struct strbuf sb = STRBUF_INIT; struct pretty_print_context ctx = {0}; ctx.date_mode.type = DATE_NORMAL; - format_commit_message(commit, " %h: %m %s", &sb, &ctx); + repo_format_commit_message(the_repository, commit, " %h: %m %s", &sb, + &ctx); fprintf(stderr, "%s\n", sb.buf); strbuf_release(&sb); } @@ -2944,7 +2945,7 @@ static int read_oid_strbuf(struct merge_options *o, void *buf; enum object_type type; unsigned long size; - buf = read_object_file(oid, &type, &size); + buf = repo_read_object_file(the_repository, oid, &type, &size); if (!buf) return err(o, _("cannot read object %s"), oid_to_hex(oid)); if (type != OBJ_BLOB) { @@ -3522,7 +3523,7 @@ static struct commit *get_ref(const struct object_id *oid, const char *name) return make_virtual_commit((struct tree*)object, name); if (object->type != OBJ_COMMIT) return NULL; - if (parse_commit((struct commit *)object)) + if (repo_parse_commit(the_repository, (struct commit *)object)) return NULL; return (struct commit *)object; } diff --git a/negotiator/default.c b/negotiator/default.c index 4b78f6bf36..19071a97df 100644 --- a/negotiator/default.c +++ b/negotiator/default.c @@ -25,7 +25,7 @@ static void rev_list_push(struct negotiation_state *ns, if (!(commit->object.flags & mark)) { commit->object.flags |= mark; - if (parse_commit(commit)) + if (repo_parse_commit(the_repository, commit)) return; prio_queue_put(&ns->rev_list, commit); @@ -68,7 +68,7 @@ static void mark_common(struct negotiation_state *ns, struct commit *commit, if (!ancestors_only && !(o->flags & POPPED)) ns->non_common_revs--; if (!o->parsed && !dont_parse) - if (parse_commit(commit)) + if (repo_parse_commit(the_repository, commit)) return; for (parents = commit->parents; @@ -95,7 +95,7 @@ static const struct object_id *get_rev(struct negotiation_state *ns) return NULL; commit = prio_queue_get(&ns->rev_list); - parse_commit(commit); + repo_parse_commit(the_repository, commit); parents = commit->parents; commit->object.flags |= POPPED; diff --git a/negotiator/skipping.c b/negotiator/skipping.c index dffbc76c49..9b76f95654 100644 --- a/negotiator/skipping.c +++ b/negotiator/skipping.c @@ -177,7 +177,7 @@ static const struct object_id *get_rev(struct data *data) if (!(commit->object.flags & COMMON) && !entry->ttl) to_send = commit; - parse_commit(commit); + repo_parse_commit(the_repository, commit); for (p = commit->parents; p; p = p->next) parent_pushed |= push_parent(data, entry, p->item); diff --git a/notes-cache.c b/notes-cache.c index d87e7ca91c..94196ef0f6 100644 --- a/notes-cache.c +++ b/notes-cache.c @@ -21,7 +21,8 @@ static int notes_cache_match_validity(const char *ref, const char *validity) return 0; memset(&pretty_ctx, 0, sizeof(pretty_ctx)); - format_commit_message(commit, "%s", &msg, &pretty_ctx); + repo_format_commit_message(the_repository, commit, "%s", &msg, + &pretty_ctx); strbuf_trim(&msg); ret = !strcmp(msg.buf, validity); @@ -79,7 +80,7 @@ char *notes_cache_get(struct notes_cache *c, struct object_id *key_oid, value_oid = get_note(&c->tree, key_oid); if (!value_oid) return NULL; - value = read_object_file(value_oid, &type, &size); + value = repo_read_object_file(the_repository, value_oid, &type, &size); *outsize = size; return value; diff --git a/notes-merge.c b/notes-merge.c index 13dd9ba158..af1f5306dd 100644 --- a/notes-merge.c +++ b/notes-merge.c @@ -324,7 +324,7 @@ static void write_note_to_worktree(const struct object_id *obj, { enum object_type type; unsigned long size; - void *buf = read_object_file(note, &type, &size); + void *buf = repo_read_object_file(the_repository, note, &type, &size); if (!buf) die("cannot read note %s for object %s", @@ -723,7 +723,7 @@ int notes_merge_commit(struct notes_merge_options *o, create_notes_commit(partial_tree, partial_commit->parents, msg, strlen(msg), result_oid); - unuse_commit_buffer(partial_commit, buffer); + repo_unuse_commit_buffer(the_repository, partial_commit, buffer); if (o->verbosity >= 4) printf("Finalized notes merge commit: %s\n", oid_to_hex(result_oid)); diff --git a/notes-utils.c b/notes-utils.c index 14ea03178e..f25ef54a77 100644 --- a/notes-utils.c +++ b/notes-utils.c @@ -22,7 +22,7 @@ void create_notes_commit(struct notes_tree *t, struct commit_list *parents, if (!read_ref(t->ref, &parent_oid)) { struct commit *parent = lookup_commit(the_repository, &parent_oid); - if (parse_commit(parent)) + if (repo_parse_commit(the_repository, parent)) die("Failed to find/parse commit %s", t->ref); commit_list_insert(parent, &parents); } diff --git a/notes.c b/notes.c index 32d3dbcc1e..766d540dd1 100644 --- a/notes.c +++ b/notes.c @@ -797,13 +797,15 @@ int combine_notes_concatenate(struct object_id *cur_oid, /* read in both note blob objects */ if (!is_null_oid(new_oid)) - new_msg = read_object_file(new_oid, &new_type, &new_len); + new_msg = repo_read_object_file(the_repository, new_oid, + &new_type, &new_len); if (!new_msg || !new_len || new_type != OBJ_BLOB) { free(new_msg); return 0; } if (!is_null_oid(cur_oid)) - cur_msg = read_object_file(cur_oid, &cur_type, &cur_len); + cur_msg = repo_read_object_file(the_repository, cur_oid, + &cur_type, &cur_len); if (!cur_msg || !cur_len || cur_type != OBJ_BLOB) { free(cur_msg); free(new_msg); @@ -859,7 +861,7 @@ static int string_list_add_note_lines(struct string_list *list, return 0; /* read_sha1_file NUL-terminates */ - data = read_object_file(oid, &t, &len); + data = repo_read_object_file(the_repository, oid, &t, &len); if (t != OBJ_BLOB || !data || !len) { free(data); return t != OBJ_BLOB || !data; @@ -1218,7 +1220,7 @@ static void format_note(struct notes_tree *t, const struct object_id *object_oid if (!oid) return; - if (!(msg = read_object_file(oid, &type, &msglen)) || type != OBJ_BLOB) { + if (!(msg = repo_read_object_file(the_repository, oid, &type, &msglen)) || type != OBJ_BLOB) { free(msg); return; } diff --git a/pretty.c b/pretty.c index 948f5346cf..4ab5b44da0 100644 --- a/pretty.c +++ b/pretty.c @@ -1799,7 +1799,8 @@ void pretty_print_commit(struct pretty_print_context *pp, int need_8bit_cte = pp->need_8bit_cte; if (pp->fmt == CMIT_FMT_USERFORMAT) { - format_commit_message(commit, user_format, sb, pp); + repo_format_commit_message(the_repository, commit, + user_format, sb, pp); return; } @@ -1861,7 +1862,7 @@ void pretty_print_commit(struct pretty_print_context *pp, if (cmit_fmt_is_mail(pp->fmt) && sb->len <= beginning_of_body) strbuf_addch(sb, '\n'); - unuse_commit_buffer(commit, reencoded); + repo_unuse_commit_buffer(the_repository, commit, reencoded); } void pp_commit_easy(enum cmit_fmt fmt, const struct commit *commit, diff --git a/read-cache.c b/read-cache.c index b707edd044..e0669b174e 100644 --- a/read-cache.c +++ b/read-cache.c @@ -232,7 +232,7 @@ static int ce_compare_link(const struct cache_entry *ce, size_t expected_size) if (strbuf_readlink(&sb, ce->name, expected_size)) return -1; - buffer = read_object_file(&ce->oid, &type, &size); + buffer = repo_read_object_file(the_repository, &ce->oid, &type, &size); if (buffer) { if (size == sb.len) match = memcmp(buffer, sb.buf, size); @@ -2901,7 +2901,8 @@ void *read_blob_data_from_index(const struct index_state *istate, } if (pos < 0) return NULL; - data = read_object_file(&istate->cache[pos]->oid, &type, &sz); + data = repo_read_object_file(the_repository, &istate->cache[pos]->oid, + &type, &sz); if (!data || type != OBJ_BLOB) { free(data); return NULL; diff --git a/remote-testsvn.c b/remote-testsvn.c index 3af708c5b6..c846c9ee3b 100644 --- a/remote-testsvn.c +++ b/remote-testsvn.c @@ -62,7 +62,7 @@ static char *read_ref_note(const struct object_id *oid) init_notes(NULL, notes_ref, NULL, 0); if (!(note_oid = get_note(NULL, oid))) return NULL; /* note tree not found */ - if (!(msg = read_object_file(note_oid, &type, &msglen))) + if (!(msg = repo_read_object_file(the_repository, note_oid, &type, &msglen))) error("Empty notes tree. %s", notes_ref); else if (!msglen || type != OBJ_BLOB) { error("Note contains unusable content. " @@ -109,7 +109,7 @@ static int note2mark_cb(const struct object_id *object_oid, enum object_type type; struct rev_note note; - if (!(msg = read_object_file(note_oid, &type, &msglen)) || + if (!(msg = repo_read_object_file(the_repository, note_oid, &type, &msglen)) || !msglen || type != OBJ_BLOB) { free(msg); return 1; diff --git a/remote.c b/remote.c index 348417f0a7..e16e8e002f 100644 --- a/remote.c +++ b/remote.c @@ -1822,7 +1822,7 @@ int ref_newer(const struct object_id *new_oid, const struct object_id *old_oid) return 0; new_commit = (struct commit *) o; - if (parse_commit(new_commit) < 0) + if (repo_parse_commit(the_repository, new_commit) < 0) return 0; used = list = NULL; diff --git a/rerere.c b/rerere.c index 8d4ac8426b..084bedfe55 100644 --- a/rerere.c +++ b/rerere.c @@ -988,8 +988,9 @@ static int handle_cache(struct index_state *istate, const char *path, break; i = ce_stage(ce) - 1; if (!mmfile[i].ptr) { - mmfile[i].ptr = read_object_file(&ce->oid, &type, - &size); + mmfile[i].ptr = repo_read_object_file(the_repository, + &ce->oid, &type, + &size); mmfile[i].size = size; } } diff --git a/revision.c b/revision.c index 28366eaccf..01c11107b8 100644 --- a/revision.c +++ b/revision.c @@ -274,7 +274,7 @@ static struct commit *handle_commit(struct rev_info *revs, if (object->type == OBJ_COMMIT) { struct commit *commit = (struct commit *)object; - if (parse_commit(commit) < 0) + if (repo_parse_commit(the_repository, commit) < 0) die("unable to parse commit %s", name); if (flags & UNINTERESTING) { mark_parents_uninteresting(commit); @@ -688,7 +688,7 @@ static void try_to_simplify_commit(struct rev_info *revs, struct commit *commit) ts->treesame[0] = 1; } } - if (parse_commit(p) < 0) + if (repo_parse_commit(the_repository, p) < 0) die("cannot simplify commit %s (because of %s)", oid_to_hex(&commit->object.oid), oid_to_hex(&p->object.oid)); @@ -721,7 +721,7 @@ static void try_to_simplify_commit(struct rev_info *revs, struct commit *commit) * IOW, we pretend this parent is a * "root" commit. */ - if (parse_commit(p) < 0) + if (repo_parse_commit(the_repository, p) < 0) die("cannot simplify commit %s (invalid %s)", oid_to_hex(&commit->object.oid), oid_to_hex(&p->object.oid)); @@ -800,7 +800,7 @@ static int add_parents_to_list(struct rev_info *revs, struct commit *commit, parent = parent->next; if (p) p->object.flags |= UNINTERESTING; - if (parse_commit_gently(p, 1) < 0) + if (repo_parse_commit_gently(the_repository, p, 1) < 0) continue; if (p->parents) mark_parents_uninteresting(p); @@ -828,7 +828,7 @@ static int add_parents_to_list(struct rev_info *revs, struct commit *commit, struct commit *p = parent->item; int gently = revs->ignore_missing_links || revs->exclude_promisor_objects; - if (parse_commit_gently(p, gently) < 0) { + if (repo_parse_commit_gently(the_repository, p, gently) < 0) { if (revs->exclude_promisor_objects && is_promisor_object(&p->object.oid)) { if (revs->first_parent_only) @@ -3095,7 +3095,7 @@ static int commit_match(struct commit *commit, struct rev_info *opt) retval = grep_buffer(&opt->grep_filter, (char *)message, strlen(message)); strbuf_release(&buf); - unuse_commit_buffer(commit, message); + repo_unuse_commit_buffer(the_repository, commit, message); return opt->invert_grep ? !retval : retval; } diff --git a/sequencer.c b/sequencer.c index da4e727cc3..5d612831e9 100644 --- a/sequencer.c +++ b/sequencer.c @@ -344,7 +344,7 @@ static void free_message(struct commit *commit, struct commit_message *msg) free(msg->parent_label); free(msg->label); free(msg->subject); - unuse_commit_buffer(commit, msg->message); + repo_unuse_commit_buffer(the_repository, commit, msg->message); } static void print_advice(int show_hint, struct replay_opts *opts) @@ -604,7 +604,7 @@ static int is_index_unchanged(void) * the commit is invalid, parse_commit() will complain. So * there is nothing for us to say here. Just return failure. */ - if (parse_commit(head_commit)) + if (repo_parse_commit(the_repository, head_commit)) return -1; if (!(cache_tree_oid = get_cache_tree_oid())) @@ -1142,13 +1142,15 @@ void print_commit_summary(const char *prefix, const struct object_id *oid, commit = lookup_commit(the_repository, oid); if (!commit) die(_("couldn't look up newly created commit")); - if (parse_commit(commit)) + if (repo_parse_commit(the_repository, commit)) die(_("could not parse newly created commit")); strbuf_addstr(&format, "format:%h] %s"); - format_commit_message(commit, "%an <%ae>", &author_ident, &pctx); - format_commit_message(commit, "%cn <%ce>", &committer_ident, &pctx); + repo_format_commit_message(the_repository, commit, "%an <%ae>", + &author_ident, &pctx); + repo_format_commit_message(the_repository, commit, "%cn <%ce>", + &committer_ident, &pctx); if (strbuf_cmp(&author_ident, &committer_ident)) { strbuf_addstr(&format, "\n Author: "); strbuf_addbuf_percentquote(&format, &author_ident); @@ -1156,7 +1158,8 @@ void print_commit_summary(const char *prefix, const struct object_id *oid, if (flags & SUMMARY_SHOW_AUTHOR_DATE) { struct strbuf date = STRBUF_INIT; - format_commit_message(commit, "%ad", &date, &pctx); + repo_format_commit_message(the_repository, commit, "%ad", + &date, &pctx); strbuf_addstr(&format, "\n Date: "); strbuf_addbuf_percentquote(&format, &date); strbuf_release(&date); @@ -1221,7 +1224,7 @@ static int parse_head(struct commit **head) warning(_("HEAD %s is not a commit!"), oid_to_hex(&oid)); } - if (parse_commit(current_head)) + if (repo_parse_commit(the_repository, current_head)) return error(_("could not parse HEAD commit")); } *head = current_head; @@ -1271,7 +1274,8 @@ static int try_to_commit(struct strbuf *msg, const char *author, hook_commit = "HEAD"; } author = amend_author = get_author(message); - unuse_commit_buffer(current_head, message); + repo_unuse_commit_buffer(the_repository, current_head, + message); if (!author) { res = error(_("unable to parse commit author")); goto out; @@ -1381,12 +1385,12 @@ static int is_original_commit_empty(struct commit *commit) { const struct object_id *ptree_oid; - if (parse_commit(commit)) + if (repo_parse_commit(the_repository, commit)) return error(_("could not parse commit %s"), oid_to_hex(&commit->object.oid)); if (commit->parents) { struct commit *parent = commit->parents->item; - if (parse_commit(parent)) + if (repo_parse_commit(the_repository, parent)) return error(_("could not parse parent commit %s"), oid_to_hex(&parent->object.oid)); ptree_oid = get_commit_tree_oid(parent); @@ -1557,7 +1561,8 @@ static int update_squash_messages(enum todo_command command, find_commit_subject(head_message, &body); if (write_message(body, strlen(body), rebase_path_fixup_msg(), 0)) { - unuse_commit_buffer(head_commit, head_message); + repo_unuse_commit_buffer(the_repository, head_commit, + head_message); return error(_("cannot write '%s'"), rebase_path_fixup_msg()); } @@ -1569,7 +1574,8 @@ static int update_squash_messages(enum todo_command command, strbuf_addstr(&buf, "\n\n"); strbuf_addstr(&buf, body); - unuse_commit_buffer(head_commit, head_message); + repo_unuse_commit_buffer(the_repository, head_commit, + head_message); } if (!(message = get_commit_buffer(commit, NULL))) @@ -1592,7 +1598,7 @@ static int update_squash_messages(enum todo_command command, strbuf_add_commented_lines(&buf, body, strlen(body)); } else return error(_("unknown command: %d"), command); - unuse_commit_buffer(commit, message); + repo_unuse_commit_buffer(the_repository, commit, message); res = write_message(buf.buf, buf.len, rebase_path_squash_msg(), 0); strbuf_release(&buf); @@ -1729,7 +1735,7 @@ static int do_pick_commit(enum todo_command command, struct commit *commit, msg_file = NULL; goto fast_forward_edit; } - if (parent && parse_commit(parent) < 0) + if (parent && repo_parse_commit(the_repository, parent) < 0) /* TRANSLATORS: The first %s will be a "todo" command like "revert" or "pick", the second %s a SHA1. */ return error(_("%s: cannot parse parent commit %s"), @@ -2357,7 +2363,8 @@ static int walk_revs_populate_todo(struct todo_list *todo_list, subject_len = find_commit_subject(commit_buffer, &subject); strbuf_addf(&todo_list->buf, "%s %s %.*s\n", command_string, short_commit_name(commit), subject_len, subject); - unuse_commit_buffer(commit, commit_buffer); + repo_unuse_commit_buffer(the_repository, commit, + commit_buffer); } if (!todo_list->nr) @@ -2616,7 +2623,8 @@ static int make_patch(struct commit *commit, struct replay_opts *opts) const char *commit_buffer = get_commit_buffer(commit, NULL); find_commit_subject(commit_buffer, &subject); res |= write_message(subject, strlen(subject), buf.buf, 1); - unuse_commit_buffer(commit, commit_buffer); + repo_unuse_commit_buffer(the_repository, commit, + commit_buffer); } strbuf_release(&buf); @@ -3013,7 +3021,7 @@ static int do_merge(struct commit *commit, const char *arg, int arg_len, find_commit_subject(message, &body); len = strlen(body); ret = write_message(body, len, git_path_merge_msg(the_repository), 0); - unuse_commit_buffer(commit, message); + repo_unuse_commit_buffer(the_repository, commit, message); if (ret) { error_errno(_("could not write '%s'"), git_path_merge_msg(the_repository)); @@ -3658,11 +3666,13 @@ static int commit_staged_changes(struct replay_opts *opts, if (parse_head(&commit) || !(p = get_commit_buffer(commit, NULL)) || write_message(p, strlen(p), path, 0)) { - unuse_commit_buffer(commit, p); + repo_unuse_commit_buffer(the_repository, + commit, p); return error(_("could not write file: " "'%s'"), path); } - unuse_commit_buffer(commit, p); + repo_unuse_commit_buffer(the_repository, + commit, p); } } @@ -4564,7 +4574,7 @@ int skip_unnecessary_picks(void) continue; if (item->command != TODO_PICK) break; - if (parse_commit(item->commit)) { + if (repo_parse_commit(the_repository, item->commit)) { todo_list_release(&todo_list); return error(_("could not parse commit '%s'"), oid_to_hex(&item->commit->object.oid)); @@ -4691,12 +4701,13 @@ int rearrange_squash(void) *commit_todo_item_at(&commit_todo, item->commit) = item; - parse_commit(item->commit); + repo_parse_commit(the_repository, item->commit); commit_buffer = get_commit_buffer(item->commit, NULL); find_commit_subject(commit_buffer, &subject); format_subject(&buf, subject, " "); subject = subjects[i] = strbuf_detach(&buf, &subject_len); - unuse_commit_buffer(item->commit, commit_buffer); + repo_unuse_commit_buffer(the_repository, item->commit, + commit_buffer); if ((skip_prefix(subject, "fixup! ", &p) || skip_prefix(subject, "squash! ", &p))) { struct commit *commit2; diff --git a/sha1-file.c b/sha1-file.c index ce47524679..4f86034d25 100644 --- a/sha1-file.c +++ b/sha1-file.c @@ -1456,7 +1456,8 @@ void *read_object_with_reference(const struct object_id *oid, int ref_length = -1; const char *ref_type = NULL; - buffer = read_object_file(&actual_oid, &type, &isize); + buffer = repo_read_object_file(the_repository, &actual_oid, + &type, &isize); if (!buffer) return NULL; if (type == required_type) { diff --git a/sha1-name.c b/sha1-name.c index c9cc1318b7..71e6bb7a9a 100644 --- a/sha1-name.c +++ b/sha1-name.c @@ -357,7 +357,8 @@ static int show_ambiguous_object(const struct object_id *oid, void *data) if (commit) { struct pretty_print_context pp = {0}; pp.date_mode.type = DATE_SHORT; - format_commit_message(commit, " %ad - %s", &desc, &pp); + repo_format_commit_message(the_repository, commit, + " %ad - %s", &desc, &pp); } } else if (type == OBJ_TAG) { struct tag *tag = lookup_tag(the_repository, oid); @@ -849,7 +850,7 @@ static int get_parent(const char *name, int len, if (ret) return ret; commit = lookup_commit_reference(the_repository, &oid); - if (parse_commit(commit)) + if (repo_parse_commit(the_repository, commit)) return -1; if (!idx) { oidcpy(result, &commit->object.oid); @@ -881,7 +882,7 @@ static int get_nth_ancestor(const char *name, int len, return -1; while (generation--) { - if (parse_commit(commit) || !commit->parents) + if (repo_parse_commit(the_repository, commit) || !commit->parents) return -1; commit = commit->parents->item; } @@ -1152,7 +1153,7 @@ static int get_oid_oneline(const char *prefix, struct object_id *oid, buf = get_commit_buffer(commit, NULL); p = strstr(buf, "\n\n"); matches = negative ^ (p && !regexec(®ex, p + 2, 0, NULL, 0)); - unuse_commit_buffer(commit, buf); + repo_unuse_commit_buffer(the_repository, commit, buf); if (matches) { oidcpy(oid, &commit->object.oid); diff --git a/shallow.c b/shallow.c index e656ce8b9c..124c03f003 100644 --- a/shallow.c +++ b/shallow.c @@ -210,7 +210,7 @@ struct commit_list *get_shallow_commits_by_rev_list(int ac, const char **av, struct commit *c = p->item; struct commit_list *parent; - if (parse_commit(c)) + if (repo_parse_commit(the_repository, c)) die("unable to parse commit %s", oid_to_hex(&c->object.oid)); @@ -533,7 +533,7 @@ static void paint_down(struct paint_info *info, const struct object_id *oid, if (c->object.flags & BOTTOM) continue; - if (parse_commit(c)) + if (repo_parse_commit(the_repository, c)) die("unable to parse commit %s", oid_to_hex(&c->object.oid)); diff --git a/submodule-config.c b/submodule-config.c index fc2c41b947..4b2104979b 100644 --- a/submodule-config.c +++ b/submodule-config.c @@ -552,7 +552,8 @@ static const struct submodule *config_from(struct submodule_cache *cache, if (submodule) goto out; - config = read_object_file(&oid, &type, &config_size); + config = repo_read_object_file(the_repository, &oid, &type, + &config_size); if (!config || type != OBJ_BLOB) goto out; diff --git a/t/helper/test-revision-walking.c b/t/helper/test-revision-walking.c index 625b2dbf82..a03cfcdae1 100644 --- a/t/helper/test-revision-walking.c +++ b/t/helper/test-revision-walking.c @@ -19,7 +19,8 @@ static void print_commit(struct commit *commit) struct strbuf sb = STRBUF_INIT; struct pretty_print_context ctx = {0}; ctx.date_mode.type = DATE_NORMAL; - format_commit_message(commit, " %m %s", &sb, &ctx); + repo_format_commit_message(the_repository, commit, " %m %s", &sb, + &ctx); printf("%s\n", sb.buf); strbuf_release(&sb); } diff --git a/tag.c b/tag.c index 1db663d716..b5a5a4c152 100644 --- a/tag.c +++ b/tag.c @@ -52,7 +52,7 @@ int gpg_verify_tag(const struct object_id *oid, const char *name_to_report, find_unique_abbrev(oid, DEFAULT_ABBREV), type_name(type)); - buf = read_object_file(oid, &type, &size); + buf = repo_read_object_file(the_repository, oid, &type, &size); if (!buf) return error("%s: unable to read file.", name_to_report ? @@ -200,7 +200,8 @@ int parse_tag(struct tag *item) if (item->object.parsed) return 0; - data = read_object_file(&item->object.oid, &type, &size); + data = repo_read_object_file(the_repository, &item->object.oid, &type, + &size); if (!data) return error("Could not read %s", oid_to_hex(&item->object.oid)); diff --git a/tree-walk.c b/tree-walk.c index 77b37f36fa..ec6045828b 100644 --- a/tree-walk.c +++ b/tree-walk.c @@ -715,8 +715,10 @@ enum follow_symlinks_result get_tree_entry_follow_symlinks(struct object_id *tre */ retval = DANGLING_SYMLINK; - contents = read_object_file(¤t_tree_oid, &type, - &link_len); + contents = repo_read_object_file(the_repository, + ¤t_tree_oid, + &type, + &link_len); if (!contents) goto done; diff --git a/tree.c b/tree.c index 215d3fdc7c..e741180482 100644 --- a/tree.c +++ b/tree.c @@ -105,7 +105,7 @@ static int read_tree_1(struct tree *tree, struct strbuf *base, oid_to_hex(entry.oid), base->buf, entry.path); - if (parse_commit(commit)) + if (repo_parse_commit(the_repository, commit)) die("Invalid commit %s in submodule path %s%s", oid_to_hex(entry.oid), base->buf, entry.path); @@ -221,7 +221,8 @@ int parse_tree_gently(struct tree *item, int quiet_on_missing) if (item->object.parsed) return 0; - buffer = read_object_file(&item->object.oid, &type, &size); + buffer = repo_read_object_file(the_repository, &item->object.oid, + &type, &size); if (!buffer) return quiet_on_missing ? -1 : error("Could not read %s", diff --git a/walker.c b/walker.c index 96990d84da..3e398cd485 100644 --- a/walker.c +++ b/walker.c @@ -78,7 +78,7 @@ static int process_commit(struct walker *walker, struct commit *commit) { struct commit_list *parents; - if (parse_commit(commit)) + if (repo_parse_commit(the_repository, commit)) return -1; while (complete && complete->item->date >= commit->date) { diff --git a/xdiff-interface.c b/xdiff-interface.c index ec6e574e4a..742553de49 100644 --- a/xdiff-interface.c +++ b/xdiff-interface.c @@ -192,7 +192,7 @@ void read_mmblob(mmfile_t *ptr, const struct object_id *oid) return; } - ptr->ptr = read_object_file(oid, &type, &size); + ptr->ptr = repo_read_object_file(the_repository, oid, &type, &size); if (!ptr->ptr || type != OBJ_BLOB) die("unable to read blob object %s", oid_to_hex(oid)); ptr->size = size;