From: Johan Herland <johan@herland.net>
To: git@vger.kernel.org
Cc: Johan Herland <johan@herland.net>,
gitster@pobox.com, mlevedahl@gmail.com, hjemli@gmail.com
Subject: [RFC/PATCH 2/6] Add selftest for 'git submodule foreach'
Date: Wed, 19 Aug 2009 03:45:20 +0200 [thread overview]
Message-ID: <1250646324-961-3-git-send-email-johan@herland.net> (raw)
In-Reply-To: <1250646324-961-1-git-send-email-johan@herland.net>
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 <johan@herland.net>
---
t/t7407-submodule-foreach.sh | 79 ++++++++++++++++++++++++++++++++++++++++++
1 files changed, 79 insertions(+), 0 deletions(-)
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 0000000..76e0734
--- /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 <<EOF
+Entering 'sub1'
+sub1-$sub1sha1
+Entering 'sub3'
+sub3-$sub3sha1
+EOF
+
+test_expect_success 'test basic "submodule foreach" usage' '
+ git clone super clone &&
+ (
+ cd clone &&
+ git submodule update --init -- sub1 sub3 &&
+ git submodule foreach "echo \$path-\$sha1" > ../actual
+ ) &&
+ test_cmp expect actual
+'
+
+test_done
--
1.6.4.304.g1365c.dirty
next prev parent reply other threads:[~2009-08-19 1:46 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-08-19 1:45 [RFC/PATCH 0/6] Git submodule: 'foreach' enhancements and nested submodule handling Johan Herland
2009-08-19 1:45 ` [RFC/PATCH 1/6] git submodule: Cleanup usage string and add option parsing to cmd_foreach() Johan Herland
2009-08-19 1:45 ` Johan Herland [this message]
2009-08-19 1:45 ` [RFC/PATCH 3/6] git submodule foreach: Provide access to submodule name, as '$name' Johan Herland
2009-08-19 1:45 ` [RFC/PATCH 4/6] git submodule foreach: Add --recursive to recurse into nested submodules Johan Herland
2009-08-19 1:45 ` [RFC/PATCH 5/6] git submodule update: Introduce --recursive to update " Johan Herland
2009-08-19 1:45 ` [RFC/PATCH 6/6] git submodule status: Add --recursive to recurse into " Johan Herland
2009-08-19 23:07 ` [RFC/PATCH 7/6] git clone: Add --recursive to automatically checkout (nested) submodules Johan Herland
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1250646324-961-3-git-send-email-johan@herland.net \
--to=johan@herland.net \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=hjemli@gmail.com \
--cc=mlevedahl@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).