From d69ecf6f0ed2c1a31875a3f642deef0358ac9377 Mon Sep 17 00:00:00 2001 From: Johan Herland Date: Wed, 19 Aug 2009 03:45:20 +0200 Subject: [PATCH] Add selftest for 'git submodule foreach' The selftest verifies that: - only checked out submodules are visited by 'git submodule foreach' - the $path, and $sha1 variables are set correctly for each submodule Signed-off-by: Johan Herland Signed-off-by: Junio C Hamano --- t/t7407-submodule-foreach.sh | 79 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100755 t/t7407-submodule-foreach.sh diff --git a/t/t7407-submodule-foreach.sh b/t/t7407-submodule-foreach.sh new file mode 100755 index 0000000000..76e0734cea --- /dev/null +++ b/t/t7407-submodule-foreach.sh @@ -0,0 +1,79 @@ +#!/bin/sh +# +# Copyright (c) 2009 Johan Herland +# + +test_description='Test "git submodule foreach" + +This test verifies that "git submodule foreach" correctly visits all submodules +that are currently checked out. +' + +. ./test-lib.sh + + +test_expect_success 'setup a submodule tree' ' + echo file > file && + git add file && + test_tick && + git commit -m upstream + git clone . super && + git clone super submodule && + ( + cd super && + git submodule add ../submodule sub1 && + git submodule add ../submodule sub2 && + git submodule add ../submodule sub3 && + git config -f .gitmodules --rename-section \ + submodule.sub1 submodule.foo1 && + git config -f .gitmodules --rename-section \ + submodule.sub2 submodule.foo2 && + git config -f .gitmodules --rename-section \ + submodule.sub3 submodule.foo3 && + git add .gitmodules + test_tick && + git commit -m "submodules" && + git submodule init sub1 && + git submodule init sub2 && + git submodule init sub3 + ) && + ( + cd submodule && + echo different > file && + git add file && + test_tick && + git commit -m "different" + ) && + ( + cd super && + ( + cd sub3 && + git pull + ) && + git add sub3 && + test_tick && + git commit -m "update sub3" + ) +' + +sub1sha1=$(cd super/sub1 && git rev-parse HEAD) +sub3sha1=$(cd super/sub3 && git rev-parse HEAD) + +cat > expect < ../actual + ) && + test_cmp expect actual +' + +test_done -- 2.11.4.GIT