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

Re: [PATCH v3 4/4] submodule: port submodule subcommand 'summary' from shell to C

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
Aug 21, 2020, 15:17 UTC
Message-ID
<nycvar.QRO.7.76.6.2008211708280.56@tvgsbejvaqbjf.bet>
In-Reply-To
<20200812194404.17028-5-shouryashukla.oo@gmail.com>
Hi Shourya,
On Thu, 13 Aug 2020, Shourya Shukla wrote:
Show 11 quoted lines
> [...]
> diff --git a/t/t7421-submodule-summary-add.sh b/t/t7421-submodule-summary-add.sh
> index 829fe26d6d..59a9b00467 100755
> --- a/t/t7421-submodule-summary-add.sh
> +++ b/t/t7421-submodule-summary-add.sh
> @@ -58,7 +58,7 @@ test_expect_success 'submodule summary output for submodules with changed paths'
>  	git commit -m "change submodule path" &&
>  	rev=$(git -C sm rev-parse --short HEAD^) &&
>  	git submodule summary HEAD^^ -- my-subm >actual 2>err &&
> -	test_i18ngrep "fatal:.*my-subm" err &&
> +	grep "fatal:.*my-subm" err &&

Sadly, this breaks on Windows: on Linux (and before this patch, also on Windows), the error message reads somewhat like this:

	fatal: exec 'rev-parse': cd to 'my-subm' failed: No such file or directory

However, with the built-in `git submodule summary`, on Windows the error message reads like this:

	error: cannot spawn git: No such file or directory

Now, this is of course not the best way to present this error message, but please note that even providing a better error message does not fix the erroneous expectation of the `fatal:` prefix (Git typically produces this when `die()`ing, which can be done in the POSIX version that uses `fork()` and `exec()` but not in the Windows version that needs to use `CreateProcessW()` instead).

Therefore, I propose this patch on top:

-- snipsnap -- [PATCH] mingw: mention if `mingw_spawnve()` failed due to a missing directory

When we recently converted the `summary` subcommand of `git submodule` to be mostly built-in, a bug was uncovered where a very unhelpful error message was produced when a process could not be spawned because the directory in which it was supposed to be run does not exist.

Even so, we _still_ have to adjust the `git submodule summary` test, to accommodate for the fact that the `mingw_spawnve()` function will return with an error instead of `die()`ing.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
 compat/mingw.c                   | 4 ++++
 t/t7421-submodule-summary-add.sh | 2 +-
 2 files changed, 5 insertions(+), 1 deletion(-)
diff --git a/compat/mingw.c b/compat/mingw.c
index 1a64d4efb26b..3c30d0cab589 100644
--- a/compat/mingw.c
+++ b/compat/mingw.c
@@ -1850,6 +1850,10 @@ static pid_t mingw_spawnve_fd(const char *cmd, const char **argv, char **deltaen
 	/* Make sure to override previous errors, if any */
 	errno = 0;

+	if (dir && !is_directory(dir))
+		return error_errno(_("could not exec '%s' in '%s'"),
+				   argv[0], dir);
+
 	if (restrict_handle_inheritance < 0)
 		restrict_handle_inheritance = core_restrict_inherited_handles;
 	/*
diff --git a/t/t7421-submodule-summary-add.sh b/t/t7421-submodule-summary-add.sh
index 59a9b00467dc..f00d69ca29ea 100755
--- a/t/t7421-submodule-summary-add.sh
+++ b/t/t7421-submodule-summary-add.sh
@@ -58,7 +58,7 @@ test_expect_success 'submodule summary output for submodules with changed paths'
 	git commit -m "change submodule path" &&
 	rev=$(git -C sm rev-parse --short HEAD^) &&
 	git submodule summary HEAD^^ -- my-subm >actual 2>err &&
-	grep "fatal:.*my-subm" err &&
+	grep "my-subm" err &&
 	cat >expected <<-EOF &&
 	* my-subm ${rev}...0000000:

--
2.28.0.windows.1
Previous: Shourya ShuklaNext: Junio C Hamano
Message 20 of 32 in “submodule: port subcommand 'summary' from shell to C”
  1. Shourya ShuklaAug 6, 2020
  2. 5/5 submodule: port submodule subcommand 'summary' from shell to CShourya Shukla, Aug 6, 2020
  3. Junio C HamanoAug 6, 2020
  4. Shourya ShuklaAug 7, 2020
  5. Junio C HamanoAug 7, 2020
  6. 2/5 submodule: remove extra line feeds between callback struct and macroShourya Shukla, Aug 6, 2020
  7. 3/5 submodule: rename helper functions to avoid ambiguityShourya Shukla, Aug 6, 2020
  8. 4/5 t7421: introduce a test script for verifying 'summary' outputShourya Shukla, Aug 6, 2020
  9. 1/5 submodule: expose the '--for-status' option of summaryShourya Shukla, Aug 6, 2020
  10. Kaartic SivaraamAug 8, 2020
  11. Christian CouderAug 8, 2020
  12. Junio C HamanoAug 8, 2020
  13. [GSoC][PATCH v3 0/4] submodule: port subcommand 'summary' from shell to CShourya Shukla, Aug 12, 2020
  14. 1/4 submodule: remove extra line feeds between callback struct and macroShourya Shukla, Aug 12, 2020
  15. 2/4 submodule: rename helper functions to avoid ambiguityShourya Shukla, Aug 12, 2020
  16. 3/4 t7421: introduce a test script for verifying 'summary' outputShourya Shukla, Aug 12, 2020
  17. 4/4 submodule: port submodule subcommand 'summary' from shell to CShourya Shukla, Aug 12, 2020
  18. Jeff KingAug 18, 2020
  19. Shourya ShuklaAug 21, 2020
  20. Johannes SchindelinAug 21, 2020
  21. Junio C HamanoAug 21, 2020
  22. Shourya ShuklaAug 21, 2020
  23. Junio C HamanoAug 21, 2020
  24. Kaartic SivaraamAug 21, 2020
  25. Junio C HamanoAug 21, 2020
  26. Kaartic SivaraamAug 23, 2020
  27. Kaartic SivaraamAug 23, 2020
  28. Shourya ShuklaAug 24, 2020
  29. Shourya ShuklaAug 24, 2020
  30. Kaartic SivaraamAug 24, 2020
  31. Shourya ShuklaAug 24, 2020
  32. Junio C HamanoAug 24, 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.