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

Re: [PATCH] submodule.c: report the submodule that an error occurs in

From
Junio C Hamano <gitster@pobox.com>
Date
Jun 21, 2018, 21:00 UTC
Message-ID
<xmqqvaabrh1d.fsf@gitster-ct.c.googlers.com>
In-Reply-To
<20180620223253.226092-1-sbeller@google.com>
Stefan Beller <sbeller@google.com> writes:
Show 30 quoted lines
> When an error occurs in updating the working tree of a submodule in
> submodule_move_head, tell the user which submodule the error occurred in.
>
> The call to read-tree contains a super-prefix, such that the read-tree
> will correctly report any path related issues, but some error messages
> do not contain a path, for example:
>
>   ~/gerrit$ git checkout --recurse-submodules origin/master
>   ~/gerrit$ fatal: failed to unpack tree object 07672f31880ba80300b38492df9d0acfcd6ee00a
>
> Give the hint which submodule has a problem.
>
> Signed-off-by: Stefan Beller <sbeller@google.com>
> ---
>  submodule.c               | 2 +-
>  t/lib-submodule-update.sh | 3 ++-
>  2 files changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/submodule.c b/submodule.c
> index 939d6870ecd..ebd092a14fd 100644
> --- a/submodule.c
> +++ b/submodule.c
> @@ -1668,7 +1668,7 @@ int submodule_move_head(const char *path,
>  	argv_array_push(&cp.args, new_head ? new_head : empty_tree_oid_hex());
>  
>  	if (run_command(&cp)) {
> -		ret = -1;
> +		ret = error(_("Submodule '%s' could not be updated."), path);
>  		goto out;
>  	}

OK. The function uses path in messages elsewhere so we know path must not be empty and have a reasonable string content at this point, which makes this a reasonably safe patch to apply ;-)

Thanks.
Show 14 quoted lines
> diff --git a/t/lib-submodule-update.sh b/t/lib-submodule-update.sh
> index 1f38a85371a..e27f5d8541d 100755
> --- a/t/lib-submodule-update.sh
> +++ b/t/lib-submodule-update.sh
> @@ -781,7 +781,8 @@ test_submodule_recursing_with_args_common() {
>  		(
>  			cd submodule_update &&
>  			git branch -t invalid_sub1 origin/invalid_sub1 &&
> -			test_must_fail $command invalid_sub1 &&
> +			test_must_fail $command invalid_sub1 2>err &&
> +			grep sub1 err &&
>  			test_superproject_content origin/add_sub1 &&
>  			test_submodule_content sub1 origin/add_sub1
>  		)
Previous: Stefan BellerNext: SZEDER Gábor
Message 2 of 5 in “submodule.c: report the submodule that an error occurs in”
  1. submodule.c: report the submodule that an error occurs inStefan Beller, Jun 20, 2018
  2. Junio C HamanoJun 21, 2018
  3. SZEDER GáborJun 22, 2018
  4. Junio C HamanoJun 25, 2018
  5. Stefan BellerJun 27, 2018

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.