lets say I have 10 submoules:
module/1
module/2
module/3
module/4
module/5
module/6
module/7
module/8
module/9
module/10
where module/
is the top-level repo.
I want to do git submodule foreach 'git status'
, but I don't want to do it for submodules 4, 6 and 7.
Is there a way to do that, somthing like :
git submodule foreach --exclude="4 6 7" 'git status'
I tried doing it inside the command block using
git submodule foreach '
if [[ $list_of_ignores =~ *"$displayname"* ]] ; then echo ignore; fi
'
update - removed --exclude="4 6 7"
that was accidently in there
But I get errors saying eval [[: not found
- I am assuming this is because it is using /bin/sh instead of /bin/bash? - not sure...
As the docs say, foreach executes shell commands,
foreach [--recursive] <command> Evaluates an arbitrary shell command in each checked out submodule. The command has access to the variables $name, $sm_path, $displaypath, $sha1 and $toplevel
so use the shell:
git submodule foreach 'case $name in 4|6|7) ;; *) git status ;; esac'
If the syntax looks strange to you, look up the syntax for bash's case
statements. The above, if written in a script with line breaks, would be:
case $name in # $name is available to `submodule foreach`
4|5|6)
;;
*) # default "catchall"
git status
;;
esac