git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 2/2] submodule: use submodule repository when preparing summary

From
Michael Forney <mforney@mforney.org>
Date
Jun 23, 2020, 20:56 UTC
Message-ID
<20200623205659.14297-2-mforney@mforney.org>
In-Reply-To
<20200623205659.14297-1-mforney@mforney.org>

In show_submodule_header(), we gather the left and right commits of the submodule repository, as well as the merge bases. However, prepare_submodule_summary() initializes the rev_info with the_repository, so we end up parsing the commit in the wrong repository.

This results in a fatal error in parse_commit_in_graph(), since the passed item does not belong to the repository's commit graph.

Signed-off-by: Michael Forney <mforney@mforney.org>
---
 submodule.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/submodule.c b/submodule.c
index e2ef5698c8..785ab47629 100644
--- a/submodule.c
+++ b/submodule.c
@@ -438,13 +438,13 @@ void handle_ignore_submodules_arg(struct diff_options *diffopt,
 	 */
 }
 
-static int prepare_submodule_summary(struct rev_info *rev, const char *path,
-		struct commit *left, struct commit *right,
+static int prepare_submodule_summary(struct repository *r, struct rev_info *rev,
+		const char *path, struct commit *left, struct commit *right,
 		struct commit_list *merge_bases)
 {
 	struct commit_list *list;
 
-	repo_init_revisions(the_repository, rev, NULL);
+	repo_init_revisions(r, rev, NULL);
 	setup_revisions(0, NULL, rev, NULL);
 	rev->left_right = 1;
 	rev->first_parent_only = 1;
@@ -632,7 +632,7 @@ void show_submodule_summary(struct diff_options *o, const char *path,
 		goto out;
 
 	/* Treat revision walker failure the same as missing commits */
-	if (prepare_submodule_summary(&rev, path, left, right, merge_bases)) {
+	if (prepare_submodule_summary(sub, &rev, path, left, right, merge_bases)) {
 		diff_emit_submodule_error(o, "(revision walker failed)\n");
 		goto out;
 	}
-- 
2.27.0
Previous: Michael ForneyNext: Derrick Stolee
Message 2 of 10 in “revision: use repository from rev_info when parsing commits”
  1. 1/2 revision: use repository from rev_info when parsing commitsMichael Forney, Jun 23, 2020
  2. 2/2 submodule: use submodule repository when preparing summaryMichael Forney, Jun 23, 2020
  3. Derrick StoleeJun 24, 2020
  4. Junio C HamanoJun 24, 2020
  5. Michael ForneyJun 30, 2020
  6. Michael ForneyAug 13, 2020
  7. Eric SunshineJun 23, 2020
  8. Derrick StoleeJun 24, 2020
  9. Junio C HamanoSep 3, 2020
  10. Derrick StoleeSep 4, 2020

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.