Re: [PATCH v2 4/5] backfill: add --sparse option
- From
Patrick Steinhardt <ps@pks.im>
- Date
- Jan 16, 2025, 10:01 UTC
- Message-ID
- <Z4jY4rELRYvS2gOk@pks.im>
- In-Reply-To
- <2723143afb397507cbc794375525c37497046dc2.1734712193.git.gitgitgadget@gmail.com>
On Fri, Dec 20, 2024 at 04:29:52PM +0000, Derrick Stolee via GitGitGadget wrote:
Show 30 quoted lines
> diff --git a/path-walk.c b/path-walk.c
> index 136ec08fb0e..c7456a9c1c0 100644
> --- a/path-walk.c
> +++ b/path-walk.c
> @@ -12,6 +12,7 @@
> #include "object.h"
> #include "oid-array.h"
> #include "prio-queue.h"
> +#include "repository.h"
> #include "revision.h"
> #include "string-list.h"
> #include "strmap.h"
> @@ -173,6 +174,23 @@ static int add_tree_entries(struct path_walk_context *ctx,
> if (type == OBJ_TREE)
> strbuf_addch(&path, '/');
>
> + if (ctx->info->pl) {
> + int dtype;
> + enum pattern_match_result match;
> + match = path_matches_pattern_list(path.buf, path.len,
> + path.buf + base_len, &dtype,
> + ctx->info->pl,
> + ctx->repo->index);
> +
> + if (ctx->info->pl->use_cone_patterns &&
> + match == NOT_MATCHED)
> + continue;
> + else if (!ctx->info->pl->use_cone_patterns &&
> + type == OBJ_BLOB &&
> + match != MATCHED)For my own understanding: is there as pecific reason why one of the branches uses `== NOT_MATCHED` whereas the other one uses `!= MATCHED`?
Show 22 quoted lines
> diff --git a/t/helper/test-path-walk.c b/t/helper/test-path-walk.c
> index 7f2d409c5bc..61e845e5ec2 100644
> --- a/t/helper/test-path-walk.c
> +++ b/t/helper/test-path-walk.c
> @@ -65,7 +67,7 @@ static int emit_block(const char *path, struct oid_array *oids,
>
> int cmd__path_walk(int argc, const char **argv)
> {
> - int res;
> + int res, stdin_pl = 0;
> struct rev_info revs = REV_INFO_INIT;
> struct path_walk_info info = PATH_WALK_INFO_INIT;
> struct path_walk_test_data data = { 0 };
> @@ -80,6 +82,8 @@ int cmd__path_walk(int argc, const char **argv)
> N_("toggle inclusion of tree objects")),
> OPT_BOOL(0, "prune", &info.prune_all_uninteresting,
> N_("toggle pruning of uninteresting paths")),
> + OPT_BOOL(0, "stdin-pl", &stdin_pl,
> + N_("read a pattern list over stdin")),
> OPT_END(),
> };
> I was about to suggest giving this a more descriptive name, as it might be confusing for anybody not intimately familiar with the code. But then I noticed that this is part of the test helper, only, so it doesn't matter as much. So feel free to ignore.
Patrick