Skip to contentSkip to conversation

Moving global state into the repository object

RFC PATCH In review Stefan Beller 10 participants 239 messages Feb 5, 2018 – Feb 14, 2018 Kbuild Page 3 of 3

lore
Share & tools
lore
#216 lore raw

PATCH 182/194 commit: add repository argument to get_commit_buffer

In reply to Stefan Beller
---
 builtin/fast-export.c                      |  2 +-
 builtin/fmt-merge-msg.c                    |  2 +-
 builtin/log.c                              |  3 ++-
 builtin/replace.c                          |  2 +-
 commit.c                                   |  8 ++++----
 commit.h                                   |  3 ++-
 contrib/coccinelle/submodule_reading.cocci |  7 +++++++
 fsck.c                                     |  3 ++-
 merge-recursive.c                          |  3 ++-
 notes-merge.c                              |  3 ++-
 pretty.c                                   |  2 +-
 sequencer.c                                | 13 ++++++++-----
 sha1_name.c                                |  2 +-
 13 files changed, 34 insertions(+), 19 deletions(-)
 create mode 100644 contrib/coccinelle/submodule_reading.cocci
builtin/fast-export.c +1 -1
index 80853bb91a..bc04e3f0a7 100644
@@ -561,7 +561,7 @@ static void handle_commit(struct commit *commit, struct rev_info *rev,
 	rev->diffopt.output_format = DIFF_FORMAT_CALLBACK;
 
 	parse_commit_or_die(commit);
-	commit_buffer = get_commit_buffer(commit, NULL);
+	commit_buffer = get_commit_buffer(the_repository, commit, NULL);
 	author = strstr(commit_buffer, "\nauthor ");
 	if (!author)
 		die ("Could not find author in commit %s",
builtin/fmt-merge-msg.c +1 -1
index c54f045ccd..6dedb92d61 100644
@@ -261,7 +261,7 @@ static void record_person_from_buf(int which, struct string_list *people,
 static void record_person(int which, struct string_list *people,
 			  struct commit *commit)
 {
-	const char *buffer = get_commit_buffer(commit, NULL);
+	const char *buffer = get_commit_buffer(the_repository, commit, NULL);
 	record_person_from_buf(which, people, buffer);
 	unuse_commit_buffer(the_repository, commit, buffer);
 }
builtin/log.c +2 -1
index 3ccab366e7..bb9d909f59 100644
@@ -1022,7 +1022,8 @@ static void make_cover_letter(struct rev_info *rev, int use_stdout,
 	log_write_email_headers(rev, head, &pp.after_subject, &need_8bit_cte);
 
 	for (i = 0; !need_8bit_cte && i < nr; i++) {
-		const char *buf = get_commit_buffer(list[i], NULL);
+		const char *buf = get_commit_buffer(the_repository, list[i],
+						    NULL);
 		if (has_non_ascii(buf))
 			need_8bit_cte = 1;
 		unuse_commit_buffer(the_repository, list[i], buf);
builtin/replace.c +1 -1
index 1a92c0082a..46bb7cdfe8 100644
@@ -401,7 +401,7 @@ static int create_graft(int argc, const char **argv, int force)
 		die(_("Not a valid object name: '%s'"), old_ref);
 	commit = lookup_commit_or_die(&old, old_ref);
 
-	buffer = get_commit_buffer(commit, &size);
+	buffer = get_commit_buffer(the_repository, commit, &size);
 	strbuf_add(&buf, buffer, size);
 	unuse_commit_buffer(the_repository, commit, buffer);
 
commit.c +4 -4
index ac65c1dbd7..b241cc7979 100644
@@ -277,7 +277,7 @@ 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 *get_commit_buffer_the_repository(const struct commit *commit, unsigned long *sizep)
 {
 	const void *ret = get_cached_commit_buffer(the_repository, commit, sizep);
 	if (!ret) {
@@ -617,7 +617,7 @@ define_commit_slab(author_date_slab, unsigned long);
 static void record_author_date(struct author_date_slab *author_date,
 			       struct commit *commit)
 {
-	const char *buffer = get_commit_buffer(commit, NULL);
+	const char *buffer = get_commit_buffer(the_repository, commit, NULL);
 	struct ident_split ident;
 	const char *ident_line;
 	size_t ident_len;
@@ -1163,7 +1163,7 @@ int parse_signed_commit(const struct commit *commit,
 {
 
 	unsigned long size;
-	const char *buffer = get_commit_buffer(commit, &size);
+	const char *buffer = get_commit_buffer(the_repository, commit, &size);
 	int in_signature, saw_signature = -1;
 	const char *line, *tail;
 
@@ -1320,7 +1320,7 @@ struct commit_extra_header *read_commit_extra_headers(struct commit *commit,
 {
 	struct commit_extra_header *extra = NULL;
 	unsigned long size;
-	const char *buffer = get_commit_buffer(commit, &size);
+	const char *buffer = get_commit_buffer(the_repository, commit, &size);
 	extra = read_commit_extra_header_lines(buffer, size, exclude);
 	unuse_commit_buffer(the_repository, commit, buffer);
 	return extra;
commit.h +2 -1
index d2d5e66b53..b9eb079e21 100644
@@ -88,7 +88,8 @@ const void *get_cached_commit_buffer(struct repository *r, 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);
+#define get_commit_buffer(r, c, s) get_commit_buffer_##r(c, s)
+const void *get_commit_buffer_the_repository(const struct commit *, unsigned long *size);
 
 /*
  * Tell the commit subsytem that we are done with a particular commit buffer.
contrib/coccinelle/submodule_reading.cocci new file +7 -0
new file mode 100644
index 0000000000..17c2e02512
@@ -0,0 +1,7 @@
+@@
+expression E;
+expression F;
+@@
+ get_commit_buffer(
++the_repository,
+ E, F)
fsck.c +2 -1
index 3155b77348..7788b60bf4 100644
@@ -791,7 +791,8 @@ static int fsck_commit_buffer(struct commit *commit, const char *buffer,
 static int fsck_commit(struct commit *commit, const char *data,
 	unsigned long size, struct fsck_options *options)
 {
-	const char *buffer = data ?  data : get_commit_buffer(commit, &size);
+	const char *buffer = data ?  data : get_commit_buffer(the_repository,
+							      commit, &size);
 	int ret = fsck_commit_buffer(commit, buffer, size, options);
 	if (!data)
 		unuse_commit_buffer(the_repository, commit, buffer);
merge-recursive.c +2 -1
index 6e06634993..30ddfcb94e 100644
@@ -237,7 +237,8 @@ static void output_commit_title(struct merge_options *o, struct commit *commit)
 			strbuf_addstr(&o->obuf, _("(bad commit)\n"));
 		else {
 			const char *title;
-			const char *msg = get_commit_buffer(commit, NULL);
+			const char *msg = get_commit_buffer(the_repository,
+							    commit, NULL);
 			int len = find_commit_subject(msg, &title);
 			if (len)
 				strbuf_addf(&o->obuf, "%.*s\n", len, title);
notes-merge.c +2 -1
index 58b518ae0a..1cb1c4f8f4 100644
@@ -672,7 +672,8 @@ int notes_merge_commit(struct notes_merge_options *o,
 	DIR *dir;
 	struct dirent *e;
 	struct strbuf path = STRBUF_INIT;
-	const char *buffer = get_commit_buffer(partial_commit, NULL);
+	const char *buffer = get_commit_buffer(the_repository, partial_commit,
+					       NULL);
 	const char *msg = strstr(buffer, "\n\n");
 	int baselen;
 
pretty.c +1 -1
index 9a7f19f8c7..c5a2f0b018 100644
@@ -602,7 +602,7 @@ const char *logmsg_reencode(const struct commit *commit,
 	static const char *utf8 = "UTF-8";
 	const char *use_encoding;
 	char *encoding;
-	const char *msg = get_commit_buffer(commit, NULL);
+	const char *msg = get_commit_buffer(the_repository, commit, NULL);
 	char *out;
 
 	if (!output_encoding || !*output_encoding) {
sequencer.c +8 -5
index 521da238b5..40ba4b6047 100644
@@ -859,7 +859,7 @@ static int update_squash_messages(enum todo_command command,
 			return error(_("need a HEAD to fixup"));
 		if (!(head_commit = lookup_commit_reference(the_repository, &head)))
 			return error(_("could not read HEAD"));
-		if (!(head_message = get_commit_buffer(head_commit, NULL)))
+		if (!(head_message = get_commit_buffer(the_repository, head_commit, NULL)))
 			return error(_("could not read HEAD's commit message"));
 
 		find_commit_subject(head_message, &body);
@@ -883,7 +883,7 @@ static int update_squash_messages(enum todo_command command,
 		unuse_commit_buffer(the_repository, head_commit, head_message);
 	}
 
-	if (!(message = get_commit_buffer(commit, NULL)))
+	if (!(message = get_commit_buffer(the_repository, commit, NULL)))
 		return error(_("could not read commit message of %s"),
 			     oid_to_hex(&commit->object.oid));
 	find_commit_subject(message, &body);
@@ -1549,7 +1549,8 @@ static int walk_revs_populate_todo(struct todo_list *todo_list,
 
 	while ((commit = get_revision(opts->revs))) {
 		struct todo_item *item = append_new_todo(todo_list);
-		const char *commit_buffer = get_commit_buffer(commit, NULL);
+		const char *commit_buffer = get_commit_buffer(the_repository,
+							      commit, NULL);
 		const char *subject;
 		int subject_len;
 
@@ -1816,7 +1817,8 @@ static int make_patch(struct commit *commit, struct replay_opts *opts)
 
 	strbuf_addf(&buf, "%s/message", get_dir(opts));
 	if (!file_exists(buf.buf)) {
-		const char *commit_buffer = get_commit_buffer(commit, NULL);
+		const char *commit_buffer = get_commit_buffer(the_repository,
+							      commit, NULL);
 		find_commit_subject(commit_buffer, &subject);
 		res |= write_message(subject, strlen(subject), buf.buf, 1);
 		unuse_commit_buffer(the_repository, commit, commit_buffer);
@@ -2906,7 +2908,8 @@ int rearrange_squash(void)
 		item->commit->util = item;
 
 		parse_commit(the_repository, item->commit);
-		commit_buffer = get_commit_buffer(item->commit, NULL);
+		commit_buffer = get_commit_buffer(the_repository,
+						  item->commit, NULL);
 		find_commit_subject(commit_buffer, &subject);
 		format_subject(&buf, subject, " ");
 		subject = subjects[i] = strbuf_detach(&buf, &subject_len);
sha1_name.c +1 -1
index 7675ec634f..ee889daead 100644
@@ -1150,7 +1150,7 @@ static int get_oid_oneline(const char *prefix, struct object_id *oid,
 		commit = pop_most_recent_commit(&list, ONELINE_SEEN);
 		if (!parse_object(the_repository, &commit->object.oid))
 			continue;
-		buf = get_commit_buffer(commit, NULL);
+		buf = get_commit_buffer(the_repository, commit, NULL);
 		p = strstr(buf, "\n\n");
 		matches = negative ^ (p && !regexec(&regex, p + 2, 0, NULL, 0));
 		unuse_commit_buffer(the_repository, commit, buf);
Signature · 1 line
2.15.1.433.g936d1b9894.dirty
#217 lore raw

PATCH 183/194 commit: add repository argument to logmsg_reencode

In reply to Stefan Beller
---
 builtin/am.c                               | 3 ++-
 builtin/blame.c                            | 2 +-
 builtin/commit.c                           | 2 +-
 builtin/reset.c                            | 3 ++-
 commit.h                                   | 3 ++-
 contrib/coccinelle/submodule_reading.cocci | 9 +++++++++
 pretty.c                                   | 7 ++++---
 revision.c                                 | 2 +-
 sequencer.c                                | 3 ++-
 9 files changed, 24 insertions(+), 10 deletions(-)
builtin/am.c +2 -1
index 7072ec78cb..9bbf41912b 100644
@@ -1328,7 +1328,8 @@ static void get_commit_info(struct am_state *state, struct commit *commit)
 	size_t ident_len;
 	struct ident_split id;
 
-	buffer = logmsg_reencode(commit, NULL, get_commit_output_encoding());
+	buffer = logmsg_reencode(the_repository, commit, NULL,
+				 get_commit_output_encoding());
 
 	ident_line = find_commit_header(buffer, "author", &ident_len);
 
builtin/blame.c +1 -1
index 956df42c67..f9c18f6413 100644
@@ -186,7 +186,7 @@ static void get_commit_info(struct commit *commit,
 	commit_info_init(ret);
 
 	encoding = get_log_output_encoding();
-	message = logmsg_reencode(commit, NULL, encoding);
+	message = logmsg_reencode(the_repository, commit, NULL, encoding);
 	get_ac_line(message, "\nauthor ",
 		    &ret->author, &ret->author_mail,
 		    &ret->author_time, &ret->author_tz);
builtin/commit.c +1 -1
index cceb965569..c903893767 100644
@@ -1113,7 +1113,7 @@ static const char *read_commit_message(const char *name)
 	if (!commit)
 		die(_("could not lookup commit %s"), name);
 	out_enc = get_commit_output_encoding();
-	return logmsg_reencode(commit, NULL, out_enc);
+	return logmsg_reencode(the_repository, commit, NULL, out_enc);
 }
 
 /*
builtin/reset.c +2 -1
index 7c57309adc..ef16cbea0d 100644
@@ -111,7 +111,8 @@ static void print_new_head_line(struct commit *commit)
 
 	hex = find_unique_abbrev(commit->object.oid.hash, DEFAULT_ABBREV);
 	printf(_("HEAD is now at %s"), hex);
-	msg = logmsg_reencode(commit, NULL, get_log_output_encoding());
+	msg = logmsg_reencode(the_repository, commit, NULL,
+			      get_log_output_encoding());
 	body = strstr(msg, "\n\n");
 	if (body) {
 		const char *eol;
commit.h +2 -1
index b9eb079e21..33f7779602 100644
@@ -130,7 +130,8 @@ void free_commit_list(struct commit_list *list);
 struct rev_info; /* in revision.h, it circularly uses enum cmit_fmt */
 
 extern int has_non_ascii(const char *text);
-extern const char *logmsg_reencode(const struct commit *commit,
+#define logmsg_reencode(r, c, e, o) logmsg_reencode_##r(c, e ,o)
+extern const char *logmsg_reencode_the_repository(const struct commit *commit,
 				   char **commit_encoding,
 				   const char *output_encoding);
 extern const char *skip_blank_lines(const char *msg);
contrib/coccinelle/submodule_reading.cocci +9 -0
index 17c2e02512..b3e3d88626 100644
@@ -5,3 +5,12 @@ expression F;
  get_commit_buffer(
 +the_repository,
  E, F)
+
+@@
+expression E;
+expression F;
+expression G;
+@@
+ logmsg_reencode(
++the_repository,
+ E, F, G)
pretty.c +4 -3
index c5a2f0b018..a0c95280f6 100644
@@ -595,7 +595,7 @@ static char *replace_encoding_header(char *buf, const char *encoding)
 	return strbuf_detach(&tmp, NULL);
 }
 
-const char *logmsg_reencode(const struct commit *commit,
+const char *logmsg_reencode_the_repository(const struct commit *commit,
 			    char **commit_encoding,
 			    const char *output_encoding)
 {
@@ -1519,7 +1519,7 @@ 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.message = logmsg_reencode(the_repository, commit,
 					  &context.commit_encoding,
 					  utf8);
 
@@ -1801,7 +1801,8 @@ void pretty_print_commit(struct pretty_print_context *pp,
 	}
 
 	encoding = get_log_output_encoding();
-	msg = reencoded = logmsg_reencode(commit, NULL, encoding);
+	msg = reencoded = logmsg_reencode(the_repository, commit, NULL,
+					  encoding);
 
 	if (pp->fmt == CMIT_FMT_ONELINE || cmit_fmt_is_mail(pp->fmt))
 		indent = 0;
revision.c +1 -1
index c5d376ba0a..427ccb1fe1 100644
@@ -3002,7 +3002,7 @@ static int commit_match(struct commit *commit, struct rev_info *opt)
 	 * in it.
 	 */
 	encoding = get_log_output_encoding();
-	message = logmsg_reencode(commit, NULL, encoding);
+	message = logmsg_reencode(the_repository, commit, NULL, encoding);
 
 	/* Copy the commit to temporary if we are using "fake" headers */
 	if (buf.len)
sequencer.c +2 -1
index 40ba4b6047..57b9ddb69b 100644
@@ -243,7 +243,8 @@ static int get_message(struct commit *commit, struct commit_message *out)
 	const char *abbrev, *subject;
 	int subject_len;
 
-	out->message = logmsg_reencode(commit, NULL, get_commit_output_encoding());
+	out->message = logmsg_reencode(the_repository, commit, NULL,
+				       get_commit_output_encoding());
 	abbrev = short_commit_name(commit);
 
 	subject_len = find_commit_subject(out->message, &subject);
Signature · 1 line
2.15.1.433.g936d1b9894.dirty
#218 lore raw

PATCH 184/194 pretty: add repository argument to format_commit_message

In reply to Stefan Beller
---
 archive.c                                  |  3 ++-
 builtin/commit.c                           | 17 +++++++++++------
 builtin/fmt-merge-msg.c                    |  2 +-
 builtin/notes.c                            |  3 ++-
 builtin/shortlog.c                         |  5 +++--
 contrib/coccinelle/submodule_reading.cocci | 10 ++++++++++
 log-tree.c                                 |  2 +-
 notes-cache.c                              |  2 +-
 pretty.c                                   |  5 +++--
 pretty.h                                   |  4 +++-
 sha1_name.c                                |  3 ++-
 submodule.c                                |  5 +++--
 t/helper/test-revision-walking.c           |  2 +-
 13 files changed, 43 insertions(+), 20 deletions(-)
archive.c +2 -1
index 6f38a5cf55..cb0b1d595c 100644
@@ -56,7 +56,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);
+		format_commit_message(the_repository, commit, fmt.buf, buf,
+				      &ctx);
 		len -= c + 1 - src;
 		src  = c + 1;
 	}
builtin/commit.c +11 -6
index c903893767..a6ddf6dd23 100644
@@ -696,7 +696,8 @@ 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,
+			format_commit_message(the_repository, c,
+					      "squash! %s\n\n", &sb,
 					      &ctx);
 		}
 	}
@@ -729,7 +730,7 @@ 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",
+		format_commit_message(the_repository, commit, "fixup! %s\n\n",
 				      &sb, &ctx);
 		hook_arg1 = "message";
 	} else if (!stat(git_path_merge_msg(the_repository), &statbuf)) {
@@ -1069,7 +1070,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);
+		format_commit_message(the_repository, commit, "%aN <%aE>",
+				      &buf, &ctx);
 		clear_mailmap(&mailmap);
 		return strbuf_detach(&buf, NULL);
 	}
@@ -1472,15 +1474,18 @@ static void print_summary(const char *prefix, const struct object_id *oid,
 
 	strbuf_addstr(&format, "format:%h] %s");
 
-	format_commit_message(commit, "%an <%ae>", &author_ident, &pctx);
-	format_commit_message(commit, "%cn <%ce>", &committer_ident, &pctx);
+	format_commit_message(the_repository, commit, "%an <%ae>",
+			      &author_ident, &pctx);
+	format_commit_message(the_repository, commit, "%cn <%ce>",
+			      &committer_ident, &pctx);
 	if (strbuf_cmp(&author_ident, &committer_ident)) {
 		strbuf_addstr(&format, "\n Author: ");
 		strbuf_addbuf_percentquote(&format, &author_ident);
 	}
 	if (author_date_is_interesting()) {
 		struct strbuf date = STRBUF_INIT;
-		format_commit_message(commit, "%ad", &date, &pctx);
+		format_commit_message(the_repository, commit, "%ad", &date,
+				      &pctx);
 		strbuf_addstr(&format, "\n Date: ");
 		strbuf_addbuf_percentquote(&format, &date);
 		strbuf_release(&date);
builtin/fmt-merge-msg.c +1 -1
index 6dedb92d61..591cf95346 100644
@@ -374,7 +374,7 @@ static void shortlog(const char *name,
 		if (subjects.nr > limit)
 			continue;
 
-		format_commit_message(commit, "%s", &sb, &ctx);
+		format_commit_message(the_repository, commit, "%s", &sb, &ctx);
 		strbuf_ltrim(&sb);
 
 		if (!sb.len)
builtin/notes.c +2 -1
index 9100ac5ce0..8633da1d5e 100644
@@ -736,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);
+	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/shortlog.c +3 -2
index e29875b843..61a8c9a6e9 100644
@@ -169,12 +169,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);
+	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);
+			format_commit_message(the_repository, commit, "%s",
+					      &oneline, &ctx);
 	}
 
 	insert_one_record(log, author.buf, oneline.len ? oneline.buf : "<none>");
contrib/coccinelle/submodule_reading.cocci +10 -0
index b3e3d88626..30935ac21d 100644
@@ -14,3 +14,13 @@ expression G;
  logmsg_reencode(
 +the_repository,
  E, F, G)
+
+@@
+expression E;
+expression F;
+expression G;
+expression H;
+@@
+ format_commit_message(
++the_repository,
+ E, F, G, H)
log-tree.c +1 -1
index c6d2883190..e32a2fe71c 100644
@@ -341,7 +341,7 @@ 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);
+	format_commit_message(the_repository, commit, "%f", &subject, &ctx);
 	fmt_output_subject(filename, subject.buf, info);
 	strbuf_release(&subject);
 }
notes-cache.c +1 -1
index a4a6ccab97..89c2284192 100644
@@ -21,7 +21,7 @@ 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);
+	format_commit_message(the_repository, commit, "%s", &msg, &pretty_ctx);
 	strbuf_trim(&msg);
 
 	ret = !strcmp(msg.buf, validity);
pretty.c +3 -2
index a0c95280f6..30d53369b5 100644
@@ -1503,7 +1503,7 @@ void userformat_find_requirements(const char *fmt, struct userformat_want *w)
 	strbuf_release(&dummy);
 }
 
-void format_commit_message(const struct commit *commit,
+void format_commit_message_the_repository(const struct commit *commit,
 			   const char *format, struct strbuf *sb,
 			   const struct pretty_print_context *pretty_ctx)
 {
@@ -1796,7 +1796,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);
+		format_commit_message(the_repository, commit, user_format, sb,
+				      pp);
 		return;
 	}
 
pretty.h +3 -1
index 5c85d94e33..14af7df4e8 100644
@@ -99,7 +99,9 @@ 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,
+#define format_commit_message(r, c, f, s, p) \
+	format_commit_message_##r(c, f, s, p)
+void format_commit_message_the_repository(const struct commit *commit,
 			const char *format, struct strbuf *sb,
 			const struct pretty_print_context *context);
 
sha1_name.c +2 -1
index ee889daead..d6c2cf969f 100644
@@ -378,7 +378,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);
+			format_commit_message(the_repository, commit,
+					      " %ad - %s", &desc, &pp);
 		}
 	} else if (type == OBJ_TAG) {
 		struct tag *tag = lookup_tag(the_repository, oid);
submodule.c +3 -2
index af4a1d2cea..b399cf46e4 100644
@@ -452,7 +452,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);
+		format_commit_message(the_repository, commit, format, &sb,
+				      &ctx);
 		strbuf_addch(&sb, '\n');
 		if (commit->object.flags & SYMMETRIC_LEFT)
 			diff_emit_submodule_del(o, sb.buf);
@@ -1786,7 +1787,7 @@ 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);
+	format_commit_message(the_repository, commit, " %h: %m %s", &sb, &ctx);
 	fprintf(stderr, "%s\n", sb.buf);
 	strbuf_release(&sb);
 }
t/helper/test-revision-walking.c +1 -1
index b8e6fe1d00..59599410ce 100644
@@ -18,7 +18,7 @@ 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);
+	format_commit_message(the_repository, commit, " %m %s", &sb, &ctx);
 	printf("%s\n", sb.buf);
 	strbuf_release(&sb);
 }
Signature · 1 line
2.15.1.433.g936d1b9894.dirty
#219 lore raw

PATCH 185/194 commit: allow get_commit_buffer to handle arbitrary repositories

In reply to Stefan Beller
---
 commit.c | 6 +++---
 commit.h | 3 +--
 2 files changed, 4 insertions(+), 5 deletions(-)
commit.c +3 -3
index b241cc7979..b74086d43d 100644
@@ -277,13 +277,13 @@ const void *get_cached_commit_buffer(struct repository *r, const struct commit *
 	return v->buffer;
 }
 
-const void *get_commit_buffer_the_repository(const struct commit *commit, unsigned long *sizep)
+const void *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_sha1_file(the_repository, commit->object.oid.hash,
+		ret = read_sha1_file(r, commit->object.oid.hash,
 				     &type, &size);
 		if (!ret)
 			die("cannot read commit object %s",
commit.h +1 -2
index 33f7779602..77e131d15b 100644
@@ -88,8 +88,7 @@ const void *get_cached_commit_buffer(struct repository *r, 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.
  */
-#define get_commit_buffer(r, c, s) get_commit_buffer_##r(c, s)
-const void *get_commit_buffer_the_repository(const struct commit *, unsigned long *size);
+const void *get_commit_buffer(struct repository *r, const struct commit *, unsigned long *size);
 
 /*
  * Tell the commit subsytem that we are done with a particular commit buffer.
Signature · 1 line
2.15.1.433.g936d1b9894.dirty
#220 lore raw

PATCH 186/194 pretty: allow logmsg_reencode to handle arbitrary repositories

In reply to Stefan Beller
---
 commit.h | 3 +--
 pretty.c | 8 ++++----
 2 files changed, 5 insertions(+), 6 deletions(-)
commit.h +1 -2
index 77e131d15b..7bdc808018 100644
@@ -129,8 +129,7 @@ void free_commit_list(struct commit_list *list);
 struct rev_info; /* in revision.h, it circularly uses enum cmit_fmt */
 
 extern int has_non_ascii(const char *text);
-#define logmsg_reencode(r, c, e, o) logmsg_reencode_##r(c, e ,o)
-extern const char *logmsg_reencode_the_repository(const struct commit *commit,
+extern const char *logmsg_reencode(struct repository *r, const struct commit *commit,
 				   char **commit_encoding,
 				   const char *output_encoding);
 extern const char *skip_blank_lines(const char *msg);
pretty.c +4 -4
index 30d53369b5..6dce4bb3c0 100644
@@ -595,14 +595,14 @@ static char *replace_encoding_header(char *buf, const char *encoding)
 	return strbuf_detach(&tmp, NULL);
 }
 
-const char *logmsg_reencode_the_repository(const struct commit *commit,
+const char *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(the_repository, commit, NULL);
+	const char *msg = get_commit_buffer(r, commit, NULL);
 	char *out;
 
 	if (!output_encoding || !*output_encoding) {
@@ -630,7 +630,7 @@ const char *logmsg_reencode_the_repository(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 +644,7 @@ const char *logmsg_reencode_the_repository(const struct commit *commit,
 		 */
 		out = reencode_string(msg, output_encoding, use_encoding);
 		if (out)
-			unuse_commit_buffer(the_repository, commit, msg);
+			unuse_commit_buffer(r, commit, msg);
 	}
 
 	/*
Signature · 1 line
2.15.1.433.g936d1b9894.dirty
#221 lore raw

PATCH 187/194 commit: add repository argument to in_merge_bases_many

In reply to Stefan Beller
---
 commit.c  | 4 ++--
 commit.h  | 3 ++-
 remote.c  | 2 +-
 shallow.c | 5 +++--
 4 files changed, 8 insertions(+), 6 deletions(-)
commit.c +2 -2
index b74086d43d..98e04b949f 100644
@@ -1049,7 +1049,7 @@ 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 in_merge_bases_many_the_repository(struct commit *commit, int nr_reference, struct commit **reference)
 {
 	struct commit_list *bases;
 	int ret = 0, i;
@@ -1074,7 +1074,7 @@ int in_merge_bases_many(struct commit *commit, int nr_reference, struct commit *
  */
 int in_merge_bases(struct commit *commit, struct commit *reference)
 {
-	return in_merge_bases_many(commit, 1, &reference);
+	return in_merge_bases_many(the_repository, commit, 1, &reference);
 }
 
 struct commit_list *reduce_heads(struct commit_list *heads)
commit.h +2 -1
index 7bdc808018..ea2c5f528c 100644
@@ -233,7 +233,8 @@ 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 **);
+#define in_merge_bases_many(r, c, n, co) in_merge_bases_many_##r(c, n, co)
+int in_merge_bases_many_the_repository(struct commit *, int, struct commit **);
 
 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,
remote.c +1 -1
index a4cf885012..0c253b82e8 100644
@@ -1396,7 +1396,7 @@ static void add_missing_tags(struct ref *src, struct ref **dst, struct ref ***ds
 			 * Is this tag, which they do not have, reachable from
 			 * any of the commits we are sending?
 			 */
-			if (!in_merge_bases_many(commit, sent_tips.nr, sent_tips.tip))
+			if (!in_merge_bases_many(the_repository, commit, sent_tips.nr, sent_tips.tip))
 				continue;
 
 			/* Add it in */
shallow.c +3 -2
index 64a4fcb57f..f43e94c8e8 100644
@@ -720,7 +720,7 @@ static void post_assign_shallow(struct shallow_info *info,
 		for (j = 0; j < bitmap_nr; j++)
 			if (bitmap[0][j] &&
 			    /* Step 7, reachability test at commit level */
-			    !in_merge_bases_many(c, ca.nr, ca.commits)) {
+			    !in_merge_bases_many(the_repository, c, ca.nr, ca.commits)) {
 				update_refstatus(ref_status, info->ref->nr, *bitmap);
 				dst++;
 				break;
@@ -748,7 +748,8 @@ int delayed_reachability_test(struct shallow_info *si, int c)
 			si->nr_commits = ca.nr;
 		}
 
-		si->reachable[c] = in_merge_bases_many(commit,
+		si->reachable[c] = in_merge_bases_many(the_repository,
+						       commit,
 						       si->nr_commits,
 						       si->commits);
 		si->need_reachability_test[c] = 0;
Signature · 1 line
2.15.1.433.g936d1b9894.dirty
#222 lore raw

PATCH 188/194 commit: add repository argument to in_merge_bases

In reply to Stefan Beller
---
 builtin/branch.c                           |  4 ++--
 builtin/fetch.c                            |  2 +-
 builtin/log.c                              |  2 +-
 builtin/merge-base.c                       |  2 +-
 builtin/receive-pack.c                     |  2 +-
 commit.c                                   |  4 ++--
 commit.h                                   |  3 ++-
 contrib/coccinelle/submodule_reading.cocci |  8 ++++++++
 fast-import.c                              |  2 +-
 http-push.c                                |  2 +-
 pack-bitmap-write.c                        |  2 +-
 submodule.c                                | 12 ++++++------
 12 files changed, 27 insertions(+), 18 deletions(-)
builtin/branch.c +2 -2
index 2d752c6614..f525b7e2b5 100644
@@ -132,7 +132,7 @@ static int branch_merged(int kind, const char *name,
 	if (!reference_rev)
 		reference_rev = head_rev;
 
-	merged = in_merge_bases(rev, reference_rev);
+	merged = in_merge_bases(the_repository, rev, reference_rev);
 
 	/*
 	 * After the safety valve is fully redefined to "check with
@@ -142,7 +142,7 @@ static int branch_merged(int kind, const char *name,
 	 * a gentle reminder is in order.
 	 */
 	if ((head_rev != reference_rev) &&
-	    in_merge_bases(rev, head_rev) != merged) {
+	    in_merge_bases(the_repository, rev, head_rev) != merged) {
 		if (merged)
 			warning(_("deleting branch '%s' that has been merged to\n"
 				"         '%s', but not yet merged to HEAD."),
builtin/fetch.c +1 -1
index b516b176f0..14eccf3f0d 100644
@@ -695,7 +695,7 @@ static int update_local_ref(struct ref *ref,
 		return r;
 	}
 
-	if (in_merge_bases(current, updated)) {
+	if (in_merge_bases(the_repository, current, updated)) {
 		struct strbuf quickref = STRBUF_INIT;
 		int r;
 		strbuf_add_unique_abbrev(&quickref, current->object.oid.hash, DEFAULT_ABBREV);
builtin/log.c +1 -1
index bb9d909f59..e8bb899e52 100644
@@ -1325,7 +1325,7 @@ static struct commit *get_base_commit(const char *base_commit,
 		rev_nr = DIV_ROUND_UP(rev_nr, 2);
 	}
 
-	if (!in_merge_bases(base, rev[0]))
+	if (!in_merge_bases(the_repository, base, rev[0]))
 		die(_("base commit should be the ancestor of revision list"));
 
 	for (i = 0; i < total; i++) {
builtin/merge-base.c +1 -1
index 426882818c..00e9f11d92 100644
@@ -104,7 +104,7 @@ static int handle_is_ancestor(int argc, const char **argv)
 		die("--is-ancestor takes exactly two commits");
 	one = get_commit_reference(argv[0]);
 	two = get_commit_reference(argv[1]);
-	if (in_merge_bases(one, two))
+	if (in_merge_bases(the_repository, one, two))
 		return 0;
 	else
 		return 1;
builtin/receive-pack.c +1 -1
index 7d00f0bad6..2b41affaf5 100644
@@ -1118,7 +1118,7 @@ static const char *update(struct command *cmd, struct shallow_info *si)
 		}
 		old_commit = (struct commit *)old_object;
 		new_commit = (struct commit *)new_object;
-		if (!in_merge_bases(old_commit, new_commit)) {
+		if (!in_merge_bases(the_repository, old_commit, new_commit)) {
 			rp_error("denying non-fast-forward %s"
 				 " (you should pull first)", name);
 			return "non-fast-forward";
commit.c +2 -2
index 98e04b949f..900ecf84b8 100644
@@ -1040,7 +1040,7 @@ int is_descendant_of(struct commit *commit, struct commit_list *with_commit)
 
 		other = with_commit->item;
 		with_commit = with_commit->next;
-		if (in_merge_bases(other, commit))
+		if (in_merge_bases(the_repository, other, commit))
 			return 1;
 	}
 	return 0;
@@ -1072,7 +1072,7 @@ int in_merge_bases_many_the_repository(struct commit *commit, int nr_reference,
 /*
  * Is "commit" an ancestor of (i.e. reachable from) the "reference"?
  */
-int in_merge_bases(struct commit *commit, struct commit *reference)
+int in_merge_bases_the_repository(struct commit *commit, struct commit *reference)
 {
 	return in_merge_bases_many(the_repository, commit, 1, &reference);
 }
commit.h +2 -1
index ea2c5f528c..0f3cdc6375 100644
@@ -232,7 +232,8 @@ 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 *);
+#define in_merge_bases(r, c1, c2) in_merge_bases_##r(c1, c2)
+int in_merge_bases_the_repository(struct commit *, struct commit *);
 #define in_merge_bases_many(r, c, n, co) in_merge_bases_many_##r(c, n, co)
 int in_merge_bases_many_the_repository(struct commit *, int, struct commit **);
 
contrib/coccinelle/submodule_reading.cocci +8 -0
index 30935ac21d..b9da6a08d3 100644
@@ -24,3 +24,11 @@ expression H;
  format_commit_message(
 +the_repository,
  E, F, G, H)
+
+@@
+expression E;
+expression F;
+@@
+ in_merge_bases(
++the_repository,
+ E, F)
fast-import.c +1 -1
index b1ff3d47df..f68d3fbd87 100644
@@ -1773,7 +1773,7 @@ static int update_branch(struct branch *b)
 		if (!old_cmit || !new_cmit)
 			return error("Branch %s is missing commits.", b->name);
 
-		if (!in_merge_bases(old_cmit, new_cmit)) {
+		if (!in_merge_bases(the_repository, old_cmit, new_cmit)) {
 			warning("Not updating %s"
 				" (new tip %s does not contain %s)",
 				b->name, oid_to_hex(&b->oid),
http-push.c +1 -1
index c7fa9ee15a..6af853d245 100644
@@ -1571,7 +1571,7 @@ static int verify_merge_base(struct object_id *head_oid, struct ref *remote)
 	struct commit *branch = lookup_commit_or_die(&remote->old_oid,
 						     remote->name);
 
-	return in_merge_bases(branch, head);
+	return in_merge_bases(the_repository, branch, head);
 }
 
 static int delete_remote_branch(const char *pattern, int force)
pack-bitmap-write.c +1 -1
index f684ed5ea2..9ac581920b 100644
@@ -286,7 +286,7 @@ void bitmap_writer_build(struct packing_data *to_pack)
 		if (stored->bitmap == NULL) {
 			if (i < writer.selected_nr - 1 &&
 			    (need_reset ||
-			     !in_merge_bases(writer.selected[i + 1].commit,
+			     !in_merge_bases(the_repository, writer.selected[i + 1].commit,
 					     stored->commit))) {
 			    bitmap_reset(base);
 			    reset_all_seen();
submodule.c +6 -6
index b399cf46e4..6125bfbdde 100644
@@ -1753,7 +1753,7 @@ static int find_first_merges(struct object_array *result, const char *path,
 		die("revision walk setup failed");
 	while ((commit = get_revision(&revs)) != NULL) {
 		struct object *o = &(commit->object);
-		if (in_merge_bases(b, commit))
+		if (in_merge_bases(the_repository, b, commit))
 			add_object_array(o, NULL, &merges);
 	}
 	reset_revision_walk();
@@ -1768,7 +1768,7 @@ static int find_first_merges(struct object_array *result, const char *path,
 		contains_another = 0;
 		for (j = 0; j < merges.nr; j++) {
 			struct commit *m2 = (struct commit *) merges.objects[j].item;
-			if (i != j && in_merge_bases(m2, m1)) {
+			if (i != j && in_merge_bases(the_repository, m2, m1)) {
 				contains_another = 1;
 				break;
 			}
@@ -1829,18 +1829,18 @@ int merge_submodule(struct object_id *result, const char *path,
 	}
 
 	/* check whether both changes are forward */
-	if (!in_merge_bases(commit_base, commit_a) ||
-	    !in_merge_bases(commit_base, commit_b)) {
+	if (!in_merge_bases(the_repository, commit_base, commit_a) ||
+	    !in_merge_bases(the_repository, commit_base, commit_b)) {
 		MERGE_WARNING(path, "commits don't follow merge-base");
 		return 0;
 	}
 
 	/* Case #1: a is contained in b or vice versa */
-	if (in_merge_bases(commit_a, commit_b)) {
+	if (in_merge_bases(the_repository, commit_a, commit_b)) {
 		oidcpy(result, b);
 		return 1;
 	}
-	if (in_merge_bases(commit_b, commit_a)) {
+	if (in_merge_bases(the_repository, commit_b, commit_a)) {
 		oidcpy(result, a);
 		return 1;
 	}
Signature · 1 line
2.15.1.433.g936d1b9894.dirty
#223 lore raw

PATCH 189/194 commit: allow in_merge_bases_many to handle arbitrary repositories

In reply to Stefan Beller
---
 commit.c | 8 ++++----
 commit.h | 3 +--
 2 files changed, 5 insertions(+), 6 deletions(-)
commit.c +4 -4
index 900ecf84b8..a14933b208 100644
@@ -1049,18 +1049,18 @@ 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_the_repository(struct commit *commit, int nr_reference, struct commit **reference)
+int in_merge_bases_many(struct repository *r, struct commit *commit, int nr_reference, struct commit **reference)
 {
 	struct commit_list *bases;
 	int ret = 0, i;
 
-	if (parse_commit(the_repository, commit))
+	if (parse_commit(r, commit))
 		return ret;
 	for (i = 0; i < nr_reference; i++)
-		if (parse_commit(the_repository, reference[i]))
+		if (parse_commit(r, reference[i]))
 			return ret;
 
-	bases = paint_down_to_common(the_repository, commit, nr_reference, reference);
+	bases = paint_down_to_common(r, commit, nr_reference, reference);
 	if (commit->object.flags & PARENT2)
 		ret = 1;
 	clear_commit_marks(commit, all_flags);
commit.h +1 -2
index 0f3cdc6375..36412a5a9e 100644
@@ -234,8 +234,7 @@ extern struct trace_key trace_shallow;
 int is_descendant_of(struct commit *, struct commit_list *);
 #define in_merge_bases(r, c1, c2) in_merge_bases_##r(c1, c2)
 int in_merge_bases_the_repository(struct commit *, struct commit *);
-#define in_merge_bases_many(r, c, n, co) in_merge_bases_many_##r(c, n, co)
-int in_merge_bases_many_the_repository(struct commit *, int, struct commit **);
+int in_merge_bases_many(struct repository *r, struct commit *, int, struct commit **);
 
 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,
Signature · 1 line
2.15.1.433.g936d1b9894.dirty
#224 lore raw

PATCH 190/194 commit: allow in_merge_bases to handle arbitrary repositories

In reply to Stefan Beller
---
 commit.c | 4 ++--
 commit.h | 3 +--
 2 files changed, 3 insertions(+), 4 deletions(-)
commit.c +2 -2
index a14933b208..cdee8d3917 100644
@@ -1072,9 +1072,9 @@ int in_merge_bases_many(struct repository *r, struct commit *commit, int nr_refe
 /*
  * Is "commit" an ancestor of (i.e. reachable from) the "reference"?
  */
-int in_merge_bases_the_repository(struct commit *commit, struct commit *reference)
+int in_merge_bases(struct repository *r, struct commit *commit, struct commit *reference)
 {
-	return in_merge_bases_many(the_repository, commit, 1, &reference);
+	return in_merge_bases_many(r, commit, 1, &reference);
 }
 
 struct commit_list *reduce_heads(struct commit_list *heads)
commit.h +1 -2
index 36412a5a9e..2281948738 100644
@@ -232,8 +232,7 @@ extern void prune_shallow(int show_only);
 extern struct trace_key trace_shallow;
 
 int is_descendant_of(struct commit *, struct commit_list *);
-#define in_merge_bases(r, c1, c2) in_merge_bases_##r(c1, c2)
-int in_merge_bases_the_repository(struct commit *, struct commit *);
+int in_merge_bases(struct repository *r, struct commit *, struct commit *);
 int in_merge_bases_many(struct repository *r, struct commit *, int, struct commit **);
 
 extern int interactive_add(int argc, const char **argv, const char *prefix, int patch);
Signature · 1 line
2.15.1.433.g936d1b9894.dirty
#225 lore raw

PATCH 191/194 pretty: allow format_commit_message to handle arbitrary repositories

In reply to Stefan Beller
---
 pretty.c | 6 +++---
 pretty.h | 4 +---
 2 files changed, 4 insertions(+), 6 deletions(-)
pretty.c +3 -3
index 6dce4bb3c0..ed1b778c92 100644
@@ -1503,7 +1503,7 @@ void userformat_find_requirements(const char *fmt, struct userformat_want *w)
 	strbuf_release(&dummy);
 }
 
-void format_commit_message_the_repository(const struct commit *commit,
+void format_commit_message(struct repository *r, const struct commit *commit,
 			   const char *format, struct strbuf *sb,
 			   const struct pretty_print_context *pretty_ctx)
 {
@@ -1519,7 +1519,7 @@ void format_commit_message_the_repository(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(the_repository, commit,
+	context.message = logmsg_reencode(r, commit,
 					  &context.commit_encoding,
 					  utf8);
 
@@ -1545,7 +1545,7 @@ void format_commit_message_the_repository(const struct commit *commit,
 	}
 
 	free(context.commit_encoding);
-	unuse_commit_buffer(the_repository, commit, context.message);
+	unuse_commit_buffer(r, commit, context.message);
 }
 
 static void pp_header(struct pretty_print_context *pp,
pretty.h +1 -3
index 14af7df4e8..c5fc07005f 100644
@@ -99,9 +99,7 @@ void pp_remainder(struct pretty_print_context *pp, const char **msg_p,
  * Put the result to "sb".
  * Please use this function for custom formats.
  */
-#define format_commit_message(r, c, f, s, p) \
-	format_commit_message_##r(c, f, s, p)
-void format_commit_message_the_repository(const struct commit *commit,
+void format_commit_message(struct repository *r, const struct commit *commit,
 			const char *format, struct strbuf *sb,
 			const struct pretty_print_context *context);
 
Signature · 1 line
2.15.1.433.g936d1b9894.dirty
#226 lore raw

PATCH 192/194 submodule: add repository argument to print_submodule_summary

In reply to Stefan Beller
---
 submodule.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
submodule.c +3 -2
index 6125bfbdde..022e366940 100644
@@ -441,7 +441,8 @@ 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)
+#define print_submodule_summary(r, rev, o) print_submodule_summary_##r(rev, o)
+static void print_submodule_summary_the_repository(struct rev_info *rev, struct diff_options *o)
 {
 	static const char format[] = "  %m %s";
 	struct strbuf sb = STRBUF_INIT;
@@ -579,7 +580,7 @@ void show_submodule_summary(struct diff_options *o, const char *path,
 		goto out;
 	}
 
-	print_submodule_summary(&rev, o);
+	print_submodule_summary(the_repository, &rev, o);
 
 out:
 	if (merge_bases)
Signature · 1 line
2.15.1.433.g936d1b9894.dirty
#227 lore raw

PATCH 193/194 submodule: Reorder open_submodule function

In reply to Stefan Beller

In the next patch we'll need open_submodule in another function, so move it up.

---
 submodule.c | 54 +++++++++++++++++++++++++++---------------------------
 1 file changed, 27 insertions(+), 27 deletions(-)
submodule.c +27 -27
index 022e366940..6b6c5a6710 100644
@@ -481,6 +481,33 @@ 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))
+		return -1;
+
+	if (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
@@ -839,33 +866,6 @@ static int check_has_commit(const struct object_id *oid, void *data)
 	}
 }
 
-/*
- * 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))
-		return -1;
-
-	if (repo_init(out, sb.buf, NULL)) {
-		strbuf_release(&sb);
-		return -1;
-	}
-
-	out->submodule_prefix = xstrdup(path);
-
-	strbuf_release(&sb);
-	return 0;
-}
-
 static int submodule_has_commits(const char *path, struct oid_array *commits)
 {
 	struct repository sub;
Signature · 1 line
2.15.1.433.g936d1b9894.dirty
#228 lore raw

PATCH 194/194 submodule: use submodule repos for object lookup

In reply to Stefan Beller

This 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.

When using the inline diff of submodules, the object store is not polluted with objects from the submodules. When using the "log" summary, we still have to pollute the object store, as the revision walking is not converted yet.

---
 submodule.c | 25 ++++++++++++++-----------
 1 file changed, 14 insertions(+), 11 deletions(-)
submodule.c +14 -11
index 6b6c5a6710..9bd337ce99 100644
@@ -441,19 +441,19 @@ static int prepare_submodule_summary(struct rev_info *rev, const char *path,
 	return prepare_revision_walk(rev);
 }
 
-#define print_submodule_summary(r, rev, o) print_submodule_summary_##r(rev, o)
-static void print_submodule_summary_the_repository(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;
 	struct commit *commit;
 
+	/* NEEDSWORK: get_revision is not adapted to repository handling? */
 	while ((commit = get_revision(rev))) {
 		struct pretty_print_context ctx = {0};
 		ctx.date_mode = rev->date_mode;
 		ctx.output_encoding = get_log_output_encoding();
 		strbuf_setlen(&sb, 0);
-		format_commit_message(the_repository, commit, format, &sb,
+		format_commit_message(r, commit, format, &sb,
 				      &ctx);
 		strbuf_addch(&sb, '\n');
 		if (commit->object.flags & SYMMETRIC_LEFT)
@@ -513,7 +513,8 @@ static int open_submodule(struct repository *out, const char *path)
  * 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,
@@ -534,7 +535,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;
@@ -544,8 +545,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
@@ -555,7 +556,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(the_repository, *left, *right);
+	*merge_bases = get_merge_bases(sub, *left, *right);
 	if (*merge_bases) {
 		if ((*merge_bases)->item == *left)
 			fast_forward = 1;
@@ -589,8 +590,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);
 
 	/*
@@ -607,7 +609,7 @@ void show_submodule_summary(struct diff_options *o, const char *path,
 		goto out;
 	}
 
-	print_submodule_summary(the_repository, &rev, o);
+	print_submodule_summary(&sub, &rev, o);
 
 out:
 	if (merge_bases)
@@ -625,8 +627,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.15.1.433.g936d1b9894.dirty
#229 lore raw
In reply to Stefan Beller
Quoted 3 lines · Stefan Beller

Any suggestions welcome!

I wouldn't say sending out this many patches is a smooth experience:

* After trying it out internally, it stopped at patch ~80 and the rate limiter kicked in.
* Okay fine, I'll rate limit myself to be able to send out as many patches!
* Apparently I did not understand the docs correctly, and after reading the code a patch was made:
https://public-inbox.org/git/[email protected]/
I think the sensible thing would be to error out instead of ignoring the relogin parameter.
This is why patches 21/22 ff. have a weird in-reply-to setup, as I hit CTRL-C to stop the unlimited sending and picked up from there using the rate limited --relogin-delay=25 --batch-size=3
* You'll notice that at patches 99/100 ff the same weird in-reply-to appeared. One patch has had a missing '>' in the signoff, such that the server refused to cc appropriately ("Stefan" not a valid recipient)
It would be nice if we could check for that before even sending out emails, but I could live with this blamed on the user. (It was my mistake)
* Patch 118 just bounced. "Message rejected."
It is found at
https://github.com/stefanbeller/git/commit/141ba1f82c223636728a476f9acc1229f353a381

Stefan

#230 lore raw
In reply to Stefan Beller
Quoted 10 lines · Stefan Beller

This series moves a lot of global state into the repository struct. It applies on top of 2512f15446149235156528dafbe75930c712b29e (2.16.0) It can be found at https://github.com/stefanbeller/git/tree/object-store

Motivation for this series:
* Easier to reason about code when all state is stored in one place, for example for multithreading
* Easier to move to processing submodules in-process instead of calling a processes for the submodule handling.
The last patch demonstrates this.

Of course, I like performance improvements (who doesn't?), but I really like the way this series gets rid of various global variables. I much prefer to have fewer globals when possible.

Quoted 25 lines

This is why this series tries to be reviewer friendly by utilizing machine assistance as much as possible. There are 3 types of patches in this series:

(A) <area>: add repository argument to <function_foo>
This sort of patch is just adding the repository as an argument to that function. It assumes the given repository is the_repository and has a compile time check for that assertion using a preprocessor trick. As did a compile check after each commit of the series, I don't expect the review burden on these patches to be high. Review on these patches is mostly checking for formatting errors or if I sneak in malicious code -- if you're inclined to believe that.

(B) <area>: allow <function_foo> to handle arbitrary repositories This sort of patch is touching code inside the given function only, usually replacing all occurrences of the_repository by the argument r. Here the review is critical: Did I miss any function that relies on state of the_repository ?
This series was developed by converting all functions of packfile/sha1-file/commit/etc using (A); after the demo patch was possible, all patches that did (A), but not (B) were deleted. Therefore I was confident at time of writing that patch that the conversion of a function which doesn't take a repository argument is okay.

Quoted 5 lines

(C) other patches, such as moving code around,
demoing this series in the last patch

This approach was chosen as I think it is review friendly, despite the huge number of patches.

I very much appreciate this approach. It made reviewing things much nicer.

Quoted 3 lines

A weakness of this approach is the buildup of a large series, which ignores the ongoing development. Rebasing that series turned out to be ok, but merging it with confidence is an issue.

That's my concern as well. This necessarily conflicts with some of the object_id and the_hash_algo work, but rebasing work on top of it shouldn't be too awful once it's ready to be picked up. In fact, long term, it makes that work easier, so I'm all for it.

I'm sure Junio will have thoughts on the size of the series and potential conflicts in flight, but I'll let him articulate those. The series could in theory be split into pieces the way you've done it: it would just be less convenient to work with some of the functions in the mean time.

Signature · 3 lines
brian m. carlson / brian with sandals: Houston, Texas, US
https://www.crustytoothpaste.net/~bmc | My opinion only
OpenPGP: https://keybase.io/bk2204
#231 lore raw
In reply to Stefan Beller
Quoted 1 line

Any suggestions welcome!

Eric repeatedly points out leaking memory.

As of today we do not care about memory leaking as it is cleaned up at the end of the program anyway, for example the objects hash table is never cleared.

In a resend I will put the infrastructure in place to free the memory via adding

raw_object_store_clear(struct raw_object_store *) object_parser_clear(struct object_parser *) ref_store_clear(struct ref_store *)

and calling these functions on repo destruction. The functions itself will be empty code-wise and contain TODO comments listing all variables that need care.

Follow up patches can figure out what is best to do, such as closing the memleaks. As repo_clear is not called for the_repository we'd even keep the property of relying on fast cleanup by the OS.

Thanks,
Stefan

#232 lore raw

It took some time to do fixes in such a long series, mostl of my time spent in rebasing and being extra careful about selecting the right commit to edit. Based on feedback so far I have queued the changes below.
The changes are also available at https://github.com/stefanbeller/git/tree/object-store-v2
I do not plan on sending out this series today, as I would want
to wait a couple of days between resending for such a large series.

I think I addressed all issues raised, except finishing the memleak issues, which I'll continue working on.

Stefan

object-store.h +2 -0
index 62763b8412..a6051ccb73 100644
@@ -60,6 +60,8 @@ struct raw_object_store {
 #define RAW_OBJECT_STORE_INIT \
 	{ NULL, MRU_INIT, ALTERNATES_INIT, { NULL, 0, 0, 0 }, 0, 0, 0 }
 
+extern void raw_object_store_clear(struct raw_object_store *o);
+
 struct packed_git {
 	struct packed_git *next;
 	struct pack_window *windows;
object.c +17 -0
index 2fe5fac3ce..f13f9d97f4 100644
@@ -440,3 +440,20 @@ void clear_object_flags(unsigned flags)
 			obj->flags &= ~flags;
 	}
 }
+
+
+void raw_object_store_clear(struct raw_object_store *o)
+{
+	/* TODO: free alt_odb_list/tail */
+	/* TODO: clear packed_git, packed_git_mru */
+}
+
+void object_parser_clear(struct object_parser *o)
+{
+	/*
+	 * TOOD free objects in o->obj_hash.
+	 *
+	 * As objects are allocated in slabs (see alloc.c), we do
+	 * not need to free each object, but each slab instead.
+	 */
+}
object.h +2 -0
index 900f1b6611..0b42b09322 100644
@@ -43,6 +43,8 @@ extern struct alloc_state the_repository_object_state;
 	&the_repository_object_state, \
 	0 }
 
+extern void object_parser_clear(struct object_parser *o);
+
 struct object_list {
 	struct object *item;
 	struct object_list *next;
repository.c +3 -0
index 64fb6d8b34..d5ea158b26 100644
@@ -141,6 +141,9 @@ static void repo_clear(struct repository *repo)
 	FREE_AND_NULL(repo->worktree);
 	FREE_AND_NULL(repo->submodule_prefix);
 
+	raw_object_store_clear(&repo->objects);
+	object_parser_clear(&repo->parsed_objects);
+
 	if (repo->config) {
 		git_configset_clear(repo->config);
 		FREE_AND_NULL(repo->config);
submodule.c +1 -4
index 9bd337ce99..c9634f84ef 100644
@@ -494,10 +494,7 @@ static int open_submodule(struct repository *out, const char *path)
 {
 	struct strbuf sb = STRBUF_INIT;
 
-	if (submodule_to_gitdir(&sb, path))
-		return -1;
-
-	if (repo_init(out, sb.buf, NULL)) {
+	if (submodule_to_gitdir(&sb, path) || repo_init(out, sb.buf, NULL)) {
 		strbuf_release(&sb);
 		return -1;
 	}
t/t5531-deep-submodule-push.sh +0 -16
index 8b2aa5a0f4..39cb2c1c34 100755
@@ -308,22 +308,6 @@ test_expect_success 'submodule entry pointing at a tag is error' '
 	test_i18ngrep "is a tag, not a commit" err
 '
 
-test_expect_success 'replace ref does not interfere with submodule access' '
-	test_commit -C work/gar/bage one &&
-	test_commit -C work/gar/bage two &&
-	git -C work/gar/bage reset HEAD^^ &&
-	git -C work/gar/bage replace two one &&
-	test_when_finished "git -C work/gar/bage replace -d two" &&
-
-	test_commit -C work/gar/bage three &&
-	git -C work add gar/bage &&
-	git -C work commit -m "advance submodule" &&
-
-	git -C work push --recurse-submodules=on-demand ../pub.git master 2>err &&
-	! grep error err &&
-	! grep fatal err
-'
-
 test_expect_success 'push fails if recurse submodules option passed as yes' '
 	(
 		cd work/gar/bage &&
#233 lore raw
In reply to Stefan Beller
Quoted 7 lines · Stefan Beller
Quoted 1 line

Any suggestions welcome!

Eric repeatedly points out leaking memory.

As of today we do not care about memory leaking as it is cleaned up at the end of the program anyway, for example the objects hash table is never cleared.

Is this still true/desirable when multiple 'repos' are involved?

Quoted 10 lines

In a resend I will put the infrastructure in place to free the memory via adding

raw_object_store_clear(struct raw_object_store *) object_parser_clear(struct object_parser *) ref_store_clear(struct ref_store *)

and calling these functions on repo destruction. The functions itself will be empty code-wise and contain TODO comments listing all variables that need care.

I'm confused. If you go to the effort of inserting TODO's why not go all the way and instead insert the actual code?

Quoted 3 lines

Follow up patches can figure out what is best to do, such as closing the memleaks. As repo_clear is not called for the_repository we'd even keep the property of relying on fast cleanup by the OS.

#234 lore raw
In reply to Stefan Beller
Quoted 10 lines · Stefan Beller

This series moves a lot of global state into the repository struct. It applies on top of 2512f15446149235156528dafbe75930c712b29e (2.16.0) It can be found at https://github.com/stefanbeller/git/tree/object-store

Motivation for this series:
* Easier to reason about code when all state is stored in one place, for example for multithreading
* Easier to move to processing submodules in-process instead of calling a processes for the submodule handling.
The last patch demonstrates this.

I have a mixed feeling about this. The end game is to keep "the_repository" references as minimum as possible, right? Like we only need to mention in in cmd_xxx() and not all over the place. If so, yay!!

Something else.. maybe "struct repository *" should not be a universal function argument to avoid global states. Like sha1_file.c is mostly about the object store, and I see that you added object store struct (nice!). These sha1 related function should take the object_store* (which probably is a combination of both packed and loose stores since they depend on each other), not repository*. This way if a function needs both access to object store and ref store, we can see the two dependencies from function arguments.

The alternate object store, if modeled right, could share the same object store interface. But I don't think we should do anything that big right now, just put alternate object store inside object_store.

Similarly those functions in blob.c, commit.c, tree.c... should take object_parser* as argument instead of repository*. Maybe there's a better name for this than object_parser. parsed_object_store I guess. Or maybe just object_pool.

Signature · 1 line
Duy
#235 lore raw
Quoted 12 lines · Duy Nguyen
Quoted 10 lines · Stefan Beller

This series moves a lot of global state into the repository struct. It applies on top of 2512f15446149235156528dafbe75930c712b29e (2.16.0) It can be found at https://github.com/stefanbeller/git/tree/object-store

Motivation for this series:
* Easier to reason about code when all state is stored in one place, for example for multithreading
* Easier to move to processing submodules in-process instead of calling a processes for the submodule handling.
The last patch demonstrates this.

Quoted 4 lines

I have a mixed feeling about this. The end game is to keep "the_repository" references as minimum as possible, right? Like we only need to mention in in cmd_xxx() and not all over the place. If so, yay!!

Yes. And the super-end-game long after this series is to have
cmd_xxx(struct repository *r, argc, argv)
or so.

Quoted 8 lines

Something else.. maybe "struct repository *" should not be a universal function argument to avoid global states. Like sha1_file.c is mostly about the object store, and I see that you added object store struct (nice!). These sha1 related function should take the object_store* (which probably is a combination of both packed and loose stores since they depend on each other), not repository*. This way if a function needs both access to object store and ref store, we can see the two dependencies from function arguments.

I tried that in the beginning and it blew up a couple of times when I realized that I forgot to pass through one of these dependencies.
Maybe we can go to the repository and shrink the scope in a follow up?

Quoted 3 lines

The alternate object store, if modeled right, could share the same object store interface. But I don't think we should do anything that big right now, just put alternate object store inside object_store.

yup that is the case, see struct raw_object_store at the end of the series
https://github.com/stefanbeller/git/blob/object-store-v2/object-store.h

Quoted 4 lines

Similarly those functions in blob.c, commit.c, tree.c... should take object_parser* as argument instead of repository*. Maybe there's a better name for this than object_parser. parsed_object_store I guess. Or maybe just object_pool.

Note that the initial few patches are misleading in the name,
https://public-inbox.org/git/[email protected]/
which splits up the object handling into two layers, the "physical" layer (where to get the data from, mmaping pack files, alternates, streams of bytes), which is "struct raw_object_store objects;" in the repository, and the "object" layer, which is about parsing the objects and making sense of the data (which tree belongs to a commit, dereferencing tags)

So maybe I'll try to make the first layer into its own series, such that we'll have a smaller series.

Thanks,
Stefan

Quoted 2 lines

--
Duy

#236 lore raw
Quoted 9 lines · Stefan Beller
Quoted 8 lines

Something else.. maybe "struct repository *" should not be a universal function argument to avoid global states. Like sha1_file.c is mostly about the object store, and I see that you added object store struct (nice!). These sha1 related function should take the object_store* (which probably is a combination of both packed and loose stores since they depend on each other), not repository*. This way if a function needs both access to object store and ref store, we can see the two dependencies from function arguments.

Quoted 3 lines

I tried that in the beginning and it blew up a couple of times when I realized that I forgot to pass through one of these dependencies.
Maybe we can go to the repository and shrink the scope in a follow up?

I think it's a good thing to do. We need to make these implicit dependencies explicit sooner or later.

Also, perhaps at the earlier steps you don't need to add everything to the_respository yet. You can have the_object_store, the_parsed_object (and we already have get_main_ref_store()), then use them internally without touching the API, which helps reduce code change. For example, read_sha1_file() could be converted to take "struct object_store *" all the way

void *read_sha1_file_extended(const unsigned char *sha1,
enum object_type *type,
unsigned long *size,
int lookup_replace)

{
        struct object_store *store = &the_object_store;
        ...
        // more access to "store"
}

When every piece is in place, the API change can be made be removing that "store = &the_object_store" line and make "store" an argument of read_sha1_file().

Signature · 1 line
Duy
#237 lore raw
In reply to Stefan Beller
Quoted 10 lines · Stefan Beller

This series moves a lot of global state into the repository struct. It applies on top of 2512f15446149235156528dafbe75930c712b29e (2.16.0) It can be found at https://github.com/stefanbeller/git/tree/object-store

Motivation for this series:
* Easier to reason about code when all state is stored in one place, for example for multithreading
* Easier to move to processing submodules in-process instead of calling a processes for the submodule handling.
The last patch demonstrates this.

[...]

Very nice. My eyes glazed over a few times, but I like the direction you're heading here.

Thanks for tackling this!
Jeff

#238 lore raw
In reply to Stefan Beller
Quoted 10 lines · Stefan Beller

This series moves a lot of global state into the repository struct. It applies on top of 2512f15446149235156528dafbe75930c712b29e (2.16.0) It can be found at https://github.com/stefanbeller/git/tree/object-store

Motivation for this series:
* Easier to reason about code when all state is stored in one place, for example for multithreading
* Easier to move to processing submodules in-process instead of calling a processes for the submodule handling.
The last patch demonstrates this.

For what it's worth...I spot checked some random patches, looked closely at the changes to merge-recursive, and looked at what was happening to cache.h

I like how you structured the series, and I like the goals. Didn't find any problems in the small pieces I looked at.