summaryrefslogtreecommitdiff
path: root/t/t7407-submodule-foreach.sh
diff options
context:
space:
mode:
authorBrandon Casey <drafnel@gmail.com>2011-06-30 00:34:57 (GMT)
committerJunio C Hamano <gitster@pobox.com>2011-06-30 01:24:40 (GMT)
commit91cd7e4b426b0dc4755212fcbac3c822499ddd15 (patch)
tree070cfe76038a274cbe3b40633c80bf49c879a8aa /t/t7407-submodule-foreach.sh
parent98dbe63dbcb44218e23ccc92e1491c36b2e31945 (diff)
downloadgit-91cd7e4b426b0dc4755212fcbac3c822499ddd15.zip
git-91cd7e4b426b0dc4755212fcbac3c822499ddd15.tar.gz
git-91cd7e4b426b0dc4755212fcbac3c822499ddd15.tar.bz2
t/t7407: demonstrate that the command called by 'submodule foreach' loses stdin
The user-supplied command spawned by 'submodule foreach' loses its connection to the original standard input. Instead, it is connected to the output of a pipe within the git-submodule script. This can cause a problem if the command requires reading from stdin or if it changes its behavior based on whether stdin is a tty or not (e.g. git shortlog). Demonstrate this flaw. Signed-off-by: Brandon Casey <drafnel@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t7407-submodule-foreach.sh')
-rwxr-xr-xt/t7407-submodule-foreach.sh18
1 files changed, 18 insertions, 0 deletions
diff --git a/t/t7407-submodule-foreach.sh b/t/t7407-submodule-foreach.sh
index d8ad250..97b7562 100755
--- a/t/t7407-submodule-foreach.sh
+++ b/t/t7407-submodule-foreach.sh
@@ -288,4 +288,22 @@ test_expect_success 'use "update --recursive nested1" to checkout all submodules
)
'
+test_expect_failure 'command passed to foreach retains notion of stdin' '
+ (
+ cd super &&
+ git submodule foreach echo success >../expected &&
+ yes | git submodule foreach "read y && test \"x\$y\" = xy && echo success" >../actual
+ ) &&
+ test_cmp expected actual
+'
+
+test_expect_failure 'command passed to foreach --recursive retains notion of stdin' '
+ (
+ cd clone2 &&
+ git submodule foreach --recursive echo success >../expected &&
+ yes | git submodule foreach --recursive "read y && test \"x\$y\" = xy && echo success" >../actual
+ ) &&
+ test_cmp expected actual
+'
+
test_done