From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS53758 23.128.96.0/24 X-Spam-Status: No, score=-4.0 required=3.0 tests=AWL,BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_LOW, SPF_HELO_PASS,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by dcvr.yhbt.net (Postfix) with ESMTP id E7D4E1F5AE for ; Fri, 21 May 2021 12:00:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233890AbhEUMBo (ORCPT ); Fri, 21 May 2021 08:01:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35886 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234282AbhEUMBO (ORCPT ); Fri, 21 May 2021 08:01:14 -0400 Received: from mail-wr1-x42c.google.com (mail-wr1-x42c.google.com [IPv6:2a00:1450:4864:20::42c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E879BC06138D for ; Fri, 21 May 2021 04:59:48 -0700 (PDT) Received: by mail-wr1-x42c.google.com with SMTP id x8so20804742wrq.9 for ; Fri, 21 May 2021 04:59:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=Xlnwaf5kg5I86PpR29UBuzCeR2oJW7UhOX0TCCBSrvU=; b=OpYoM7rQJulmw+izVMlIR2/VeynrBzfU9SdCGFsvSBCunmILEvzfGO/jaWtN4eReGa qbg/vBf+SGjN+7errIZ//oy14abUzom2cEV1otpj0l47iqa39YipO9qoJJI2Rk08iHP0 6i4u5dytePQfmfg1GSqEgj0VrQ3Z2dBFRy3v1jGUtlo0EAnRF3sLZCMzc64bk0oYHIIj lCyJPWHstoUI3y2BmKd7Nuu5f6k9Mw54zzPtaXmN5UaPyKjQOHoZDh8LJeMkGqTh8dkj L7EC4UXQBDT2NhPORgdXyBtrceO4ckLFDsI8+aqWDAwk+xaox5USfmJN0CGidCnViPyr wzTg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=Xlnwaf5kg5I86PpR29UBuzCeR2oJW7UhOX0TCCBSrvU=; b=ulYWEIxw4ln0JDGYtainpSLaZSSqfkU4t8blKfz4H30qs+tErPM25DuV9+JUNEU5zE vkSmFfLRCvlqYTRWrbawj8Udos/38WSnmQcQM9HMn5wiou12G8EwKtUEkIcxlydZO4tB /uvrDcSHZCwmKCrOfn7+cITMfoD5qZdTSZDBbjmVpDPlfwydY4FuCpdymGVG80ghhovx Gw4eZvNISM6AhlsEvOyoDKXTTaiJYRFX4oGRW5CT0LYYayvgOw3Wc0n+ESKFK941NQLG ihVOx5mVSu/AP6rrTektgyjpXM6V1kNX+PmYBhv//D8MaSJscd2D+KeElXGbzkrVQXfo /tIQ== X-Gm-Message-State: AOAM532sbgI+fK+kPgqnrOqapGh+abFWV3k1d+mWXl8eiOwu/+ugewuj h4mjhyXoCjUVocBKBoM6vHkIEAzQ9ds= X-Google-Smtp-Source: ABdhPJzyJQCrYusKigGxlVWXuAqTpRplWdHrO+rMrvwGuRwIgX8FaThmO0Rves90uLxR33qno+T+IA== X-Received: by 2002:a05:6000:1189:: with SMTP id g9mr9115023wrx.385.1621598387631; Fri, 21 May 2021 04:59:47 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id x10sm1876109wrt.65.2021.05.21.04.59.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 May 2021 04:59:47 -0700 (PDT) Message-Id: In-Reply-To: References: From: "Derrick Stolee via GitGitGadget" Date: Fri, 21 May 2021 11:59:36 +0000 Subject: [PATCH v4 07/12] unpack-trees: be careful around sparse directory entries Fcc: Sent Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit MIME-Version: 1.0 To: git@vger.kernel.org Cc: gitster@pobox.com, newren@gmail.com, Matheus Tavares Bernardino , Derrick Stolee , Derrick Stolee , Derrick Stolee Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Derrick Stolee The methods traverse_by_cache_tree() and unpack_nondirectories() have similar behavior in trying to demonstrate the difference between and index and a tree, with some differences about how they walk the index. Each of these is expecting every cache entry to correspond to a file path. We need to skip over the sparse directory entries in the case of a sparse-index. Those entries are discovered in the portion that looks for subtrees among the cache entries by scanning the paths for slashes. Skipping these sparse directory entries will have a measurable effect when we relax 'git status' to work with sparse-indexes: without this change these methods would call call_unpack_fn() which in turn calls oneway_diff() and then shows these sparse directory entries as added or modified files. Signed-off-by: Derrick Stolee --- unpack-trees.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/unpack-trees.c b/unpack-trees.c index ef6a2b1c951c..22634d98e72b 100644 --- a/unpack-trees.c +++ b/unpack-trees.c @@ -802,6 +802,9 @@ static int traverse_by_cache_tree(int pos, int nr_entries, int nr_names, src[0] = o->src_index->cache[pos + i]; + if (S_ISSPARSEDIR(src[0]->ce_mode)) + continue; + len = ce_namelen(src[0]); new_ce_len = cache_entry_size(len); @@ -1074,6 +1077,9 @@ static int unpack_nondirectories(int n, unsigned long mask, if (mask == dirmask && !src[0]) return 0; + if (src[0] && S_ISSPARSEDIR(src[0]->ce_mode)) + return 0; + /* * Ok, we've filled in up to any potential index entry in src[0], * now do the rest. -- gitgitgadget