Merge branch 'bc/submodule-foreach-stdin-fix-1.7.4'
* bc/submodule-foreach-stdin-fix-1.7.4: git-submodule.sh: preserve stdin for the command spawned by foreach t/t7407: demonstrate that the command called by 'submodule foreach' loses stdin Conflicts: git-submodule.sh
This commit is contained in:
commit
13ac90a478
@ -304,6 +304,10 @@ cmd_foreach()
|
|||||||
|
|
||||||
toplevel=$(pwd)
|
toplevel=$(pwd)
|
||||||
|
|
||||||
|
# dup stdin so that it can be restored when running the external
|
||||||
|
# command in the subshell (and a recursive call to this function)
|
||||||
|
exec 3<&0
|
||||||
|
|
||||||
module_list |
|
module_list |
|
||||||
while read mode sha1 stage path
|
while read mode sha1 stage path
|
||||||
do
|
do
|
||||||
@ -320,7 +324,7 @@ cmd_foreach()
|
|||||||
then
|
then
|
||||||
cmd_foreach "--recursive" "$@"
|
cmd_foreach "--recursive" "$@"
|
||||||
fi
|
fi
|
||||||
) ||
|
) <&3 3<&- ||
|
||||||
die "$(eval_gettext "Stopping at '\$path'; script returned non-zero status.")"
|
die "$(eval_gettext "Stopping at '\$path'; script returned non-zero status.")"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
@ -292,4 +292,22 @@ test_expect_success 'use "update --recursive nested1" to checkout all submodules
|
|||||||
)
|
)
|
||||||
'
|
'
|
||||||
|
|
||||||
|
test_expect_success '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_success '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
|
test_done
|
||||||
|
Loading…
Reference in New Issue
Block a user