[PATCH 5/6] t7400: Add short "git submodule add" testsuite
This patch introduces basic tests for
git submodule add
covering the basic functionality and the -b parameter.
A trivial update --init test fix freeloads on this commit as well.
Signed-off-by: Petr Baudis <pasky@suse.cz>
---
t/t7400-submodule-basic.sh | 28 +++++++++++++++++++++++++++-
1 files changed, 27 insertions(+), 1 deletions(-)
diff --git a/t/t7400-submodule-basic.sh b/t/t7400-submodule-basic.sh
index be73f7b..8a002bc 100755
--- a/t/t7400-submodule-basic.sh
+++ b/t/t7400-submodule-basic.sh
@@ -200,7 +200,7 @@ test_expect_success 'update --init' '
mv init init2 &&
git config -f .gitmodules submodule.example.url "$(pwd)/init2" &&
- git config --remove-section submodule.example
+ git config --remove-section submodule.example &&
git submodule update init > update.out &&
grep "not initialized" update.out &&
test ! -d init/.git &&
@@ -209,4 +209,30 @@ test_expect_success 'update --init' '
'
+test_expect_success 'submodule add' '
+
+ git submodule add "$(pwd)/init2" init-added &&
+ test -d init-added/.git &&
+ [ "$(git config -f .gitmodules submodule.init-added.url)" = "$(pwd)/init2" ] &&
+ [ "$(git config -f .gitmodules submodule.init-added.path)" = "init-added" ]
+
+'
+
+test_expect_success 'submodule add -b' '
+
+ (
+ cd init2 &&
+ git checkout -b branch &&
+ echo t >s &&
+ git add s &&
+ git commit -m "change branch" &&
+ git checkout master
+ ) &&
+ git submodule add -b branch -- "$(pwd)/init2" init-added-b &&
+ test -d init-added-b/.git &&
+ [ "$(git config -f .gitmodules submodule.init-added-b.url)" = "$(pwd)/init2" ] &&
+ [ "$(cd init2 && git rev-parse branch)" = "$(cd init-added-b && git rev-parse HEAD)" ]
+
+'
+
test_done