From: "Elijah Newren via GitGitGadget" <gitgitgadget@gmail.com>
To: git@vger.kernel.org
Cc: Derrick Stolee <derrickstolee@github.com>,
Elijah Newren <newren@gmail.com>,
Jacob Keller <jacob.keller@gmail.com>,
Jonathan Tan <jonathantanmy@google.com>,
Elijah Newren <newren@gmail.com>,
Elijah Newren <newren@gmail.com>
Subject: [PATCH v3 12/13] unpack-trees: special case read-tree debugging as internal usage
Date: Mon, 27 Feb 2023 15:28:19 +0000 [thread overview]
Message-ID: <ee36935adb5e2e3bb78b4bdf36809d9edb47d5ff.1677511700.git.gitgitgadget@gmail.com> (raw)
In-Reply-To: <pull.1149.v3.git.1677511700.gitgitgadget@gmail.com>
From: Elijah Newren <newren@gmail.com>
builtin/read-tree.c has some special functionality explicitly designed
for debugging unpack-trees.[ch]. Associated with that is two fields
that no other external caller would or should use. Mark these as
internal to unpack-trees, but allow builtin/read-tree to read or write
them for this special case.
Signed-off-by: Elijah Newren <newren@gmail.com>
---
builtin/read-tree.c | 10 +++++-----
unpack-trees.c | 22 +++++++++++-----------
unpack-trees.h | 6 +++---
3 files changed, 19 insertions(+), 19 deletions(-)
diff --git a/builtin/read-tree.c b/builtin/read-tree.c
index 3ce75417833..6034408d486 100644
--- a/builtin/read-tree.c
+++ b/builtin/read-tree.c
@@ -87,9 +87,9 @@ static int debug_merge(const struct cache_entry * const *stages,
{
int i;
- printf("* %d-way merge\n", o->merge_size);
+ printf("* %d-way merge\n", o->internal.merge_size);
debug_stage("index", stages[0], o);
- for (i = 1; i <= o->merge_size; i++) {
+ for (i = 1; i <= o->internal.merge_size; i++) {
char buf[24];
xsnprintf(buf, sizeof(buf), "ent#%d", i);
debug_stage(buf, stages[i], o);
@@ -144,7 +144,7 @@ int cmd_read_tree(int argc, const char **argv, const char *cmd_prefix)
OPT__DRY_RUN(&opts.dry_run, N_("don't update the index or the work tree")),
OPT_BOOL(0, "no-sparse-checkout", &opts.skip_sparse_checkout,
N_("skip applying sparse checkout filter")),
- OPT_BOOL(0, "debug-unpack", &opts.debug_unpack,
+ OPT_BOOL(0, "debug-unpack", &opts.internal.debug_unpack,
N_("debug unpack-trees")),
OPT_CALLBACK_F(0, "recurse-submodules", NULL,
"checkout", "control recursive updating of submodules",
@@ -247,7 +247,7 @@ int cmd_read_tree(int argc, const char **argv, const char *cmd_prefix)
opts.head_idx = 1;
}
- if (opts.debug_unpack)
+ if (opts.internal.debug_unpack)
opts.fn = debug_merge;
/* If we're going to prime_cache_tree later, skip cache tree update */
@@ -263,7 +263,7 @@ int cmd_read_tree(int argc, const char **argv, const char *cmd_prefix)
if (unpack_trees(nr_trees, t, &opts))
return 128;
- if (opts.debug_unpack || opts.dry_run)
+ if (opts.internal.debug_unpack || opts.dry_run)
return 0; /* do not write the index out */
/*
diff --git a/unpack-trees.c b/unpack-trees.c
index cac5dd0da37..3e5f4bd2355 100644
--- a/unpack-trees.c
+++ b/unpack-trees.c
@@ -839,7 +839,7 @@ static int traverse_by_cache_tree(int pos, int nr_entries, int nr_names,
mark_ce_used(src[0], o);
}
free(tree_ce);
- if (o->debug_unpack)
+ if (o->internal.debug_unpack)
printf("Unpacked %d entries from %s to %s using cache-tree\n",
nr_entries,
o->src_index->cache[pos]->name,
@@ -1488,7 +1488,7 @@ static int unpack_callback(int n, unsigned long mask, unsigned long dirmask, str
while (!p->mode)
p++;
- if (o->debug_unpack)
+ if (o->internal.debug_unpack)
debug_unpack_callback(n, mask, dirmask, names, info);
/* Are we supposed to look at the index too? */
@@ -1929,7 +1929,7 @@ int unpack_trees(unsigned len, struct tree_desc *t, struct unpack_trees_options
init_split_index(&o->internal.result);
}
oidcpy(&o->internal.result.oid, &o->src_index->oid);
- o->merge_size = len;
+ o->internal.merge_size = len;
mark_all_ce_unused(o->src_index);
o->internal.result.fsmonitor_last_update =
@@ -2882,9 +2882,9 @@ int twoway_merge(const struct cache_entry * const *src,
const struct cache_entry *oldtree = src[1];
const struct cache_entry *newtree = src[2];
- if (o->merge_size != 2)
+ if (o->internal.merge_size != 2)
return error("Cannot do a twoway merge of %d trees",
- o->merge_size);
+ o->internal.merge_size);
if (oldtree == o->df_conflict_entry)
oldtree = NULL;
@@ -2964,9 +2964,9 @@ int bind_merge(const struct cache_entry * const *src,
const struct cache_entry *old = src[0];
const struct cache_entry *a = src[1];
- if (o->merge_size != 1)
+ if (o->internal.merge_size != 1)
return error("Cannot do a bind merge of %d trees",
- o->merge_size);
+ o->internal.merge_size);
if (a && old)
return o->quiet ? -1 :
error(ERRORMSG(o, ERROR_BIND_OVERLAP),
@@ -2990,9 +2990,9 @@ int oneway_merge(const struct cache_entry * const *src,
const struct cache_entry *old = src[0];
const struct cache_entry *a = src[1];
- if (o->merge_size != 1)
+ if (o->internal.merge_size != 1)
return error("Cannot do a oneway merge of %d trees",
- o->merge_size);
+ o->internal.merge_size);
if (!a || a == o->df_conflict_entry)
return deleted_entry(old, old, o);
@@ -3027,8 +3027,8 @@ int stash_worktree_untracked_merge(const struct cache_entry * const *src,
const struct cache_entry *worktree = src[1];
const struct cache_entry *untracked = src[2];
- if (o->merge_size != 2)
- BUG("invalid merge_size: %d", o->merge_size);
+ if (o->internal.merge_size != 2)
+ BUG("invalid merge_size: %d", o->internal.merge_size);
if (worktree && untracked)
return error(_("worktree and untracked commit have duplicate entries: %s"),
diff --git a/unpack-trees.h b/unpack-trees.h
index 0335c89bc75..e8737adfeda 100644
--- a/unpack-trees.h
+++ b/unpack-trees.h
@@ -65,7 +65,6 @@ struct unpack_trees_options {
skip_unmerged,
initial_checkout,
diff_index_cached,
- debug_unpack,
skip_sparse_checkout,
quiet,
exiting_early,
@@ -78,7 +77,6 @@ struct unpack_trees_options {
merge_fn_t fn;
int head_idx;
- int merge_size;
struct cache_entry *df_conflict_entry;
void *unpack_data;
@@ -90,8 +88,10 @@ struct unpack_trees_options {
struct unpack_trees_options_internal {
unsigned int nontrivial_merge,
- show_all_errors;
+ show_all_errors,
+ debug_unpack; /* used by read-tree debugging */
+ int merge_size; /* used by read-tree debugging */
int cache_bottom;
const char *msgs[NB_UNPACK_TREES_WARNING_TYPES];
struct strvec msgs_to_free;
--
gitgitgadget
next prev parent reply other threads:[~2023-02-27 15:29 UTC|newest]
Thread overview: 57+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-23 9:14 [PATCH 00/11] Clarify API for dir.[ch] and unpack-trees.[ch] -- mark relevant fields as internal Elijah Newren via GitGitGadget
2023-02-23 9:14 ` [PATCH 01/11] dir: separate public from internal portion of dir_struct Elijah Newren via GitGitGadget
2023-02-23 9:14 ` [PATCH 02/11] dir: add a usage note to exclude_per_dir Elijah Newren via GitGitGadget
2023-02-24 22:31 ` Jonathan Tan
2023-02-25 0:23 ` Elijah Newren
2023-02-25 1:54 ` Jonathan Tan
2023-02-25 3:23 ` Elijah Newren
2023-02-23 9:14 ` [PATCH 03/11] dir: mark output only fields of dir_struct as such Elijah Newren via GitGitGadget
2023-02-23 9:14 ` [PATCH 04/11] unpack-trees: clean up some flow control Elijah Newren via GitGitGadget
2023-02-24 22:33 ` Jonathan Tan
2023-02-23 9:14 ` [PATCH 05/11] sparse-checkout: avoid using internal API of unpack-trees Elijah Newren via GitGitGadget
2023-02-24 22:37 ` Jonathan Tan
2023-02-25 0:33 ` Elijah Newren
2023-02-23 9:14 ` [PATCH 06/11] sparse-checkout: avoid using internal API of unpack-trees, take 2 Elijah Newren via GitGitGadget
2023-02-24 23:22 ` Jonathan Tan
2023-02-25 0:40 ` Elijah Newren
2023-02-23 9:14 ` [PATCH 07/11] unpack_trees: start splitting internal fields from public API Elijah Newren via GitGitGadget
2023-02-23 9:14 ` [PATCH 08/11] unpack-trees: mark fields only used internally as internal Elijah Newren via GitGitGadget
2023-02-23 9:14 ` [PATCH 09/11] unpack-trees: rewrap a few overlong lines from previous patch Elijah Newren via GitGitGadget
2023-02-23 9:14 ` [PATCH 10/11] unpack-trees: special case read-tree debugging as internal usage Elijah Newren via GitGitGadget
2023-02-23 9:15 ` [PATCH 11/11] unpack-trees: add usage notices around df_conflict_entry Elijah Newren via GitGitGadget
2023-02-23 15:18 ` [PATCH 00/11] Clarify API for dir.[ch] and unpack-trees.[ch] -- mark relevant fields as internal Derrick Stolee
2023-02-23 15:26 ` Derrick Stolee
2023-02-23 20:35 ` Elijah Newren
2023-02-23 20:31 ` Elijah Newren
2023-02-24 1:24 ` Junio C Hamano
2023-02-24 5:54 ` Jacob Keller
2023-02-24 23:36 ` Jonathan Tan
2023-02-25 2:25 ` [PATCH v2 " Elijah Newren via GitGitGadget
2023-02-25 2:25 ` [PATCH v2 01/11] dir: separate public from internal portion of dir_struct Elijah Newren via GitGitGadget
2023-02-25 2:25 ` [PATCH v2 02/11] dir: add a usage note to exclude_per_dir Elijah Newren via GitGitGadget
2023-02-25 2:25 ` [PATCH v2 03/11] dir: mark output only fields of dir_struct as such Elijah Newren via GitGitGadget
2023-02-25 2:25 ` [PATCH v2 04/11] unpack-trees: clean up some flow control Elijah Newren via GitGitGadget
2023-02-25 2:25 ` [PATCH v2 05/11] sparse-checkout: avoid using internal API of unpack-trees Elijah Newren via GitGitGadget
2023-02-25 2:25 ` [PATCH v2 06/11] sparse-checkout: avoid using internal API of unpack-trees, take 2 Elijah Newren via GitGitGadget
2023-02-25 2:25 ` [PATCH v2 07/11] unpack_trees: start splitting internal fields from public API Elijah Newren via GitGitGadget
2023-02-25 2:25 ` [PATCH v2 08/11] unpack-trees: mark fields only used internally as internal Elijah Newren via GitGitGadget
2023-02-25 2:25 ` [PATCH v2 09/11] unpack-trees: rewrap a few overlong lines from previous patch Elijah Newren via GitGitGadget
2023-02-25 2:25 ` [PATCH v2 10/11] unpack-trees: special case read-tree debugging as internal usage Elijah Newren via GitGitGadget
2023-02-25 2:26 ` [PATCH v2 11/11] unpack-trees: add usage notices around df_conflict_entry Elijah Newren via GitGitGadget
2023-02-25 23:30 ` [PATCH v2 00/11] Clarify API for dir.[ch] and unpack-trees.[ch] -- mark relevant fields as internal Junio C Hamano
2023-02-27 15:28 ` [PATCH v3 00/13] " Elijah Newren via GitGitGadget
2023-02-27 15:28 ` [PATCH v3 01/13] t2021: fix platform-specific leftover cruft Elijah Newren via GitGitGadget
2023-02-27 19:11 ` Derrick Stolee
2023-02-27 15:28 ` [PATCH v3 02/13] unpack-trees: heed requests to overwrite ignored files Elijah Newren via GitGitGadget
2023-02-27 23:20 ` Jonathan Tan
2023-02-27 15:28 ` [PATCH v3 03/13] dir: separate public from internal portion of dir_struct Elijah Newren via GitGitGadget
2023-02-27 15:28 ` [PATCH v3 04/13] dir: add a usage note to exclude_per_dir Elijah Newren via GitGitGadget
2023-02-27 15:28 ` [PATCH v3 05/13] dir: mark output only fields of dir_struct as such Elijah Newren via GitGitGadget
2023-02-27 15:28 ` [PATCH v3 06/13] unpack-trees: clean up some flow control Elijah Newren via GitGitGadget
2023-02-27 15:28 ` [PATCH v3 07/13] sparse-checkout: avoid using internal API of unpack-trees Elijah Newren via GitGitGadget
2023-02-27 15:28 ` [PATCH v3 08/13] sparse-checkout: avoid using internal API of unpack-trees, take 2 Elijah Newren via GitGitGadget
2023-02-27 15:28 ` [PATCH v3 09/13] unpack_trees: start splitting internal fields from public API Elijah Newren via GitGitGadget
2023-02-27 15:28 ` [PATCH v3 10/13] unpack-trees: mark fields only used internally as internal Elijah Newren via GitGitGadget
2023-02-27 15:28 ` [PATCH v3 11/13] unpack-trees: rewrap a few overlong lines from previous patch Elijah Newren via GitGitGadget
2023-02-27 15:28 ` Elijah Newren via GitGitGadget [this message]
2023-02-27 15:28 ` [PATCH v3 13/13] unpack-trees: add usage notices around df_conflict_entry Elijah Newren via GitGitGadget
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=ee36935adb5e2e3bb78b4bdf36809d9edb47d5ff.1677511700.git.gitgitgadget@gmail.com \
--to=gitgitgadget@gmail.com \
--cc=derrickstolee@github.com \
--cc=git@vger.kernel.org \
--cc=jacob.keller@gmail.com \
--cc=jonathantanmy@google.com \
--cc=newren@gmail.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).