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

Re: [PATCH 11/25] t7400: fix broken "submodule add/reconfigure --force" test

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
Jul 16, 2018, 15:51 UTC
Message-ID
<nycvar.QRO.7.76.6.1807161749410.71@tvgsbejvaqbjf.bet>
In-Reply-To
<nycvar.QRO.7.76.6.1807161641140.71@tvgsbejvaqbjf.bet>
Hi Eric,
On Mon, 16 Jul 2018, Johannes Schindelin wrote:
Show 59 quoted lines
> On Sun, 1 Jul 2018, Eric Sunshine wrote:
> 
> > This test has been dysfunctional since it was added by 619acfc78c
> > (submodule add: extend force flag to add existing repos, 2016-10-06),
> > however, two problems early in the test went unnoticed due to a broken
> > &&-chain later in the test.
> > 
> > First, it tries configuring the submodule with repository "bogus-url",
> > however, "git submodule add" insists that the repository be either an
> > absolute URL or a relative pathname requiring prefix "./" or "../" (this
> > is true even with --force), but "bogus-url" does not meet those
> > criteria, thus the command fails.
> > 
> > Second, it then tries configuring a submodule with a path which is
> > .gitignore'd, which is disallowed. This restriction can be overridden
> > with --force, but the test neglects to use that option.
> > 
> > Fix both problems, as well as the broken &&-chain behind which they hid.
> > 
> > Reviewed-by: Stefan Beller <sbeller@google.com>
> > Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
> > ---
> >  t/t7400-submodule-basic.sh | 10 +++++-----
> >  1 file changed, 5 insertions(+), 5 deletions(-)
> > 
> > diff --git a/t/t7400-submodule-basic.sh b/t/t7400-submodule-basic.sh
> > index 812db137b8..401adaed32 100755
> > --- a/t/t7400-submodule-basic.sh
> > +++ b/t/t7400-submodule-basic.sh
> > @@ -171,12 +171,12 @@ test_expect_success 'submodule add to .gitignored path with --force' '
> >  test_expect_success 'submodule add to reconfigure existing submodule with --force' '
> >  	(
> >  		cd addtest-ignore &&
> > -		git submodule add --force bogus-url submod &&
> > -		git submodule add -b initial "$submodurl" submod-branch &&
> > -		test "bogus-url" = "$(git config -f .gitmodules submodule.submod.url)" &&
> > -		test "bogus-url" = "$(git config submodule.submod.url)" &&
> > +		git submodule add --force /bogus-url submod &&
> > +		git submodule add --force -b initial "$submodurl" submod-branch &&
> > +		test "/bogus-url" = "$(git config -f .gitmodules submodule.submod.url)" &&
> > +		test "/bogus-url" = "$(git config submodule.submod.url)" &&
> >  		# Restore the url
> > -		git submodule add --force "$submodurl" submod
> > +		git submodule add --force "$submodurl" submod &&
> >  		test "$submodurl" = "$(git config -f .gitmodules submodule.submod.url)" &&
> >  		test "$submodurl" = "$(git config submodule.submod.url)"
> >  	)
> 
> This breaks on Windows because of the absolute Unix-y path having to be
> translated to a Windows path:
> 
> 	https://git-for-windows.visualstudio.com/git/git%20Team/_build/results?buildId=12365&view=logs
> 
> (In this case, it is prefixed with `C:/git-sdk-64-ci` because that is the
> pseudo root when running in a Git for Windows SDK that is installed into
> that directory.)
> 
> I could imagine that using "$(pwd)/bogus-url" (which will generate a
> Windows-y absolute path on Windows) would work, though.

Yes, this works indeed, see the patch below. Could you please squash it in if you send another iteration of your patch series? Junio, could you please add this as a SQUASH??? commit so that `pu` is fixed on Windows? Thanks.

-- snipsnap --
diff --git a/t/t7400-submodule-basic.sh b/t/t7400-submodule-basic.sh
index 5ffc2726aad..2c2c97e1441 100755
--- a/t/t7400-submodule-basic.sh
+++ b/t/t7400-submodule-basic.sh
@@ -171,10 +171,11 @@ test_expect_success 'submodule add to .gitignored path with --force' '
 test_expect_success 'submodule add to reconfigure existing submodule with --force' '
 	(
 		cd addtest-ignore &&
-		git submodule add --force /bogus-url submod &&
+		bogus_url="$(pwd)/bogus-url" &&
+		git submodule add --force "$bogus_url" submod &&
 		git submodule add --force -b initial "$submodurl" submod-branch &&
-		test "/bogus-url" = "$(git config -f .gitmodules submodule.submod.url)" &&
-		test "/bogus-url" = "$(git config submodule.submod.url)" &&
+		test "$bogus_url" = "$(git config -f .gitmodules submodule.submod.url)" &&
+		test "$bogus_url" = "$(git config submodule.submod.url)" &&
 		# Restore the url
 		git submodule add --force "$submodurl" submod &&
 		test "$submodurl" = "$(git config -f .gitmodules submodule.submod.url)" &&
Previous: Johannes SchindelinNext: Eric Sunshine
Message 17 of 52 in “fix buggy tests, modernize tests, fix broken &&-chains”
  1. 00/25 fix buggy tests, modernize tests, fix broken &&-chainsEric Sunshine, Jul 2, 2018
  2. 01/25 t: use test_might_fail() instead of manipulating exit code manuallyEric Sunshine, Jul 2, 2018
  3. Stefan BellerJul 2, 2018
  4. Eric SunshineJul 2, 2018
  5. Junio C HamanoJul 3, 2018
  6. 04/25 t: drop unnecessary terminating semicolon in subshellEric Sunshine, Jul 2, 2018
  7. Junio C HamanoJul 3, 2018
  8. 05/25 t/lib-submodule-update: fix "absorbing" testEric Sunshine, Jul 2, 2018
  9. 03/25 t: use sane_unset() rather than 'unset' with broken &&-chainEric Sunshine, Jul 2, 2018
  10. 02/25 t: use test_write_lines() instead of series of 'echo' commandsEric Sunshine, Jul 2, 2018
  11. Stefan BellerJul 2, 2018
  12. 08/25 t5505: modernize and simplify hard-to-digest testEric Sunshine, Jul 2, 2018
  13. 07/25 t5406: use write_script() instead of birthing shell script manuallyEric Sunshine, Jul 2, 2018
  14. 10/25 t7201: drop pointless "exit 0" at end of subshellEric Sunshine, Jul 2, 2018
  15. 11/25 t7400: fix broken "submodule add/reconfigure --force" testEric Sunshine, Jul 2, 2018
  16. Johannes SchindelinJul 16, 2018
  17. Johannes SchindelinJul 16, 2018
  18. Eric SunshineJul 16, 2018
  19. Junio C HamanoJul 16, 2018
  20. Eric SunshineJul 16, 2018
  21. Johannes SchindelinJul 17, 2018
  22. Junio C HamanoJul 17, 2018
  23. 12/25 t7810: use test_expect_code() instead of hand-rolled comparisonEric Sunshine, Jul 2, 2018
  24. Stefan BellerJul 2, 2018
  25. Eric SunshineJul 2, 2018
  26. 15/25 t0000-t0999: fix broken &&-chainsEric Sunshine, Jul 2, 2018
  27. 16/25 t1000-t1999: fix broken &&-chainsEric Sunshine, Jul 2, 2018
  28. 17/25 t2000-t2999: fix broken &&-chainsEric Sunshine, Jul 2, 2018
  29. 25/25 t9119: fix broken &&-chainsEric Sunshine, Jul 2, 2018
  30. 24/25 t9000-t9999: fix broken &&-chainsEric Sunshine, Jul 2, 2018
  31. 23/25 t7000-t7999: fix broken &&-chainsEric Sunshine, Jul 2, 2018
  32. 22/25 t6000-t6999: fix broken &&-chainsEric Sunshine, Jul 2, 2018
  33. 21/25 t5000-t5999: fix broken &&-chainsEric Sunshine, Jul 2, 2018
  34. SZEDER GáborJul 12, 2018
  35. Eric SunshineJul 12, 2018
  36. Jeff KingJul 12, 2018
  37. Junio C HamanoJul 12, 2018
  38. Junio C HamanoJul 12, 2018
  39. Eric SunshineJul 12, 2018
  40. Junio C HamanoJul 12, 2018
  41. Eric SunshineJul 12, 2018
  42. SZEDER GáborJul 17, 2018
  43. 20/25 t4000-t4999: fix broken &&-chainsEric Sunshine, Jul 2, 2018
  44. 19/25 t3030: fix broken &&-chainsEric Sunshine, Jul 2, 2018
  45. 18/25 t3000-t3999: fix broken &&-chainsEric Sunshine, Jul 2, 2018
  46. 14/25 t9814: simplify convoluted check that command correctly errors outEric Sunshine, Jul 2, 2018
  47. 09/25 t6036: fix broken "merge fails but has appropriate contents" testsEric Sunshine, Jul 2, 2018
  48. 06/25 t5405: use test_must_fail() instead of checking exit code manuallyEric Sunshine, Jul 2, 2018
  49. 13/25 t9001: fix broken "invoke hook" testEric Sunshine, Jul 2, 2018
  50. Stefan BellerJul 2, 2018
  51. Eric SunshineJul 2, 2018
  52. Junio C HamanoJul 3, 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.