summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 98dbe63)
raw | patch | inline | side by side (parent: 98dbe63)
author | Brandon Casey <drafnel@gmail.com> | |
Thu, 30 Jun 2011 00:34:57 +0000 (19:34 -0500) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Thu, 30 Jun 2011 01:24:40 +0000 (18:24 -0700) |
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>
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>
t/t7407-submodule-foreach.sh | patch | blob | history |
index d8ad25036f325ecdcc71257614e19b5e6ab2cdc5..97b7562dbfe510daa86f9888a4a5bc401c789b6c 100755 (executable)
@@ -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