summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorStefan Beller <sbeller@google.com>2016-10-06 19:37:24 (GMT)
committerJunio C Hamano <gitster@pobox.com>2016-11-29 22:25:09 (GMT)
commit619acfc78c526bc9df17b7704e60d0512ab7a84c (patch)
treedcf2fbb2e6814b51aa4c4f05871601e3b5742294 /t
parent250ab24ab3a35d5857855a2e00483dcd8867fdca (diff)
downloadgit-619acfc78c526bc9df17b7704e60d0512ab7a84c.zip
git-619acfc78c526bc9df17b7704e60d0512ab7a84c.tar.gz
git-619acfc78c526bc9df17b7704e60d0512ab7a84c.tar.bz2
submodule add: extend force flag to add existing repos
Currently the force flag in `git submodule add` takes care of possibly ignored files or when a name collision occurs. However there is another situation where submodule add comes in handy: When you already have a gitlink recorded, but no configuration was done (i.e. no .gitmodules file nor any entry in .git/config) and you want to generate these config entries. For this situation allow `git submodule add` to proceed if there is already a submodule at the given path in the index. Signed-off-by: Stefan Beller <sbeller@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't')
-rwxr-xr-xt/t7400-submodule-basic.sh14
1 files changed, 14 insertions, 0 deletions
diff --git a/t/t7400-submodule-basic.sh b/t/t7400-submodule-basic.sh
index b77cce8..c09ce0d 100755
--- a/t/t7400-submodule-basic.sh
+++ b/t/t7400-submodule-basic.sh
@@ -152,6 +152,20 @@ 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)" &&
+ # Restore the url
+ git submodule add --force "$submodurl" submod
+ test "$submodurl" = "$(git config -f .gitmodules submodule.submod.url)" &&
+ test "$submodurl" = "$(git config submodule.submod.url)"
+ )
+'
+
test_expect_success 'submodule add --branch' '
echo "refs/heads/initial" >expect-head &&
cat <<-\EOF >expect-heads &&