tree: stop using the_repository
cover tree: stop using the_repository
The tree parsing functions use the_repository internally. Add variants that allow using arbitrary repositories. Fix callers one by one for which had USE_THE_REPOSITORY_VARIABLE removed despite this implicit usage and convert the rest mechanically.
environment: move access to core.maxTreeDepth into repo settings
tree: add repo_parse_tree*()
add-interactive: use repo_parse_tree_indirect()
bloom: use repo_parse_tree()
delta-islands: use repo_parse_tree()
pack-bitmap-write: use repo_parse_tree()
path-walk: use repo_parse_tree_gently()
tree: use repo_parse_tree()
tree: stop using the_repository
cocci: convert parse_tree functions to repo_ variants
add-interactive.c | 2 +- archive.c | 2 +- bloom.c | 2 +- builtin/am.c | 10 ++++----- builtin/checkout.c | 12 +++++----- builtin/clone.c | 4 ++-- builtin/commit.c | 5 +++-- builtin/diff-tree.c | 2 +- builtin/ls-tree.c | 2 +- builtin/merge-tree.c | 9 +++++--- builtin/merge.c | 8 +++---- builtin/read-tree.c | 4 ++-- builtin/reset.c | 4 ++-- builtin/stash.c | 8 +++---- cache-tree.c | 2 +- contrib/coccinelle/the_repository.cocci | 10 +++++++++ delta-islands.c | 2 +- diff-lib.c | 2 +- environment.c | 29 ------------------------- environment.h | 1 - fsck.c | 2 +- git-compat-util.h | 24 ++++++++++++++++++++ http-push.c | 2 +- list-objects.c | 4 ++-- merge-ort.c | 13 ++++++----- merge.c | 6 ++--- pack-bitmap-write.c | 2 +- path-walk.c | 2 +- read-cache.c | 2 +- repo-settings.c | 3 +++ repo-settings.h | 3 +++ reset.c | 2 +- revision.c | 4 ++-- sequencer.c | 4 ++-- t/helper/test-cache-tree.c | 2 +- t/helper/test-match-trees.c | 4 ++-- tree-diff.c | 2 +- tree-walk.c | 4 +++- tree.c | 16 ++++++-------- tree.h | 13 +++++++---- walker.c | 2 +- 41 files changed, 129 insertions(+), 107 deletions(-)
Signature · 1 line
2.52.0
PATCH 1/10 environment: move access to core.maxTreeDepth into repo settings
The config setting core.maxTreeDepth is stored in a global variable and populated by the function git_default_core_config. This won't work if we need to access multiple repositories with different values of that setting in the same process. Store the setting in struct repo_settings instead and track it separately for each repository.
--- environment.c | 29 ----------------------------- environment.h | 1 - git-compat-util.h | 24 ++++++++++++++++++++++++ list-objects.c | 2 +- repo-settings.c | 3 +++ repo-settings.h | 3 +++ tree-diff.c | 2 +- tree-walk.c | 4 +++- tree.c | 2 +- 9 files changed, 36 insertions(+), 34 deletions(-)
environment.c +0 -29
@@ -80,30 +80,6 @@ int core_sparse_checkout_cone;int sparse_expect_files_outside_of_patterns;int precomposed_unicode =-1 ;/* see probe_utf8_pathname_composition() */ unsigned long pack_size_limit_cfg; -int max_allowed_tree_depth = -#ifdef _MSC_VER -/* -* When traversing into too-deep trees, Visual C-compiled Git seems to -* run into some internal stack overflow detection in the -* `RtlpAllocateHeap()` function that is called from within -* `git_inflate_init()`'s call tree. The following value seems to be -* low enough to avoid that by letting Git exit with an error before -* the stack overflow can occur. -*/ -512 ; -#elif defined(GIT_WINDOWS_NATIVE ) && defined(__clang__) && defined(__aarch64__) -/* -* Similar to Visual C, it seems that on Windows/ARM64 the clang-based -* builds have a smaller stack space available. When running out of -* that stack space, a `STATUS_STACK_OVERFLOW` is produced. When the -* Git command was run from an MSYS2 Bash, this unfortunately results -* in an exit code 127. Let's prevent that by lowering the maximal -* tree depth; This value seems to be low enough. -*/ -1280 ; -#else -2048 ; -#endif #ifndef PROTECT_HFS_DEFAULT #define PROTECT_HFS_DEFAULT 0
@@ -569,11 +545,6 @@ static int git_default_core_config(const char *var, const char *value,return 0 ; } -if (!strcmp (var,"core.maxtreedepth" )) { - max_allowed_tree_depth =git_config_int (var, value, ctx->kvi); -return 0 ; - } -/* Add other config variables here and to Documentation/config.adoc. */ return platform_core_config (var, value, ctx, cb); }
environment.h +0 -1
@@ -156,7 +156,6 @@ extern char *git_attributes_file;extern int zlib_compression_level;extern int pack_compression_level;extern unsigned long pack_size_limit_cfg; -extern int max_allowed_tree_depth;extern int precomposed_unicode;extern int protect_hfs;
git-compat-util.h +24 -0
@@ -578,6 +578,30 @@ static inline bool strip_suffix(const char *str, const char *suffix,#define DEFAULT_PACKED_GIT_LIMIT \ ((1024L * 1024L) * (size_t)(sizeof(void*) >= 8 ? (32 * 1024L * 1024L) : 256)) +#ifdef _MSC_VER +/* +* When traversing into too-deep trees, Visual C-compiled Git seems to +* run into some internal stack overflow detection in the +* `RtlpAllocateHeap()` function that is called from within +* `git_inflate_init()`'s call tree. The following value seems to be +* low enough to avoid that by letting Git exit with an error before +* the stack overflow can occur. +*/ +#define DEFAULT_MAX_ALLOWED_TREE_DEPTH 512 +#elif defined(GIT_WINDOWS_NATIVE ) && defined(__clang__) && defined(__aarch64__) +/* +* Similar to Visual C, it seems that on Windows/ARM64 the clang-based +* builds have a smaller stack space available. When running out of +* that stack space, a `STATUS_STACK_OVERFLOW` is produced. When the +* Git command was run from an MSYS2 Bash, this unfortunately results +* in an exit code 127. Let's prevent that by lowering the maximal +* tree depth; This value seems to be low enough. +*/ +#define DEFAULT_MAX_ALLOWED_TREE_DEPTH 1280 +#else +#define DEFAULT_MAX_ALLOWED_TREE_DEPTH 2048 +#endif +int git_open_cloexec (const char *name,int flags);#define git_open (name) git_open_cloexec(name, O_RDONLY)
list-objects.c +1 -1
@@ -167,7 +167,7 @@ static void process_tree(struct traversal_context *ctx, !revs->include_check_obj(&tree->object, revs->include_check_data)) return; -if (ctx->depth > max_allowed_tree_depth) +if (ctx->depth > revs->repo->settings.max_allowed_tree_depth)die ("exceeded maximum allowed tree depth" ); failed_parse =parse_tree_gently (tree,1 );
repo-settings.c +3 -0
@@ -100,6 +100,9 @@ void prepare_repo_settings(struct repository *r)*/ if (!repo_config_get_int (r,"index.version" , &value)) r->settings.index_version = value; +repo_cfg_int (r,"core.maxtreedepth" , + &r->settings.max_allowed_tree_depth, +DEFAULT_MAX_ALLOWED_TREE_DEPTH );if (!repo_config_get_string_tmp (r,"core.untrackedcache" , &strval)) {int v =git_parse_maybe_bool (strval);
repo-settings.h +3 -0
@@ -67,6 +67,8 @@ struct repo_settings {size_t packed_git_limit;unsigned long big_file_threshold; +int max_allowed_tree_depth; +char *hooks_path; };#define REPO_SETTINGS_INIT { \
@@ -78,6 +80,7 @@ struct repo_settings { .delta_base_cache_limit = DEFAULT_DELTA_BASE_CACHE_LIMIT, \ .packed_git_window_size = DEFAULT_PACKED_GIT_WINDOW_SIZE, \ .packed_git_limit = DEFAULT_PACKED_GIT_LIMIT, \ + .max_allowed_tree_depth = DEFAULT_MAX_ALLOWED_TREE_DEPTH, \ }void prepare_repo_settings (struct repository *r);
tree-diff.c +1 -1
@@ -439,7 +439,7 @@ static void ll_diff_tree_paths(void *ttree, **tptree;int i; -if (depth > max_allowed_tree_depth) +if (depth > opt->repo->settings.max_allowed_tree_depth)die ("exceeded maximum allowed tree depth" );FAST_ARRAY_ALLOC (tp, nparent);
tree-walk.c +3 -1
@@ -12,6 +12,7 @@#include "pathspec.h" #include "json-writer.h" #include "environment.h" +#include "read-cache-ll.h" static int decode_tree_entry (struct tree_desc *desc,const char *buf,unsigned long size,struct strbuf *err) {
@@ -441,8 +442,9 @@ int traverse_trees(struct index_state *istate,struct strbuf base =STRBUF_INIT ;int interesting =1 ;char *traverse_path; +struct repository *r = istate ? istate->repo : the_repository; -if (traverse_trees_cur_depth > max_allowed_tree_depth) +if (traverse_trees_cur_depth > r->settings.max_allowed_tree_depth)return error ("exceeded maximum allowed tree depth" ); traverse_trees_count++;
tree.c +1 -1
@@ -25,7 +25,7 @@ int read_tree_at(struct repository *r,int len, oldlen = base->len;enum interesting retval = entry_not_interesting; -if (depth > max_allowed_tree_depth) +if (depth > r->settings.max_allowed_tree_depth)return error ("exceeded maximum allowed tree depth" );if (parse_tree (tree))
Signature · 1 line
2.52.0
Re: [PATCH 01/10] environment: move access to core.maxTreeDepth into repo settings
Quoted 25 lines · René Scharfe
git-compat-util.h +17
-0@@ -578,6 +578,30 @@ static inline bool strip_suffix(const char *str, const char *suffix,#define DEFAULT_PACKED_GIT_LIMIT \ ((1024L * 1024L) * (size_t)(sizeof(void*) >= 8 ? (32 * 1024L * 1024L) : 256)) +#ifdef _MSC_VER +/* +* When traversing into too-deep trees, Visual C-compiled Git seems to +* run into some internal stack overflow detection in the +* `RtlpAllocateHeap()` function that is called from within +* `git_inflate_init()`'s call tree. The following value seems to be +* low enough to avoid that by letting Git exit with an error before +* the stack overflow can occur. +*/ +#define DEFAULT_MAX_ALLOWED_TREE_DEPTH 512 +#elif defined(GIT_WINDOWS_NATIVE ) && defined(__clang__) && defined(__aarch64__) +/* +* Similar to Visual C, it seems that on Windows/ARM64 the clang-based +* builds have a smaller stack space available. When running out of +* that stack space, a `STATUS_STACK_OVERFLOW` is produced. When the +* Git command was run from an MSYS2 Bash, this unfortunately results +* in an exit code 127. Let's prevent that by lowering the maximal
git-compat-util.h static inline bool strip_suffix(const char *str, const char *suffix, · line 607
Quoted 10 lines
git-compat-util.h +7
-0+* tree depth; This value seems to be low enough. +*/ +#define DEFAULT_MAX_ALLOWED_TREE_DEPTH 1280 +#else +#define DEFAULT_MAX_ALLOWED_TREE_DEPTH 2048 +#endif +int git_open_cloexec (const char *name,int flags);#define git_open (name) git_open_cloexec(name, O_RDONLY)
Why is this new constant defined in "git-compat-util.h"? That feels way too global for my taste for a value that should ultimately only be required by "repo-settings.c". Is there a reason why it's not declared in "repo-settings.h"?
I think we could even get away with declaring it in "repo-settings.c". The expectation is that the settings need to be prepared anyway, so we can simply set up the default when parsing the config.
Patrick
Re: [PATCH 01/10] environment: move access to core.maxTreeDepth into repo settings
Quoted 30 lines · Patrick Steinhardt
Quoted 29 lines · René Scharfe
git-compat-util.h +21
-0@@ -578,6 +578,30 @@ static inline bool strip_suffix(const char *str, const char *suffix,#define DEFAULT_PACKED_GIT_LIMIT \ ((1024L * 1024L) * (size_t)(sizeof(void*) >= 8 ? (32 * 1024L * 1024L) : 256)) +#ifdef _MSC_VER +/* +* When traversing into too-deep trees, Visual C-compiled Git seems to +* run into some internal stack overflow detection in the +* `RtlpAllocateHeap()` function that is called from within +* `git_inflate_init()`'s call tree. The following value seems to be +* low enough to avoid that by letting Git exit with an error before +* the stack overflow can occur. +*/ +#define DEFAULT_MAX_ALLOWED_TREE_DEPTH 512 +#elif defined(GIT_WINDOWS_NATIVE ) && defined(__clang__) && defined(__aarch64__) +/* +* Similar to Visual C, it seems that on Windows/ARM64 the clang-based +* builds have a smaller stack space available. When running out of +* that stack space, a `STATUS_STACK_OVERFLOW` is produced. When the +* Git command was run from an MSYS2 Bash, this unfortunately results +* in an exit code 127. Let's prevent that by lowering the maximal +* tree depth; This value seems to be low enough. +*/ +#define DEFAULT_MAX_ALLOWED_TREE_DEPTH 1280 +#else
Quoted 8 lines
git-compat-util.h static inline bool strip_suffix(const char *str, const char *suffix, · line 607
Quoted 6 lines
git-compat-util.h +3
-0+#define DEFAULT_MAX_ALLOWED_TREE_DEPTH 2048 +#endif +int git_open_cloexec (const char *name,int flags);#define git_open (name) git_open_cloexec(name, O_RDONLY)Why is this new constant defined in "
git-compat-util.h"?
No particular reason, I just put it next to the existing similar macros DEFAULT_PACKED_GIT_WINDOW_SIZE and DEFAULT_PACKED_GIT_LIMIT.
Quoted 4 lines
That feels way
too global for my taste for a value that should ultimately only be required by "repo-settings.c". Is there a reason why it's not declared in "repo-settings.h"?
No. The same goes for the above two, I guess. Or they could go to packfile.h and DEFAULT_MAX_ALLOWED_TREE_DEPTH to tree.h.
Quoted 3 lines
I think we could even get away with declaring it in "
repo-settings.c". The expectation is that the settings need to be prepared anyway, so we can simply set up the default when parsing the config.
True, REPO_SETTINGS_INIT is the only user of DEFAULT_MAX_ALLOWED_TREE_DEPTH outside of repo-settings.c and is itself only referenced there, so we could make it private, or even inline it to its only user, repo_settings_clear().
René
PATCH 2/10 tree: add repo_parse_tree*()
In reply to René ScharfeAdd variants of parse_tree(), parse_tree_gently() and parse_tree_indirect() that allow using an arbitrary repository.
--- tree.c | 16 +++++++++++++--- tree.h | 8 ++++++++ 2 files changed, 21 insertions(+), 3 deletions(-)
tree.c +13 -3
@@ -186,6 +186,12 @@ int parse_tree_buffer(struct tree *item, void *buffer, unsigned long size) }int parse_tree_gently (struct tree *item,int quiet_on_missing) +{ +return repo_parse_tree_gently (the_repository, item, quiet_on_missing); +} + +int repo_parse_tree_gently (struct repository *r,struct tree *item, +int quiet_on_missing) {enum object_type type;void *buffer;
@@ -193,8 +199,7 @@ int parse_tree_gently(struct tree *item, int quiet_on_missing)if (item->object.parsed)return 0 ; - buffer =odb_read_object (the_repository->objects, &item->object.oid, - &type, &size); + buffer =odb_read_object (r->objects, &item->object.oid, &type, &size);if (!buffer)return quiet_on_missing ?-1 : error("Could not read %s",
@@ -216,7 +221,12 @@ void free_tree_buffer(struct tree *tree)struct tree *parse_tree_indirect (const struct object_id *oid) { -struct repository *r = the_repository; +return repo_parse_tree_indirect (the_repository, oid); +} + +struct tree *repo_parse_tree_indirect (struct repository *r, +const struct object_id *oid) +{struct object *obj =parse_object (r, oid);return (struct tree *)repo_peel_to_type (r,NULL ,0 , obj,OBJ_TREE ); }
tree.h +8 -0
@@ -20,14 +20,22 @@ struct tree *lookup_tree(struct repository *r, const struct object_id *oid);int parse_tree_buffer (struct tree *item,void *buffer,unsigned long size);int parse_tree_gently (struct tree *tree,int quiet_on_missing); +int repo_parse_tree_gently (struct repository *r,struct tree *item, +int quiet_on_missing);static inline int parse_tree (struct tree *tree) {return parse_tree_gently (tree,0 ); } +static inline int repo_parse_tree (struct repository *r,struct tree *item) +{ +return repo_parse_tree_gently (r, item,0 ); +}void free_tree_buffer (struct tree *tree);/* Parses and returns the tree in the given ent, chasing tags and commits. */ struct tree *parse_tree_indirect (const struct object_id *oid); +struct tree *repo_parse_tree_indirect (struct repository *r, +const struct object_id *oid);/* * Functions for comparing pathnames
Signature · 1 line
2.52.0
PATCH 3/10 add-interactive: use repo_parse_tree_indirect()
In reply to René Scharfe1b374ad71f (add-interactive: stop using the_repository, 2024-12-17) replaced explicit uses of the_repository. parse_tree_indirect() uses it internally, though, so call repo_parse_tree_indirect() instead and hand it the correct repository.
--- add-interactive.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
add-interactive.c +1 -1
@@ -840,7 +840,7 @@ static int run_revert(struct add_i_state *s, const struct pathspec *ps,if (is_initial)oidcpy (&oid, s->r->hash_algo->empty_tree);else { - tree =parse_tree_indirect (&oid); + tree =repo_parse_tree_indirect (s->r, &oid);if (!tree) { res =error (_ ("Could not parse HEAD^{tree}" )); goto finish_revert;
Signature · 1 line
2.52.0
PATCH 4/10 bloom: use repo_parse_tree()
In reply to René ScharfeUse the passed in repository instead of the implicit the_repository when parsing the tree.
--- bloom.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
bloom.c +1 -1
@@ -354,7 +354,7 @@ static void init_truncated_large_filter(struct bloom_filter *filter,static int has_entries_with_high_bit (struct repository *r,struct tree *t) { -if (parse_tree (t)) +if (repo_parse_tree (r, t))return 1 ;if (!(t->object.flags &VISITED )) {
Signature · 1 line
2.52.0
PATCH 5/10 delta-islands: use repo_parse_tree()
In reply to René Scharfe19be71db9c (delta-islands: stop depending on the_repository, 2025-03-10) replaced explicit uses of the_repository. parse_tree() uses it internally, though, so call repo_parse_tree() instead and hand it the correct repository.
--- delta-islands.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
delta-islands.c +1 -1
@@ -283,7 +283,7 @@ void resolve_tree_islands(struct repository *r, root_marks =kh_value (island_marks, pos); tree =lookup_tree (r, &ent->idx.oid); -if (!tree ||parse_tree (tree) <0 ) +if (!tree ||repo_parse_tree (r, tree) <0 )die (_ ("bad tree object %s" ),oid_to_hex (&ent->idx.oid));init_tree_desc (&desc, &tree->object.oid, tree->buffer, tree->size);
Signature · 1 line
2.52.0
PATCH 6/10 pack-bitmap-write: use repo_parse_tree()
In reply to René Scharfe1a6768d1dd (pack-bitmap-write: stop depending on the_repository, 2025-03-10) replaced explicit uses of the_repository. parse_tree() uses it internally, though, so call repo_parse_tree() instead and hand it the correct repository.
--- pack-bitmap-write.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
pack-bitmap-write.c +1 -1
@@ -478,7 +478,7 @@ static int fill_bitmap_tree(struct bitmap_writer *writer,return 0 ;bitmap_set (bitmap, pos); -if (parse_tree (tree) <0 ) +if (repo_parse_tree (writer->repo, tree) <0 )die ("unable to load tree object %s" ,oid_to_hex (&tree->object.oid));init_tree_desc (&desc, &tree->object.oid, tree->buffer, tree->size);
Signature · 1 line
2.52.0
PATCH 7/10 path-walk: use repo_parse_tree_gently()
In reply to René ScharfeUse the passed in repository instead of the implicit the_repository when parsing the tree.
--- path-walk.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
path-walk.c +1 -1
@@ -137,7 +137,7 @@ static int add_tree_entries(struct path_walk_context *ctx,error (_ ("failed to walk children of tree %s: not found" ),oid_to_hex (oid));return -1 ; - }else if (parse_tree_gently (tree,1 )) { + }else if (repo_parse_tree_gently (ctx->repo, tree,1 )) {error ("bad tree object %s" ,oid_to_hex (oid));return -1 ; }
Signature · 1 line
2.52.0
PATCH 8/10 tree: use repo_parse_tree()
In reply to René Scharfee092073d64 (tree.c: make read_tree*() take 'struct repository *', 2018-11-18) replaced explicit uses of the_repository. parse_tree() uses it internally, though, so call repo_parse_tree() instead and hand it the correct repository.
--- tree.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tree.c +1 -1
@@ -28,7 +28,7 @@ int read_tree_at(struct repository *r,if (depth > r->settings.max_allowed_tree_depth)return error ("exceeded maximum allowed tree depth" ); -if (parse_tree (tree)) +if (repo_parse_tree (r, tree))return -1 ;init_tree_desc (&desc, &tree->object.oid, tree->buffer, tree->size);
Signature · 1 line
2.52.0
Re: [PATCH 08/10] tree: use repo_parse_tree()
Quoted 4 lines · René Scharfe
e092073d64(tree.c: make read_tree*() take 'struct repository *', 2018-11-18) replaced explicit uses ofthe_repository.parse_tree()uses it internally, though, so callrepo_parse_tree()instead and hand it the correct repository.
All of the conversions in preceding commits were trivial, so I feel like they could've just been squashed together. Please feel free to ignore this suggestion though.
Patrick
PATCH 9/10 tree: stop using the_repository
In reply to René ScharfePush the use of the_repository to the remaining callers by turning the compatibility wrappers into macros, whose use still requires USE_THE_REPOSITORY_VARIABLE to be defined.
--- tree.c | 12 ------------ tree.h | 9 +++------ 2 files changed, 3 insertions(+), 18 deletions(-)
tree.c +0 -12
@@ -1,5 +1,3 @@ -#define USE_THE_REPOSITORY_VARIABLE -#include "git-compat-util.h" #include "hex.h" #include "tree.h"
@@ -185,11 +183,6 @@ int parse_tree_buffer(struct tree *item, void *buffer, unsigned long size)return 0 ; } -int parse_tree_gently (struct tree *item,int quiet_on_missing) -{ -return repo_parse_tree_gently (the_repository, item, quiet_on_missing); -} -int repo_parse_tree_gently (struct repository *r,struct tree *item,int quiet_on_missing) {
@@ -219,11 +212,6 @@ void free_tree_buffer(struct tree *tree) tree->object.parsed =0 ; } -struct tree *parse_tree_indirect (const struct object_id *oid) -{ -return repo_parse_tree_indirect (the_repository, oid); -} -struct tree *repo_parse_tree_indirect (struct repository *r,const struct object_id *oid) {
tree.h +3 -6
@@ -19,13 +19,10 @@ struct tree *lookup_tree(struct repository *r, const struct object_id *oid);int parse_tree_buffer (struct tree *item,void *buffer,unsigned long size); -int parse_tree_gently (struct tree *tree,int quiet_on_missing); +#define parse_tree_gently (t, q) repo_parse_tree_gently(the_repository, t, q)int repo_parse_tree_gently (struct repository *r,struct tree *item,int quiet_on_missing); -static inline int parse_tree (struct tree *tree) -{ -return parse_tree_gently (tree,0 ); -} +#define parse_tree (t) repo_parse_tree(the_repository, t)static inline int repo_parse_tree (struct repository *r,struct tree *item) {return repo_parse_tree_gently (r, item,0 );
@@ -33,7 +30,7 @@ static inline int repo_parse_tree(struct repository *r, struct tree *item)void free_tree_buffer (struct tree *tree);/* Parses and returns the tree in the given ent, chasing tags and commits. */ -struct tree *parse_tree_indirect (const struct object_id *oid); +#define parse_tree_indirect (o) repo_parse_tree_indirect(the_repository, o)struct tree *repo_parse_tree_indirect (struct repository *r,const struct object_id *oid);
Signature · 1 line
2.52.0
Quoted 3 lines · René Scharfe
Push the use of
the_repositoryto the remaining callers by turning the compatibility wrappers into macros, whose use still requiresUSE_THE_REPOSITORY_VARIABLEto be defined.
Can't we make this step a bit more explicit by adapting all callers to parse repo_parse_tree() with the_repository? That makes it way more obvious that we rely on the global repository.
Edit: I see that you _do_ edit all callsites in the next commit, nice.
In any case, I'd propose to move the compatibility macros into a section that says something like:
/* Deprecated wrappers that will be removed once Git 2.53 is released. */
We can then have a follow-up patch in a couple weeks to convert any new callsites that were added meanwhile and then purge the compatibility wrappers.
Thanks!
Patrick
Quoted 9 lines · Patrick Steinhardt
Quoted 3 lines · René Scharfe
Push the use of
the_repositoryto the remaining callers by turning the compatibility wrappers into macros, whose use still requiresUSE_THE_REPOSITORY_VARIABLEto be defined.Can't we make this step a bit more explicit by adapting all callers to parse
repo_parse_tree()withthe_repository? That makes it way more obvious that we rely on the global repository.
Quoted 6 lines
Edit: I see that you _do_ edit all callsites in the next commit, nice.
In any case, I'd propose to move the compatibility macros into a section that says something like:
/* Deprecated wrappers that will be removed once Git 2.53 is released. */
Please do not take release schedule hostage to one particular fix-up series of patches. Thanks.
Quoted 8 lines
We can then have a follow-up patch in a couple weeks to convert any new callsites that were added meanwhile and then purge the compatibility wrappers.
Thanks!
Patrick
Quoted 13 lines · Junio C Hamano
Quoted 11 lines · Patrick Steinhardt
Quoted 3 lines · René Scharfe
Push the use of
the_repositoryto the remaining callers by turning the compatibility wrappers into macros, whose use still requiresUSE_THE_REPOSITORY_VARIABLEto be defined.Can't we make this step a bit more explicit by adapting all callers to parse
repo_parse_tree()withthe_repository? That makes it way more obvious that we rely on the global repository.Edit: I see that you _do_ edit all callsites in the next commit, nice.
Quoted 7 lines
Quoted 4 lines
In any case, I'd propose to move the compatibility macros into a section that says something like:
/* Deprecated wrappers that will be removed once Git 2.53 is released. */Please do not take release schedule hostage to one particular fix-up series of patches. Thanks.
The intent isn't really to take anything hostage. It's rather intended as a hint that once a specific event has happened, we should take another look at removing these wrappers.
We regularly have the case that we add compatibility wrappers to not break in-flight patch series. We then have to wait a bit before we can remove those wrappers, which makes it likely that we forget doing so. By having the above marker we basically crowdsource their removal as everyone passing by the comment will now wonder "Wait, we already have Git 2.67, why do these wrappers still exist?".
Patrick
Quoted 11 lines · Patrick Steinhardt
Quoted 7 lines
Quoted 4 lines
In any case, I'd propose to move the compatibility macros into a section that says something like:
/* Deprecated wrappers that will be removed once Git 2.53 is released. */Please do not take release schedule hostage to one particular fix-up series of patches. Thanks.
The intent isn't really to take anything hostage. It's rather intended as a hint that once a specific event has happened, we should take another look at removing these wrappers.
I am OK with a comment that records the intent, e.g., "let's work towards reducing the use of these wrappers", with the plan for the next step, e.g., "and once we have done so, remove these."
But the comment you wrote is forcing people to make sure we remove the code that uses these wrappers and unless we finish it we cannot release 2.53, no?
Quoted 14 lines · Junio C Hamano
Quoted 11 lines · Patrick Steinhardt
Quoted 7 lines
Quoted 4 lines
In any case, I'd propose to move the compatibility macros into a section that says something like:
/* Deprecated wrappers that will be removed once Git 2.53 is released. */Please do not take release schedule hostage to one particular fix-up series of patches. Thanks.
The intent isn't really to take anything hostage. It's rather intended as a hint that once a specific event has happened, we should take another look at removing these wrappers.
Quoted 7 lines
I am OK with a comment that records the intent, e.g., "let's work towards reducing the use of these wrappers", with the plan for the next step, e.g., "and once we have done so, remove these."
But the comment you wrote is forcing people to make sure we remove the code that uses these wrappers and unless we finish it we cannot release 2.53, no?
That's definitely not my intent. It's really only intended as a hint when those should be removed at the earliest. Maybe something like the following instead?
/*
* These wrappers can be removed once Git 2.53 is released. If you
* see this comment and that release has been published then chances
* are high that we forgot to remove them.
*/
Patrick
Quoted 27 lines · Patrick Steinhardt
Quoted 14 lines · Junio C Hamano
Quoted 11 lines · Patrick Steinhardt
Quoted 7 lines
Quoted 4 lines
In any case, I'd propose to move the compatibility macros into a section that says something like:
/* Deprecated wrappers that will be removed once Git 2.53 is released. */Please do not take release schedule hostage to one particular fix-up series of patches. Thanks.
The intent isn't really to take anything hostage. It's rather intended as a hint that once a specific event has happened, we should take another look at removing these wrappers.
Quoted 7 lines
I am OK with a comment that records the intent, e.g., "let's work towards reducing the use of these wrappers", with the plan for the next step, e.g., "and once we have done so, remove these."
But the comment you wrote is forcing people to make sure we remove the code that uses these wrappers and unless we finish it we cannot release 2.53, no?
That's definitely not my intent. It's really only intended as a hint when those should be removed at the earliest. Maybe something like the following instead?
Quoted 5 lines
/*
* These wrappers can be removed once Git 2.53 is released. If you
* see this comment and that release has been published then chances
* are high that we forgot to remove them.
*/
Forgetting to remove the three macro definitions is very cheap. Forgetting to remove their Coccinelle rules is a bit more expensive. Can add a reminder.
René
Quoted 34 lines · René Scharfe
Quoted 27 lines · Patrick Steinhardt
Quoted 14 lines · Junio C Hamano
Quoted 11 lines · Patrick Steinhardt
Quoted 7 lines
Quoted 4 lines
In any case, I'd propose to move the compatibility macros into a section that says something like:
/* Deprecated wrappers that will be removed once Git 2.53 is released. */Please do not take release schedule hostage to one particular fix-up series of patches. Thanks.
The intent isn't really to take anything hostage. It's rather intended as a hint that once a specific event has happened, we should take another look at removing these wrappers.
Quoted 7 lines
I am OK with a comment that records the intent, e.g., "let's work towards reducing the use of these wrappers", with the plan for the next step, e.g., "and once we have done so, remove these."
But the comment you wrote is forcing people to make sure we remove the code that uses these wrappers and unless we finish it we cannot release 2.53, no?
That's definitely not my intent. It's really only intended as a hint when those should be removed at the earliest. Maybe something like the following instead?
Quoted 5 lines
/*
* These wrappers can be removed once Git 2.53 is released. If you
* see this comment and that release has been published then chances
* are high that we forgot to remove them.
*/
Quoted 3 lines
Forgetting to remove the three macro definitions is very cheap. Forgetting to remove their Coccinelle rules is a bit more expensive. Can add a reminder.
True indeed. We have a bunch of Coccinelle rules that are not needed anymore. We should probably do a spring cleanup of those.
Patrick
PATCH 10/10 cocci: convert parse_tree functions to repo_ variants
In reply to René ScharfeAdd and apply a semantic patch to convert calls to parse_tree() and friends to the corresponding variant that takes a repository argument, to allow the functions that implicitly use the_repository to be retired once all potential in-flight topics are settled and converted as well.
The changes in .c files were generated by Coccinelle, but I fixed a whitespace bug it would have introduced to builtin/commit.c.
--- archive.c | 2 +- builtin/am.c | 10 +++++----- builtin/checkout.c | 12 +++++++----- builtin/clone.c | 4 ++-- builtin/commit.c | 5 +++-- builtin/diff-tree.c | 2 +- builtin/ls-tree.c | 2 +- builtin/merge-tree.c | 9 ++++++--- builtin/merge.c | 8 ++++---- builtin/read-tree.c | 4 ++-- builtin/reset.c | 4 ++-- builtin/stash.c | 8 ++++---- cache-tree.c | 2 +- contrib/coccinelle/the_repository.cocci | 10 ++++++++++ diff-lib.c | 2 +- fsck.c | 2 +- http-push.c | 2 +- list-objects.c | 2 +- merge-ort.c | 13 +++++++------ merge.c | 6 +++--- read-cache.c | 2 +- reset.c | 2 +- revision.c | 4 ++-- sequencer.c | 4 ++-- t/helper/test-cache-tree.c | 2 +- t/helper/test-match-trees.c | 4 ++-- walker.c | 2 +- 27 files changed, 73 insertions(+), 56 deletions(-)
archive.c +1 -1
@@ -519,7 +519,7 @@ static void parse_treeish_arg(const char **argv,if (ar_args->mtime_option) archive_time =approxidate (ar_args->mtime_option); - tree =parse_tree_indirect (&oid); + tree =repo_parse_tree_indirect (the_repository, &oid);if (!tree)die (_ ("not a tree object: %s" ),oid_to_hex (&oid));
builtin/am.c +5 -5
@@ -1998,7 +1998,7 @@ static int fast_forward_to(struct tree *head, struct tree *remote, int reset)struct unpack_trees_options opts;struct tree_desc t[2 ]; -if (parse_tree (head) ||parse_tree (remote)) +if (repo_parse_tree (the_repository, head) ||repo_parse_tree (the_repository, remote))return -1 ;repo_hold_locked_index (the_repository, &lock_file,LOCK_DIE_ON_ERROR );
@@ -2038,7 +2038,7 @@ static int merge_tree(struct tree *tree)struct unpack_trees_options opts;struct tree_desc t[1 ]; -if (parse_tree (tree)) +if (repo_parse_tree (the_repository, tree))return -1 ;repo_hold_locked_index (the_repository, &lock_file,LOCK_DIE_ON_ERROR );
@@ -2071,11 +2071,11 @@ static int clean_index(const struct object_id *head, const struct object_id *remstruct tree *head_tree, *remote_tree, *index_tree;struct object_id index; - head_tree =parse_tree_indirect (head); + head_tree =repo_parse_tree_indirect (the_repository, head);if (!head_tree)return error (_ ("Could not parse object '%s'." ),oid_to_hex (head)); - remote_tree =parse_tree_indirect (remote); + remote_tree =repo_parse_tree_indirect (the_repository, remote);if (!remote_tree)return error (_ ("Could not parse object '%s'." ),oid_to_hex (remote));
@@ -2089,7 +2089,7 @@ static int clean_index(const struct object_id *head, const struct object_id *rem 0, NULL))return -1 ; - index_tree =parse_tree_indirect (&index); + index_tree =repo_parse_tree_indirect (the_repository, &index);if (!index_tree)return error (_ ("Could not parse object '%s'." ),oid_to_hex (&index));
builtin/checkout.c +7 -5
@@ -724,7 +724,7 @@ static int reset_tree(struct tree *tree, const struct checkout_opts *o,init_checkout_metadata (&opts.meta, info->refname, info->commit ? &info->commit->object.oid :null_oid (the_hash_algo),NULL ); -if (parse_tree (tree) <0 ) +if (repo_parse_tree (the_repository, tree) <0 )return 128 ;init_tree_desc (&tree_desc, &tree->object.oid, tree->buffer, tree->size);switch (unpack_trees (1 , &tree_desc, &opts)) {
@@ -803,7 +803,8 @@ static int merge_working_tree(const struct checkout_opts *opts,if (opts->new_orphan_branch && opts->orphan_from_empty_tree) {if (new_branch_info->commit)BUG ("'switch --orphan' should never accept a commit as starting point" ); - new_tree =parse_tree_indirect (the_hash_algo->empty_tree); + new_tree =repo_parse_tree_indirect (the_repository, + the_hash_algo->empty_tree);if (!new_tree)BUG ("unable to read empty tree" ); }else {
@@ -841,14 +842,15 @@ static int merge_working_tree(const struct checkout_opts *opts, old_commit_oid = old_branch_info->commit ? &old_branch_info->commit->object.oid : the_hash_algo->empty_tree; - tree =parse_tree_indirect (old_commit_oid); + tree =repo_parse_tree_indirect (the_repository, + old_commit_oid);if (!tree)die (_ ("unable to parse commit %s" ),oid_to_hex (old_commit_oid));init_tree_desc (&trees[0 ], &tree->object.oid, tree->buffer, tree->size); -if (parse_tree (new_tree) <0 ) +if (repo_parse_tree (the_repository, new_tree) <0 )die (NULL ); tree = new_tree; init_tree_desc(&trees[1], &tree->object.oid,
@@ -1278,7 +1280,7 @@ static void setup_new_branch_info_and_source_tree( new_branch_info->commit =lookup_commit_reference_gently (the_repository, rev,1 );if (!new_branch_info->commit) {/* not a commit */ - *source_tree =parse_tree_indirect (rev); + *source_tree =repo_parse_tree_indirect (the_repository, rev);if (!*source_tree)die (_ ("unable to read tree (%s)" ),oid_to_hex (rev)); }else {
builtin/clone.c +2 -2
@@ -680,10 +680,10 @@ static int checkout(int submodule_progress, int filter_submodules, opts.dst_index = the_repository->index;init_checkout_metadata (&opts.meta, head, &oid,NULL ); - tree =parse_tree_indirect (&oid); + tree =repo_parse_tree_indirect (the_repository, &oid);if (!tree)die (_ ("unable to parse commit %s" ),oid_to_hex (&oid)); -if (parse_tree (tree) <0 ) +if (repo_parse_tree (the_repository, tree) <0 )exit (128 );init_tree_desc (&t, &tree->object.oid, tree->buffer, tree->size);if (unpack_trees (1 , &t, &opts) <0 )
builtin/commit.c +3 -2
@@ -327,10 +327,11 @@ static void create_base_index(const struct commit *current_head) opts.dst_index = the_repository->index; opts.fn = oneway_merge; - tree =parse_tree_indirect (¤t_head->object.oid); + tree =repo_parse_tree_indirect (the_repository, + ¤t_head->object.oid);if (!tree)die (_ ("failed to unpack HEAD tree object" )); -if (parse_tree (tree) <0 ) +if (repo_parse_tree (the_repository, tree) <0 )exit (128 );init_tree_desc (&t, &tree->object.oid, tree->buffer, tree->size);if (unpack_trees (1 , &t, &opts))
builtin/diff-tree.c +1 -1
@@ -52,7 +52,7 @@ static int stdin_diff_trees(struct tree *tree1, const char *p)if (!isspace (*p++) ||parse_oid_hex (p, &oid, &p) || *p)return error ("Need exactly two trees, separated by a space" ); tree2 =lookup_tree (the_repository, &oid); -if (!tree2 ||parse_tree (tree2)) +if (!tree2 ||repo_parse_tree (the_repository, tree2))return -1 ;printf ("%s %s\n" ,oid_to_hex (&tree1->object.oid),oid_to_hex (&tree2->object.oid));
builtin/ls-tree.c +1 -1
@@ -421,7 +421,7 @@ int cmd_ls_tree(int argc,for (i =0 ; i < options.pathspec.nr; i++) options.pathspec.items[i].nowildcard_len = options.pathspec.items[i].len; options.pathspec.has_wildcard =0 ; - tree =parse_tree_indirect (&oid); + tree =repo_parse_tree_indirect (the_repository, &oid);if (!tree)die ("not a tree object" );/*
builtin/merge-tree.c +6 -3
@@ -447,17 +447,20 @@ static int real_merge(struct merge_tree_options *o,if (repo_get_oid_treeish (the_repository, merge_base, &base_oid))die (_ ("could not parse as tree '%s'" ), merge_base); - base_tree =parse_tree_indirect (&base_oid); + base_tree =repo_parse_tree_indirect (the_repository, + &base_oid);if (!base_tree)die (_ ("unable to read tree (%s)" ),oid_to_hex (&base_oid));if (repo_get_oid_treeish (the_repository, branch1, &head_oid))die (_ ("could not parse as tree '%s'" ), branch1); - parent1_tree =parse_tree_indirect (&head_oid); + parent1_tree =repo_parse_tree_indirect (the_repository, + &head_oid);if (!parent1_tree)die (_ ("unable to read tree (%s)" ),oid_to_hex (&head_oid));if (repo_get_oid_treeish (the_repository, branch2, &merge_oid))die (_ ("could not parse as tree '%s'" ), branch2); - parent2_tree =parse_tree_indirect (&merge_oid); + parent2_tree =repo_parse_tree_indirect (the_repository, + &merge_oid);if (!parent2_tree)die (_ ("unable to read tree (%s)" ),oid_to_hex (&merge_oid));
builtin/merge.c +4 -4
@@ -756,19 +756,19 @@ static int read_tree_trivial(struct object_id *common, struct object_id *head, opts.trivial_merges_only =1 ; opts.merge =1 ; opts.preserve_ignored =0 ;/* FIXME: !overwrite_ignore */ - trees[nr_trees] =parse_tree_indirect (common); + trees[nr_trees] =repo_parse_tree_indirect (the_repository, common);if (!trees[nr_trees++])return -1 ; - trees[nr_trees] =parse_tree_indirect (head); + trees[nr_trees] =repo_parse_tree_indirect (the_repository, head);if (!trees[nr_trees++])return -1 ; - trees[nr_trees] =parse_tree_indirect (one); + trees[nr_trees] =repo_parse_tree_indirect (the_repository, one);if (!trees[nr_trees++])return -1 ; opts.fn = threeway_merge;cache_tree_free (&the_repository->index->cache_tree);for (i =0 ; i < nr_trees; i++) { -parse_tree (trees[i]); +repo_parse_tree (the_repository, trees[i]);init_tree_desc (t+i, &trees[i]->object.oid, trees[i]->buffer, trees[i]->size); }
builtin/read-tree.c +2 -2
@@ -32,7 +32,7 @@ static int list_tree(struct object_id *oid)if (nr_trees >=MAX_UNPACK_TREES )die ("I cannot read more than %d trees" ,MAX_UNPACK_TREES ); - tree =parse_tree_indirect (oid); + tree =repo_parse_tree_indirect (the_repository, oid);if (!tree)return -1 ; trees[nr_trees++] = tree;
@@ -268,7 +268,7 @@ int cmd_read_tree(int argc,cache_tree_free (&the_repository->index->cache_tree);for (i =0 ; i < nr_trees; i++) {struct tree *tree = trees[i]; -if (parse_tree (tree) <0 ) +if (repo_parse_tree (the_repository, tree) <0 )return 128 ;init_tree_desc (t+i, &tree->object.oid, tree->buffer, tree->size); }
builtin/reset.c +2 -2
@@ -118,7 +118,7 @@ static int reset_index(const char *ref, const struct object_id *oid, int reset_t goto out;if (reset_type ==MIXED || reset_type ==HARD ) { - tree =parse_tree_indirect (oid); + tree =repo_parse_tree_indirect (the_repository, oid);if (!tree) {error (_ ("unable to read tree (%s)" ),oid_to_hex (oid)); goto out;
@@ -417,7 +417,7 @@ int cmd_reset(int argc,struct tree *tree;if (repo_get_oid_treeish (the_repository, rev, &oid))die (_ ("Failed to resolve '%s' as a valid tree." ), rev); - tree =parse_tree_indirect (&oid); + tree =repo_parse_tree_indirect (the_repository, &oid);if (!tree)die (_ ("Could not parse object '%s'." ), rev);oidcpy (&oid, &tree->object.oid);
builtin/stash.c +4 -4
@@ -347,8 +347,8 @@ static int reset_tree(struct object_id *i_tree, int update, int reset)memset (&opts,0 ,sizeof (opts)); - tree =parse_tree_indirect (i_tree); -if (parse_tree (tree)) + tree =repo_parse_tree_indirect (the_repository, i_tree); +if (repo_parse_tree (the_repository, tree))return -1 ;init_tree_desc (t, &tree->object.oid, tree->buffer, tree->size);
@@ -940,8 +940,8 @@ static void diff_include_untracked(const struct stash_info *info, struct diff_opstruct unpack_trees_options unpack_tree_opt = {0 };for (size_t i =0 ; i <ARRAY_SIZE (oid); i++) { - tree[i] =parse_tree_indirect (oid[i]); -if (parse_tree (tree[i]) <0 ) + tree[i] =repo_parse_tree_indirect (the_repository, oid[i]); +if (repo_parse_tree (the_repository, tree[i]) <0 )die (_ ("failed to parse tree" ));init_tree_desc (&tree_desc[i], &tree[i]->object.oid, tree[i]->buffer, tree[i]->size);
cache-tree.c +1 -1
@@ -813,7 +813,7 @@ static void prime_cache_tree_rec(struct repository *r,struct cache_tree_sub *sub;struct tree *subtree =lookup_tree (r, &entry.oid); -if (parse_tree (subtree) <0 ) +if (repo_parse_tree (the_repository, subtree) <0 )exit (128 ); sub =cache_tree_sub (it, entry.path); sub->cache_tree =cache_tree ();
contrib/coccinelle/the_repository.cocci +10 -0
@@ -117,6 +117,16 @@ | - init_revisions + repo_init_revisions +// tree.h +| +- parse_tree ++ repo_parse_tree +| +- parse_tree_gently ++ repo_parse_tree_gently +| +- parse_tree_indirect ++ repo_parse_tree_indirect ) ( + the_repository,
diff-lib.c +1 -1
@@ -552,7 +552,7 @@ static int diff_cache(struct rev_info *revs,struct tree_desc t;struct unpack_trees_options opts; - tree =parse_tree_indirect (tree_oid); + tree =repo_parse_tree_indirect (the_repository, tree_oid);if (!tree)return error ("bad tree object %s" , tree_name ? tree_name :oid_to_hex (tree_oid));
fsck.c +1 -1
@@ -360,7 +360,7 @@ static int fsck_walk_tree(struct tree *tree, void *data, struct fsck_options *opint res =0 ;const char *name; -if (parse_tree (tree)) +if (repo_parse_tree (the_repository, tree))return -1 ; name =fsck_get_object_name (options, &tree->object.oid);
http-push.c +1 -1
@@ -1311,7 +1311,7 @@ static struct object_list **process_tree(struct tree *tree,if (obj->flags & (UNINTERESTING |SEEN ))return p; -if (parse_tree (tree) <0 ) +if (repo_parse_tree (the_repository, tree) <0 )die ("bad tree object %s" ,oid_to_hex (&obj->oid)); obj->flags |=SEEN ;
list-objects.c +1 -1
@@ -170,7 +170,7 @@ static void process_tree(struct traversal_context *ctx,if (ctx->depth > revs->repo->settings.max_allowed_tree_depth)die ("exceeded maximum allowed tree depth" ); - failed_parse =parse_tree_gently (tree,1 ); + failed_parse =repo_parse_tree_gently (the_repository, tree,1 );if (failed_parse) {if (revs->ignore_missing_links)return ;
merge-ort.c +7 -6
@@ -1732,9 +1732,9 @@ static int collect_merge_info(struct merge_options *opt, info.data = opt; info.show_all_errors =1 ; -if (parse_tree (merge_base) <0 || -parse_tree (side1) <0 || -parse_tree (side2) <0 ) +if (repo_parse_tree (the_repository, merge_base) <0 || +repo_parse_tree (the_repository, side1) <0 || +repo_parse_tree (the_repository, side2) <0 )return -1 ;init_tree_desc (t +0 , &merge_base->object.oid, merge_base->buffer, merge_base->size);
@@ -4619,10 +4619,10 @@ static int checkout(struct merge_options *opt, unpack_opts.verbose_update = (opt->verbosity >2 ); unpack_opts.fn = twoway_merge; unpack_opts.preserve_ignored =0 ;/* FIXME: !opts->overwrite_ignore */ -if (parse_tree (prev) <0 ) +if (repo_parse_tree (the_repository, prev) <0 )return -1 ;init_tree_desc (&trees[0 ], &prev->object.oid, prev->buffer, prev->size); -if (parse_tree (next) <0 ) +if (repo_parse_tree (the_repository, next) <0 )return -1 ;init_tree_desc (&trees[1 ], &next->object.oid, next->buffer, next->size);
@@ -5280,7 +5280,8 @@ static void merge_ort_nonrecursive_internal(struct merge_options *opt,if (result->clean >=0 ) {if (!opt->mergeability_only) { - result->tree =parse_tree_indirect (&working_tree_oid); + result->tree =repo_parse_tree_indirect (the_repository, + &working_tree_oid);if (!result->tree)die (_ ("unable to read tree (%s)" ),oid_to_hex (&working_tree_oid));
merge.c +3 -3
@@ -68,18 +68,18 @@ int checkout_fast_forward(struct repository *r,memset (&trees,0 ,sizeof (trees));memset (&t,0 ,sizeof (t)); - trees[nr_trees] =parse_tree_indirect (head); + trees[nr_trees] =repo_parse_tree_indirect (the_repository, head);if (!trees[nr_trees++]) {rollback_lock_file (&lock_file);return -1 ; } - trees[nr_trees] =parse_tree_indirect (remote); + trees[nr_trees] =repo_parse_tree_indirect (the_repository, remote);if (!trees[nr_trees++]) {rollback_lock_file (&lock_file);return -1 ; }for (i =0 ; i < nr_trees; i++) { -if (parse_tree (trees[i]) <0 ) { +if (repo_parse_tree (the_repository, trees[i]) <0 ) {rollback_lock_file (&lock_file);return -1 ; }
read-cache.c +1 -1
@@ -3807,7 +3807,7 @@ void overlay_tree_on_index(struct index_state *istate,if (repo_get_oid (the_repository, tree_name, &oid))die ("tree-ish %s not found." , tree_name); - tree =parse_tree_indirect (&oid); + tree =repo_parse_tree_indirect (the_repository, &oid);if (!tree)die ("bad tree-ish %s" , tree_name);
reset.c +1 -1
@@ -163,7 +163,7 @@ int reset_head(struct repository *r, const struct reset_head_opts *opts) goto leave_reset_head; } - tree =parse_tree_indirect (oid); + tree =repo_parse_tree_indirect (the_repository, oid);if (!tree) { ret =error (_ ("unable to read tree (%s)" ),oid_to_hex (oid)); goto leave_reset_head;
revision.c +2 -2
@@ -72,7 +72,7 @@ static void mark_tree_contents_uninteresting(struct repository *r,struct tree_desc desc;struct name_entry entry; -if (parse_tree_gently (tree,1 ) <0 ) +if (repo_parse_tree_gently (the_repository, tree,1 ) <0 )return ;init_tree_desc (&desc, &tree->object.oid, tree->buffer, tree->size);
@@ -179,7 +179,7 @@ static void add_children_by_path(struct repository *r,if (!tree)return ; -if (parse_tree_gently (tree,1 ) <0 ) +if (repo_parse_tree_gently (the_repository, tree,1 ) <0 )return ;init_tree_desc (&desc, &tree->object.oid, tree->buffer, tree->size);
sequencer.c +2 -2
@@ -767,7 +767,7 @@ static int do_recursive_merge(struct repository *r, o.buffer_output =2 ; o.show_rename_progress =1 ; - head_tree =parse_tree_indirect (head); + head_tree =repo_parse_tree_indirect (the_repository, head);if (!head_tree)return error (_ ("unable to read tree (%s)" ),oid_to_hex (head)); next_tree = next ?repo_get_commit_tree (r, next) :empty_tree (r);
@@ -4052,7 +4052,7 @@ static int do_reset(struct repository *r, goto cleanup; } - tree =parse_tree_indirect (&oid); + tree =repo_parse_tree_indirect (the_repository, &oid);if (!tree)return error (_ ("unable to read tree (%s)" ),oid_to_hex (&oid));prime_cache_tree (r, r->index, tree);
t/helper/test-cache-tree.c +1 -1
@@ -41,7 +41,7 @@ int cmd__cache_tree(int argc, const char **argv)die (_ ("unable to read index file" ));oidcpy (&oid, &the_repository->index->cache_tree->oid); - tree =parse_tree_indirect (&oid); + tree =repo_parse_tree_indirect (the_repository, &oid);if (!tree)die (_ ("not a tree object: %s" ),oid_to_hex (&oid));
t/helper/test-match-trees.c +2 -2
@@ -19,10 +19,10 @@ int cmd__match_trees(int ac UNUSED, const char **av)die ("cannot parse %s as an object name" , av[1 ]);if (repo_get_oid (the_repository, av[2 ], &hash2))die ("cannot parse %s as an object name" , av[2 ]); - one =parse_tree_indirect (&hash1); + one =repo_parse_tree_indirect (the_repository, &hash1);if (!one)die ("not a tree-ish %s" , av[1 ]); - two =parse_tree_indirect (&hash2); + two =repo_parse_tree_indirect (the_repository, &hash2);if (!two)die ("not a tree-ish %s" , av[2 ]);
walker.c +1 -1
@@ -45,7 +45,7 @@ static int process_tree(struct walker *walker, struct tree *tree)struct tree_desc desc;struct name_entry entry; -if (parse_tree (tree)) +if (repo_parse_tree (the_repository, tree))return -1 ;init_tree_desc (&desc, &tree->object.oid, tree->buffer, tree->size);
Signature · 1 line
2.52.0
[PATCH 11/10] cocci: remove obsolete the_repository rules
In reply to René Scharfe035c7de9e9e (cocci: apply the "revision.h" part of "the_repository.pending", 2023-03-28) removed the last of the repo-less functions and macros mentioned in the_repository.cocci at the time. No stragglers appeared since then. Remove the applied rules now that they have outlived their usefulness.
Also add a reminder to eventually remove the just added rules for tree.h.
--- contrib/coccinelle/the_repository.cocci | 119 +----------------------- 1 file changed, 2 insertions(+), 117 deletions(-)
contrib/coccinelle/the_repository.cocci +2 -117
@@ -2,123 +2,8 @@ @@ @@ ( -// cache.h -- get_oid -+ repo_get_oid -| -- get_oid_commit -+ repo_get_oid_commit -| -- get_oid_committish -+ repo_get_oid_committish -| -- get_oid_tree -+ repo_get_oid_tree -| -- get_oid_treeish -+ repo_get_oid_treeish -| -- get_oid_blob -+ repo_get_oid_blob -| -- get_oid_mb -+ repo_get_oid_mb -| -- find_unique_abbrev -+ repo_find_unique_abbrev -| -- find_unique_abbrev_r -+ repo_find_unique_abbrev_r -| -- for_each_abbrev -+ repo_for_each_abbrev -| -- interpret_branch_name -+ repo_interpret_branch_name -| -- peel_to_type -+ repo_peel_to_type -// commit-reach.h -| -- get_merge_bases -+ repo_get_merge_bases -| -- get_merge_bases_many -+ repo_get_merge_bases_many -| -- get_merge_bases_many_dirty -+ repo_get_merge_bases_many_dirty -| -- in_merge_bases -+ repo_in_merge_bases -| -- in_merge_bases_many -+ repo_in_merge_bases_many -// commit.h -| -- parse_commit_internal -+ repo_parse_commit_internal -| -- parse_commit -+ repo_parse_commit -| -- get_commit_buffer -+ repo_get_commit_buffer -| -- unuse_commit_buffer -+ repo_unuse_commit_buffer -| -- logmsg_reencode -+ repo_logmsg_reencode -| -- get_commit_tree -+ repo_get_commit_tree -// diff.h -| -- diff_setup -+ repo_diff_setup -// odb.h -| -- read_object_file -+ repo_read_object_file -| -- has_object_file -+ repo_has_object_file -| -- has_object_file_with_flags -+ repo_has_object_file_with_flags -// pretty.h -| -- format_commit_message -+ repo_format_commit_message -// packfile.h -| -- approximate_object_count -+ repo_approximate_object_count -// promisor-remote.h -| -- promisor_remote_reinit -+ repo_promisor_remote_reinit -| -- promisor_remote_find -+ repo_promisor_remote_find -| -- has_promisor_remote -+ repo_has_promisor_remote -// refs.h -| -- dwim_ref -+ repo_dwim_ref -// rerere.h -| -- rerere -+ repo_rerere -// revision.h -| -- init_revisions -+ repo_init_revisions -// tree.h -| +// TODO: remove the rules below and the macros from tree.h after the +// next Git release. - parse_tree + repo_parse_tree |
Signature · 1 line
2.52.0
Re: [PATCH 11/10] cocci: remove obsolete the_repository rules
Quoted 8 lines · René Scharfe
035c7de9e9e(cocci: apply the "revision.h" part of "the_repository.pending", 2023-03-28) removed the last of the repo-less functions and macros mentioned inthe_repository.cocciat the time. No stragglers appeared since then. Remove the applied rules now that they have outlived their usefulness.Also add a reminder to eventually remove the just added rules for
tree.h.
All of the removals look good to me, and I verified that we indeed don't have these functions anymore. Thanks!
Patrick
Re: [PATCH 11/10] cocci: remove obsolete the_repository rules
Quoted 7 lines · Patrick Steinhardt
Quoted 6 lines · René Scharfe
035c7de9e9e(cocci: apply the "revision.h" part of "the_repository.pending", 2023-03-28) removed the last of the repo-less functions and macros mentioned inthe_repository.cocciat the time. No stragglers appeared since then. Remove the applied rules now that they have outlived their usefulness.
Quoted 7 lines
Quoted 2 lines
Also add a reminder to eventually remove the just added rules for
tree.h.All of the removals look good to me, and I verified that we indeed don't have these functions anymore. Thanks!
Patrick
Thanks, both. These look good to me, too.