From: "Derrick Stolee via GitGitGadget" <gitgitgadget@gmail.com>
To: git@vger.kernel.org
Cc: gitster@pobox.com, newren@gmail.com, peff@peff.net,
jrnieder@gmail.com, sunshine@sunshineco.com, pclouds@gmail.com,
Derrick Stolee <derrickstolee@github.com>,
Derrick Stolee <dstolee@microsoft.com>
Subject: [PATCH 05/27] test-tool: read-cache --table --no-stat
Date: Mon, 25 Jan 2021 17:41:51 +0000 [thread overview]
Message-ID: <e1e2f2b75b2848e9b4c9cfc8fe89b11e6ad2b776.1611596534.git.gitgitgadget@gmail.com> (raw)
In-Reply-To: <pull.847.git.1611596533.gitgitgadget@gmail.com>
From: Derrick Stolee <dstolee@microsoft.com>
The 'test-tool read-cache --table' output is helpful to understand the
full contents of the index entries on-disk. This is particularly helpful
when trying to diagnose issues with a real repository example.
However, for test cases we might want to compare the index contents of
two repositories that were updated in similar ways, but will not
actually share the same stat data. Add the '--no-stat' option to remove
the timestamps and other stat data from the output. This allows us to
compare index contents directly.
Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
---
t/helper/test-read-cache.c | 44 ++++++++++++++----------
t/t1092-sparse-checkout-compatibility.sh | 2 +-
2 files changed, 26 insertions(+), 20 deletions(-)
diff --git a/t/helper/test-read-cache.c b/t/helper/test-read-cache.c
index cd7d106a675..f858d0d0a0c 100644
--- a/t/helper/test-read-cache.c
+++ b/t/helper/test-read-cache.c
@@ -2,16 +2,18 @@
#include "cache.h"
#include "config.h"
-static void print_cache_entry(struct cache_entry *ce)
+static void print_cache_entry(struct cache_entry *ce, unsigned stat)
{
- /* stat info */
- printf("%08x %08x %08x %08x %08x %08x ",
- ce->ce_stat_data.sd_ctime.sec,
- ce->ce_stat_data.sd_ctime.nsec,
- ce->ce_stat_data.sd_mtime.sec,
- ce->ce_stat_data.sd_mtime.nsec,
- ce->ce_stat_data.sd_dev,
- ce->ce_stat_data.sd_ino);
+ if (stat) {
+ /* stat info */
+ printf("%08x %08x %08x %08x %08x %08x ",
+ ce->ce_stat_data.sd_ctime.sec,
+ ce->ce_stat_data.sd_ctime.nsec,
+ ce->ce_stat_data.sd_mtime.sec,
+ ce->ce_stat_data.sd_mtime.nsec,
+ ce->ce_stat_data.sd_dev,
+ ce->ce_stat_data.sd_ino);
+ }
/* mode in binary */
printf("0b%d%d%d%d ",
@@ -28,48 +30,52 @@ static void print_cache_entry(struct cache_entry *ce)
printf("%s\n", ce->name);
}
-static void print_cache(struct index_state *cache)
+static void print_cache(struct index_state *cache, unsigned stat)
{
int i;
for (i = 0; i < the_index.cache_nr; i++)
- print_cache_entry(the_index.cache[i]);
+ print_cache_entry(the_index.cache[i], stat);
}
int cmd__read_cache(int argc, const char **argv)
{
+ struct repository *r = the_repository;
int i, cnt = 1;
const char *name = NULL;
int table = 0;
+ int stat = 1;
for (++argv, --argc; *argv && starts_with(*argv, "--"); ++argv, --argc) {
if (skip_prefix(*argv, "--print-and-refresh=", &name))
continue;
- if (!strcmp(*argv, "--table")) {
+ if (!strcmp(*argv, "--table"))
table = 1;
- }
+ else if (!strcmp(*argv, "--no-stat"))
+ stat = 0;
}
if (argc == 1)
cnt = strtol(argv[0], NULL, 0);
setup_git_directory();
git_config(git_default_config, NULL);
+
for (i = 0; i < cnt; i++) {
- read_cache();
+ repo_read_index(r);
if (name) {
int pos;
- refresh_index(&the_index, REFRESH_QUIET,
+ refresh_index(r->index, REFRESH_QUIET,
NULL, NULL, NULL);
- pos = index_name_pos(&the_index, name, strlen(name));
+ pos = index_name_pos(r->index, name, strlen(name));
if (pos < 0)
die("%s not in index", name);
printf("%s is%s up to date\n", name,
- ce_uptodate(the_index.cache[pos]) ? "" : " not");
+ ce_uptodate(r->index->cache[pos]) ? "" : " not");
write_file(name, "%d\n", i);
}
if (table)
- print_cache(&the_index);
- discard_cache();
+ print_cache(r->index, stat);
+ discard_index(r->index);
}
return 0;
}
diff --git a/t/t1092-sparse-checkout-compatibility.sh b/t/t1092-sparse-checkout-compatibility.sh
index 8876eae0fe3..3aa9b0d21b4 100755
--- a/t/t1092-sparse-checkout-compatibility.sh
+++ b/t/t1092-sparse-checkout-compatibility.sh
@@ -132,7 +132,7 @@ test_sparse_match () {
test_expect_success 'expanded in-memory index matches full index' '
init_repos &&
- test_sparse_match test-tool read-cache --expand --table-no-stat
+ test_sparse_match test-tool read-cache --expand --table --no-stat
'
test_expect_success 'status with options' '
--
gitgitgadget
next prev parent reply other threads:[~2021-01-25 18:05 UTC|newest]
Thread overview: 61+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-25 17:41 [PATCH 00/27] [RFC] Sparse Index Derrick Stolee via GitGitGadget
2021-01-25 17:41 ` [PATCH 01/27] sparse-index: add guard to ensure full index Derrick Stolee via GitGitGadget
2021-01-25 17:41 ` [PATCH 02/27] sparse-index: implement ensure_full_index() Derrick Stolee via GitGitGadget
2021-01-27 3:05 ` Elijah Newren
2021-01-27 13:43 ` Derrick Stolee
2021-01-27 16:38 ` Elijah Newren
2021-01-28 5:25 ` Junio C Hamano
2021-01-25 17:41 ` [PATCH 03/27] t1092: compare sparse-checkout to sparse-index Derrick Stolee via GitGitGadget
2021-01-27 3:08 ` Elijah Newren
2021-01-27 13:30 ` Derrick Stolee
2021-01-27 16:54 ` Elijah Newren
2021-01-25 17:41 ` [PATCH 04/27] test-read-cache: print cache entries with --table Derrick Stolee via GitGitGadget
2021-01-27 3:25 ` Elijah Newren
2021-01-25 17:41 ` Derrick Stolee via GitGitGadget [this message]
2021-01-25 17:41 ` [PATCH 06/27] test-tool: don't force full index Derrick Stolee via GitGitGadget
2021-01-25 17:41 ` [PATCH 07/27] unpack-trees: ensure " Derrick Stolee via GitGitGadget
2021-01-27 4:43 ` Elijah Newren
2021-01-25 17:41 ` [PATCH 08/27] sparse-checkout: hold pattern list in index Derrick Stolee via GitGitGadget
2021-01-27 17:00 ` Elijah Newren
2021-01-28 13:12 ` Derrick Stolee
2021-01-25 17:41 ` [PATCH 09/27] sparse-index: convert from full to sparse Derrick Stolee via GitGitGadget
2021-01-27 17:30 ` Elijah Newren
2021-01-25 17:41 ` [PATCH 10/27] submodule: sparse-index should not collapse links Derrick Stolee via GitGitGadget
2021-01-25 17:41 ` [PATCH 11/27] unpack-trees: allow sparse directories Derrick Stolee via GitGitGadget
2021-01-27 17:36 ` Elijah Newren
2021-01-25 17:41 ` [PATCH 12/27] sparse-index: check index conversion happens Derrick Stolee via GitGitGadget
2021-01-27 17:46 ` Elijah Newren
2021-01-25 17:41 ` [PATCH 13/27] sparse-index: create extension for compatibility Derrick Stolee via GitGitGadget
2021-01-27 18:03 ` Elijah Newren
2021-01-25 17:42 ` [PATCH 14/27] sparse-checkout: toggle sparse index from builtin Derrick Stolee via GitGitGadget
2021-01-27 18:18 ` Elijah Newren
2021-01-28 15:26 ` Derrick Stolee
2021-01-25 17:42 ` [PATCH 15/27] [RFC-VERSION] *: ensure full index Derrick Stolee via GitGitGadget
2021-02-01 20:22 ` Elijah Newren
2021-02-01 21:10 ` Derrick Stolee
2021-01-25 17:42 ` [PATCH 16/27] unpack-trees: make sparse aware Derrick Stolee via GitGitGadget
2021-02-01 20:50 ` Elijah Newren
2021-02-09 17:23 ` Derrick Stolee
2021-01-25 17:42 ` [PATCH 17/27] dir.c: accept a directory as part of cone-mode patterns Derrick Stolee via GitGitGadget
2021-02-01 22:12 ` Elijah Newren
2021-01-25 17:42 ` [PATCH 18/27] status: use sparse-index throughout Derrick Stolee via GitGitGadget
2021-01-25 17:42 ` [PATCH 19/27] status: skip sparse-checkout percentage with sparse-index Derrick Stolee via GitGitGadget
2021-01-25 17:42 ` [PATCH 20/27] sparse-index: expand_to_path() trivial implementation Derrick Stolee via GitGitGadget
2021-01-25 17:42 ` [PATCH 21/27] sparse-index: expand_to_path no-op if path exists Derrick Stolee via GitGitGadget
2021-02-01 22:34 ` Elijah Newren
2021-01-25 17:42 ` [PATCH 22/27] add: allow operating on a sparse-only index Derrick Stolee via GitGitGadget
2021-02-01 23:08 ` Elijah Newren
2021-01-25 17:42 ` [PATCH 23/27] submodule: die_path_inside_submodule is sparse aware Derrick Stolee via GitGitGadget
2021-01-25 17:42 ` [PATCH 24/27] dir: use expand_to_path in add_patterns() Derrick Stolee via GitGitGadget
2021-02-01 23:21 ` Elijah Newren
2021-01-25 17:42 ` [PATCH 25/27] fsmonitor: disable if index is sparse Derrick Stolee via GitGitGadget
2021-01-25 17:42 ` [PATCH 26/27] pathspec: stop calling ensure_full_index Derrick Stolee via GitGitGadget
2021-02-01 23:24 ` Elijah Newren
2021-02-02 2:39 ` Derrick Stolee
2021-01-25 17:42 ` [PATCH 27/27] cache-tree: integrate with sparse directory entries Derrick Stolee via GitGitGadget
2021-02-01 23:54 ` Elijah Newren
2021-02-02 2:41 ` Derrick Stolee
2021-02-02 3:05 ` Elijah Newren
2021-01-25 20:10 ` [PATCH 00/27] [RFC] Sparse Index Junio C Hamano
2021-01-25 21:18 ` Derrick Stolee
2021-02-02 3:11 ` Elijah Newren
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=e1e2f2b75b2848e9b4c9cfc8fe89b11e6ad2b776.1611596534.git.gitgitgadget@gmail.com \
--to=gitgitgadget@gmail.com \
--cc=derrickstolee@github.com \
--cc=dstolee@microsoft.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=jrnieder@gmail.com \
--cc=newren@gmail.com \
--cc=pclouds@gmail.com \
--cc=peff@peff.net \
--cc=sunshine@sunshineco.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).