From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS31976 209.132.180.0/23 X-Spam-Status: No, score=-3.1 required=3.0 tests=AWL,BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD shortcircuit=no autolearn=ham autolearn_force=no version=3.4.0 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by dcvr.yhbt.net (Postfix) with ESMTP id E498B20209 for ; Sat, 1 Jul 2017 18:31:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752045AbdGASbo (ORCPT ); Sat, 1 Jul 2017 14:31:44 -0400 Received: from alum-mailsec-scanner-3.mit.edu ([18.7.68.14]:48709 "EHLO alum-mailsec-scanner-3.mit.edu" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752033AbdGASbm (ORCPT ); Sat, 1 Jul 2017 14:31:42 -0400 X-AuditID: 1207440e-8a7ff70000006f9a-c0-5957ea85451d Received: from outgoing-alum.mit.edu (OUTGOING-ALUM.MIT.EDU [18.7.68.33]) (using TLS with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by alum-mailsec-scanner-3.mit.edu (Symantec Messaging Gateway) with SMTP id 37.A9.28570.58AE7595; Sat, 1 Jul 2017 14:31:33 -0400 (EDT) Received: from bagpipes.fritz.box (p57BCCCEF.dip0.t-ipconnect.de [87.188.204.239]) (authenticated bits=0) (User authenticated as mhagger@ALUM.MIT.EDU) by outgoing-alum.mit.edu (8.13.8/8.12.4) with ESMTP id v61IVBBL010294 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=NOT); Sat, 1 Jul 2017 14:31:31 -0400 From: Michael Haggerty To: Junio C Hamano Cc: =?UTF-8?q?Nguy=E1=BB=85n=20Th=C3=A1i=20Ng=E1=BB=8Dc=20Duy?= , Stefan Beller , Jeff King , =?UTF-8?q?=C3=86var=20Arnfj=C3=B6r=C3=B0=20Bjarmason?= , David Turner , Brandon Williams , git@vger.kernel.org, Michael Haggerty Subject: [PATCH v3 08/30] get_packed_ref_cache(): take a `packed_ref_store *` parameter Date: Sat, 1 Jul 2017 20:30:46 +0200 Message-Id: <34ec9fea5819575908a5e622b0ef79465f234112.1498933362.git.mhagger@alum.mit.edu> X-Mailer: git-send-email 2.11.0 In-Reply-To: References: X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrHIsWRmVeSWpSXmKPExsUixO6iqNv6KjzS4N9VPou1z+4wWTxff4Ld outKN5NFQ+8VZovbK+YzWyx5+JrZonvKW0aLHy09zBabN7ezOHB6/H3/gclj56y77B4LNpV6 dLUfYfN41ruH0ePiJWWPz5vkAtijuGxSUnMyy1KL9O0SuDJenTvNXrBPpmLRoktsDYwLJboY OTkkBEwkfpz+xwhiCwnsYJI4/juui5ELyD7JJPHuZwsbSIJNQFdiUU8zE4gtIqAmMbHtEAtI EbPAJGaJt9cWgiWEBcIluieuA2tgEVCV2Li0F8zmFYiSeHe7kRlim7zErraLrCA2p4CFxJ+2 9cwQm80lmg/2sUxg5FnAyLCKUS4xpzRXNzcxM6c4NVm3ODkxLy+1SNdYLzezRC81pXQTIyTo +HYwtq+XOcQowMGoxMO7ISQsUog1say4MvcQoyQHk5Io78proZFCfEn5KZUZicUZ8UWlOanF hxglOJiVRHhzn4dHCvGmJFZWpRblw6SkOViUxHnVlqj7CQmkJ5akZqemFqQWwWRlODiUJHgn vQRqFCxKTU+tSMvMKUFIM3FwggznARq+8C7I8OKCxNzizHSI/ClGXY5XE/5/YxJiycvPS5US 520FGSQAUpRRmgc3B5YsXjGKA70lzBvxAqiKB5ho4Ca9AlrCBLREeEYIyJKSRISUVANj6dmG uVdb215+33pr+cbet9POaym08wqqXT4uv2eWQ9Xs/c9W3dggvEJu8yNDj1cMs75x/nhls6N5 W63YegbFZIMJn7Td5u55ZOe8ged7UMpdd62+BZdC1mtm3a6Iaki43D1lauOy4isPg1XfX2L0 nRS5IOIks9SqjY0bIjWuZJsH9cluO8LPoMRSnJFoqMVcVJwIAKUYBYzxAgAA Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org It only cares about the packed-refs part of the reference store. Signed-off-by: Michael Haggerty --- refs/files-backend.c | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/refs/files-backend.c b/refs/files-backend.c index f061506bf0..b2ef7b3bb9 100644 --- a/refs/files-backend.c +++ b/refs/files-backend.c @@ -404,24 +404,22 @@ static void validate_packed_ref_cache(struct packed_ref_store *refs) } /* - * Get the packed_ref_cache for the specified files_ref_store, + * Get the packed_ref_cache for the specified packed_ref_store, * creating and populating it if it hasn't been read before or if the * file has been changed (according to its `validity` field) since it * was last read. On the other hand, if we hold the lock, then assume * that the file hasn't been changed out from under us, so skip the * extra `stat()` call in `stat_validity_check()`. */ -static struct packed_ref_cache *get_packed_ref_cache(struct files_ref_store *refs) +static struct packed_ref_cache *get_packed_ref_cache(struct packed_ref_store *refs) { - const char *packed_refs_file = refs->packed_ref_store->path; + if (!is_lock_file_locked(&refs->lock)) + validate_packed_ref_cache(refs); - if (!is_lock_file_locked(&refs->packed_ref_store->lock)) - validate_packed_ref_cache(refs->packed_ref_store); - - if (!refs->packed_ref_store->cache) - refs->packed_ref_store->cache = read_packed_refs(packed_refs_file); + if (!refs->cache) + refs->cache = read_packed_refs(refs->path); - return refs->packed_ref_store->cache; + return refs->cache; } static struct ref_dir *get_packed_ref_dir(struct packed_ref_cache *packed_ref_cache) @@ -431,7 +429,7 @@ static struct ref_dir *get_packed_ref_dir(struct packed_ref_cache *packed_ref_ca static struct ref_dir *get_packed_refs(struct files_ref_store *refs) { - return get_packed_ref_dir(get_packed_ref_cache(refs)); + return get_packed_ref_dir(get_packed_ref_cache(refs->packed_ref_store)); } /* @@ -1151,7 +1149,7 @@ static struct ref_iterator *files_ref_iterator_begin( loose_iter = cache_ref_iterator_begin(get_loose_ref_cache(refs), prefix, 1); - iter->packed_ref_cache = get_packed_ref_cache(refs); + iter->packed_ref_cache = get_packed_ref_cache(refs->packed_ref_store); acquire_packed_ref_cache(iter->packed_ref_cache); packed_iter = cache_ref_iterator_begin(iter->packed_ref_cache->cache, prefix, 0); @@ -1365,7 +1363,7 @@ static int lock_packed_refs(struct files_ref_store *refs, int flags) */ validate_packed_ref_cache(refs->packed_ref_store); - packed_ref_cache = get_packed_ref_cache(refs); + packed_ref_cache = get_packed_ref_cache(refs->packed_ref_store); /* Increment the reference count to prevent it from being freed: */ acquire_packed_ref_cache(packed_ref_cache); return 0; @@ -1380,7 +1378,7 @@ static int lock_packed_refs(struct files_ref_store *refs, int flags) static int commit_packed_refs(struct files_ref_store *refs) { struct packed_ref_cache *packed_ref_cache = - get_packed_ref_cache(refs); + get_packed_ref_cache(refs->packed_ref_store); int ok, error = 0; int save_errno = 0; FILE *out; @@ -1426,7 +1424,7 @@ static int commit_packed_refs(struct files_ref_store *refs) static void rollback_packed_refs(struct files_ref_store *refs) { struct packed_ref_cache *packed_ref_cache = - get_packed_ref_cache(refs); + get_packed_ref_cache(refs->packed_ref_store); files_assert_main_repository(refs, "rollback_packed_refs"); -- 2.11.0