Bring more repository handles into our code base
cover Bring more repository handles into our code base
This applies on nd/the-index (b3c7eef9b05) and is the logical continuation of the object store series, which I sent over the last year.
The previous series did take a very slow and pedantic approach, using a #define trick, see cfc62fc98c for details, but it turns out, that it doesn't work:
When changing the signature of widely used functions, it burdens the maintainer in resolving the semantic conflicts.
In the orginal approach this was called a feature, as then we can ensure that not bugs creep into the code base during the merge window (while such a refactoring series wanders from pu to master). It turns out this was not well received and was just burdensome.
The #define trick doesn't buy us much to begin with when dealing with non-merge-conflicts. For example, see deref_tag at tag.c:68, which got the repository argument in 286d258d4f (tag.c: allow deref_tag to handle arbitrary repositories, 2018-06-28) but lost its property of working on any repository while 8c4cc32689 (tag: don't warn if target is missing but promised, 2018-07-12) was in flight simultaneously.
Another example of failure of this approach is seen in patch 5, which shows that the pedantry was missed.
This series takes another approach as it doesn't change the signature of functions, but introduces new functions that can deal with arbitrary repositories, keeping the old function signature around using a shallow wrapper.
Additionally each patch adds a semantic patch, that would port from the old to the new function. These semantic patches are all applied in the very last patch, but we could omit applying the last patch if it causes too many merge conflicts and trickl in the semantic patches over time when there are no merge conflicts.
The original goal of all these refactoring series was to remove add_submodule_odb in submodule.c, which was partially reached with this series. I'll investigate the remaining calls in another series, but it shows we're close to be done with these large refactorings as far as I am concerned.
Thanks,
Stefan
Stefan Beller (19):
sha1_file: allow read_object to read objects in arbitrary repositories
packfile: allow has_packed_and_bad to handle arbitrary repositories
object-store: allow read_object_file_extended to read from arbitrary
repositories
object-store: prepare read_object_file to deal with arbitrary
repositories
object: parse_object to honor its repository argument
commit: allow parse_commit* to handle arbitrary repositories commit.c: allow paint_down_to_common to handle arbitrary repositories commit.c: allow merge_bases_many to handle arbitrary repositories commit.c: allow remove_redundant to handle arbitrary repositories
commit: allow get_merge_bases_many_0 to handle arbitrary repositories
commit: prepare get_merge_bases to handle arbitrary repositories
commit: prepare get_commit_buffer to handle arbitrary repositories
commit: prepare in_merge_bases[_many] to handle arbitrary repositories
commit: prepare repo_unuse_commit_buffer to handle arbitrary
repositories
commit: prepare logmsg_reencode to handle arbitrary repositories
pretty: prepare format_commit_message to handle arbitrary repositories
submodule: use submodule repos for object lookup
submodule: don't add submodule as odb for push
Apply semantic patches from previous patches
apply.c | 6 +- archive.c | 5 +- bisect.c | 5 +- blame.c | 15 +-- builtin/am.c | 2 +- builtin/blame.c | 4 +- builtin/cat-file.c | 21 +++-- builtin/checkout.c | 4 +- builtin/commit.c | 13 ++- builtin/describe.c | 4 +- builtin/difftool.c | 3 +- builtin/fast-export.c | 7 +- builtin/fmt-merge-msg.c | 8 +- builtin/grep.c | 2 +- builtin/index-pack.c | 8 +- builtin/log.c | 4 +- builtin/merge-base.c | 2 +- builtin/merge-tree.c | 9 +- builtin/mktag.c | 3 +- builtin/name-rev.c | 2 +- builtin/notes.c | 12 ++- builtin/pack-objects.c | 22 +++-- builtin/reflog.c | 5 +- builtin/replace.c | 2 +- builtin/shortlog.c | 5 +- builtin/show-branch.c | 4 +- builtin/tag.c | 4 +- builtin/unpack-file.c | 2 +- builtin/unpack-objects.c | 3 +- builtin/verify-commit.c | 2 +- bundle.c | 2 +- combine-diff.c | 2 +- commit-graph.c | 8 +- commit.c | 120 ++++++++++++++---------- commit.h | 67 ++++++++++--- config.c | 2 +- contrib/coccinelle/the_repository.cocci | 114 ++++++++++++++++++++++ diff.c | 3 +- dir.c | 2 +- entry.c | 3 +- fast-import.c | 7 +- fsck.c | 9 +- grep.c | 3 +- http-push.c | 3 +- log-tree.c | 3 +- mailmap.c | 2 +- match-trees.c | 4 +- merge-blobs.c | 6 +- merge-recursive.c | 13 +-- negotiator/default.c | 6 +- negotiator/skipping.c | 2 +- notes-cache.c | 5 +- notes-merge.c | 4 +- notes-utils.c | 2 +- notes.c | 10 +- object-store.h | 13 ++- object.c | 2 +- packfile.c | 5 +- packfile.h | 2 +- pretty.c | 33 ++++--- pretty.h | 7 +- read-cache.c | 5 +- remote-testsvn.c | 4 +- remote.c | 2 +- rerere.c | 5 +- revision.c | 12 +-- sequencer.c | 55 ++++++----- sha1-file.c | 22 +++-- sha1-name.c | 9 +- shallow.c | 4 +- streaming.c | 2 +- submodule-config.c | 3 +- submodule.c | 51 +++++++--- t/helper/test-revision-walking.c | 3 +- tag.c | 5 +- tree-walk.c | 6 +- tree.c | 5 +- walker.c | 2 +- xdiff-interface.c | 2 +- 79 files changed, 571 insertions(+), 278 deletions(-) create mode 100644 contrib/coccinelle/the_repository.cocci
Signature · 1 line
2.19.0
PATCH 1/19 sha1_file: allow read_object to read objects in arbitrary repositories
Allow read_object (a file local functon in sha1_file) to handle arbitrary repositories by passing the repository down to oid_object_info_extended.
--- sha1-file.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
sha1-file.c +6 -4
@@ -1361,7 +1361,9 @@ int oid_object_info(struct repository *r,return type; } -static void *read_object (const unsigned char *sha1,enum object_type *type, +static void *read_object (struct repository *r, +const unsigned char *sha1, +enum object_type *type,unsigned long *size) {struct object_id oid;
@@ -1373,7 +1375,7 @@ static void *read_object(const unsigned char *sha1, enum object_type *type,hashcpy (oid.hash, sha1); -if (oid_object_info_extended (the_repository, &oid, &oi,0 ) <0 ) +if (oid_object_info_extended (r, &oid, &oi,0 ) <0 )return NULL ;return content; }
@@ -1414,7 +1416,7 @@ void *read_object_file_extended(const struct object_id *oid, lookup_replace_object(the_repository, oid) : oid; errno =0 ; - data =read_object (repl->hash, type, size); + data =read_object (the_repository, repl->hash, type, size);if (data)return data;
@@ -1755,7 +1757,7 @@ int force_object_loose(const struct object_id *oid, time_t mtime)if (has_loose_object (oid))return 0 ; - buf =read_object (oid->hash, &type, &len); + buf =read_object (the_repository, oid->hash, &type, &len);if (!buf)return error (_ ("cannot read sha1_file for %s" ),oid_to_hex (oid)); hdrlen =xsnprintf (hdr,sizeof (hdr),"%s %lu" ,type_name (type), len) +1 ;
Signature · 1 line
2.19.0
PATCH 2/19 packfile: allow has_packed_and_bad to handle arbitrary repositories
In reply to Stefan Bellerhas_packed_and_bad is not widely used, so just migrate it all at once.
--- packfile.c | 5 +++-- packfile.h | 2 +- sha1-file.c | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-)
packfile.c +3 -2
@@ -1024,12 +1024,13 @@ void mark_bad_packed_object(struct packed_git *p, const unsigned char *sha1) p->num_bad_objects++; } -const struct packed_git *has_packed_and_bad (const unsigned char *sha1) +const struct packed_git *has_packed_and_bad (struct repository *r, +const unsigned char *sha1) {struct packed_git *p;unsigned i; -for (p = the_repository->objects->packed_git; p; p = p->next) +for (p = r->objects->packed_git; p; p = p->next)for (i =0 ; i < p->num_bad_objects; i++)if (!hashcmp (sha1, p->bad_object_sha1 + the_hash_algo->rawsz * i))
packfile.h +1 -1
@@ -136,7 +136,7 @@ extern int packed_object_info(struct repository *r, off_t offset, struct object_info *);extern void mark_bad_packed_object (struct packed_git *p,const unsigned char *sha1); -extern const struct packed_git *has_packed_and_bad (const unsigned char *sha1); +extern const struct packed_git *has_packed_and_bad (struct repository *r,const unsigned char *sha1);/* * Iff a pack file in the given repository contains the object named by sha1,
sha1-file.c +1 -1
@@ -1432,7 +1432,7 @@ void *read_object_file_extended(const struct object_id *oid,die (_ ("loose object %s (stored in %s) is corrupt" ),oid_to_hex (repl), path); -if ((p =has_packed_and_bad (repl->hash)) !=NULL ) +if ((p =has_packed_and_bad (the_repository, repl->hash)) !=NULL )die (_ ("packed object %s (stored in %s) is corrupt" ),oid_to_hex (repl), p->pack_name);
Signature · 1 line
2.19.0
PATCH 3/19 object-store: allow read_object_file_extended to read from arbitrary repositories
In reply to Stefan Bellerread_object_file_extended is not widely used, so migrate it all at once.
--- object-store.h | 5 +++-- sha1-file.c | 11 ++++++----- streaming.c | 2 +- 3 files changed, 10 insertions(+), 8 deletions(-)
object-store.h +3 -2
@@ -146,12 +146,13 @@ void sha1_file_name(struct repository *r, struct strbuf *buf, const unsigned chavoid *map_sha1_file (struct repository *r,const unsigned char *sha1,unsigned long *size); -extern void *read_object_file_extended (const struct object_id *oid, +extern void *read_object_file_extended (struct repository *r, +const struct object_id *oid,enum object_type *type,unsigned long *size,int lookup_replace);static inline void *read_object_file (const struct object_id *oid,enum object_type *type,unsigned long *size) { -return read_object_file_extended (oid, type, size,1 ); +return read_object_file_extended (the_repository, oid, type, size,1 ); }/* Read and unpack an object file into memory, write memory to an object file */
sha1-file.c +6 -5
@@ -1403,7 +1403,8 @@ int pretend_object_file(void *buf, unsigned long len, enum object_type type,* deal with them should arrange to call read_object() and give error * messages themselves. */ -void *read_object_file_extended (const struct object_id *oid, +void *read_object_file_extended (struct repository *r, +const struct object_id *oid,enum object_type *type,unsigned long *size,int lookup_replace)
@@ -1413,10 +1414,10 @@ void *read_object_file_extended(const struct object_id *oid,const char *path;struct stat st;const struct object_id *repl = lookup_replace ? -lookup_replace_object (the_repository, oid) : oid; +lookup_replace_object (r, oid) : oid; errno =0 ; - data =read_object (the_repository, repl->hash, type, size); + data =read_object (r, repl->hash, type, size);if (data)return data;
@@ -1428,11 +1429,11 @@ void *read_object_file_extended(const struct object_id *oid,die (_ ("replacement %s not found for %s" ),oid_to_hex (repl),oid_to_hex (oid)); -if (!stat_sha1_file (the_repository, repl->hash, &st, &path)) +if (!stat_sha1_file (r, repl->hash, &st, &path))die (_ ("loose object %s (stored in %s) is corrupt" ),oid_to_hex (repl), path); -if ((p =has_packed_and_bad (the_repository, repl->hash)) !=NULL ) +if ((p =has_packed_and_bad (r, repl->hash)) !=NULL )die (_ ("packed object %s (stored in %s) is corrupt" ),oid_to_hex (repl), p->pack_name);
streaming.c +1 -1
@@ -490,7 +490,7 @@ static struct stream_vtbl incore_vtbl = {static open_method_decl (incore) { - st->u.incore.buf =read_object_file_extended (oid, type, &st->size,0 ); + st->u.incore.buf =read_object_file_extended (the_repository, oid, type, &st->size,0 ); st->u.incore.read_ptr =0 ; st->vtbl = &incore_vtbl;
Signature · 1 line
2.19.0
Re: [PATCH 03/19] object-store: allow read_object_file_extended to read from arbitrary repositories
sha1-file.c void *read_object_file_extended(const struct object_id *oid, · line 1417
Quoted 6 lines
sha1-file.c +1
-1@@ -1413,10 +1414,10 @@ void *read_object_file_extended(const struct object_id *oid,const char *path;struct stat st;const struct object_id *repl = lookup_replace ? -lookup_replace_object (the_repository, oid) : oid; +lookup_replace_object (r, oid) : oid;
Firstly, patches 1 and 2 are obviously correct.
This lookup_replace_object() is a bit tricky in that at 'master', register_replace_ref() (indirectly called by lookup_replace_object()) did not handle arbitrary repositories correctly, but 'next' has a patch that solves this, so this shouldn't be an issue. The other function changes look fine. So this patch looks correct too.
PATCH 4/19 object-store: prepare read_object_file to deal with arbitrary repositories
In reply to Stefan BellerAs read_object_file is a widely used function (which is also regularly used in new code in flight between master..pu), changing its signature is painful is hard, as other series in flight rely on the original signature. It would burden the maintainer if we'd just change the signature.
Introduce repo_read_object_file which takes the repository argument, and hide the original read_object_file as a macro behind NO_THE_REPOSITORY_COMPATIBILITY_MACROS, which we planned for in e675765235 (diff.c: remove implicit dependency on the_index, 2018-09-21)
Add a coccinelle patch to convert existing callers, but do not apply the resulting patch from 'make coccicheck' to keep the diff of this patch small.
--- contrib/coccinelle/the_repository.cocci | 13 +++++++++++++ object-store.h | 10 ++++++++-- 2 files changed, 21 insertions(+), 2 deletions(-) create mode 100644 contrib/coccinelle/the_repository.cocci
contrib/coccinelle/the_repository.cocci new file +13 -0
@@ -0,0 +1,13 @@ +// This file is used for the ongoing refactoring of +// bringing the index or repository struct in all of +// our code base. + +@@ +expression E; +expression F; +expression G; +@@ +- read_object_file( ++ repo_read_object_file(the_repository, + E, F, G) +
object-store.h +8 -2
@@ -150,10 +150,16 @@ extern void *read_object_file_extended(struct repository *r,const struct object_id *oid, enum object_type *type, unsigned long *size, int lookup_replace); -static inline void *read_object_file (const struct object_id *oid,enum object_type *type,unsigned long *size) +static inline void *repo_read_object_file (struct repository *r, +const struct object_id *oid, +enum object_type *type, +unsigned long *size) { -return read_object_file_extended (the_repository, oid, type, size,1 ); +return read_object_file_extended (r, oid, type, size,1 ); } +#ifndef NO_THE_REPOSITORY_COMPATIBILITY_MACROS +#define read_object_file (oid, type, size) repo_read_object_file(the_repository, oid, type, size) +#endif /* Read and unpack an object file into memory, write memory to an object file */ int oid_object_info (struct repository *r,const struct object_id *,unsigned long *);
Signature · 1 line
2.19.0
Re: [PATCH 04/19] object-store: prepare read_object_file to deal with arbitrary repositories
Quoted 4 lines
Introduce
repo_read_object_filewhich takes the repository argument, and hide the originalread_object_fileas a macro behindNO_THE_REPOSITORY_COMPATIBILITY_MACROS, which we planned for ine675765235(diff.c: remove implicit dependency onthe_index, 2018-09-21)
That commit didn't seem to plan for anything - it just seems to add a new function with the name "repo_" preprended and define a macro if NO_THE_REPOSITORY_COMPATIBILITY_MACROS is not set, just like this patch. Maybe s/which we planned for in/just like in/.
The patch itself looks good.
Re: [PATCH 04/19] object-store: prepare read_object_file to deal with arbitrary repositories
Quoted 10 lines · Jonathan Tan
Quoted 5 lines
Introduce
repo_read_object_filewhich takes the repository argument, and hide the originalread_object_fileas a macro behindNO_THE_REPOSITORY_COMPATIBILITY_MACROS, which we planned for ine675765235(diff.c: remove implicit dependency onthe_index, 2018-09-21)That commit didn't seem to plan for anything - it just seems to add a new function with the name "
repo_" preprended and define a macro ifNO_THE_REPOSITORY_COMPATIBILITY_MACROSis not set, just like this patch. Maybe s/which we planned for in/just like in/.
I was reading too much into
The plan is these macros will always be defined for all library files and the macros are only accessible in builtin/
of that commit message.
PATCH 5/19 object: parse_object to honor its repository argument
In reply to Stefan BellerIn 8e4b0b6047 (object.c: allow parse_object to handle arbitrary repositories, 2018-06-28), we forgot to pass the repository down to the read_object_file.
--- object.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
object.c +1 -1
@@ -270,7 +270,7 @@ struct object *parse_object(struct repository *r, const struct object_id *oid)return lookup_object (r, oid->hash); } - buffer =read_object_file (oid, &type, &size); + buffer =repo_read_object_file (r, oid, &type, &size);if (buffer) {if (check_object_signature (repl, buffer, size,type_name (type)) <0 ) {free (buffer);
Signature · 1 line
2.19.0
Re: [PATCH 05/19] object: parse_object to honor its repository argument
Quoted 3 lines
In
8e4b0b6047(object.c: allowparse_objectto handle arbitrary repositories, 2018-06-28), we forgot to pass the repository down to theread_object_file.
[snip]
object.c struct object *parse_object(struct repository *r, const struct object_id *oid) · line 273
Quoted 6 lines
object.c +1
-1@@ -270,7 +270,7 @@ struct object *parse_object(struct repository *r, const struct object_id *oid)return lookup_object (r, oid->hash); } - buffer =read_object_file (oid, &type, &size); + buffer =repo_read_object_file (r, oid, &type, &size);
There is still the matter of the 2 invocations of has_object_file() earlier in this function. The first one probably can be replaced with oid_object_info_extended() (see the definition of has_sha1_file_with_flags() to see how to do it), and the second one looks redundant to me and can be removed. Apart from that, I don't see any other invocations that need to be converted, so parse_object() will indeed fully honor its repository argument.
Re: [PATCH 05/19] object: parse_object to honor its repository argument
Quoted 11 lines · Jonathan Tan
Quoted 4 lines
In
8e4b0b6047(object.c: allowparse_objectto handle arbitrary repositories, 2018-06-28), we forgot to pass the repository down to theread_object_file.[snip]
Quoted 4 lines
object.c +0
-0@@ -270,7 +270,7 @@ struct object *parse_object(struct repository *r, const struct object_id *oid)return lookup_object (r, oid->hash); }
Quoted 10 lines
object.c struct object *parse_object(struct repository *r, const struct object_id *oid) · line 273
Quoted 2 lines
object.c +1
-1- buffer =read_object_file (oid, &type, &size); + buffer =repo_read_object_file (r, oid, &type, &size);There is still the matter of the 2 invocations of
has_object_file()earlier in this function. The first one probably can be replaced withoid_object_info_extended()(see the definition ofhas_sha1_file_with_flags()to see how to do it), and the second one looks redundant to me and can be removed. Apart from that, I don't see any other invocations that need to be converted, soparse_object()will indeed fully honor its repository argument.
I will convert the has_{sha1, object}_file[_with_flags] functions before this patch in a resend and just pass along the repository.
I'll defer the change of logic to another patch to be followed up later.
PATCH 6/19 commit: allow parse_commit* to handle arbitrary repositories
In reply to Stefan BellerJust like the previous commit, parse_commit and friends are used a lot and are found in new patches, so we cannot change their signature easily.
Re-introduce these function prefixed with 'repo_' that take a repository argument and keep the original as a shallow macro.
--- commit.c | 18 +++++++++++------- commit.h | 17 +++++++++++++---- contrib/coccinelle/the_repository.cocci | 24 ++++++++++++++++++++++++ 3 files changed, 48 insertions(+), 11 deletions(-)
commit.c +11 -7
@@ -443,7 +443,10 @@ int parse_commit_buffer(struct repository *r, struct commit *item, const void *breturn 0 ; } -int parse_commit_internal (struct commit *item,int quiet_on_missing,int use_commit_graph) +int repo_parse_commit_internal (struct repository *r, +struct commit *item, +int quiet_on_missing, +int use_commit_graph) {enum object_type type;void *buffer;
@@ -454,9 +457,9 @@ int parse_commit_internal(struct commit *item, int quiet_on_missing, int use_comreturn -1 ;if (item->object.parsed)return 0 ; -if (use_commit_graph &&parse_commit_in_graph (the_repository, item)) +if (use_commit_graph &&parse_commit_in_graph (r, item))return 0 ; - buffer =read_object_file (&item->object.oid, &type, &size); + buffer =repo_read_object_file (r, &item->object.oid, &type, &size);if (!buffer)return quiet_on_missing ?-1 : error("Could not read %s",
@@ -467,18 +470,19 @@ int parse_commit_internal(struct commit *item, int quiet_on_missing, int use_com oid_to_hex(&item->object.oid)); } - ret =parse_commit_buffer (the_repository, item, buffer, size,0 ); + ret =parse_commit_buffer (r, item, buffer, size,0 );if (save_commit_buffer && !ret) { -set_commit_buffer (the_repository, item, buffer, size); +set_commit_buffer (r, item, buffer, size);return 0 ; }free (buffer);return ret; } -int parse_commit_gently (struct commit *item,int quiet_on_missing) +int repo_parse_commit_gently (struct repository *r, +struct commit *item,int quiet_on_missing) { -return parse_commit_internal (item, quiet_on_missing,1 ); +return repo_parse_commit_internal (r, item, quiet_on_missing,1 ); }void parse_commit_or_die (struct commit *item)
commit.h +13 -4
@@ -79,12 +79,21 @@ struct commit *lookup_commit_reference_by_name(const char *name);struct commit *lookup_commit_or_die (const struct object_id *oid,const char *ref_name);int parse_commit_buffer (struct repository *r,struct commit *item,const void *buffer,unsigned long size,int check_graph); -int parse_commit_internal (struct commit *item,int quiet_on_missing,int use_commit_graph); -int parse_commit_gently (struct commit *item,int quiet_on_missing); -static inline int parse_commit (struct commit *item) +int repo_parse_commit_internal (struct repository *r,struct commit *item, +int quiet_on_missing,int use_commit_graph); +int repo_parse_commit_gently (struct repository *r, +struct commit *item, +int quiet_on_missing); +static inline int repo_parse_commit (struct repository *r,struct commit *item) { -return parse_commit_gently (item,0 ); +return repo_parse_commit_gently (r, item,0 ); } +#ifndef NO_THE_REPOSITORY_COMPATIBILITY_MACROS +#define parse_commit_internal (item, quiet, use) repo_parse_commit_internal(the_repository, item, quiet, use) +#define parse_commit_gently (item, quiet) repo_parse_commit_gently(the_repository, item, quiet) +#define parse_commit (item) repo_parse_commit(the_repository, item) +#endif +void parse_commit_or_die (struct commit *item);struct buffer_slab ;
contrib/coccinelle/the_repository.cocci +24 -0
@@ -11,3 +11,27 @@ expression G; + repo_read_object_file(the_repository, E, F, G) +@@ +expression E; +expression F; +expression G; +@@ +- parse_commit_internal( ++ repo_parse_commit_internal(the_repository, + E, F, G) + +@@ +expression E; +expression F; +@@ +- parse_commit_gently( ++ repo_parse_commit_gently(the_repository, + E, F) + +@@ +expression E; +@@ +- parse_commit( ++ repo_parse_commit(the_repository, + E) +
Signature · 1 line
2.19.0
PATCH 7/19 commit.c: allow paint_down_to_common to handle arbitrary repositories
In reply to Stefan BellerAs the function is file local and not widely used, migrate it all at once.
--- commit.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-)
commit.c +9 -6
@@ -869,7 +869,8 @@ static int queue_has_nonstale(struct prio_queue *queue) }/* all input commits in one and twos[] must have been parsed! */ -static struct commit_list *paint_down_to_common (struct commit *one,int n, +static struct commit_list *paint_down_to_common (struct repository *r, +struct commit *one,int n,struct commit **twos,int min_generation) {
@@ -922,7 +923,7 @@ static struct commit_list *paint_down_to_common(struct commit *one, int n, parents = parents->next;if ((p->object.flags & flags) == flags)continue ; -if (parse_commit (p)) +if (repo_parse_commit (r, p))return NULL ; p->object.flags |= flags;prio_queue_put (&queue, p);
@@ -955,7 +956,7 @@ static struct commit_list *merge_bases_many(struct commit *one, int n, struct coreturn NULL ; } - list =paint_down_to_common (one, n, twos,0 ); + list =paint_down_to_common (the_repository, one, n, twos,0 );while (list) {struct commit *commit =pop_commit (&list);
@@ -1026,8 +1027,8 @@ static int remove_redundant(struct commit **array, int cnt)if (array[j]->generation < min_generation) min_generation = array[j]->generation; } - common =paint_down_to_common (array[i], filled, work, - min_generation); + common =paint_down_to_common (the_repository, array[i], filled, + work, min_generation);if (array[i]->object.flags &PARENT2 ) redundant[i] =1 ;for (j =0 ; j < filled; j++)
@@ -1151,7 +1152,9 @@ int in_merge_bases_many(struct commit *commit, int nr_reference, struct commit *if (commit->generation > min_generation)return ret; - bases =paint_down_to_common (commit, nr_reference, reference, commit->generation); + bases =paint_down_to_common (the_repository, commit, + nr_reference, reference, + commit->generation);if (commit->object.flags &PARENT2 ) ret =1 ;clear_commit_marks (commit, all_flags);
Signature · 1 line
2.19.0
PATCH 8/19 commit.c: allow merge_bases_many to handle arbitrary repositories
In reply to Stefan Beller--- commit.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
commit.c +7 -5
@@ -934,7 +934,9 @@ static struct commit_list *paint_down_to_common(struct repository *r,return result; } -static struct commit_list *merge_bases_many (struct commit *one,int n,struct commit **twos) +static struct commit_list *merge_bases_many (struct repository *r, +struct commit *one,int n, +struct commit **twos) {struct commit_list *list =NULL ;struct commit_list *result =NULL ;
@@ -949,14 +951,14 @@ static struct commit_list *merge_bases_many(struct commit *one, int n, struct coreturn commit_list_insert (one, &result); } -if (parse_commit (one)) +if (repo_parse_commit (r, one))return NULL ;for (i =0 ; i < n; i++) { -if (parse_commit (twos[i])) +if (repo_parse_commit (r, twos[i]))return NULL ; } - list =paint_down_to_common (the_repository, one, n, twos,0 ); + list =paint_down_to_common (r, one, n, twos,0 );while (list) {struct commit *commit =pop_commit (&list);
@@ -1063,7 +1065,7 @@ static struct commit_list *get_merge_bases_many_0(struct commit *one,struct commit_list *result;int cnt, i; - result =merge_bases_many (one, n, twos); + result =merge_bases_many (the_repository, one, n, twos);for (i =0 ; i < n; i++) {if (one == twos[i])return result;
Signature · 1 line
2.19.0
PATCH 9/19 commit.c: allow remove_redundant to handle arbitrary repositories
In reply to Stefan Beller--- commit.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
commit.c +5 -5
@@ -995,7 +995,7 @@ struct commit_list *get_octopus_merge_bases(struct commit_list *in)return ret; } -static int remove_redundant (struct commit **array,int cnt) +static int remove_redundant (struct repository *r,struct commit **array,int cnt) {/* * Some commit in the array may be an ancestor of
@@ -1013,7 +1013,7 @@ static int remove_redundant(struct commit **array, int cnt)ALLOC_ARRAY (filled_index, cnt -1 );for (i =0 ; i < cnt; i++) -parse_commit (array[i]); +repo_parse_commit (r, array[i]);for (i =0 ; i < cnt; i++) {struct commit_list *common;uint32_t min_generation = array[i]->generation;
@@ -1029,7 +1029,7 @@ static int remove_redundant(struct commit **array, int cnt)if (array[j]->generation < min_generation) min_generation = array[j]->generation; } - common =paint_down_to_common (the_repository, array[i], filled, + common =paint_down_to_common (r, array[i], filled, work, min_generation);if (array[i]->object.flags &PARENT2 ) redundant[i] =1 ;
@@ -1088,7 +1088,7 @@ static struct commit_list *get_merge_bases_many_0(struct commit *one,clear_commit_marks (one, all_flags);clear_commit_marks_many (n, twos, all_flags); - cnt =remove_redundant (rslt, cnt); + cnt =remove_redundant (the_repository, rslt, cnt); result =NULL ;for (i =0 ; i < cnt; i++)commit_list_insert_by_date (rslt[i], &result);
@@ -1199,7 +1199,7 @@ struct commit_list *reduce_heads(struct commit_list *heads) p->item->object.flags &= ~STALE ; } } - num_head =remove_redundant (array, num_head); + num_head =remove_redundant (the_repository, array, num_head);for (i =0 ; i < num_head; i++) tail = &commit_list_insert (array[i], tail)->next;free (array);
Signature · 1 line
2.19.0
PATCH 10/19 commit: allow get_merge_bases_many_0 to handle arbitrary repositories
In reply to Stefan Beller--- commit.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-)
commit.c +7 -6
@@ -1055,7 +1055,8 @@ static int remove_redundant(struct repository *r, struct commit **array, int cntreturn filled; } -static struct commit_list *get_merge_bases_many_0 (struct commit *one, +static struct commit_list *get_merge_bases_many_0 (struct repository *r, +struct commit *one,int n,struct commit **twos,int cleanup)
@@ -1065,7 +1066,7 @@ static struct commit_list *get_merge_bases_many_0(struct commit *one,struct commit_list *result;int cnt, i; - result =merge_bases_many (the_repository, one, n, twos); + result =merge_bases_many (r, one, n, twos);for (i =0 ; i < n; i++) {if (one == twos[i])return result;
@@ -1088,7 +1089,7 @@ static struct commit_list *get_merge_bases_many_0(struct commit *one,clear_commit_marks (one, all_flags);clear_commit_marks_many (n, twos, all_flags); - cnt =remove_redundant (the_repository, rslt, cnt); + cnt =remove_redundant (r, rslt, cnt); result =NULL ;for (i =0 ; i < cnt; i++)commit_list_insert_by_date (rslt[i], &result);
@@ -1100,19 +1101,19 @@ struct commit_list *get_merge_bases_many(struct commit *one,int n, struct commit **twos) { - return get_merge_bases_many_0(one, n, twos, 1); + return get_merge_bases_many_0(the_repository, one, n, twos, 1); }struct commit_list *get_merge_bases_many_dirty (struct commit *one,int n,struct commit **twos) { -return get_merge_bases_many_0 (one, n, twos,0 ); +return get_merge_bases_many_0 (the_repository, one, n, twos,0 ); }struct commit_list *get_merge_bases (struct commit *one,struct commit *two) { -return get_merge_bases_many_0 (one,1 , &two,1 ); +return get_merge_bases_many_0 (the_repository, one,1 , &two,1 ); }/*
Signature · 1 line
2.19.0
PATCH 11/19 commit: prepare get_merge_bases to handle arbitrary repositories
In reply to Stefan BellerSimilarly to previous patches, the get_merge_base functions are used often in the code base, which makes migrating them hard.
Implement the new functions, prefixed with 'repo_' and hide the old functions behind a wrapper macro.
--- commit.c | 24 +++++++++++++---------- commit.h | 20 ++++++++++++++----- contrib/coccinelle/the_repository.cocci | 26 +++++++++++++++++++++++++ 3 files changed, 55 insertions(+), 15 deletions(-)
commit.c +14 -10
@@ -1097,23 +1097,27 @@ static struct commit_list *get_merge_bases_many_0(struct repository *r,return result; } -struct commit_list *get_merge_bases_many (struct commit *one, -int n, -struct commit **twos) +struct commit_list *repo_get_merge_bases_many (struct repository *r, +struct commit *one, +int n, +struct commit **twos) { -return get_merge_bases_many_0 (the_repository, one, n, twos,1 ); +return get_merge_bases_many_0 (r, one, n, twos,1 ); } -struct commit_list *get_merge_bases_many_dirty (struct commit *one, -int n, -struct commit **twos) +struct commit_list *repo_get_merge_bases_many_dirty (struct repository *r, +struct commit *one, +int n, +struct commit **twos) { -return get_merge_bases_many_0 (the_repository, one, n, twos,0 ); +return get_merge_bases_many_0 (r, one, n, twos,0 ); } -struct commit_list *get_merge_bases (struct commit *one,struct commit *two) +struct commit_list *repo_get_merge_bases (struct repository *r, +struct commit *one, +struct commit *two) { -return get_merge_bases_many_0 (the_repository, one,1 , &two,1 ); +return get_merge_bases_many_0 (r, one,1 , &two,1 ); }/*
commit.h +15 -5
@@ -213,12 +213,22 @@ struct commit_graft *read_graft_line(struct strbuf *line);int register_commit_graft (struct repository *r,struct commit_graft *,int );struct commit_graft *lookup_commit_graft (struct repository *r,const struct object_id *oid); -extern struct commit_list *get_merge_bases (struct commit *rev1,struct commit *rev2); -extern struct commit_list *get_merge_bases_many (struct commit *one,int n,struct commit **twos); -extern struct commit_list *get_octopus_merge_bases (struct commit_list *in); - +struct commit_list *repo_get_merge_bases (struct repository *r, +struct commit *rev1, +struct commit *rev2); +struct commit_list *repo_get_merge_bases_many (struct repository *r, +struct commit *one,int n, +struct commit **twos);/* To be used only when object flags after this call no longer matter */ -extern struct commit_list *get_merge_bases_many_dirty (struct commit *one,int n,struct commit **twos); +struct commit_list *repo_get_merge_bases_many_dirty (struct repository *r, +struct commit *one,int n, +struct commit **twos); +#ifndef NO_THE_REPOSITORY_COMPATIBILITY_MACROS +#define get_merge_bases (r1, r2) repo_get_merge_bases(the_repository, r1, r2) +#define get_merge_bases_many (one, n, two) repo_get_merge_bases_many(the_repository, one, n, two) +#define get_merge_bases_many_dirty (one, n, twos) repo_get_merge_bases_many_dirty(the_repository, one, n, twos) +#endif +extern struct commit_list *get_octopus_merge_bases (struct commit_list *in);/* largest positive number a signed 32-bit integer can contain */ #define INFINITE_DEPTH 0x7fffffff
contrib/coccinelle/the_repository.cocci +26 -0
@@ -35,3 +35,29 @@ expression E; + repo_parse_commit(the_repository, E) +@@ +expression E; +expression F; +@@ +- get_merge_bases( ++ repo_get_merge_bases(the_repository, + E, F); + +@@ +expression E; +expression F; +expression G; +@@ +- get_merge_bases_many( ++ repo_get_merge_bases_many(the_repository, + E, F, G); + +@@ +expression E; +expression F; +expression G; +@@ +- get_merge_bases_many_dirty( ++ repo_get_merge_bases_many_dirty(the_repository, + E, F, G); +
Signature · 1 line
2.19.0
PATCH 12/19 commit: prepare get_commit_buffer to handle arbitrary repositories
In reply to Stefan Beller--- commit.c | 8 +++++--- commit.h | 7 ++++++- contrib/coccinelle/the_repository.cocci | 7 +++++++ 3 files changed, 18 insertions(+), 4 deletions(-)
commit.c +5 -3
@@ -297,13 +297,15 @@ const void *get_cached_commit_buffer(struct repository *r, const struct commit *return v->buffer; } -const void *get_commit_buffer (const struct commit *commit,unsigned long *sizep) +const void *repo_get_commit_buffer (struct repository *r, +const struct commit *commit, +unsigned long *sizep) { -const void *ret =get_cached_commit_buffer (the_repository, commit, sizep); +const void *ret =get_cached_commit_buffer (r, commit, sizep);if (!ret) {enum object_type type;unsigned long size; - ret =read_object_file (&commit->object.oid, &type, &size); + ret =repo_read_object_file (r, &commit->object.oid, &type, &size);if (!ret)die ("cannot read commit object %s" ,oid_to_hex (&commit->object.oid));
commit.h +6 -1
@@ -117,7 +117,12 @@ const void *get_cached_commit_buffer(struct repository *, const struct commit *,* from disk. The resulting memory should not be modified, and must be given * to unuse_commit_buffer when the caller is done. */ -const void *get_commit_buffer (const struct commit *,unsigned long *size); +const void *repo_get_commit_buffer (struct repository *r, +const struct commit *, +unsigned long *size); +#ifndef NO_THE_REPOSITORY_COMPATIBILITY_MACROS +#define get_commit_buffer (c, s) repo_get_commit_buffer(the_repository, c, s) +#endif /* * Tell the commit subsytem that we are done with a particular commit buffer.
contrib/coccinelle/the_repository.cocci +7 -0
@@ -61,3 +61,10 @@ expression G; + repo_get_merge_bases_many_dirty(the_repository, E, F, G); +@@ +expression E; +expression F; +@@ +- get_commit_buffer( ++ repo_get_commit_buffer(the_repository, + E, F);
Signature · 1 line
2.19.0
PATCH 13/19 commit: prepare in_merge_bases[_many] to handle arbitrary repositories
In reply to Stefan Beller--- commit.c | 15 +++++++++------ commit.h | 8 ++++++-- contrib/coccinelle/the_repository.cocci | 17 +++++++++++++++++ 3 files changed, 32 insertions(+), 8 deletions(-)
commit.c +9 -6
@@ -1143,16 +1143,17 @@ int is_descendant_of(struct commit *commit, struct commit_list *with_commit)/* * Is "commit" an ancestor of one of the "references"? */ -int in_merge_bases_many (struct commit *commit,int nr_reference,struct commit **reference) +int repo_in_merge_bases_many (struct repository *r,struct commit *commit, +int nr_reference,struct commit **reference) {struct commit_list *bases;int ret =0 , i;uint32_t min_generation =GENERATION_NUMBER_INFINITY ; -if (parse_commit (commit)) +if (repo_parse_commit (r, commit))return ret;for (i =0 ; i < nr_reference; i++) { -if (parse_commit (reference[i])) +if (repo_parse_commit (r, reference[i]))return ret;if (reference[i]->generation < min_generation) min_generation = reference[i]->generation;
@@ -1161,7 +1162,7 @@ int in_merge_bases_many(struct commit *commit, int nr_reference, struct commit *if (commit->generation > min_generation)return ret; - bases =paint_down_to_common (the_repository, commit, + bases =paint_down_to_common (r, commit, nr_reference, reference, commit->generation);if (commit->object.flags &PARENT2 )
@@ -1175,9 +1176,11 @@ int in_merge_bases_many(struct commit *commit, int nr_reference, struct commit */* * Is "commit" an ancestor of (i.e. reachable from) the "reference"? */ -int in_merge_bases (struct commit *commit,struct commit *reference) +int repo_in_merge_bases (struct repository *r, +struct commit *commit, +struct commit *reference) { -return in_merge_bases_many (commit,1 , &reference); +return repo_in_merge_bases_many (r, commit,1 , &reference); }struct commit_list *reduce_heads (struct commit_list *heads)
commit.h +6 -2
@@ -283,8 +283,12 @@ extern void prune_shallow(int show_only);extern struct trace_key trace_shallow;int is_descendant_of (struct commit *,struct commit_list *); -int in_merge_bases (struct commit *,struct commit *); -int in_merge_bases_many (struct commit *,int ,struct commit **); +int repo_in_merge_bases (struct repository *r,struct commit *,struct commit *); +int repo_in_merge_bases_many (struct repository *r,struct commit *,int ,struct commit **); +#ifndef NO_THE_REPOSITORY_COMPATIBILITY_MACROS +#define in_merge_bases (c1, c2) repo_in_merge_bases(the_repository, c1, c2) +#define in_merge_bases_many (c1, n, cs) repo_in_merge_bases_many(the_repository, c1, n, cs) +#endif extern int interactive_add (int argc,const char **argv,const char *prefix,int patch); extern int run_add_interactive(const char *revision, const char *patch_mode,
contrib/coccinelle/the_repository.cocci +17 -0
@@ -68,3 +68,20 @@ expression F; - get_commit_buffer( + repo_get_commit_buffer(the_repository, E, F); + +@@ +expression E; +expression F; +@@ +- in_merge_bases( ++ repo_in_merge_bases(the_repository, + E, F); + +@@ +expression E; +expression F; +expression G; +@@ +- in_merge_bases_many( ++ repo_in_merge_bases_many(the_repository, + E, F, G);
Signature · 1 line
2.19.0
PATCH 14/19 commit: prepare repo_unuse_commit_buffer to handle arbitrary repositories
In reply to Stefan Beller--- commit.c | 6 ++++-- commit.h | 7 ++++++- contrib/coccinelle/the_repository.cocci | 8 ++++++++ 3 files changed, 18 insertions(+), 3 deletions(-)
commit.c +4 -2
@@ -318,10 +318,12 @@ const void *repo_get_commit_buffer(struct repository *r,return ret; } -void unuse_commit_buffer (const struct commit *commit,const void *buffer) +void repo_unuse_commit_buffer (struct repository *r, +const struct commit *commit, +const void *buffer) {struct commit_buffer *v =buffer_slab_peek ( - the_repository->parsed_objects->buffer_slab, commit); + r->parsed_objects->buffer_slab, commit);if (!(v && v->buffer == buffer))free ((void *)buffer); }
commit.h +6 -1
@@ -130,7 +130,12 @@ const void *repo_get_commit_buffer(struct repository *r,* from an earlier call to get_commit_buffer. The buffer may or may not be * freed by this call; callers should not access the memory afterwards. */ -void unuse_commit_buffer (const struct commit *,const void *buffer); +void repo_unuse_commit_buffer (struct repository *r, +const struct commit *, +const void *buffer); +#ifndef NO_THE_REPOSITORY_COMPATIBILITY_MACROS +#define unuse_commit_buffer (c, b) repo_unuse_commit_buffer(the_repository, c, b) +#endif /* * Free any cached object buffer associated with the commit.
contrib/coccinelle/the_repository.cocci +8 -0
@@ -69,6 +69,14 @@ expression F; + repo_get_commit_buffer(the_repository, E, F); +@@ +expression E; +expression F; +@@ +- unuse_commit_buffer( ++ repo_unuse_commit_buffer(the_repository, + E, F); + @@ expression E; expression F;
Signature · 1 line
2.19.0
PATCH 15/19 commit: prepare logmsg_reencode to handle arbitrary repositories
In reply to Stefan Beller--- commit.h | 8 ++++++++ contrib/coccinelle/the_repository.cocci | 9 +++++++++ pretty.c | 13 +++++++------ 3 files changed, 24 insertions(+), 6 deletions(-)
commit.h +8 -0
@@ -180,6 +180,14 @@ extern int has_non_ascii(const char *text);extern const char *logmsg_reencode (const struct commit *commit,char **commit_encoding,const char *output_encoding); +const char *repo_logmsg_reencode (struct repository *r, +const struct commit *commit, +char **commit_encoding, +const char *output_encoding); +#ifndef NO_THE_REPOSITORY_COMPATIBILITY_MACROS +#define logmsg_reencode (c, enc, out) repo_logmsg_reencode(the_repository, c, enc, out) +#endif +extern const char *skip_blank_lines (const char *msg);/** Removes the first commit from a list sorted by date, and adds all
contrib/coccinelle/the_repository.cocci +9 -0
@@ -93,3 +93,12 @@ expression G; - in_merge_bases_many( + repo_in_merge_bases_many(the_repository, E, F, G); + +@@ +expression E; +expression F; +expression G; +@@ +- logmsg_reencode( ++ repo_logmsg_reencode(the_repository, + E, F, G);
pretty.c +7 -6
@@ -595,14 +595,15 @@ static char *replace_encoding_header(char *buf, const char *encoding)return strbuf_detach (&tmp,NULL ); } -const char *logmsg_reencode (const struct commit *commit, -char **commit_encoding, -const char *output_encoding) +const char *repo_logmsg_reencode (struct repository *r, +const struct commit *commit, +char **commit_encoding, +const char *output_encoding) {static const char *utf8 ="UTF-8" ;const char *use_encoding;char *encoding; -const char *msg =get_commit_buffer (commit,NULL ); +const char *msg =repo_get_commit_buffer (r, commit,NULL );char *out;if (!output_encoding || !*output_encoding) {
@@ -630,7 +631,7 @@ const char *logmsg_reencode(const struct commit *commit,* the cached copy from get_commit_buffer, we need to duplicate it * to avoid munging the cached copy. */ -if (msg ==get_cached_commit_buffer (the_repository, commit,NULL )) +if (msg ==get_cached_commit_buffer (r, commit,NULL )) out =xstrdup (msg);else out = (char *)msg;
@@ -644,7 +645,7 @@ const char *logmsg_reencode(const struct commit *commit,*/ out =reencode_string (msg, output_encoding, use_encoding);if (out) -unuse_commit_buffer (commit, msg); +repo_unuse_commit_buffer (r, commit, msg); }/*
Signature · 1 line
2.19.0
PATCH 16/19 pretty: prepare format_commit_message to handle arbitrary repositories
In reply to Stefan Beller--- contrib/coccinelle/the_repository.cocci | 10 ++++++++++ pretty.c | 15 ++++++++------- pretty.h | 7 ++++++- 3 files changed, 24 insertions(+), 8 deletions(-)
contrib/coccinelle/the_repository.cocci +10 -0
@@ -102,3 +102,13 @@ expression G; - logmsg_reencode( + repo_logmsg_reencode(the_repository, E, F, G); + +@@ +expression E; +expression F; +expression G; +expression H; +@@ +- format_commit_message( ++ repo_format_commit_message(the_repository, + E, F, G, H);
pretty.c +8 -7
@@ -1505,9 +1505,10 @@ void userformat_find_requirements(const char *fmt, struct userformat_want *w)strbuf_release (&dummy); } -void format_commit_message (const struct commit *commit, -const char *format,struct strbuf *sb, -const struct pretty_print_context *pretty_ctx) +void repo_format_commit_message (struct repository *r, +const struct commit *commit, +const char *format,struct strbuf *sb, +const struct pretty_print_context *pretty_ctx) {struct format_commit_context context;const char *output_enc = pretty_ctx->output_encoding;
@@ -1521,9 +1522,9 @@ void format_commit_message(const struct commit *commit,* convert a commit message to UTF-8 first * as far as 'format_commit_item' assumes it in UTF-8 */ - context.message =logmsg_reencode (commit, - &context.commit_encoding, - utf8); + context.message =repo_logmsg_reencode (r, commit, + &context.commit_encoding, + utf8);strbuf_expand (sb, format, format_commit_item, &context);rewrap_message_tail (sb, &context,0 ,0 ,0 );
@@ -1547,7 +1548,7 @@ void format_commit_message(const struct commit *commit, }free (context.commit_encoding); -unuse_commit_buffer (commit, context.message); +repo_unuse_commit_buffer (r, commit, context.message); } static void pp_header(struct pretty_print_context *pp,
pretty.h +6 -1
@@ -103,9 +103,14 @@ void pp_remainder(struct pretty_print_context *pp, const char **msg_p,* Put the result to "sb". * Please use this function for custom formats. */ -void format_commit_message (const struct commit *commit, +void repo_format_commit_message (struct repository *r, +const struct commit *commit,const char *format,struct strbuf *sb,const struct pretty_print_context *context); +#ifndef NO_THE_REPOSITORY_COMPATIBILITY_MACROS +#define format_commit_message (c, f, s, con) \ + repo_format_commit_message(the_repository, c, f, s, con) +#endif /* * Parse given arguments from "arg", check it for correctness and
Signature · 1 line
2.19.0
Re: [PATCH 16/19] pretty: prepare format_commit_message to handle arbitrary repositories
Patches 6-16 are all quite straightforward, and are reviewed-by: me.
PATCH 17/19 submodule: use submodule repos for object lookup
In reply to Stefan BellerThis converts the 'show_submodule_header' function to use the repository API properly, such that the submodule objects are not added to the main object store.
--- submodule.c | 48 ++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 38 insertions(+), 10 deletions(-)
submodule.c +38 -10
@@ -443,7 +443,7 @@ static int prepare_submodule_summary(struct rev_info *rev, const char *path,return prepare_revision_walk (rev); } -static void print_submodule_summary (struct rev_info *rev,struct diff_options *o) +static void print_submodule_summary (struct repository *r,struct rev_info *rev,struct diff_options *o) {static const char format[] =" %m %s" ;struct strbuf sb =STRBUF_INIT ;
@@ -454,7 +454,8 @@ static void print_submodule_summary(struct rev_info *rev, struct diff_options *o ctx.date_mode = rev->date_mode; ctx.output_encoding =get_log_output_encoding ();strbuf_setlen (&sb,0 ); -format_commit_message (commit, format, &sb, &ctx); +repo_format_commit_message (r, commit, format, &sb, + &ctx);strbuf_addch (&sb,'\n' );if (commit->object.flags &SYMMETRIC_LEFT )diff_emit_submodule_del (o, sb.buf);
@@ -481,12 +482,37 @@ void prepare_submodule_repo_env(struct argv_array *out) DEFAULT_GIT_DIR_ENVIRONMENT); } +/* +* Initialize 'out' based on the provided submodule path. +* +* Unlike repo_submodule_init, this tolerates submodules not present +* in .gitmodules. NEEDSWORK: The repo_submodule_init behavior is +* preferrable. This function exists only to preserve historical behavior. +* +* Returns 0 on success, -1 when the submodule is not present. +*/ +static int open_submodule (struct repository *out,const char *path) +{ +struct strbuf sb =STRBUF_INIT ; + +if (submodule_to_gitdir (&sb, path) ||repo_init (out, sb.buf,NULL )) { +strbuf_release (&sb); +return -1 ; + } + + out->submodule_prefix =xstrdup (path); + +strbuf_release (&sb); +return 0 ; +} +/* Helper function to display the submodule header line prior to the full * summary output. If it can locate the submodule objects directory it will * attempt to lookup both the left and right commits and put them into the * left and right pointers. */ -static void show_submodule_header(struct diff_options *o, const char *path, +static void show_submodule_header(struct diff_options *o, struct repository *sub, + const char *path, struct object_id *one, struct object_id *two, unsigned dirty_submodule, struct commit **left, struct commit **right,
@@ -507,7 +533,7 @@ static void show_submodule_header(struct diff_options *o, const char *path,else if (is_null_oid (two)) message ="(submodule deleted)" ; -if (add_submodule_odb (path)) { +if (open_submodule (sub, path) <0 ) {if (!message) message ="(commits not present)" ; goto output_header;
@@ -517,8 +543,8 @@ static void show_submodule_header(struct diff_options *o, const char *path,* Attempt to lookup the commit references, and determine if this is * a fast forward or fast backwards update. */ - *left =lookup_commit_reference (the_repository, one); - *right =lookup_commit_reference (the_repository, two); + *left =lookup_commit_reference (sub, one); + *right =lookup_commit_reference (sub, two);/* * Warn about missing commits in the submodule project, but only if
@@ -528,7 +554,7 @@ static void show_submodule_header(struct diff_options *o, const char *path, (!is_null_oid(two) && !*right)) message ="(commits not present)" ; - *merge_bases =get_merge_bases (*left, *right); + *merge_bases =repo_get_merge_bases (sub, *left, *right);if (*merge_bases) {if ((*merge_bases)->item == *left) fast_forward =1 ;
@@ -562,8 +588,9 @@ void show_submodule_summary(struct diff_options *o, const char *path,struct rev_info rev;struct commit *left =NULL , *right =NULL ;struct commit_list *merge_bases =NULL ; +struct repository sub; -show_submodule_header (o, path, one, two, dirty_submodule, +show_submodule_header (o, &sub, path, one, two, dirty_submodule, &left, &right, &merge_bases);/*
@@ -580,7 +607,7 @@ void show_submodule_summary(struct diff_options *o, const char *path, goto out; } -print_submodule_summary (&rev, o); +print_submodule_summary (&sub, &rev, o); out:if (merge_bases)
@@ -598,8 +625,9 @@ void show_submodule_inline_diff(struct diff_options *o, const char *path,struct commit_list *merge_bases =NULL ;struct child_process cp =CHILD_PROCESS_INIT ;struct strbuf sb =STRBUF_INIT ; +struct repository sub; -show_submodule_header (o, path, one, two, dirty_submodule, +show_submodule_header (o, &sub, path, one, two, dirty_submodule, &left, &right, &merge_bases);/* We need a valid left and right commit to display a difference */
Signature · 1 line
2.19.0
Re: [PATCH 17/19] submodule: use submodule repos for object lookup
Quoted 6 lines
+/*
+ * Initialize 'out' based on the provided submodule path.
+ *
+ * Unlikerepo_submodule_init, this tolerates submodules not present
+ * in .gitmodules. NEEDSWORK: Therepo_submodule_initbehavior is
+ * preferrable. This function exists only to preserve historical behavior.
What do you mean by "The repo_submodule_init behavior is preferable"? If we need to preserve historical behavior, then it seems that the most preferable one is something that meets our needs (like open_submodule() in this patch).
submodule.c void prepare_submodule_repo_env(struct argv_array *out) · line 503
Quoted 10 lines
submodule.c +10
-0+static int open_submodule (struct repository *out,const char *path) +{ +struct strbuf sb =STRBUF_INIT ; + +if (submodule_to_gitdir (&sb, path) ||repo_init (out, sb.buf,NULL )) { +strbuf_release (&sb); +return -1 ; + } + + out->submodule_prefix =xstrdup (path);
Do we need to set submodule_prefix?
submodule.c static void show_submodule_header(struct diff_options *o, const char *path, · line 536
Quoted 6 lines
submodule.c +1
-1@@ -507,7 +533,7 @@ static void show_submodule_header(struct diff_options *o, const char *path,else if (is_null_oid (two)) message ="(submodule deleted)" ; -if (add_submodule_odb (path)) { +if (open_submodule (sub, path) <0 ) {
This function, as a side effect, writes the open repository to "sub" for its caller to use. I think it's better if its callers open "sub" and then pass it to show_submodule_header() if successful. If opening the submodule is expected to fail sometimes (like it seems here), then we can allow callers to also pass NULL, and document what happens when NULL is passed.
Also, repositories open in this way should also be freed.
Re: [PATCH 17/19] submodule: use submodule repos for object lookup
Quoted 9 lines · Jonathan Tan
Quoted 7 lines
+/*
+ * Initialize 'out' based on the provided submodule path.
+ *
+ * Unlikerepo_submodule_init, this tolerates submodules not present
+ * in .gitmodules. NEEDSWORK: Therepo_submodule_initbehavior is
+ * preferrable. This function exists only to preserve historical behavior.What do you mean by "The
repo_submodule_initbehavior is preferable"?
Preferable in the sense that it follows the definition of a submodule, but this here works for "any repo" that happens to be at the gitlink.
Quoted 4 lines
If
we need to preserve historical behavior, then it seems that the most preferable one is something that meets our needs (likeopen_submodule()in this patch).
Yes, I'll reword to drop the preferrable, but still state the difference.
I wonder if instead we'd want to introduce a
repo_submodule_init(struct repository *submodule \
struct repository *superproject \
const char *path, \
int tolerate_lookalikes)Another patch proposes to replace the path
by a struct submodule, but for lookalikes, we do not have a struct submodule to begin with (though in the other patches we cook up a fake entry in the submodule config)
Quoted 4 lines
Quoted 4 lines
submodule.c +4
-0+static int open_submodule (struct repository *out,const char *path) +{ +struct strbuf sb =STRBUF_INIT ; +
Quoted 8 lines
submodule.c void prepare_submodule_repo_env(struct argv_array *out) · line 503
Quoted 6 lines
submodule.c +6
-0+if (submodule_to_gitdir (&sb, path) ||repo_init (out, sb.buf,NULL )) { +strbuf_release (&sb); +return -1 ; + } + + out->submodule_prefix =xstrdup (path);Do we need to set
submodule_prefix?
Good point! Thanks for catching this.
Quoted 5 lines
Quoted 5 lines
submodule.c +0
-0@@ -507,7 +533,7 @@ static void show_submodule_header(struct diff_options *o, const char *path,else if (is_null_oid (two)) message ="(submodule deleted)" ;
Quoted 9 lines
submodule.c static void show_submodule_header(struct diff_options *o, const char *path, · line 536
Quoted 2 lines
submodule.c +1
-1-if (add_submodule_odb (path)) { +if (open_submodule (sub, path) <0 ) {This function, as a side effect, writes the open repository to "sub" for its caller to use. I think it's better if its callers open "sub" and then pass it to
show_submodule_header()if successful. If opening the submodule is expected to fail sometimes (like it seems here), then we can allow callers to also pass NULL, and document what happens when NULL is passed.
That looks intriguing, I'll take a look. Note that we also pass in **left and **right to have it assigned in there.
Quoted 2 lines
Also, repositories open in this way should also be freed.
Yes, thanks!
Re: [PATCH 17/19] submodule: use submodule repos for object lookup
In reply to Jonathan TanQuoted 30 lines · Jonathan Tan
Quoted 7 lines
+/*
+ * Initialize 'out' based on the provided submodule path.
+ *
+ * Unlikerepo_submodule_init, this tolerates submodules not present
+ * in .gitmodules. NEEDSWORK: Therepo_submodule_initbehavior is
+ * preferrable. This function exists only to preserve historical behavior.What do you mean by "The
repo_submodule_initbehavior is preferable"? If we need to preserve historical behavior, then it seems that the most preferable one is something that meets our needs (likeopen_submodule()in this patch).submodule.c void prepare_submodule_repo_env(struct argv_array *out) · line 503
Quoted 10 lines
submodule.c +10
-0+static int open_submodule (struct repository *out,const char *path) +{ +struct strbuf sb =STRBUF_INIT ; + +if (submodule_to_gitdir (&sb, path) ||repo_init (out, sb.buf,NULL )) { +strbuf_release (&sb); +return -1 ; + } + + out->submodule_prefix =xstrdup (path);Do we need to set
submodule_prefix?Quoted 4 lines
submodule.c +0
-0@@ -507,7 +533,7 @@ static void show_submodule_header(struct diff_options *o, const char *path,else if (is_null_oid (two)) message ="(submodule deleted)" ;
Quoted 9 lines
submodule.c static void show_submodule_header(struct diff_options *o, const char *path, · line 536
Quoted 2 lines
submodule.c +1
-1-if (add_submodule_odb (path)) { +if (open_submodule (sub, path) <0 ) {This function, as a side effect, writes the open repository to "sub" for its caller to use. I think it's better if its callers open "sub" and then pass it to
show_submodule_header()if successful. If opening the submodule is expected to fail sometimes (like it seems here), then we can allow callers to also pass NULL, and document what happens when NULL is passed.
Thanks for the review of the whole series!
I have redone this series, addressing all your comments. I addressed this comment differently than suggested, and put the submodule repository argument at the end of the parameter list, such that it goes with all the other arguments to be filled in.
I was about to resend the series, but test-merged with the other submodule series in flight (origin/sb/submodule-recursive-fetch-gets-the-tip) which had some conflicts that I can easily resolve by rebasing on top.
It conflicts a lot when merging to next, due to the latest patch ("Apply semantic patches from previous patches"), so I am not sure how to proceed properly. Maybe we'd omit that patch and run 'make coccicheck' on next to apply the semantic patches there instead.
Re: [PATCH 17/19] submodule: use submodule repos for object lookup
Quoted 6 lines
Thanks for the review of the whole series!
I have redone this series, addressing all your comments. I addressed this comment differently than suggested, and put the submodule repository argument at the end of the parameter list, such that it goes with all the other arguments to be filled in.
Sounds good.
Quoted 3 lines
I was about to resend the series, but test-merged with the other submodule series in flight (origin/sb/submodule-recursive-fetch-gets-the-tip) which had some conflicts that I can easily resolve by rebasing on top.
I presume you are talking about [1]? Maybe consider rebasing that one on top of this instead, since this is just a refactoring whereas submodule-recursive-fetch-gets-the-tip changes functionality, from what I understand of patches 8 and 9.
[1] https://public-inbox.org/git/[email protected]/
Quoted 5 lines
It conflicts a lot when merging to next, due to the latest patch ("Apply semantic patches from previous patches"), so I am not sure how to proceed properly. Maybe we'd omit that patch and run 'make coccicheck' on next to apply the semantic patches there instead.
Omitting the patch sounds good to me. For me, just stating that you have excluded any coccinelle-generated patches in order to ease merging into the various branches is sufficient, and people can test the coccinelle patches included by running "make coccicheck" then "patch -p1 <contrib/coccinelle/the_repository.cocci.patch".
Re: [PATCH 17/19] submodule: use submodule repos for object lookup
Quoted 9 lines · Jonathan Tan
Quoted 7 lines
Thanks for the review of the whole series!
I have redone this series, addressing all your comments. I addressed this comment differently than suggested, and put the submodule repository argument at the end of the parameter list, such that it goes with all the other arguments to be filled in.
Sounds good.
Actually I changed my mind on that after figuring out how to free the submodule repository appropriately and went with your original suggestion.
Quoted 9 lines
Quoted 4 lines
I was about to resend the series, but test-merged with the other submodule series in flight (origin/sb/submodule-recursive-fetch-gets-the-tip) which had some conflicts that I can easily resolve by rebasing on top.
I presume you are talking about [1]? Maybe consider rebasing that one on top of this instead, since this is just a refactoring whereas submodule-recursive-fetch-gets-the-tip changes functionality, from what I understand of patches 8 and 9.
From my understanding, that series is further along than this one, so I would not want to mix up their order.
Currently I am rebasing this on top of select topics from next, (ds/reachable) as that are the other conflicts that I'd have to deal with.
Quoted 8 lines
[1] https://public-inbox.org/git/[email protected]/
Quoted 5 lines
It conflicts a lot when merging to next, due to the latest patch ("Apply semantic patches from previous patches"), so I am not sure how to proceed properly. Maybe we'd omit that patch and run 'make coccicheck' on next to apply the semantic patches there instead.
Quoted 5 lines
Omitting the patch sounds good to me. For me, just stating that you have excluded any coccinelle-generated patches in order to ease merging into the various branches is sufficient, and people can test the coccinelle patches included by running "make coccicheck" then "patch -p1 <
contrib/coccinelle/the_repository.cocci.patch".
ok.
Thanks,
Stefan
PATCH 18/19 submodule: don't add submodule as odb for push
In reply to Stefan BellerThe submodule was added as an alternative in eb21c732d6 (push: teach --recurse-submodules the on-demand option, 2012-03-29), but was not explained, why.
In similar code, submodule_has_commits, the submodule is added as an alternative to perform a quick check if we need to dive into the submodule.
However in push_submodule
(a) for_each_remote_ref_submodule will also provide the quick check and
(b) after that we don't need to have submodule objects around, as all further code is to spawn a separate process.
--- submodule.c | 3 --- 1 file changed, 3 deletions(-)
submodule.c +0 -3
@@ -1006,9 +1006,6 @@ static int push_submodule(const char *path,const struct string_list *push_options, int dry_run) { - if (add_submodule_odb(path)) - return 1; - if (for_each_remote_ref_submodule(path, has_remote, NULL) > 0) { struct child_process cp = CHILD_PROCESS_INIT;argv_array_push (&cp.args,"push" );
Signature · 1 line
2.19.0
Re: [PATCH 18/19] submodule: don't add submodule as odb for push
Quoted 11 lines
The submodule was added as an alternative in
eb21c732d6(push: teach --recurse-submodules the on-demand option, 2012-03-29), but was not explained, why.In similar code,
submodule_has_commits, the submodule is added as an alternative to perform a quick check if we need to dive into the submodule.However in
push_submodule
(a)for_each_remote_ref_submodulewill also provide the quick check and
(b) after that we don't need to have submodule objects around, as all further code is to spawn a separate process.
After some investigation, I think I understand. I would explain it this way:
In push_submodule(), because we do not actually need access to objects in the submodule, do not invoke add_submodule_odb(). (for_each_remote_ref_submodule() does not require access to those objects, and the actual push is done by spawning another process, which handles object access by itself.)
I'm not sure if it's worth mentioning the commit in which the call was introduced, since nothing seems to have changed between then and now (the same bug is present when it was introduced, and now).
I also checked the users of push_submodule() (transport_push()) and indeed it doesn't seem to make use of the additional objects brought in by add_submodule_odb().
Do you know if pushing of submodules is exercised by any test?
Other than that, the code itself looks good.
Re: [PATCH 18/19] submodule: don't add submodule as odb for push
Quoted 1 line
Do you know if pushing of submodules is exercised by any test?
t5531-deep-submodule-push.sh (all of them) t5545-push-options.sh (ok 4 - push options and submodules)
PATCH 19/19 Apply semantic patches from previous patches
In reply to Stefan BellerPrevious commits added some cocci rules, but did not patch the whole tree, as to not dilute the focus for reviewing the previous patches.
This patch is generated by 'make coccicheck' and applying the resulting diff, which was white space damaged (>8 spaces after a tab) in blame.c, which has been fixed.
--- apply.c | 6 ++-- archive.c | 5 +-- bisect.c | 5 +-- blame.c | 15 +++++---- builtin/am.c | 2 +- builtin/blame.c | 4 +-- builtin/cat-file.c | 21 +++++++----- builtin/checkout.c | 4 +-- builtin/commit.c | 13 +++++--- builtin/describe.c | 4 +-- builtin/difftool.c | 3 +- builtin/fast-export.c | 7 ++-- builtin/fmt-merge-msg.c | 8 +++-- builtin/grep.c | 2 +- builtin/index-pack.c | 8 +++-- builtin/log.c | 4 +-- builtin/merge-base.c | 2 +- builtin/merge-tree.c | 9 ++++-- builtin/mktag.c | 3 +- builtin/name-rev.c | 2 +- builtin/notes.c | 12 ++++--- builtin/pack-objects.c | 22 +++++++++---- builtin/reflog.c | 5 +-- builtin/replace.c | 2 +- builtin/shortlog.c | 5 +-- builtin/show-branch.c | 4 +-- builtin/tag.c | 4 +-- builtin/unpack-file.c | 2 +- builtin/unpack-objects.c | 3 +- builtin/verify-commit.c | 2 +- bundle.c | 2 +- combine-diff.c | 2 +- commit-graph.c | 8 ++--- commit.c | 15 +++++---- config.c | 2 +- diff.c | 3 +- dir.c | 2 +- entry.c | 3 +- fast-import.c | 7 ++-- fsck.c | 9 +++--- grep.c | 3 +- http-push.c | 3 +- log-tree.c | 3 +- mailmap.c | 2 +- match-trees.c | 4 +-- merge-blobs.c | 6 ++-- merge-recursive.c | 13 ++++---- negotiator/default.c | 6 ++-- negotiator/skipping.c | 2 +- notes-cache.c | 5 +-- notes-merge.c | 4 +-- notes-utils.c | 2 +- notes.c | 10 +++--- pretty.c | 5 +-- read-cache.c | 5 +-- remote-testsvn.c | 4 +-- remote.c | 2 +- rerere.c | 5 +-- revision.c | 12 +++---- sequencer.c | 55 +++++++++++++++++++------------- sha1-file.c | 3 +- sha1-name.c | 9 +++--- shallow.c | 4 +-- submodule-config.c | 3 +- t/helper/test-revision-walking.c | 3 +- tag.c | 5 +-- tree-walk.c | 6 ++-- tree.c | 5 +-- walker.c | 2 +- xdiff-interface.c | 2 +- 70 files changed, 254 insertions(+), 180 deletions(-)
apply.c +4 -2
@@ -3187,7 +3187,8 @@ static int apply_binary(struct apply_state *state,unsigned long size;char *result; - result =read_object_file (&oid, &type, &size); + result =repo_read_object_file (the_repository, &oid, &type, + &size);if (!result) return error(_("the necessary postimage %s for " "'%s' cannot be read"),
@@ -3249,7 +3250,8 @@ static int read_blob_object(struct strbuf *buf, const struct object_id *oid, unsunsigned long sz;char *result; - result =read_object_file (oid, &type, &sz); + result =repo_read_object_file (the_repository, oid, &type, + &sz);if (!result)return -1 ;/* XXX read_sha1_file NUL-terminates */
archive.c +3 -2
@@ -55,7 +55,8 @@ static void format_subst(const struct commit *commit,strbuf_add (&fmt, b +8 , c - b -8 );strbuf_add (buf, src, b - src); -format_commit_message (commit, fmt.buf, buf, &ctx); +repo_format_commit_message (the_repository, commit, fmt.buf, + buf, &ctx); len -= c +1 - src; src = c +1 ; }
@@ -73,7 +74,7 @@ void *object_file_to_archive(const struct archiver_args *args,const struct commit *commit = args->convert ? args->commit :NULL ; path += args->baselen; - buffer =read_object_file (oid, type, sizep); + buffer =repo_read_object_file (the_repository, oid, type, sizep);if (buffer &&S_ISREG (mode)) {struct strbuf buf =STRBUF_INIT ;size_t size =0 ;
bisect.c +3 -2
@@ -136,8 +136,9 @@ static void show_list(const char *debug, int counted, int nr,unsigned flags = commit->object.flags;enum object_type type;unsigned long size; -char *buf =read_object_file (&commit->object.oid, &type, - &size); +char *buf =repo_read_object_file (the_repository, + &commit->object.oid, &type, + &size);const char *subject_start;int subject_len;
blame.c +9 -6
@@ -322,8 +322,9 @@ static void fill_origin_blob(struct diff_options *opt, &o->blob_oid, 1, &file->ptr, &file_size)) ; else - file->ptr = read_object_file(&o->blob_oid, &type, - &file_size); + file->ptr = repo_read_object_file(the_repository, + &o->blob_oid, &type, + &file_size); file->size = file_size;if (!file->ptr)
@@ -1455,7 +1456,7 @@ static void pass_blame(struct blame_scoreboard *sb, struct blame_origin *origin,if (sg_origin[i])continue ; -if (parse_commit (p)) +if (repo_parse_commit (the_repository, p))continue ; porigin =find (sb->repo, p, origin);if (!porigin)
@@ -1594,7 +1595,7 @@ void assign_blame(struct blame_scoreboard *sb, int opt)* so hold onto it in the meantime. */ blame_origin_incref (suspect); -parse_commit (commit); +repo_parse_commit (the_repository, commit);if (sb->reverse || (!(commit->object.flags &UNINTERESTING ) && !(revs->max_age !=-1 && commit->date < revs->max_age)))
@@ -1864,8 +1865,10 @@ void setup_scoreboard(struct blame_scoreboard *sb, &sb->final_buf_size)) ; else - sb->final_buf = read_object_file(&o->blob_oid, &type, - &sb->final_buf_size); + sb->final_buf = repo_read_object_file(the_repository, + &o->blob_oid, + &type, + &sb->final_buf_size);if (!sb->final_buf) die(_("cannot read blob %s for path %s"),
builtin/am.c +1 -1
@@ -1360,7 +1360,7 @@ static void get_commit_info(struct am_state *state, struct commit *commit)die (_ ("unable to parse commit %s" ),oid_to_hex (&commit->object.oid)); state->msg =xstrdup (msg +2 ); state->msg_len =strlen (state->msg); -unuse_commit_buffer (commit, buffer); +repo_unuse_commit_buffer (the_repository, commit, buffer); }/**
builtin/blame.c +2 -2
@@ -197,7 +197,7 @@ static void get_commit_info(struct commit *commit, &ret->author_time, &ret->author_tz);if (!detailed) { -unuse_commit_buffer (commit, message); +repo_unuse_commit_buffer (the_repository, commit, message);return ; }
@@ -211,7 +211,7 @@ static void get_commit_info(struct commit *commit,else strbuf_addf (&ret->summary,"(%s)" ,oid_to_hex (&commit->object.oid)); -unuse_commit_buffer (commit, message); +repo_unuse_commit_buffer (the_repository, commit, message); }/*
builtin/cat-file.c +13 -8
@@ -34,7 +34,7 @@ static int filter_object(const char *path, unsigned mode, {enum object_type type; - *buf =read_object_file (oid, &type, size); + *buf =repo_read_object_file (the_repository, oid, &type, size);if (!*buf)return error (_ ("cannot read object %s '%s'" ),oid_to_hex (oid), path);
@@ -133,7 +133,8 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name,if (type ==OBJ_BLOB )return stream_blob_to_fd (1 , &oid,NULL ,0 ); - buf =read_object_file (&oid, &type, &size); + buf =repo_read_object_file (the_repository, &oid, &type, + &size);if (!buf)die ("Cannot read object %s" , obj_name);
@@ -144,8 +145,10 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name,if (type_from_string (exp_type) ==OBJ_BLOB ) {struct object_id blob_oid;if (oid_object_info (the_repository, &oid,NULL ) ==OBJ_TAG ) { -char *buffer =read_object_file (&oid, &type, - &size); +char *buffer =repo_read_object_file (the_repository, + &oid, + &type, + &size);const char *target;if (!skip_prefix (buffer,"object " , &target) ||get_oid_hex (target, &blob_oid))
@@ -309,9 +312,10 @@ static void print_object_or_die(struct batch_options *opt, struct expand_data *dif (!textconv_object (the_repository, data->rest,0100644 , oid,1 , &contents, &size)) - contents =read_object_file (oid, - &type, - &size); + contents =repo_read_object_file (the_repository, + oid, + &type, + &size);if (!contents)die ("could not convert '%s' %s" ,oid_to_hex (oid), data->rest);
@@ -327,7 +331,8 @@ static void print_object_or_die(struct batch_options *opt, struct expand_data *dunsigned long size;void *contents; - contents =read_object_file (oid, &type, &size); + contents =repo_read_object_file (the_repository, oid, &type, + &size);if (!contents)die ("object %s disappeared" ,oid_to_hex (oid));if (type != data->type)
builtin/checkout.c +2 -2
@@ -404,7 +404,7 @@ static void describe_detached_head(const char *msg, struct commit *commit) {struct strbuf sb =STRBUF_INIT ; -if (!parse_commit (commit)) +if (!repo_parse_commit (the_repository, commit))pp_commit_easy (CMIT_FMT_ONELINE , commit, &sb);if (print_sha1_ellipsis ()) { fprintf(stderr, "%s %s... %s\n", msg,
@@ -732,7 +732,7 @@ static void describe_one_orphan(struct strbuf *sb, struct commit *commit)strbuf_addstr (sb," " );strbuf_add_unique_abbrev (sb, &commit->object.oid,DEFAULT_ABBREV );strbuf_addch (sb,' ' ); -if (!parse_commit (commit)) +if (!repo_parse_commit (the_repository, commit))pp_commit_easy (CMIT_FMT_ONELINE , commit, sb);strbuf_addch (sb,'\n' ); }
builtin/commit.c +8 -5
@@ -680,8 +680,9 @@ static int prepare_to_commit(const char *index_file, const char *prefix,if (!c)die (_ ("could not lookup commit %s" ), squash_message); ctx.output_encoding =get_commit_output_encoding (); -format_commit_message (c,"squash! %s\n\n" , &sb, - &ctx); +repo_format_commit_message (the_repository, c, +"squash! %s\n\n" , &sb, + &ctx); } }
@@ -713,8 +714,9 @@ static int prepare_to_commit(const char *index_file, const char *prefix,if (!commit)die (_ ("could not lookup commit %s" ), fixup_message); ctx.output_encoding =get_commit_output_encoding (); -format_commit_message (commit,"fixup! %s\n\n" , - &sb, &ctx); +repo_format_commit_message (the_repository, commit, +"fixup! %s\n\n" , + &sb, &ctx);if (have_option_m)strbuf_addbuf (&sb, &message); hook_arg1 ="message" ;
@@ -997,7 +999,8 @@ static const char *find_author_by_nickname(const char *name)struct pretty_print_context ctx = {0 }; ctx.date_mode.type =DATE_NORMAL ;strbuf_release (&buf); -format_commit_message (commit,"%aN <%aE>" , &buf, &ctx); +repo_format_commit_message (the_repository, commit, +"%aN <%aE>" , &buf, &ctx);clear_mailmap (&mailmap);return strbuf_detach (&buf,NULL ); }
builtin/describe.c +2 -2
@@ -254,7 +254,7 @@ static unsigned long finish_depth_computation( best->depth++;while (parents) {struct commit *p = parents->item; -parse_commit (p); +repo_parse_commit (the_repository, p);if (!(p->object.flags &SEEN ))commit_list_insert_by_date (p, list); p->object.flags |= c->object.flags;
@@ -381,7 +381,7 @@ static void describe_commit(struct object_id *oid, struct strbuf *dst) }while (parents) {struct commit *p = parents->item; -parse_commit (p); +repo_parse_commit (the_repository, p);if (!(p->object.flags &SEEN ))commit_list_insert_by_date (p, &list); p->object.flags |= c->object.flags;
builtin/difftool.c +2 -1
@@ -307,7 +307,8 @@ static char *get_symlink(const struct object_id *oid, const char *path) }else {enum object_type type;unsigned long size; - data =read_object_file (oid, &type, &size); + data =repo_read_object_file (the_repository, oid, &type, + &size);if (!data)die (_ ("could not read object %s for symlink %s" ),oid_to_hex (oid), path);
builtin/fast-export.c +4 -3
@@ -239,7 +239,7 @@ static void export_blob(const struct object_id *oid) object = (struct object *)lookup_blob (the_repository, oid); eaten =0 ; }else { - buf =read_object_file (oid, &type, &size); + buf =repo_read_object_file (the_repository, oid, &type, &size);if (!buf)die ("could not read blob %s" ,oid_to_hex (oid));if (check_object_signature (oid, buf, size,type_name (type)) <0 )
@@ -617,7 +617,7 @@ static void handle_commit(struct commit *commit, struct rev_info *rev, ? strlen(message) : 0), reencoded ? reencoded : message ? message : "");free (reencoded); -unuse_commit_buffer (commit, commit_buffer); +repo_unuse_commit_buffer (the_repository, commit, commit_buffer);for (i =0 , p = commit->parents; p; p = p->next) {int mark =get_object_mark (&p->item->object);
@@ -689,7 +689,8 @@ static void handle_tag(const char *name, struct tag *tag)return ; } - buf =read_object_file (&tag->object.oid, &type, &size); + buf =repo_read_object_file (the_repository, &tag->object.oid, &type, + &size);if (!buf)die ("could not read tag %s" ,oid_to_hex (&tag->object.oid)); message =memmem (buf, size,"\n\n" ,2 );
builtin/fmt-merge-msg.c +5 -3
@@ -264,7 +264,7 @@ static void record_person(int which, struct string_list *people, {const char *buffer =get_commit_buffer (commit,NULL );record_person_from_buf (which, people, buffer); -unuse_commit_buffer (commit, buffer); +repo_unuse_commit_buffer (the_repository, commit, buffer); }static int cmp_string_list_util_as_integral (const void *a_,const void *b_)
@@ -375,7 +375,8 @@ static void shortlog(const char *name,if (subjects.nr > limit)continue ; -format_commit_message (commit,"%s" , &sb, &ctx); +repo_format_commit_message (the_repository, commit,"%s" , &sb, + &ctx);strbuf_ltrim (&sb);if (!sb.len)
@@ -493,7 +494,8 @@ static void fmt_merge_msg_sigs(struct strbuf *out)struct object_id *oid = origins.items[i].util;enum object_type type;unsigned long size, len; -char *buf =read_object_file (oid, &type, &size); +char *buf =repo_read_object_file (the_repository, oid, &type, + &size);struct strbuf sig =STRBUF_INIT ;if (!buf || type !=OBJ_TAG )
builtin/grep.c +1 -1
@@ -308,7 +308,7 @@ static void *lock_and_read_oid_file(const struct object_id *oid, enum object_typvoid *data;grep_read_lock (); - data =read_object_file (oid, type, size); + data =repo_read_object_file (the_repository, oid, type, size);grep_read_unlock ();return data; }
builtin/index-pack.c +5 -3
@@ -817,7 +817,8 @@ static void sha1_object(const void *data, struct object_entry *obj_entry,die (_ ("cannot read existing object info %s" ),oid_to_hex (oid));if (has_type != type || has_size != size)die (_ ("SHA1 COLLISION FOUND WITH %s !" ),oid_to_hex (oid)); - has_data =read_object_file (oid, &has_type, &has_size); + has_data =repo_read_object_file (the_repository, oid, + &has_type, &has_size);read_unlock ();if (!data) data = new_data =get_data_from_pack (obj_entry);
@@ -1379,8 +1380,9 @@ static void fix_unresolved_deltas(struct hashfile *f)if (objects[d->obj_no].real_type !=OBJ_REF_DELTA )continue ; - base_obj->data =read_object_file (&d->oid, &type, - &base_obj->size); + base_obj->data =repo_read_object_file (the_repository, + &d->oid, &type, + &base_obj->size);if (!base_obj->data)continue ;
builtin/log.c +2 -2
@@ -525,7 +525,7 @@ static int show_tag_object(const struct object_id *oid, struct rev_info *rev) {unsigned long size;enum object_type type; -char *buf =read_object_file (oid, &type, &size); +char *buf =repo_read_object_file (the_repository, oid, &type, &size);int offset =0 ;if (!buf)
@@ -1032,7 +1032,7 @@ static void make_cover_letter(struct rev_info *rev, int use_stdout,const char *buf =get_commit_buffer (list[i],NULL );if (has_non_ascii (buf)) need_8bit_cte =1 ; -unuse_commit_buffer (list[i], buf); +repo_unuse_commit_buffer (the_repository, list[i], buf); }if (!branch_name)
builtin/merge-base.c +1 -1
@@ -127,7 +127,7 @@ static void add_one_commit(struct object_id *oid, struct rev_collect *revs) commit =lookup_commit (the_repository, oid);if (!commit || (commit->object.flags &TMP_MARK ) || -parse_commit (commit)) +repo_parse_commit (the_repository, commit))return ;ALLOC_GROW (revs->commit, revs->nr +1 , revs->alloc);
builtin/merge-tree.c +6 -3
@@ -62,7 +62,9 @@ static void *result(struct merge_list *entry, unsigned long *size)const char *path = entry->path;if (!entry->stage) -return read_object_file (&entry->blob->object.oid, &type, size); +return repo_read_object_file (the_repository, + &entry->blob->object.oid, &type, + size); base =NULL ;if (entry->stage ==1 ) { base = entry->blob;
@@ -84,8 +86,9 @@ static void *origin(struct merge_list *entry, unsigned long *size)enum object_type type;while (entry) {if (entry->stage ==2 ) -return read_object_file (&entry->blob->object.oid, - &type, size); +return repo_read_object_file (the_repository, + &entry->blob->object.oid, + &type, size); entry = entry->link; }return NULL ;
builtin/mktag.c +2 -1
@@ -25,7 +25,8 @@ static int verify_object(const struct object_id *oid, const char *expected_type)int ret =-1 ;enum object_type type;unsigned long size; -void *buffer =read_object_file (oid, &type, &size); +void *buffer =repo_read_object_file (the_repository, oid, &type, + &size);const struct object_id *repl =lookup_replace_object (the_repository, oid);if (buffer) {
builtin/name-rev.c +1 -1
@@ -87,7 +87,7 @@ static void name_rev(struct commit *commit,int parent_number =1 ;char *to_free =NULL ; -parse_commit (commit); +repo_parse_commit (the_repository, commit);if (commit->date < cutoff)return ;
builtin/notes.c +7 -5
@@ -124,7 +124,7 @@ static void copy_obj_to_fd(int fd, const struct object_id *oid) {unsigned long size;enum object_type type; -char *buf =read_object_file (oid, &type, &size); +char *buf =repo_read_object_file (the_repository, oid, &type, &size);if (buf) {if (size)write_or_die (fd, buf, size);
@@ -255,7 +255,7 @@ static int parse_reuse_arg(const struct option *opt, const char *arg, int unset)if (get_oid (arg, &object))die (_ ("failed to resolve '%s' as a valid ref." ), arg); -if (!(buf =read_object_file (&object, &type, &len))) { +if (!(buf =repo_read_object_file (the_repository, &object, &type, &len))) {free (buf);die (_ ("failed to read object '%s'." ), arg); }
@@ -610,7 +610,8 @@ static int append_edit(int argc, const char **argv, const char *prefix)/* Append buf to previous note contents */ unsigned long size;enum object_type type; -char *prev_buf =read_object_file (note, &type, &size); +char *prev_buf =repo_read_object_file (the_repository, note, + &type, &size);strbuf_grow (&d.buf, size +1 );if (d.buf.len && prev_buf && size)
@@ -714,7 +715,7 @@ static int merge_commit(struct notes_merge_options *o)die (_ ("failed to read ref NOTES_MERGE_PARTIAL" )); else if (!(partial = lookup_commit_reference(the_repository, &oid)))die (_ ("could not find commit from NOTES_MERGE_PARTIAL." )); - else if (parse_commit(partial)) + else if (repo_parse_commit(the_repository, partial)) die(_("could not parse commit from NOTES_MERGE_PARTIAL."));if (partial->parents)
@@ -735,7 +736,8 @@ static int merge_commit(struct notes_merge_options *o)/* Reuse existing commit message in reflog message */ memset (&pretty_ctx,0 ,sizeof (pretty_ctx)); -format_commit_message (partial,"%s" , &msg, &pretty_ctx); +repo_format_commit_message (the_repository, partial,"%s" , &msg, + &pretty_ctx);strbuf_trim (&msg);strbuf_insert (&msg,0 ,"notes: " ,7 ); update_ref(msg.buf, o->local_ref, &oid,
builtin/pack-objects.c +15 -7
@@ -138,11 +138,13 @@ static void *get_delta(struct object_entry *entry)void *buf, *base_buf, *delta_buf;enum object_type type; - buf =read_object_file (&entry->idx.oid, &type, &size); + buf =repo_read_object_file (the_repository, &entry->idx.oid, &type, + &size);if (!buf)die (_ ("unable to read %s" ),oid_to_hex (&entry->idx.oid)); - base_buf =read_object_file (&DELTA (entry)->idx.oid, &type, - &base_size); + base_buf =repo_read_object_file (the_repository, + &DELTA (entry)->idx.oid, &type, + &base_size);if (!base_buf)die ("unable to read %s" ,oid_to_hex (&DELTA (entry)->idx.oid));
@@ -292,7 +294,9 @@ static unsigned long write_no_reuse_object(struct hashfile *f, struct object_ent (st = open_istream(&entry->idx.oid, &type, &size, NULL)) != NULL) buf = NULL; else { - buf =read_object_file (&entry->idx.oid, &type, &size); + buf =repo_read_object_file (the_repository, + &entry->idx.oid, &type, + &size);if (!buf)die (_ ("unable to read %s" ),oid_to_hex (&entry->idx.oid));
@@ -1218,7 +1222,7 @@ static struct pbase_tree_cache *pbase_tree_get(const struct object_id *oid)/* Did not find one. Either we got a bogus request or * we need to read and perhaps cache. */ - data =read_object_file (oid, &type, &size); + data =repo_read_object_file (the_repository, oid, &type, &size);if (!data)return NULL ;if (type !=OBJ_TREE ) {
@@ -1989,7 +1993,9 @@ static int try_delta(struct unpacked *trg, struct unpacked *src,/* Load data if not already done */ if (!trg->data) {read_lock (); - trg->data =read_object_file (&trg_entry->idx.oid, &type, &sz); + trg->data =repo_read_object_file (the_repository, + &trg_entry->idx.oid, &type, + &sz);read_unlock ();if (!trg->data) die(_("object %s cannot be read"),
@@ -2002,7 +2008,9 @@ static int try_delta(struct unpacked *trg, struct unpacked *src, }if (!src->data) {read_lock (); - src->data =read_object_file (&src_entry->idx.oid, &type, &sz); + src->data =repo_read_object_file (the_repository, + &src_entry->idx.oid, &type, + &sz);read_unlock ();if (!src->data) {if (src_entry->preferred_base) {
builtin/reflog.c +3 -2
@@ -77,7 +77,8 @@ static int tree_is_complete(const struct object_id *oid)if (!tree->buffer) {enum object_type type;unsigned long size; -void *data =read_object_file (oid, &type, &size); +void *data =repo_read_object_file (the_repository, oid, &type, + &size);if (!data) { tree->object.flags |=INCOMPLETE ;return 0 ;
@@ -235,7 +236,7 @@ static void mark_reachable(struct expire_reflog_policy_cb *cb)struct commit *commit =pop_commit (&pending);if (commit->object.flags &REACHABLE )continue ; -if (parse_commit (commit)) +if (repo_parse_commit (the_repository, commit))continue ; commit->object.flags |=REACHABLE ;if (commit->date < expire_limit) {
builtin/replace.c +1 -1
@@ -449,7 +449,7 @@ static int create_graft(int argc, const char **argv, int force, int gentle) buffer =get_commit_buffer (commit, &size);strbuf_add (&buf, buffer, size); -unuse_commit_buffer (commit, buffer); +repo_unuse_commit_buffer (the_repository, commit, buffer);if (replace_parents (&buf, argc -1 , &argv[1 ]) <0 ) {strbuf_release (&buf);
builtin/shortlog.c +3 -2
@@ -170,12 +170,13 @@ void shortlog_add_commit(struct shortlog *log, struct commit *commit) (log->email ? "%cN <%cE>" : "%cN") : (log->email ?"%aN <%aE>" :"%aN" ); -format_commit_message (commit, fmt, &author, &ctx); +repo_format_commit_message (the_repository, commit, fmt, &author, &ctx);if (!log->summary) {if (log->user_format)pretty_print_commit (&ctx, commit, &oneline);else -format_commit_message (commit,"%s" , &oneline, &ctx); +repo_format_commit_message (the_repository, commit, +"%s" , &oneline, &ctx); }insert_one_record (log, author.buf, oneline.len ? oneline.buf :"<none>" );
builtin/show-branch.c +2 -2
@@ -238,7 +238,7 @@ static void join_revs(struct commit_list **list_p, parents = parents->next;if ((this_flag & flags) == flags)continue ; -parse_commit (p); +repo_parse_commit (the_repository, p);if (mark_seen (p, seen_p) && !still_interesting) extra--; p->object.flags |= flags;
@@ -835,7 +835,7 @@ int cmd_show_branch(int ac, const char **av, const char *prefix)if (!commit)die (_ ("cannot find commit %s (%s)" ), ref_name[num_rev],oid_to_hex (&revkey)); -parse_commit (commit); +repo_parse_commit (the_repository, commit);mark_seen (commit, &seen);/* rev#0 uses bit REV_SHIFT, rev#1 uses bit REV_SHIFT+1,
builtin/tag.c +2 -2
@@ -169,7 +169,7 @@ static void write_tag_body(int fd, const struct object_id *oid)enum object_type type;char *buf, *sp; - buf =read_object_file (oid, &type, &size); + buf =repo_read_object_file (the_repository, oid, &type, &size);if (!buf)return ;/* skip header */
@@ -305,7 +305,7 @@ static void create_reflog_msg(const struct object_id *oid, struct strbuf *sb)strbuf_addstr (sb,"object of unknown type" );break ;case OBJ_COMMIT : -if ((buf =read_object_file (oid, &type, &size)) !=NULL ) { +if ((buf =repo_read_object_file (the_repository, oid, &type, &size)) !=NULL ) { subject_len =find_commit_subject (buf, &subject_start);strbuf_insert (sb, sb->len, subject_start, subject_len); }else {
builtin/unpack-file.c +1 -1
@@ -10,7 +10,7 @@ static char *create_temp_file(struct object_id *oid)unsigned long size;int fd; - buf =read_object_file (oid, &type, &size); + buf =repo_read_object_file (the_repository, oid, &type, &size);if (!buf || type !=OBJ_BLOB )die ("unable to read blob object %s" ,oid_to_hex (oid));
builtin/unpack-objects.c +2 -1
@@ -425,7 +425,8 @@ static void unpack_delta_entry(enum object_type type, unsigned long delta_size,if (resolve_against_held (nr, &base_oid, delta_data, delta_size))return ; - base =read_object_file (&base_oid, &type, &base_size); + base =repo_read_object_file (the_repository, &base_oid, &type, + &base_size);if (!base) {error ("failed to read delta-pack base object %s" ,oid_to_hex (&base_oid));
builtin/verify-commit.c +1 -1
@@ -47,7 +47,7 @@ static int verify_commit(const char *name, unsigned flags)if (get_oid (name, &oid))return error ("commit '%s' not found." , name); - buf =read_object_file (&oid, &type, &size); + buf =repo_read_object_file (the_repository, &oid, &type, &size);if (!buf)return error ("%s: unable to read file." , name);if (type !=OBJ_COMMIT )
bundle.c +1 -1
@@ -224,7 +224,7 @@ static int is_tag_in_date_range(struct object *tag, struct rev_info *revs)if (revs->max_age ==-1 && revs->min_age ==-1 ) goto out; - buf =read_object_file (&tag->oid, &type, &size); + buf =repo_read_object_file (the_repository, &tag->oid, &type, &size);if (!buf) goto out; line =memmem (buf, size,"\ntagger " ,8 );
combine-diff.c +1 -1
@@ -308,7 +308,7 @@ static char *grab_blob(struct repository *r, *size =fill_textconv (r, textconv, df, &blob);free_filespec (df); }else { - blob =read_object_file (oid, &type, size); + blob =repo_read_object_file (the_repository, oid, &type, size);if (type !=OBJ_BLOB )die ("object '%s' is not a blob!" ,oid_to_hex (oid)); }
commit-graph.c +4 -4
@@ -435,7 +435,7 @@ static void write_graph_chunk_data(struct hashfile *f, int hash_len,int edge_value;uint32_t packedDate[2 ]; -parse_commit (*list); +repo_parse_commit (the_repository, *list);hashwrite (f,get_commit_tree_oid (*list)->hash, hash_len); parent = (*list)->parents;
@@ -606,7 +606,7 @@ static void close_reachable(struct packed_oid_list *oids)for (i =0 ; i < oids->nr; i++) { commit =lookup_commit (the_repository, &oids->list[i]); -if (commit && !parse_commit (commit)) +if (commit && !repo_parse_commit (the_repository, commit))add_missing_parents (oids, commit); }
@@ -783,7 +783,7 @@ void write_commit_graph(const char *obj_dir,continue ; commits.list[commits.nr] =lookup_commit (the_repository, &oids.list[i]); -parse_commit (commits.list[commits.nr]); +repo_parse_commit (the_repository, commits.list[commits.nr]);for (parent = commits.list[commits.nr]->parents; parent; parent = parent->next)
@@ -954,7 +954,7 @@ int verify_commit_graph(struct repository *r, struct commit_graph *g) graph_commit =lookup_commit (r, &cur_oid); odb_commit = (struct commit *)create_object (r, cur_oid.hash,alloc_commit_node (r)); -if (parse_commit_internal (odb_commit,0 ,0 )) { +if (repo_parse_commit_internal (the_repository, odb_commit,0 ,0 )) {graph_report ("failed to parse %s from object database" ,oid_to_hex (&cur_oid));continue ;
commit.c +8 -7
@@ -70,7 +70,7 @@ struct commit *lookup_commit_reference_by_name(const char *name)if (get_oid_committish (name, &oid))return NULL ; commit =lookup_commit_reference (the_repository, &oid); -if (parse_commit (commit)) +if (repo_parse_commit (the_repository, commit))return NULL ;return commit; }
@@ -491,7 +491,7 @@ int repo_parse_commit_gently(struct repository *r,void parse_commit_or_die (struct commit *item) { -if (parse_commit (item)) +if (repo_parse_commit (the_repository, item))die ("unable to parse commit %s" , item ?oid_to_hex (&item->object.oid) :"(null)" ); }
@@ -596,7 +596,7 @@ struct commit *pop_most_recent_commit(struct commit_list **list,while (parents) {struct commit *commit = parents->item; -if (!parse_commit (commit) && !(commit->object.flags & mark)) { +if (!repo_parse_commit (the_repository, commit) && !(commit->object.flags & mark)) { commit->object.flags |= mark;commit_list_insert_by_date (commit, list); }
@@ -689,7 +689,7 @@ static void record_author_date(struct author_date_slab *author_date, *(author_date_slab_at (author_date, commit)) = date; fail_exit: -unuse_commit_buffer (commit, buffer); +repo_unuse_commit_buffer (the_repository, commit, buffer); } static int compare_commits_by_author_date(const void *a_, const void *b_,
@@ -1302,7 +1302,7 @@ int parse_signed_commit(const struct commit *commit, } line = next; } -unuse_commit_buffer (commit, buffer); +repo_unuse_commit_buffer (the_repository, commit, buffer);return saw_signature; }
@@ -1351,7 +1351,8 @@ static void handle_signed_tag(struct commit *parent, struct commit_extra_header desc =merge_remote_util (parent);if (!desc || !desc->obj)return ; - buf =read_object_file (&desc->obj->oid, &type, &size); + buf =repo_read_object_file (the_repository, &desc->obj->oid, &type, + &size);if (!buf || type !=OBJ_TAG ) goto free_return; len =parse_signature (buf, size);
@@ -1429,7 +1430,7 @@ struct commit_extra_header *read_commit_extra_headers(struct commit *commit,unsigned long size;const char *buffer =get_commit_buffer (commit, &size); extra =read_commit_extra_header_lines (buffer, size, exclude); -unuse_commit_buffer (commit, buffer); +repo_unuse_commit_buffer (the_repository, commit, buffer);return extra; }
config.c +1 -1
@@ -1605,7 +1605,7 @@ int git_config_from_blob_oid(config_fn_t fn,unsigned long size;int ret; - buf =read_object_file (oid, &type, &size); + buf =repo_read_object_file (the_repository, oid, &type, &size);if (!buf)return error (_ ("unable to load config blob object '%s'" ), name);if (type !=OBJ_BLOB ) {
diff.c +2 -1
@@ -3939,7 +3939,8 @@ int diff_populate_filespec(struct repository *r,return 0 ; } } - s->data =read_object_file (&s->oid, &type, &s->size); + s->data =repo_read_object_file (the_repository, &s->oid, + &type, &s->size);if (!s->data)die ("unable to read %s" ,oid_to_hex (&s->oid)); s->should_free =1 ;
dir.c +1 -1
@@ -245,7 +245,7 @@ static int do_read_blob(const struct object_id *oid, struct oid_stat *oid_stat, *size_out =0 ; *data_out =NULL ; - data =read_object_file (oid, &type, &sz); + data =repo_read_object_file (the_repository, oid, &type, &sz);if (!data || type !=OBJ_BLOB ) {free (data);return -1 ;
entry.c +2 -1
@@ -86,7 +86,8 @@ static int create_file(const char *path, unsigned int mode)static void *read_blob_entry (const struct cache_entry *ce,unsigned long *size) {enum object_type type; -void *blob_data =read_object_file (&ce->oid, &type, size); +void *blob_data =repo_read_object_file (the_repository, &ce->oid, + &type, size);if (blob_data) {if (type ==OBJ_BLOB )
fast-import.c +4 -3
@@ -1371,7 +1371,7 @@ static void load_tree(struct tree_entry *root)die ("Can't load tree %s" ,oid_to_hex (oid)); }else {enum object_type type; - buf =read_object_file (oid, &type, &size); + buf =repo_read_object_file (the_repository, oid, &type, &size);if (!buf || type !=OBJ_TREE )die ("Can't load tree %s" ,oid_to_hex (oid)); }
@@ -2931,7 +2931,7 @@ static void cat_blob(struct object_entry *oe, struct object_id *oid)char *buf;if (!oe || oe->pack_id ==MAX_PACK_ID ) { - buf =read_object_file (oid, &type, &size); + buf =repo_read_object_file (the_repository, oid, &type, &size); }else { type = oe->type; buf =gfi_unpack_entry (oe, &size);
@@ -3037,7 +3037,8 @@ static struct object_entry *dereference(struct object_entry *oe, buf =gfi_unpack_entry (oe, &size); }else {enum object_type unused; - buf =read_object_file (oid, &unused, &size); + buf =repo_read_object_file (the_repository, oid, &unused, + &size); }if (!buf)die ("Can't load object %s" ,oid_to_hex (oid));
fsck.c +5 -4
@@ -447,7 +447,7 @@ static int fsck_walk_commit(struct commit *commit, void *data, struct fsck_optioint result;const char *name; -if (parse_commit (commit)) +if (repo_parse_commit (the_repository, commit))return -1 ; name =get_object_name (options, &commit->object);
@@ -859,7 +859,7 @@ static int fsck_commit(struct commit *commit, const char *data,const char *buffer = data ? data :get_commit_buffer (commit, &size);int ret =fsck_commit_buffer (commit, buffer, size, options);if (!data) -unuse_commit_buffer (commit, buffer); +repo_unuse_commit_buffer (the_repository, commit, buffer);return ret; }
@@ -879,7 +879,8 @@ static int fsck_tag_buffer(struct tag *tag, const char *data,enum object_type type; buffer = to_free = -read_object_file (&tag->object.oid, &type, &size); +repo_read_object_file (the_repository, + &tag->object.oid, &type, &size);if (!buffer) return report(options, &tag->object, FSCK_MSG_MISSING_TAG_OBJECT,
@@ -1091,7 +1092,7 @@ int fsck_finish(struct fsck_options *options)continue ; } - buf =read_object_file (oid, &type, &size); + buf =repo_read_object_file (the_repository, oid, &type, &size);if (!buf) {if (is_promisor_object (&blob->object.oid))continue ;
grep.c +2 -1
@@ -2112,7 +2112,8 @@ static int grep_source_load_oid(struct grep_source *gs)enum object_type type;grep_read_lock (); - gs->buf =read_object_file (gs->identifier, &type, &gs->size); + gs->buf =repo_read_object_file (the_repository, gs->identifier, &type, + &gs->size);grep_read_unlock ();if (!gs->buf)
http-push.c +2 -1
@@ -364,7 +364,8 @@ static void start_put(struct transfer_request *request)ssize_t size;git_zstream stream; - unpacked =read_object_file (&request->obj->oid, &type, &len); + unpacked =repo_read_object_file (the_repository, &request->obj->oid, + &type, &len); hdrlen =xsnprintf (hdr,sizeof (hdr),"%s %lu" ,type_name (type), len) +1 ;/* Set it up */
log-tree.c +2 -1
@@ -332,7 +332,8 @@ void fmt_output_commit(struct strbuf *filename,struct pretty_print_context ctx = {0 };struct strbuf subject =STRBUF_INIT ; -format_commit_message (commit,"%f" , &subject, &ctx); +repo_format_commit_message (the_repository, commit,"%f" , &subject, + &ctx);fmt_output_subject (filename, subject.buf, info);strbuf_release (&subject); }
mailmap.c +1 -1
@@ -225,7 +225,7 @@ static int read_mailmap_blob(struct string_list *map,if (get_oid (name, &oid) <0 )return 0 ; - buf =read_object_file (&oid, &type, &size); + buf =repo_read_object_file (the_repository, &oid, &type, &size);if (!buf)return error ("unable to read mailmap object at %s" , name);if (type !=OBJ_BLOB )
match-trees.c +2 -2
@@ -55,7 +55,7 @@ static void *fill_tree_desc_strict(struct tree_desc *desc,enum object_type type;unsigned long size; - buffer =read_object_file (hash, &type, &size); + buffer =repo_read_object_file (the_repository, hash, &type, &size);if (!buffer)die ("unable to read tree (%s)" ,oid_to_hex (hash));if (type !=OBJ_TREE )
@@ -190,7 +190,7 @@ static int splice_tree(const struct object_id *oid1, const char *prefix,if (*subpath) subpath++; - buf =read_object_file (oid1, &type, &sz); + buf =repo_read_object_file (the_repository, oid1, &type, &sz);if (!buf)die ("cannot read tree %s" ,oid_to_hex (oid1));init_tree_desc (&desc, buf, sz);
merge-blobs.c +4 -2
@@ -12,7 +12,8 @@ static int fill_mmfile_blob(mmfile_t *f, struct blob *obj)unsigned long size;enum object_type type; - buf =read_object_file (&obj->object.oid, &type, &size); + buf =repo_read_object_file (the_repository, &obj->object.oid, &type, + &size);if (!buf)return -1 ;if (type !=OBJ_BLOB ) {
@@ -75,7 +76,8 @@ void *merge_blobs(struct index_state *istate, const char *path,return NULL ;if (!our) our = their; -return read_object_file (&our->object.oid, &type, size); +return repo_read_object_file (the_repository, &our->object.oid, + &type, size); }if (fill_mmfile_blob (&f1, our) <0 )
merge-recursive.c +7 -6
@@ -299,7 +299,7 @@ static void output_commit_title(struct merge_options *o, struct commit *commit)strbuf_add_unique_abbrev (&o->obuf, &commit->object.oid,DEFAULT_ABBREV );strbuf_addch (&o->obuf,' ' ); -if (parse_commit (commit) !=0 ) +if (repo_parse_commit (the_repository, commit) !=0 )strbuf_addstr (&o->obuf,_ ("(bad commit)\n" ));else {const char *title;
@@ -307,7 +307,7 @@ static void output_commit_title(struct merge_options *o, struct commit *commit)int len =find_commit_subject (msg, &title);if (len)strbuf_addf (&o->obuf,"%.*s\n" , len, title); -unuse_commit_buffer (commit, msg); +repo_unuse_commit_buffer (the_repository, commit, msg); } }flush_output (o);
@@ -957,7 +957,7 @@ static int update_file_flags(struct merge_options *o, goto update_index; } - buf =read_object_file (oid, &type, &size); + buf =repo_read_object_file (the_repository, oid, &type, &size);if (!buf)return err (o,_ ("cannot read object %s '%s'" ),oid_to_hex (oid), path);if (type !=OBJ_BLOB ) {
@@ -1160,7 +1160,8 @@ static void print_commit(struct commit *commit)struct strbuf sb =STRBUF_INIT ;struct pretty_print_context ctx = {0 }; ctx.date_mode.type =DATE_NORMAL ; -format_commit_message (commit," %h: %m %s" , &sb, &ctx); +repo_format_commit_message (the_repository, commit," %h: %m %s" , &sb, + &ctx);fprintf (stderr,"%s\n" , sb.buf);strbuf_release (&sb); }
@@ -2944,7 +2945,7 @@ static int read_oid_strbuf(struct merge_options *o,void *buf;enum object_type type;unsigned long size; - buf =read_object_file (oid, &type, &size); + buf =repo_read_object_file (the_repository, oid, &type, &size);if (!buf)return err (o,_ ("cannot read object %s" ),oid_to_hex (oid));if (type !=OBJ_BLOB ) {
@@ -3522,7 +3523,7 @@ static struct commit *get_ref(const struct object_id *oid, const char *name)return make_virtual_commit ((struct tree *)object, name);if (object->type !=OBJ_COMMIT )return NULL ; -if (parse_commit ((struct commit *)object)) +if (repo_parse_commit (the_repository, (struct commit *)object))return NULL ;return (struct commit *)object; }
negotiator/default.c +3 -3
@@ -25,7 +25,7 @@ static void rev_list_push(struct negotiation_state *ns,if (!(commit->object.flags & mark)) { commit->object.flags |= mark; -if (parse_commit (commit)) +if (repo_parse_commit (the_repository, commit))return ;prio_queue_put (&ns->rev_list, commit);
@@ -68,7 +68,7 @@ static void mark_common(struct negotiation_state *ns, struct commit *commit,if (!ancestors_only && !(o->flags &POPPED )) ns->non_common_revs--;if (!o->parsed && !dont_parse) -if (parse_commit (commit)) +if (repo_parse_commit (the_repository, commit))return ; for (parents = commit->parents;
@@ -95,7 +95,7 @@ static const struct object_id *get_rev(struct negotiation_state *ns)return NULL ; commit =prio_queue_get (&ns->rev_list); -parse_commit (commit); +repo_parse_commit (the_repository, commit); parents = commit->parents; commit->object.flags |=POPPED ;
negotiator/skipping.c +1 -1
@@ -177,7 +177,7 @@ static const struct object_id *get_rev(struct data *data)if (!(commit->object.flags &COMMON ) && !entry->ttl) to_send = commit; -parse_commit (commit); +repo_parse_commit (the_repository, commit);for (p = commit->parents; p; p = p->next) parent_pushed |=push_parent (data, entry, p->item);
notes-cache.c +3 -2
@@ -21,7 +21,8 @@ static int notes_cache_match_validity(const char *ref, const char *validity)return 0 ;memset (&pretty_ctx,0 ,sizeof (pretty_ctx)); -format_commit_message (commit,"%s" , &msg, &pretty_ctx); +repo_format_commit_message (the_repository, commit,"%s" , &msg, + &pretty_ctx);strbuf_trim (&msg); ret = !strcmp (msg.buf, validity);
@@ -79,7 +80,7 @@ char *notes_cache_get(struct notes_cache *c, struct object_id *key_oid, value_oid =get_note (&c->tree, key_oid);if (!value_oid)return NULL ; - value =read_object_file (value_oid, &type, &size); + value =repo_read_object_file (the_repository, value_oid, &type, &size); *outsize = size;return value;
notes-merge.c +2 -2
@@ -324,7 +324,7 @@ static void write_note_to_worktree(const struct object_id *obj, {enum object_type type;unsigned long size; -void *buf =read_object_file (note, &type, &size); +void *buf =repo_read_object_file (the_repository, note, &type, &size);if (!buf) die("cannot read note %s for object %s",
@@ -723,7 +723,7 @@ int notes_merge_commit(struct notes_merge_options *o,create_notes_commit (partial_tree, partial_commit->parents, msg,strlen (msg), result_oid); -unuse_commit_buffer (partial_commit, buffer); +repo_unuse_commit_buffer (the_repository, partial_commit, buffer);if (o->verbosity >=4 )printf ("Finalized notes merge commit: %s\n" ,oid_to_hex (result_oid));
notes-utils.c +1 -1
@@ -22,7 +22,7 @@ void create_notes_commit(struct notes_tree *t, struct commit_list *parents,if (!read_ref (t->ref, &parent_oid)) {struct commit *parent =lookup_commit (the_repository, &parent_oid); -if (parse_commit (parent)) +if (repo_parse_commit (the_repository, parent))die ("Failed to find/parse commit %s" , t->ref);commit_list_insert (parent, &parents); }
notes.c +6 -4
@@ -797,13 +797,15 @@ int combine_notes_concatenate(struct object_id *cur_oid,/* read in both note blob objects */ if (!is_null_oid (new_oid)) - new_msg =read_object_file (new_oid, &new_type, &new_len); + new_msg =repo_read_object_file (the_repository, new_oid, + &new_type, &new_len);if (!new_msg || !new_len || new_type !=OBJ_BLOB ) {free (new_msg);return 0 ; }if (!is_null_oid (cur_oid)) - cur_msg =read_object_file (cur_oid, &cur_type, &cur_len); + cur_msg =repo_read_object_file (the_repository, cur_oid, + &cur_type, &cur_len);if (!cur_msg || !cur_len || cur_type !=OBJ_BLOB ) {free (cur_msg);free (new_msg);
@@ -859,7 +861,7 @@ static int string_list_add_note_lines(struct string_list *list,return 0 ;/* read_sha1_file NUL-terminates */ - data =read_object_file (oid, &t, &len); + data =repo_read_object_file (the_repository, oid, &t, &len);if (t !=OBJ_BLOB || !data || !len) {free (data);return t !=OBJ_BLOB || !data;
@@ -1218,7 +1220,7 @@ static void format_note(struct notes_tree *t, const struct object_id *object_oidif (!oid)return ; -if (!(msg =read_object_file (oid, &type, &msglen)) || type !=OBJ_BLOB ) { +if (!(msg =repo_read_object_file (the_repository, oid, &type, &msglen)) || type !=OBJ_BLOB ) {free (msg);return ; }
pretty.c +3 -2
@@ -1799,7 +1799,8 @@ void pretty_print_commit(struct pretty_print_context *pp,int need_8bit_cte = pp->need_8bit_cte;if (pp->fmt ==CMIT_FMT_USERFORMAT ) { -format_commit_message (commit, user_format, sb, pp); +repo_format_commit_message (the_repository, commit, + user_format, sb, pp);return ; }
@@ -1861,7 +1862,7 @@ void pretty_print_commit(struct pretty_print_context *pp,if (cmit_fmt_is_mail (pp->fmt) && sb->len <= beginning_of_body)strbuf_addch (sb,'\n' ); -unuse_commit_buffer (commit, reencoded); +repo_unuse_commit_buffer (the_repository, commit, reencoded); } void pp_commit_easy(enum cmit_fmt fmt, const struct commit *commit,
read-cache.c +3 -2
@@ -232,7 +232,7 @@ static int ce_compare_link(const struct cache_entry *ce, size_t expected_size)if (strbuf_readlink (&sb, ce->name, expected_size))return -1 ; - buffer =read_object_file (&ce->oid, &type, &size); + buffer =repo_read_object_file (the_repository, &ce->oid, &type, &size);if (buffer) {if (size == sb.len) match =memcmp (buffer, sb.buf, size);
@@ -2901,7 +2901,8 @@ void *read_blob_data_from_index(const struct index_state *istate, }if (pos <0 )return NULL ; - data =read_object_file (&istate->cache[pos]->oid, &type, &sz); + data =repo_read_object_file (the_repository, &istate->cache[pos]->oid, + &type, &sz);if (!data || type !=OBJ_BLOB ) {free (data);return NULL ;
remote-testsvn.c +2 -2
@@ -62,7 +62,7 @@ static char *read_ref_note(const struct object_id *oid)init_notes (NULL , notes_ref,NULL ,0 );if (!(note_oid =get_note (NULL , oid)))return NULL ;/* note tree not found */ -if (!(msg =read_object_file (note_oid, &type, &msglen))) +if (!(msg =repo_read_object_file (the_repository, note_oid, &type, &msglen)))error ("Empty notes tree. %s" , notes_ref);else if (!msglen || type !=OBJ_BLOB ) { error("Note contains unusable content. "
@@ -109,7 +109,7 @@ static int note2mark_cb(const struct object_id *object_oid,enum object_type type;struct rev_note note; -if (!(msg =read_object_file (note_oid, &type, &msglen)) || +if (!(msg =repo_read_object_file (the_repository, note_oid, &type, &msglen)) || !msglen || type !=OBJ_BLOB ) {free (msg);return 1 ;
remote.c +1 -1
@@ -1822,7 +1822,7 @@ int ref_newer(const struct object_id *new_oid, const struct object_id *old_oid)return 0 ; new_commit = (struct commit *) o; -if (parse_commit (new_commit) <0 ) +if (repo_parse_commit (the_repository, new_commit) <0 )return 0 ; used = list =NULL ;
rerere.c +3 -2
@@ -988,8 +988,9 @@ static int handle_cache(struct index_state *istate, const char *path,break ; i =ce_stage (ce) -1 ;if (!mmfile[i].ptr) { - mmfile[i].ptr =read_object_file (&ce->oid, &type, - &size); + mmfile[i].ptr =repo_read_object_file (the_repository, + &ce->oid, &type, + &size); mmfile[i].size = size; } }
revision.c +6 -6
@@ -274,7 +274,7 @@ static struct commit *handle_commit(struct rev_info *revs,if (object->type ==OBJ_COMMIT ) {struct commit *commit = (struct commit *)object; -if (parse_commit (commit) <0 ) +if (repo_parse_commit (the_repository, commit) <0 )die ("unable to parse commit %s" , name);if (flags &UNINTERESTING ) {mark_parents_uninteresting (commit);
@@ -688,7 +688,7 @@ static void try_to_simplify_commit(struct rev_info *revs, struct commit *commit) ts->treesame[0 ] =1 ; } } -if (parse_commit (p) <0 ) +if (repo_parse_commit (the_repository, p) <0 )die ("cannot simplify commit %s (because of %s)" ,oid_to_hex (&commit->object.oid),oid_to_hex (&p->object.oid));
@@ -721,7 +721,7 @@ static void try_to_simplify_commit(struct rev_info *revs, struct commit *commit)* IOW, we pretend this parent is a * "root" commit. */ -if (parse_commit (p) <0 ) +if (repo_parse_commit (the_repository, p) <0 )die ("cannot simplify commit %s (invalid %s)" ,oid_to_hex (&commit->object.oid),oid_to_hex (&p->object.oid));
@@ -800,7 +800,7 @@ static int add_parents_to_list(struct rev_info *revs, struct commit *commit, parent = parent->next;if (p) p->object.flags |=UNINTERESTING ; -if (parse_commit_gently (p,1 ) <0 ) +if (repo_parse_commit_gently (the_repository, p,1 ) <0 )continue ;if (p->parents)mark_parents_uninteresting (p);
@@ -828,7 +828,7 @@ static int add_parents_to_list(struct rev_info *revs, struct commit *commit,struct commit *p = parent->item;int gently = revs->ignore_missing_links || revs->exclude_promisor_objects; -if (parse_commit_gently (p, gently) <0 ) { +if (repo_parse_commit_gently (the_repository, p, gently) <0 ) {if (revs->exclude_promisor_objects &&is_promisor_object (&p->object.oid)) {if (revs->first_parent_only)
@@ -3095,7 +3095,7 @@ static int commit_match(struct commit *commit, struct rev_info *opt) retval =grep_buffer (&opt->grep_filter, (char *)message,strlen (message));strbuf_release (&buf); -unuse_commit_buffer (commit, message); +repo_unuse_commit_buffer (the_repository, commit, message);return opt->invert_grep ? !retval : retval; }
sequencer.c +33 -22
172 lines not on this page · raw message
sha1-file.c +2 -1
@@ -1456,7 +1456,8 @@ void *read_object_with_reference(const struct object_id *oid,int ref_length =-1 ;const char *ref_type =NULL ; - buffer =read_object_file (&actual_oid, &type, &isize); + buffer =repo_read_object_file (the_repository, &actual_oid, + &type, &isize);if (!buffer)return NULL ;if (type == required_type) {
sha1-name.c +5 -4
@@ -357,7 +357,8 @@ static int show_ambiguous_object(const struct object_id *oid, void *data)if (commit) {struct pretty_print_context pp = {0 }; pp.date_mode.type =DATE_SHORT ; -format_commit_message (commit," %ad - %s" , &desc, &pp); +repo_format_commit_message (the_repository, commit, +" %ad - %s" , &desc, &pp); } }else if (type ==OBJ_TAG ) {struct tag *tag =lookup_tag (the_repository, oid);
@@ -849,7 +850,7 @@ static int get_parent(const char *name, int len,if (ret)return ret; commit =lookup_commit_reference (the_repository, &oid); -if (parse_commit (commit)) +if (repo_parse_commit (the_repository, commit))return -1 ;if (!idx) {oidcpy (result, &commit->object.oid);
@@ -881,7 +882,7 @@ static int get_nth_ancestor(const char *name, int len,return -1 ;while (generation--) { -if (parse_commit (commit) || !commit->parents) +if (repo_parse_commit (the_repository, commit) || !commit->parents)return -1 ; commit = commit->parents->item; }
@@ -1152,7 +1153,7 @@ static int get_oid_oneline(const char *prefix, struct object_id *oid, buf =get_commit_buffer (commit,NULL ); p =strstr (buf,"\n\n" ); matches = negative ^ (p && !regexec (®ex, p +2 ,0 ,NULL ,0 )); -unuse_commit_buffer (commit, buf); +repo_unuse_commit_buffer (the_repository, commit, buf);if (matches) {oidcpy (oid, &commit->object.oid);
shallow.c +2 -2
@@ -210,7 +210,7 @@ struct commit_list *get_shallow_commits_by_rev_list(int ac, const char **av,struct commit *c = p->item;struct commit_list *parent; -if (parse_commit (c)) +if (repo_parse_commit (the_repository, c))die ("unable to parse commit %s" ,oid_to_hex (&c->object.oid));
@@ -533,7 +533,7 @@ static void paint_down(struct paint_info *info, const struct object_id *oid,if (c->object.flags &BOTTOM )continue ; -if (parse_commit (c)) +if (repo_parse_commit (the_repository, c))die ("unable to parse commit %s" ,oid_to_hex (&c->object.oid));
submodule-config.c +2 -1
@@ -552,7 +552,8 @@ static const struct submodule *config_from(struct submodule_cache *cache,if (submodule) goto out; - config =read_object_file (&oid, &type, &config_size); + config =repo_read_object_file (the_repository, &oid, &type, + &config_size);if (!config || type !=OBJ_BLOB ) goto out;
t/helper/test-revision-walking.c +2 -1
@@ -19,7 +19,8 @@ static void print_commit(struct commit *commit)struct strbuf sb =STRBUF_INIT ;struct pretty_print_context ctx = {0 }; ctx.date_mode.type =DATE_NORMAL ; -format_commit_message (commit," %m %s" , &sb, &ctx); +repo_format_commit_message (the_repository, commit," %m %s" , &sb, + &ctx);printf ("%s\n" , sb.buf);strbuf_release (&sb); }
tag.c +3 -2
@@ -52,7 +52,7 @@ int gpg_verify_tag(const struct object_id *oid, const char *name_to_report,find_unique_abbrev (oid,DEFAULT_ABBREV ), type_name(type)); - buf =read_object_file (oid, &type, &size); + buf =repo_read_object_file (the_repository, oid, &type, &size);if (!buf) return error("%s: unable to read file.", name_to_report ?
@@ -200,7 +200,8 @@ int parse_tag(struct tag *item)if (item->object.parsed)return 0 ; - data =read_object_file (&item->object.oid, &type, &size); + data =repo_read_object_file (the_repository, &item->object.oid, &type, + &size);if (!data)return error ("Could not read %s" ,oid_to_hex (&item->object.oid));
tree-walk.c +4 -2
@@ -715,8 +715,10 @@ enum follow_symlinks_result get_tree_entry_follow_symlinks(struct object_id *tre*/ retval =DANGLING_SYMLINK ; - contents =read_object_file (¤t_tree_oid, &type, - &link_len); + contents =repo_read_object_file (the_repository, + ¤t_tree_oid, + &type, + &link_len);if (!contents) goto done;
tree.c +3 -2
@@ -105,7 +105,7 @@ static int read_tree_1(struct tree *tree, struct strbuf *base,oid_to_hex (entry.oid), base->buf, entry.path); -if (parse_commit (commit)) +if (repo_parse_commit (the_repository, commit))die ("Invalid commit %s in submodule path %s%s" ,oid_to_hex (entry.oid), base->buf, entry.path);
@@ -221,7 +221,8 @@ int parse_tree_gently(struct tree *item, int quiet_on_missing)if (item->object.parsed)return 0 ; - buffer =read_object_file (&item->object.oid, &type, &size); + buffer =repo_read_object_file (the_repository, &item->object.oid, + &type, &size);if (!buffer)return quiet_on_missing ?-1 : error("Could not read %s",
walker.c +1 -1
@@ -78,7 +78,7 @@ static int process_commit(struct walker *walker, struct commit *commit) {struct commit_list *parents; -if (parse_commit (commit)) +if (repo_parse_commit (the_repository, commit))return -1 ;while (complete && complete->item->date >= commit->date) {
xdiff-interface.c +1 -1
@@ -192,7 +192,7 @@ void read_mmblob(mmfile_t *ptr, const struct object_id *oid)return ; } - ptr->ptr =read_object_file (oid, &type, &size); + ptr->ptr =repo_read_object_file (the_repository, oid, &type, &size);if (!ptr->ptr || type !=OBJ_BLOB )die ("unable to read blob object %s" ,oid_to_hex (oid)); ptr->size = size;
Signature · 1 line
2.19.0
Quoted 8 lines
This series takes another approach as it doesn't change the signature of functions, but introduces new functions that can deal with arbitrary repositories, keeping the old function signature around using a shallow wrapper.
Additionally each patch adds a semantic patch, that would port from the old to the new function. These semantic patches are all applied in the very last patch, but we could omit applying the last patch if it causes too many merge conflicts and trickl in the semantic patches over time when there are no merge conflicts.
Thanks, this looks like a good plan.
One concern is that if we leave 2 versions of functions around, it will be difficult to look at a function and see if it's truly multi-repository-compatible (or making a call to a function that internally uses the_repository, and is thus wrong). But with the plan Stefan quoted [1], mentioned in commit e675765235 ("diff.c: remove implicit dependency on the_index", 2018-09-21):
The plan is these macros will always be defined for all library files and the macros are only accessible in builtin/
(The macros include NO_THE_REPOSITORY_COMPATIBILITY_MACROS, which disables the single-repository function-like macros.) This mitigates the concern somewhat.
Quoted 4 lines · Stefan Beller
Additionally each patch adds a semantic patch, that would port from the old to the new function. These semantic patches are all applied in the very last patch, but we could omit applying the last patch if it causes too many merge conflicts and trickl in the semantic patches over time when there are no merge conflicts.
That's an interesting approach ;-)
Quoted 2 lines
The original goal of all these refactoring series was to remove
add_submodule_odbinsubmodule.c, which was partially reached with this series.
Yup, that is a very good goalpost to keep in mind.
Quoted 2 lines
remaining calls in another series, but it shows we're close to be done with these large refactorings as far as I am concerned.
Nice.
Hi,
Quoted 6 lines · Stefan Beller
This applies on nd/the-index (
b3c7eef9b05) and is the logical continuation of the object store series, which I sent over the last year.The previous series did take a very slow and pedantic approach, using a #define trick, see
cfc62fc98cfor details, but it turns out, that it doesn't work:
Thanks for the heads up --- this will remind me to review this new series more carefully, since it differs from what was reviewed before.
I think this will be easiest to review with --function-context. I can generate that diff locally, so no need to resend.
Quoted 7 lines
When changing the signature of widely used functions, it burdens the maintainer in resolving the semantic conflicts.
In the orginal approach this was called a feature, as then we can ensure that not bugs creep into the code base during the merge window (while such a refactoring series wanders from pu to master). It turns out this was not well received and was just burdensome.
I don't agree with this characterization.
The question of who resolves conflicts is separate from the question of whether conflicts appear, which is in turn separate from the question of whether the build breaks.
I consider making the build break when a caller tries to use a half-converted function too early to be a very useful feature. There is a way to do that in C++ that allows decoupled conversions, but the C version forced an ordering of the conversions. It seems that the pain was caused by the combination of
1. that coupling, which forced an ordering on the conversions and prevented us from ordering the patches in an order based on convenience of integration (unlike e.g. the "struct object_id" series which was able to proceed by taking a batch covering a quiet area of the tree at a time)
2. as you mentioned, removal of old API at the same time of addition of new API forced callers across the tree to update at once
3. the lack of having decided how to handle the anticipated churn
Now most of the conversions are done (thanks much for that) so the ordering (1) is not the main remaining pain point. Thanks for tackling the other two in this series.
I want future API changes to be easier. That means tackling the following questions up front:
i. Where does this fit in Rusty's API rating scheme
<http://sweng.the-davies.net/Home/rustys-api-design-manifesto>?
Does misuse (or misconverted callers) break the build, break visibly at runtime, or are the effects more subtle?
ii. Is there good test coverage for the new API? Are there tests
that need to be migrated?
iii. Is there a way to automatically migrate callers, or does this
require manual, error-prone work (thanks for tackling that in this one.)
iv. How are we planning to handle multiple patches in flight? Will
the change produce merge conflicts? How can others on the list help the maintainer with integrating this set of changes?
iv. Is the ending point cleaner than where we started?
The #define trick you're referring to was a way of addressing (i).
[...]
Quoted 1 line
79 files changed, 571 insertions(+), 278 deletions(-)
Most of the increase is in the coccinelle file and in improved documentation.
It appears that some patches use a the_index-style NO_THE_REPOSITORY_COMPATIBILITY_MACROS backward compatibility synonym and others don't. Can you say a little more about this aspect of the approach? Would the compatibility macros go away eventually?
Thanks,
Jonathan
Quoted 5 lines · Jonathan Nieder
It appears that some patches use a the_index-style
NO_THE_REPOSITORY_COMPATIBILITY_MACROSbackward compatibility synonym and others don't. Can you say a little more about this aspect of the approach? Would the compatibility macros go away eventually?
I use the macro only when not doing the whole conversion in the patch (i.e. there is a coccinelle patch IFF there is the macro and vice versa).
It's quite frankly a judgement call what I would convert as a whole and what not, it depends on the usage of the functions and if I know series that are in flight using it. The full conversion is easy to write if there are less than a hand full of callers, so for the "small case", I just did it, hoping it won't break other topics in flight.