From patchwork Tue Jan 10 06:17:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 13094735 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id AE152C54EBE for ; Tue, 10 Jan 2023 06:17:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229917AbjAJGRp (ORCPT ); Tue, 10 Jan 2023 01:17:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42982 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230161AbjAJGRl (ORCPT ); Tue, 10 Jan 2023 01:17:41 -0500 Received: from mail-ed1-x535.google.com (mail-ed1-x535.google.com [IPv6:2a00:1450:4864:20::535]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B240C1C912 for ; Mon, 9 Jan 2023 22:17:40 -0800 (PST) Received: by mail-ed1-x535.google.com with SMTP id x10so13081521edd.10 for ; Mon, 09 Jan 2023 22:17:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=KH8wHgZPT5jUEBRn+r5h7oxAazaP5ARLEm+xQHgqjBs=; b=OFlcLWksUheyjMI58HvbbIs77fP2eMBivyHEfDcmjPHdiRZVOB1pcyrXh6BHGCEUwl 5vOr4ycFesGRaSKaf+qUN7k6FlG8f0xcX8GBKUDdZza4lkRDZrUWL/uH/h0AE4DNXGZd Fok7haSq0MzC0nN/bmafUD5c5LOWMWIYWqOkMizwfsq+FIaCUh5BA9BCwQfiQt2dHhzX Tm1JQjfr9qh0Pcjo++KqsjEvT4XhxbLS+YuWm602O8R8cPtgedYg9Kg9C9uGx0lwjMTT T/5nWLOhnKZvkS64R8Z8WPdPXpPelhdyf0Aj3fMiPP+BZNoneYHZocszhGaCd96o/G5J PinQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=KH8wHgZPT5jUEBRn+r5h7oxAazaP5ARLEm+xQHgqjBs=; b=QTj7/7/WE7ud8OZY+nITaIsJf3rS70YCII6EKcG5rc9tY7CjQczlcx4qF+ag/f/nhG OGMGxFBGQwwrAqei+lR7W7e17+wvE2gMmwqSeyuIUnK0iq8k7zYjkvIrRmMSDLkwsh1C H9+HiaS6phFgRPZRfY9/Txv0A7CSwFi2YSQbvcWHEn9GvoL0qBp7LQcujoRYwKt5unqu auSqclDomA1t/Pji1dktXm3z/QqVSNAZ87Q4xKNFRcNrYcwFL6xxlkilPSjzsjhhI4QR I0jwuQEjdxGUWm7tKM0xmxpGyvqUXtefmGF3KwUFX6cC+y4K1MEhHOrEUlDY/qKtO+Ps XI1A== X-Gm-Message-State: AFqh2kqXMHtD7vZz8BecTj+jIw0q6+nmmLf5PoLMWAYuXwzB1GpWRMec mLf8iiNfQhXmIFWemOH1s19DcITpkL0aAA== X-Google-Smtp-Source: AMrXdXtg/+oADhlDyL54HJNL5UbbMLPqlKIjN2KzA75AqnnpR8WjVfZx/UdPAM3qzNftsYTY7KbBqw== X-Received: by 2002:a05:6402:c0e:b0:483:2c00:a851 with SMTP id co14-20020a0564020c0e00b004832c00a851mr45879601edb.31.1673331458750; Mon, 09 Jan 2023 22:17:38 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id k16-20020a05640212d000b0048b4e2aaba0sm4555601edx.34.2023.01.09.22.17.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Jan 2023 22:17:37 -0800 (PST) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Derrick Stolee , Victoria Dye , Jeff Hostetler , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBC?= =?utf-8?b?amFybWFzb24=?= Subject: [PATCH 1/5] builtin/difftool.c: { 0 }-initialize rather than using memset() Date: Tue, 10 Jan 2023 07:17:29 +0100 Message-Id: X-Mailer: git-send-email 2.39.0.1195.gabc92c078c4 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Refactor an initialization of a variable added in 03831ef7b50 (difftool: implement the functionality in the builtin, 2017-01-19). This refactoring makes a subsequent change smaller. Signed-off-by: Ævar Arnfjörð Bjarmason --- builtin/difftool.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/builtin/difftool.c b/builtin/difftool.c index d9b76226f6a..1f9d4324df5 100644 --- a/builtin/difftool.c +++ b/builtin/difftool.c @@ -361,7 +361,7 @@ static int run_dir_diff(const char *extcmd, int symlinks, const char *prefix, struct hashmap symlinks2 = HASHMAP_INIT(pair_cmp, NULL); struct hashmap_iter iter; struct pair_entry *entry; - struct index_state wtindex; + struct index_state wtindex = { 0 }; struct checkout lstate, rstate; int err = 0; struct child_process cmd = CHILD_PROCESS_INIT; @@ -387,8 +387,6 @@ static int run_dir_diff(const char *extcmd, int symlinks, const char *prefix, mkdir(ldir.buf, 0700); mkdir(rdir.buf, 0700); - memset(&wtindex, 0, sizeof(wtindex)); - memset(&lstate, 0, sizeof(lstate)); lstate.base_dir = lbase_dir = xstrdup(ldir.buf); lstate.base_dir_len = ldir.len; From patchwork Tue Jan 10 06:17:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 13094736 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 48C69C46467 for ; Tue, 10 Jan 2023 06:17:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230403AbjAJGRu (ORCPT ); Tue, 10 Jan 2023 01:17:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43048 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230253AbjAJGRo (ORCPT ); Tue, 10 Jan 2023 01:17:44 -0500 Received: from mail-ed1-x52d.google.com (mail-ed1-x52d.google.com [IPv6:2a00:1450:4864:20::52d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 691731C420 for ; Mon, 9 Jan 2023 22:17:41 -0800 (PST) Received: by mail-ed1-x52d.google.com with SMTP id i9so16000686edj.4 for ; Mon, 09 Jan 2023 22:17:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=NF+Npn4IYn8MYiiFLZZMS4lxEToW/kMgWRWF9wQijx4=; b=RxaXnHquRBs65fvCFgg2PHpN1qIX/MzYNGq6Cw2xz2lN1EBTWALrt9k9fleiaSP3CI Dh3zpxgCIxucGSVDsHqb373uv/8nYEugtrdC3QiIFl2RJmDigFTt52UwFJev/4rkqXxd lyGAGl5CvCjzLpPxvUVw2NalRT9ovLnqYSNVR3VtR0Hw1OFzd1qI06K+cmEVjydhdxDq OnEHw/V51TfukNio07ZqPYY6KsdeRiza5fxgffPZZsdPxm7vppg3KjyqF8SvRyfvmPdf 5kDLJgWxWV4x6H2rxs7Q9noOpSU6k1DZV8ZsY4AH/zlqMoFltQzbEMxWxvD8ETMkVIru nuJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=NF+Npn4IYn8MYiiFLZZMS4lxEToW/kMgWRWF9wQijx4=; b=ywKBgYP4HsOTXR79g6bgZ+taA0HwHmCCcdR/H1UQUQEjiF6IdPoNlsPj6gFPQgqZoh m24XKWqzcqrrzfUUHpVamODNM2RfDdSESMBhvPoai0SJzjyI/dJvOXGZTfzI0ohtrQvw AHcdokeBB0A015sL+WPKr8SVJKhQ93ixepuqEFCNFD1whQAXsyVfZggLy/a0tWqdZ7T9 PxNf3y+OAo8nS18GMioD99gB+EOxDHIGdu7opQZsvE3mfi2bmQO7LMRHGQ3NZOjrB4ic aK0DG3PsraZ5BUA4dNtGIZzdI5lnUbZiS1GUtqFz/D59oxE4bgSq9aqnk+0MZTAhlVIo ITdw== X-Gm-Message-State: AFqh2kr82MeXNoIzTTpe63TKo1EefXzDeygicQEk61J7y5IsDlAAyZ3y hBTa21rCWiWQdstPnxYq9RgREy7pHfvrOA== X-Google-Smtp-Source: AMrXdXvfO06FDVyeUmQ7qz8w+/zj9XSvJn5EI+/TrEWXT2H951e3OcWxWNuyq/wNpS7pPGXTwBAetQ== X-Received: by 2002:a05:6402:3985:b0:467:9976:2e38 with SMTP id fk5-20020a056402398500b0046799762e38mr62767870edb.18.1673331459671; Mon, 09 Jan 2023 22:17:39 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id k16-20020a05640212d000b0048b4e2aaba0sm4555601edx.34.2023.01.09.22.17.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Jan 2023 22:17:38 -0800 (PST) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Derrick Stolee , Victoria Dye , Jeff Hostetler , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBC?= =?utf-8?b?amFybWFzb24=?= Subject: [PATCH 2/5] sparse-index.c: expand_to_path() can assume non-NULL "istate" Date: Tue, 10 Jan 2023 07:17:30 +0100 Message-Id: X-Mailer: git-send-email 2.39.0.1195.gabc92c078c4 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org This function added in [1] was subsequently used in [2]. All of the calls to it are in name-hash.c, and come after calls to lazy_init_name_hash(istate). The first thing that function does is: if (istate->name_hash_initialized) return; So we can already assume that we have a non-NULL "istate" here, or we'd be segfaulting. Let's not confuse matters by making it appear that's not the case. 1. 71f82d032f3 (sparse-index: expand_to_path(), 2021-04-12) 2. 4589bca829a (name-hash: use expand_to_path(), 2021-04-12) Signed-off-by: Ævar Arnfjörð Bjarmason --- sparse-index.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sparse-index.c b/sparse-index.c index 8c269dab803..65a08d33c73 100644 --- a/sparse-index.c +++ b/sparse-index.c @@ -547,7 +547,7 @@ void expand_to_path(struct index_state *istate, if (in_expand_to_path) return; - if (!istate || !istate->sparse_index) + if (!istate->sparse_index) return; if (!istate->repo) From patchwork Tue Jan 10 06:17:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 13094737 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id BCC22C46467 for ; Tue, 10 Jan 2023 06:18:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231248AbjAJGSF (ORCPT ); Tue, 10 Jan 2023 01:18:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43082 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230336AbjAJGRq (ORCPT ); Tue, 10 Jan 2023 01:17:46 -0500 Received: from mail-ed1-x534.google.com (mail-ed1-x534.google.com [IPv6:2a00:1450:4864:20::534]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 690FE1C13E for ; Mon, 9 Jan 2023 22:17:42 -0800 (PST) Received: by mail-ed1-x534.google.com with SMTP id v30so15959536edb.9 for ; Mon, 09 Jan 2023 22:17:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=I630ZkCPAdQ4L15RWoitoZtakXFJm54p6dncO9flkwo=; b=OC2Q4Y3zEjEdzKH85mJyaqQdOmP6zzKXlSGNotibftZ+mB+CT+PfKas9kJ3hiFYaVx CErd9tb8O4517Pyf5TAn5Xvwh3BZUvFxiVBd+ete0Bp1p2Ex7GdLQ7UEh9ZIGd/c7Urk sLx17o9TmNFR4wZg0C0S0hyenXM2MjBFG1woXPXa7VPsX3QpDaBo9XrK5Sb5ZIvU9+/t CnH/Osk8HYKu98kSot9s7+Qy9ipr280g4dtm51HZSziRSGyXnXjjOJ76ph8i11EatxfJ Y23/FFESDXwFBDkYjnqUu5o/Ezqz0+4dDUkH699wiEw7ujh9bZczRc7fFgzf5fuCAxfG I64g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=I630ZkCPAdQ4L15RWoitoZtakXFJm54p6dncO9flkwo=; b=2TWWhSyiQSDJ3kQTlksSaYyDkFIxQbOWBQhI1pJeEiq5X42Ee4jtvFQjVfNGGcf8Bp VhZmXjyoFs/C4L/PLEPIs5A4kEOXiUJb7sfN7VL+hHx6aQZw08rIsxh9etCoZ4X08lfF iEwTkVts7A6IwXwvA/sFKuJUHcto+a6J77iCfT/doyqyAbhIjv3Sa6PLIPe58GaPQPr1 S8PHFvvOH1E3IBl1+qfI4YoaZy1VZRr2vNitsODwAUMK8zzvPDNSb5Devup/5YppGG4G JEJOH5Br1u0UzVBoNbrEraa8114RmWN11a185df55W6ciGyrC2JZ47/iKZY6qg0CpAKe 1ISg== X-Gm-Message-State: AFqh2kp1qsjU0ehxahufJXhV4QCP8JjTyPJhtMwicPFeyYSjpDMgNcFa eutrwLQtICiFTuGE2oHImN7E9QAK2hx33Q== X-Google-Smtp-Source: AMrXdXttQdq7h3zziDbzZJUQCasB6gdOWV+YbJLANggDIFXANr/JoOolZTOIylKlEY12/+hU+jWHng== X-Received: by 2002:a05:6402:520b:b0:48b:58be:472c with SMTP id s11-20020a056402520b00b0048b58be472cmr49029126edd.18.1673331460622; Mon, 09 Jan 2023 22:17:40 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id k16-20020a05640212d000b0048b4e2aaba0sm4555601edx.34.2023.01.09.22.17.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Jan 2023 22:17:39 -0800 (PST) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Derrick Stolee , Victoria Dye , Jeff Hostetler , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBC?= =?utf-8?b?amFybWFzb24=?= Subject: [PATCH 3/5] sparse-index API: fix TODO, BUG() out on NULL ensure_full_index() Date: Tue, 10 Jan 2023 07:17:31 +0100 Message-Id: X-Mailer: git-send-email 2.39.0.1195.gabc92c078c4 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Make the ensure_full_index() function stricter, and have it only accept a non-NULL "struct index_state". This function (and this behavior) was added in [1]. The only reason it needed to be this lax was due to interaction with repo_index_has_changes(). See the addition of that code in . This fixes one of the TODO comments added in 0c18c059a15, the other one was already removed in [3]. The other reason for why this was needed dates back to interaction with code added in [4]. In [5] we started calling ensure_full_index() in unpack_trees(), but the caller added in 34110cd4e39 wants to pass us a NULL "dst_index". Let's instead do the NULL check in unpack_trees() itself. 1. 4300f8442a2 (sparse-index: implement ensure_full_index(), 2021-03-30) 2. 0c18c059a15 (read-cache: ensure full index, 2021-04-01) 3. d76723ee531 (status: use sparse-index throughout, 2021-07-14). 4. 34110cd4e39 (Make 'unpack_trees()' have a separate source and destination index, 2008-03-06) 5. 6863df35503 (unpack-trees: ensure full index, 2021-03-30) Signed-off-by: Ævar Arnfjörð Bjarmason --- read-cache.c | 5 +++-- sparse-index.c | 4 +++- unpack-trees.c | 3 ++- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/read-cache.c b/read-cache.c index cf87ad70970..9fbff4bc6aa 100644 --- a/read-cache.c +++ b/read-cache.c @@ -2646,8 +2646,7 @@ int repo_index_has_changes(struct repository *repo, } diff_flush(&opt); return opt.flags.has_changes != 0; - } else { - /* TODO: audit for interaction with sparse-index. */ + } else if (istate) { ensure_full_index(istate); for (i = 0; sb && i < istate->cache_nr; i++) { if (i) @@ -2655,6 +2654,8 @@ int repo_index_has_changes(struct repository *repo, strbuf_addstr(sb, istate->cache[i]->name); } return !!istate->cache_nr; + } else { + return 0; } } diff --git a/sparse-index.c b/sparse-index.c index 65a08d33c73..86e3b99870b 100644 --- a/sparse-index.c +++ b/sparse-index.c @@ -299,7 +299,7 @@ void expand_index(struct index_state *istate, struct pattern_list *pl) * If the index is already full, then keep it full. We will convert * it to a sparse index on write, if possible. */ - if (!istate || istate->sparse_index == INDEX_EXPANDED) + if (istate->sparse_index == INDEX_EXPANDED) return; /* @@ -424,6 +424,8 @@ void expand_index(struct index_state *istate, struct pattern_list *pl) void ensure_full_index(struct index_state *istate) { + if (!istate) + BUG("ensure_full_index() must get an index!"); expand_index(istate, NULL); } diff --git a/unpack-trees.c b/unpack-trees.c index ea09023b015..2381cd7cac4 100644 --- a/unpack-trees.c +++ b/unpack-trees.c @@ -1880,7 +1880,8 @@ int unpack_trees(unsigned len, struct tree_desc *t, struct unpack_trees_options prepare_repo_settings(repo); if (repo->settings.command_requires_full_index) { ensure_full_index(o->src_index); - ensure_full_index(o->dst_index); + if (o->dst_index) + ensure_full_index(o->dst_index); } if (o->reset == UNPACK_RESET_OVERWRITE_UNTRACKED && From patchwork Tue Jan 10 06:17:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 13094738 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1402CC54EBE for ; Tue, 10 Jan 2023 06:18:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230336AbjAJGSI (ORCPT ); Tue, 10 Jan 2023 01:18:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43132 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230289AbjAJGRt (ORCPT ); Tue, 10 Jan 2023 01:17:49 -0500 Received: from mail-ej1-x62b.google.com (mail-ej1-x62b.google.com [IPv6:2a00:1450:4864:20::62b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4442E1C927 for ; Mon, 9 Jan 2023 22:17:43 -0800 (PST) Received: by mail-ej1-x62b.google.com with SMTP id vm8so25944698ejc.2 for ; Mon, 09 Jan 2023 22:17:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=kS7t+d8VH/H4jV4AnOENMqR5Xe4q8EmLEGqnwk9sdiA=; b=S1NHdrRNSx6K9ReI95mukeS42gK7+LT7mRNOxlT9+lfcmfjmuTEF8Ho+TjtG17n24K k7qjpOQYdVWoLwFI6MA1wy6L2LQLICt13gmoS7pfdn15eviD81nKL9szhbh85EpGs0+0 cef/dVh9Sb76gZNuYTr43AuG80F44KakQspsmXMoGWVccXUS8hODklIqEsMwjoicI/0E CG6KR8gPQgFknKFccu6B7/wL0LOYfKsKM5b7dV13ucYMufSPZIQCIajRaWbTG8CqkWjk 7CR6EB8KA2YvLPPPkvgdVgFAr94QpRbUJGvkTpgk6IxHRQ/xe0uEFwU8jA1WknB84PfH Fjcg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=kS7t+d8VH/H4jV4AnOENMqR5Xe4q8EmLEGqnwk9sdiA=; b=CMncHNfyVmSEwSbKuWEDMkC07W5fWmbfL8/hJz3qPLU0h8j/xW3c6R1pV0W0ngIU6e sh6aduTx7RxfO7Kixu8WMcB5xf/e4RiAQHR9sDxZc4yZms3ecU0EC0M2/u5BkPqGU2gV tUnc0Bn+LCruWP8r4Z8oYqHGVSMiPJVCnDj20Jcto6MsJqyA9qV6L929ggNxzGv+dAlC cT/+KfhgojUWM8KjdsWsaNdPFH+1khltIUrEgwpfmUGNaDkam74kODMOqUG2RXU6fXU9 UqEvDpOVLooB//AC9aLYe6mAV7aRPQoCk1fCH/kJmy90IGSKpR0MfHD58iThqRxxFP9a rO9g== X-Gm-Message-State: AFqh2krhQF4eETOKNorb0liNjmHZ6PdkyHbQb3tsGOTGt/okYSjYb2EY /ZwJRlf6uxKfi+EHOsQBbbIqUOqJA42dCg== X-Google-Smtp-Source: AMrXdXsj5nFZH8MkMR2Z1HuBgTVzXnhhQNXOhZ8P6mlvGB+8TPjqtM0JIkQVPvCtUxhBiu7fY5xuaA== X-Received: by 2002:a17:906:b00c:b0:7c4:fa17:7202 with SMTP id v12-20020a170906b00c00b007c4fa177202mr56201150ejy.33.1673331461572; Mon, 09 Jan 2023 22:17:41 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id k16-20020a05640212d000b0048b4e2aaba0sm4555601edx.34.2023.01.09.22.17.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Jan 2023 22:17:40 -0800 (PST) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Derrick Stolee , Victoria Dye , Jeff Hostetler , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBC?= =?utf-8?b?amFybWFzb24=?= Subject: [PATCH 4/5] read-cache.c: refactor set_new_index_sparsity() for subsequent commit Date: Tue, 10 Jan 2023 07:17:32 +0100 Message-Id: X-Mailer: git-send-email 2.39.0.1195.gabc92c078c4 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Refactor code added to set_new_index_sparsity() in [1] to eliminate indentation resulting from putting the body of his function within the "if" block. Let's instead return early if we have no istate->repo. This trivial change makes the subsequent commit's diff smaller. 1. 491df5f679f (read-cache: set sparsity when index is new, 2022-05-10) Signed-off-by: Ævar Arnfjörð Bjarmason --- read-cache.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/read-cache.c b/read-cache.c index 9fbff4bc6aa..78e38b0da28 100644 --- a/read-cache.c +++ b/read-cache.c @@ -2300,12 +2300,12 @@ static void set_new_index_sparsity(struct index_state *istate) * If the index's repo exists, mark it sparse according to * repo settings. */ - if (istate->repo) { - prepare_repo_settings(istate->repo); - if (!istate->repo->settings.command_requires_full_index && - is_sparse_index_allowed(istate, 0)) - istate->sparse_index = 1; - } + if (!istate->repo) + return; + prepare_repo_settings(istate->repo); + if (!istate->repo->settings.command_requires_full_index && + is_sparse_index_allowed(istate, 0)) + istate->sparse_index = 1; } /* remember to discard_cache() before reading a different cache! */ From patchwork Tue Jan 10 06:17:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 13094739 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7E860C46467 for ; Tue, 10 Jan 2023 06:18:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230361AbjAJGSL (ORCPT ); Tue, 10 Jan 2023 01:18:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43058 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230395AbjAJGRt (ORCPT ); Tue, 10 Jan 2023 01:17:49 -0500 Received: from mail-ed1-x534.google.com (mail-ed1-x534.google.com [IPv6:2a00:1450:4864:20::534]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 484FE1C90F for ; Mon, 9 Jan 2023 22:17:44 -0800 (PST) Received: by mail-ed1-x534.google.com with SMTP id v10so14746625edi.8 for ; Mon, 09 Jan 2023 22:17:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=kft42KdAS5kQUVt8Sur19lC8rR+RERTHrxepCIsAj28=; b=BXC9MqxPhDbyNY9djnK0BDDaMVWAO1CXmff5ysJ9gLY7oswkwjE/f03+VLYXoHLGPS Je7KHkuAOq7vy1SGDrr1EVh6PeOVf2SsD49WWMar4hUU8qhlNfVbucTTLXNAA6cyDmfV 2GwWKhbrExyUHl8ho085RkfYVDsSTJsba+HctyStARtfWjeey2BN1gf22DvUYwSeofQC SvZvtCn/SVlE6YDa8gS+HZeJ62LGRFEB9I04JvUqBWYfGmDTUBZNTrAdvYGi5r7xSMsT iHW5WHSv+aGSoX4GOrHt+smHpcC+anyAl8XblHPg6hAHiyH/8Rj17wQ7RrJAN0v7dD9V /8Vg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=kft42KdAS5kQUVt8Sur19lC8rR+RERTHrxepCIsAj28=; b=lcIXl3liEz4rf9PBCAokoD+zBbGR4JoUYQx66KzqSZbCFlze96mF3BZEwiRSmG6Y5d PrQrWFPIjYOywI6QvWfSU0V4l6AamVaiQQLZeaeynlcMhyJHcamOtZqg+hWEk0je9ieR ss/KyY0BCBMRNM/qc6cKg0twZUE7ys4Rmb58m7bmZgmXd/lXEwgc3N7NyeSjVQM0X5Kt sPA7szVBwIDxXfnWGXLh6Cw+oRA6xzOKXhGpVT6rkVZXgopeqe8QuIjrlk2hGwV6A1AK IjC0IbL56tnTGpyWuiIaBLGFrVSvSPlnHDZ/DTku9LmfLDgJq0WV4K8fbFFFGOZwlPY7 j6Dg== X-Gm-Message-State: AFqh2koWj/IiDgKQJAfmjWIxfh/x+kwb1E5mfwhSrSjdYNaG9/ATQi1o FSTPcUUFZ2NLfV8P7PiAqOXMaHOjlw88Ww== X-Google-Smtp-Source: AMrXdXvDDSprLChYEqf0HVC1xXVe0NtjClYzVRJtE+bh8fXGbIno7jtbpBq3nrcL2Dq3uj/3W4mjog== X-Received: by 2002:a05:6402:f02:b0:498:8c60:d7d7 with SMTP id i2-20020a0564020f0200b004988c60d7d7mr8388480eda.40.1673331462431; Mon, 09 Jan 2023 22:17:42 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id k16-20020a05640212d000b0048b4e2aaba0sm4555601edx.34.2023.01.09.22.17.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Jan 2023 22:17:41 -0800 (PST) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Derrick Stolee , Victoria Dye , Jeff Hostetler , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBC?= =?utf-8?b?amFybWFzb24=?= Subject: [PATCH 5/5] treewide: always have a valid "index_state.repo" member Date: Tue, 10 Jan 2023 07:17:33 +0100 Message-Id: X-Mailer: git-send-email 2.39.0.1195.gabc92c078c4 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org When the "repo" member was added to "the_index" in [1] the repo_read_index() was made to populate it, but the unpopulated "the_index" variable didn't get the same treatment. Let's do that in initialize_the_repository() when we set it up, and likewise for all of the current callers initialized an empty "struct index_state". This simplifies code that needs to deal with "the_index" or a custom "struct index_state", we no longer need to second-guess this part of the "index_state" deep in the stack. A recent example of such second-guessing is the "istate->repo ? istate->repo : the_repository" code in [2]. We can now simply use "istate->repo". For "fsmonitor-settings.c" we can remove the initialization of a NULL "r" argument to "the_repository". This was added back in [3], and was needed at the time for callers that would pass us the "r" from an "istate->repo". Before this change such a change to "fsmonitor-settings.c" would segfault all over the test suite (e.g. in t0002-gitfile.sh). This change has wider eventual implications for "fsmonitor-settings.c". The reason the other lazy loading behavior in it is required (starting with "if (!r->settings.fsmonitor) ..." is because of the previously passed "r" being "NULL". I have other local changes on top of this which move its configuration reading to "prepare_repo_settings()" in "repo-settings.c", as we could now start to rely on it being called for our "r". But let's leave all of that for now, and narrowly remove this particular part of the lazy-loading. 1. 1fd9ae517c4 (repository: add repo reference to index_state, 2021-01-23) 2. ee1f0c242ef (read-cache: add index.skipHash config option, 2023-01-06) 3. 1e0ea5c4316 (fsmonitor: config settings are repository-specific, 2022-03-25) Signed-off-by: Ævar Arnfjörð Bjarmason --- apply.c | 2 +- builtin/difftool.c | 2 +- builtin/sparse-checkout.c | 1 + builtin/stash.c | 8 ++++---- builtin/worktree.c | 2 +- fsmonitor-settings.c | 14 -------------- fsmonitor.c | 2 +- merge-recursive.c | 2 +- read-cache.c | 10 ++-------- repository.c | 2 ++ revision.c | 2 +- sparse-index.c | 9 --------- split-index.c | 1 + unpack-trees.c | 1 + 14 files changed, 17 insertions(+), 41 deletions(-) diff --git a/apply.c b/apply.c index 85822280476..47bc6598573 100644 --- a/apply.c +++ b/apply.c @@ -4105,7 +4105,7 @@ static int preimage_oid_in_gitlink_patch(struct patch *p, struct object_id *oid) static int build_fake_ancestor(struct apply_state *state, struct patch *list) { struct patch *patch; - struct index_state result = { NULL }; + struct index_state result = { .repo = state->repo }; struct lock_file lock = LOCK_INIT; int res; diff --git a/builtin/difftool.c b/builtin/difftool.c index 1f9d4324df5..ff29906f64a 100644 --- a/builtin/difftool.c +++ b/builtin/difftool.c @@ -361,7 +361,7 @@ static int run_dir_diff(const char *extcmd, int symlinks, const char *prefix, struct hashmap symlinks2 = HASHMAP_INIT(pair_cmp, NULL); struct hashmap_iter iter; struct pair_entry *entry; - struct index_state wtindex = { 0 }; + struct index_state wtindex = { .repo = the_repository }; struct checkout lstate, rstate; int err = 0; struct child_process cmd = CHILD_PROCESS_INIT; diff --git a/builtin/sparse-checkout.c b/builtin/sparse-checkout.c index 58a22503f04..6f0ea71ebb1 100644 --- a/builtin/sparse-checkout.c +++ b/builtin/sparse-checkout.c @@ -217,6 +217,7 @@ static int update_working_directory(struct pattern_list *pl) o.head_idx = -1; o.src_index = r->index; o.dst_index = r->index; + o.result.repo = r; o.skip_sparse_checkout = 0; o.pl = pl; diff --git a/builtin/stash.c b/builtin/stash.c index bb0fd861434..a4ff967ea59 100644 --- a/builtin/stash.c +++ b/builtin/stash.c @@ -1137,7 +1137,7 @@ static int save_untracked_files(struct stash_info *info, struct strbuf *msg, int ret = 0; struct strbuf untracked_msg = STRBUF_INIT; struct child_process cp_upd_index = CHILD_PROCESS_INIT; - struct index_state istate = { NULL }; + struct index_state istate = { .repo = the_repository }; cp_upd_index.git_cmd = 1; strvec_pushl(&cp_upd_index.args, "update-index", "-z", "--add", @@ -1176,7 +1176,7 @@ static int stash_staged(struct stash_info *info, struct strbuf *out_patch, { int ret = 0; struct child_process cp_diff_tree = CHILD_PROCESS_INIT; - struct index_state istate = { NULL }; + struct index_state istate = { .repo = the_repository }; if (write_index_as_tree(&info->w_tree, &istate, the_repository->index_file, 0, NULL)) { @@ -1209,7 +1209,7 @@ static int stash_patch(struct stash_info *info, const struct pathspec *ps, int ret = 0; struct child_process cp_read_tree = CHILD_PROCESS_INIT; struct child_process cp_diff_tree = CHILD_PROCESS_INIT; - struct index_state istate = { NULL }; + struct index_state istate = { .repo = the_repository }; char *old_index_env = NULL, *old_repo_index_file; remove_path(stash_index_path.buf); @@ -1271,7 +1271,7 @@ static int stash_working_tree(struct stash_info *info, const struct pathspec *ps struct rev_info rev; struct child_process cp_upd_index = CHILD_PROCESS_INIT; struct strbuf diff_output = STRBUF_INIT; - struct index_state istate = { NULL }; + struct index_state istate = { .repo = the_repository }; init_revisions(&rev, NULL); copy_pathspec(&rev.prune_data, ps); diff --git a/builtin/worktree.c b/builtin/worktree.c index 591d659faea..fd66fb4c165 100644 --- a/builtin/worktree.c +++ b/builtin/worktree.c @@ -923,7 +923,7 @@ static int unlock_worktree(int ac, const char **av, const char *prefix) static void validate_no_submodules(const struct worktree *wt) { - struct index_state istate = { NULL }; + struct index_state istate = { .repo = the_repository }; struct strbuf path = STRBUF_INIT; int i, found_submodules = 0; diff --git a/fsmonitor-settings.c b/fsmonitor-settings.c index ee63a97dc51..899bfe9c813 100644 --- a/fsmonitor-settings.c +++ b/fsmonitor-settings.c @@ -143,8 +143,6 @@ static void lookup_fsmonitor_settings(struct repository *r) enum fsmonitor_mode fsm_settings__get_mode(struct repository *r) { - if (!r) - r = the_repository; if (!r->settings.fsmonitor) lookup_fsmonitor_settings(r); @@ -153,8 +151,6 @@ enum fsmonitor_mode fsm_settings__get_mode(struct repository *r) const char *fsm_settings__get_hook_path(struct repository *r) { - if (!r) - r = the_repository; if (!r->settings.fsmonitor) lookup_fsmonitor_settings(r); @@ -174,8 +170,6 @@ void fsm_settings__set_ipc(struct repository *r) * Caller requested IPC explicitly, so avoid (possibly * recursive) config lookup. */ - if (!r) - r = the_repository; if (!r->settings.fsmonitor) r->settings.fsmonitor = alloc_settings(); @@ -197,8 +191,6 @@ void fsm_settings__set_hook(struct repository *r, const char *path) * Caller requested hook explicitly, so avoid (possibly * recursive) config lookup. */ - if (!r) - r = the_repository; if (!r->settings.fsmonitor) r->settings.fsmonitor = alloc_settings(); @@ -210,8 +202,6 @@ void fsm_settings__set_hook(struct repository *r, const char *path) void fsm_settings__set_disabled(struct repository *r) { - if (!r) - r = the_repository; if (!r->settings.fsmonitor) r->settings.fsmonitor = alloc_settings(); @@ -223,8 +213,6 @@ void fsm_settings__set_disabled(struct repository *r) void fsm_settings__set_incompatible(struct repository *r, enum fsmonitor_reason reason) { - if (!r) - r = the_repository; if (!r->settings.fsmonitor) r->settings.fsmonitor = alloc_settings(); @@ -235,8 +223,6 @@ void fsm_settings__set_incompatible(struct repository *r, enum fsmonitor_reason fsm_settings__get_reason(struct repository *r) { - if (!r) - r = the_repository; if (!r->settings.fsmonitor) lookup_fsmonitor_settings(r); diff --git a/fsmonitor.c b/fsmonitor.c index 08af00c7387..a5b9e75437b 100644 --- a/fsmonitor.c +++ b/fsmonitor.c @@ -304,7 +304,7 @@ void refresh_fsmonitor(struct index_state *istate) char *buf; unsigned int i; int is_trivial = 0; - struct repository *r = istate->repo ? istate->repo : the_repository; + struct repository *r = istate->repo; enum fsmonitor_mode fsm_mode = fsm_settings__get_mode(r); enum fsmonitor_reason reason = fsm_settings__get_reason(r); diff --git a/merge-recursive.c b/merge-recursive.c index 2fd0aa96875..a63d2e330d5 100644 --- a/merge-recursive.c +++ b/merge-recursive.c @@ -412,7 +412,7 @@ static int unpack_trees_start(struct merge_options *opt, { int rc; struct tree_desc t[3]; - struct index_state tmp_index = { NULL }; + struct index_state tmp_index = { .repo = opt->repo }; memset(&opt->priv->unpack_opts, 0, sizeof(opt->priv->unpack_opts)); if (opt->priv->call_depth) diff --git a/read-cache.c b/read-cache.c index 78e38b0da28..3f018874926 100644 --- a/read-cache.c +++ b/read-cache.c @@ -2300,8 +2300,6 @@ static void set_new_index_sparsity(struct index_state *istate) * If the index's repo exists, mark it sparse according to * repo settings. */ - if (!istate->repo) - return; prepare_repo_settings(istate->repo); if (!istate->repo->settings.command_requires_full_index && is_sparse_index_allowed(istate, 0)) @@ -2330,8 +2328,6 @@ int do_read_index(struct index_state *istate, const char *path, int must_exist) fd = open(path, O_RDONLY); if (fd < 0) { if (!must_exist && errno == ENOENT) { - if (!istate->repo) - istate->repo = the_repository; set_new_index_sparsity(istate); return 0; } @@ -2433,9 +2429,6 @@ int do_read_index(struct index_state *istate, const char *path, int must_exist) trace2_data_intmax("index", the_repository, "read/cache_nr", istate->cache_nr); - if (!istate->repo) - istate->repo = the_repository; - /* * If the command explicitly requires a full index, force it * to be full. Otherwise, correct the sparsity based on repository @@ -2501,6 +2494,7 @@ int read_index_from(struct index_state *istate, const char *path, discard_index(split_index->base); else CALLOC_ARRAY(split_index->base, 1); + split_index->base->repo = istate->repo; base_oid_hex = oid_to_hex(&split_index->base_oid); base_path = xstrfmt("%s/sharedindex.%s", gitdir, base_oid_hex); @@ -2929,7 +2923,7 @@ static int do_write_index(struct index_state *istate, struct tempfile *tempfile, int ieot_entries = 1; struct index_entry_offset_table *ieot = NULL; int nr, nr_threads; - struct repository *r = istate->repo ? istate->repo : the_repository; + struct repository *r = istate->repo; f = hashfd(tempfile->fd, tempfile->filename.buf); diff --git a/repository.c b/repository.c index 3427085fd6d..fdebc8c597c 100644 --- a/repository.c +++ b/repository.c @@ -28,6 +28,8 @@ void initialize_the_repository(void) the_repo.remote_state = remote_state_new(); the_repo.parsed_objects = parsed_object_pool_new(); + the_index.repo = the_repository; + repo_set_hash_algo(&the_repo, GIT_HASH_SHA1); } diff --git a/revision.c b/revision.c index 100e5ad5110..785be1eb3bf 100644 --- a/revision.c +++ b/revision.c @@ -1813,7 +1813,7 @@ void add_index_objects_to_pending(struct rev_info *revs, unsigned int flags) worktrees = get_worktrees(); for (p = worktrees; *p; p++) { struct worktree *wt = *p; - struct index_state istate = { NULL }; + struct index_state istate = { .repo = revs->repo }; if (wt->is_current) continue; /* current index already taken care of */ diff --git a/sparse-index.c b/sparse-index.c index 86e3b99870b..147a13386a4 100644 --- a/sparse-index.c +++ b/sparse-index.c @@ -128,9 +128,6 @@ int is_sparse_index_allowed(struct index_state *istate, int flags) if (!core_apply_sparse_checkout || !core_sparse_checkout_cone) return 0; - if (!istate->repo) - istate->repo = the_repository; - if (!(flags & SPARSE_INDEX_MEMORY_ONLY)) { int test_env; @@ -327,9 +324,6 @@ void expand_index(struct index_state *istate, struct pattern_list *pl) pl = NULL; } - if (!istate->repo) - istate->repo = the_repository; - /* * A NULL pattern set indicates we are expanding a full index, so * we use a special region name that indicates the full expansion. @@ -552,9 +546,6 @@ void expand_to_path(struct index_state *istate, if (!istate->sparse_index) return; - if (!istate->repo) - istate->repo = the_repository; - in_expand_to_path = 1; /* diff --git a/split-index.c b/split-index.c index 9d0ccc30d00..7815ca9f33e 100644 --- a/split-index.c +++ b/split-index.c @@ -91,6 +91,7 @@ void move_cache_to_base_index(struct index_state *istate) } CALLOC_ARRAY(si->base, 1); + si->base->repo = istate->repo; si->base->version = istate->version; /* zero timestamp disables racy test in ce_write_index() */ si->base->timestamp = istate->timestamp; diff --git a/unpack-trees.c b/unpack-trees.c index 2381cd7cac4..e8f25bbdce7 100644 --- a/unpack-trees.c +++ b/unpack-trees.c @@ -1906,6 +1906,7 @@ int unpack_trees(unsigned len, struct tree_desc *t, struct unpack_trees_options } memset(&o->result, 0, sizeof(o->result)); + o->result.repo = o->src_index->repo; o->result.initialized = 1; o->result.timestamp.sec = o->src_index->timestamp.sec; o->result.timestamp.nsec = o->src_index->timestamp.nsec;