t7400: fix broken "submodule add/reconfigure --force" test

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> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Eric Sunshine committed Jul 1, 2018 at 20:23 UTC adc73318fe120e7b4366c734d574c6316745bc68
1 file changed +6 -5
t/t7400-submodule-basic.sh
+6 -5
@@ -171,12 +171,13 @@ test_expect_success 'submodule add to .gitignored path with --force' '
171 test_expect_success 'submodule add to reconfigure existing submodule with --force' '
172 (
173 cd addtest-ignore &&
174 - git submodule add --force bogus-url submod &&
175 - git submodule add -b initial "$submodurl" submod-branch &&
176 - test "bogus-url" = "$(git config -f .gitmodules submodule.submod.url)" &&
177 - test "bogus-url" = "$(git config submodule.submod.url)" &&
174 + bogus_url="$(pwd)/bogus-url" &&
175 + git submodule add --force "$bogus_url" submod &&
176 + git submodule add --force -b initial "$submodurl" submod-branch &&
177 + test "$bogus_url" = "$(git config -f .gitmodules submodule.submod.url)" &&
178 + test "$bogus_url" = "$(git config submodule.submod.url)" &&
179 # Restore the url
179 - git submodule add --force "$submodurl" submod
180 + git submodule add --force "$submodurl" submod &&
181 test "$submodurl" = "$(git config -f .gitmodules submodule.submod.url)" &&
182 test "$submodurl" = "$(git config submodule.submod.url)"
183 )