From: "SZEDER Gábor" <szeder.dev@gmail.com>
To: Victoria Dye via GitGitGadget <gitgitgadget@gmail.com>
Cc: git@vger.kernel.org, gitster@pobox.com,
phillip.wood123@gmail.com, derrickstolee@github.com,
jonathantanmy@google.com, Victoria Dye <vdye@github.com>
Subject: Re: [PATCH 1/5] cache-tree: add perf test comparing update and prime
Date: Thu, 10 Nov 2022 08:23:42 +0100 [thread overview]
Message-ID: <20221110072342.GA1159673@szeder.dev> (raw)
In-Reply-To: <45c198c629da1627eabf0e63539f50aaa50381bf.1667947465.git.gitgitgadget@gmail.com>
On Tue, Nov 08, 2022 at 10:44:21PM +0000, Victoria Dye via GitGitGadget wrote:
> diff --git a/t/helper/test-cache-tree.c b/t/helper/test-cache-tree.c
> new file mode 100644
> index 00000000000..2fad6d06d30
> --- /dev/null
> +++ b/t/helper/test-cache-tree.c
> @@ -0,0 +1,52 @@
> +#include "test-tool.h"
> +#include "cache.h"
> +#include "tree.h"
> +#include "cache-tree.h"
> +#include "parse-options.h"
> +
> +static char const * const test_cache_tree_usage[] = {
> + N_("test-tool cache-tree <options> (prime|repair)"),
The code looking at 'argv[0]' below only handles "prime" and "update",
but not "repair".
> + NULL
> +};
> +
> +int cmd__cache_tree(int argc, const char **argv)
> +{
> + struct object_id oid;
> + struct tree *tree;
> + int fresh = 0;
> + int count = 1;
> + int i;
> +
> + struct option options[] = {
> + OPT_BOOL(0, "fresh", &fresh,
> + N_("clear the cache tree before each repetition")),
> + OPT_INTEGER_F(0, "count", &count, N_("number of times to repeat the operation"),
> + PARSE_OPT_NONEG),
> + OPT_END()
> + };
> +
> + setup_git_directory();
> +
> + parse_options(argc, argv, NULL, options, test_cache_tree_usage, 0);
Here 'argc' must be updated with the return value of parse_options(),
otherwise the 'if (!argc)' condition doesn't catch what it's supposed
to, and the subsequent 'else if' segfaults when passes the NULL
argv[0] to strcmp().
> +
> + if (read_cache() < 0)
> + die("unable to read index file");
> +
> + get_oid("HEAD", &oid);
> + tree = parse_tree_indirect(&oid);
> + for (i = 0; i < count; i++) {
> + if (fresh)
> + cache_tree_free(&the_index.cache_tree);
> +
> + if (!argc)
What if argc > 1?
> + die("Must specify subcommand");
I think it would be nice to show usage here ...
> + else if (!strcmp(argv[0], "prime"))
> + prime_cache_tree(the_repository, &the_index, tree);
> + else if (!strcmp(argv[0], "update"))
> + cache_tree_update(&the_index, WRITE_TREE_SILENT | WRITE_TREE_REPAIR);
> + else
> + die("Unknown command %s", argv[0]);
... and here as well.
> + }
> +
> + return 0;
> +}
next prev parent reply other threads:[~2022-11-10 7:25 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-08 22:44 [PATCH 0/5] Skip 'cache_tree_update()' when 'prime_cache_tree()' is called immediate after Victoria Dye via GitGitGadget
2022-11-08 22:44 ` [PATCH 1/5] cache-tree: add perf test comparing update and prime Victoria Dye via GitGitGadget
2022-11-10 7:23 ` SZEDER Gábor [this message]
2022-11-08 22:44 ` [PATCH 2/5] unpack-trees: add 'skip_cache_tree_update' option Victoria Dye via GitGitGadget
2022-11-08 22:44 ` [PATCH 3/5] reset: use " Victoria Dye via GitGitGadget
2022-11-08 22:44 ` [PATCH 4/5] read-tree: " Victoria Dye via GitGitGadget
2022-11-08 22:44 ` [PATCH 5/5] rebase: " Victoria Dye via GitGitGadget
2022-11-09 15:23 ` [PATCH 0/5] Skip 'cache_tree_update()' when 'prime_cache_tree()' is called immediate after Derrick Stolee
2022-11-09 22:18 ` Victoria Dye
2022-11-10 14:44 ` Derrick Stolee
2022-11-09 23:01 ` Taylor Blau
2022-11-10 1:57 ` [PATCH v2 " Victoria Dye via GitGitGadget
2022-11-10 1:57 ` [PATCH v2 1/5] cache-tree: add perf test comparing update and prime Victoria Dye via GitGitGadget
2022-11-10 1:57 ` [PATCH v2 2/5] unpack-trees: add 'skip_cache_tree_update' option Victoria Dye via GitGitGadget
2022-11-10 1:57 ` [PATCH v2 3/5] reset: use " Victoria Dye via GitGitGadget
2022-11-10 1:57 ` [PATCH v2 4/5] read-tree: " Victoria Dye via GitGitGadget
2022-11-10 1:57 ` [PATCH v2 5/5] rebase: " Victoria Dye via GitGitGadget
2022-11-10 14:40 ` Phillip Wood
2022-11-10 18:19 ` Victoria Dye
2022-11-10 2:12 ` [PATCH v2 0/5] Skip 'cache_tree_update()' when 'prime_cache_tree()' is called immediate after Taylor Blau
2022-11-10 17:26 ` Derrick Stolee
2022-11-10 19:06 ` [PATCH v3 " Victoria Dye via GitGitGadget
2022-11-10 19:06 ` [PATCH v3 1/5] cache-tree: add perf test comparing update and prime Victoria Dye via GitGitGadget
2022-11-10 19:06 ` [PATCH v3 2/5] unpack-trees: add 'skip_cache_tree_update' option Victoria Dye via GitGitGadget
2022-11-10 19:06 ` [PATCH v3 3/5] reset: use " Victoria Dye via GitGitGadget
2022-11-10 19:06 ` [PATCH v3 4/5] read-tree: " Victoria Dye via GitGitGadget
2022-11-10 19:06 ` [PATCH v3 5/5] rebase: " Victoria Dye via GitGitGadget
2022-11-10 19:50 ` [PATCH v3 0/5] Skip 'cache_tree_update()' when 'prime_cache_tree()' is called immediate after SZEDER Gábor
2022-11-10 20:54 ` Victoria Dye
2022-11-11 2:50 ` Taylor Blau
2022-11-14 0:08 ` Derrick Stolee
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
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20221110072342.GA1159673@szeder.dev \
--to=szeder.dev@gmail.com \
--cc=derrickstolee@github.com \
--cc=git@vger.kernel.org \
--cc=gitgitgadget@gmail.com \
--cc=gitster@pobox.com \
--cc=jonathantanmy@google.com \
--cc=phillip.wood123@gmail.com \
--cc=vdye@github.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.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
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 read-only IMAP folder(s) and NNTP newsgroup(s).