Re: [PATCH 2/2] submodule: use submodule repository when preparing summary
- From
Derrick Stolee <stolee@gmail.com>
- Date
- Jun 24, 2020, 14:35 UTC
- Message-ID
- <33de1078-5f19-e76c-2a30-1754494d1e31@gmail.com>
- In-Reply-To
- <20200623205659.14297-2-mforney@mforney.org>
On 6/23/2020 4:56 PM, Michael Forney wrote:
Show 31 quoted lines
> 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);This is how we properly initialize the repository in the rev_info. It's unfortunate that this use of the_repository was pretty clearly incorrect. This is submodule.c, so every instance of the_repository should be examined carefully. Taking a brief look right now, the rest seem to be correct in that they are finding submodules within the super-repo. The only issue will arise when recursing into submodules, which is known to be broken in-process and are handled with subprocesses instead.
Show 12 quoted lines
> 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;
> }Perhaps the test I requested in patch 1 is only appropriate here? Or, maybe the test should be test_expect_failure in the first patch and switched to test_expect_success here?
Thanks, -Stolee