@@ -109,26 +109,48 @@ resolve_relative_url ()
109
109
#
110
110
module_list ()
111
111
{
112
- git ls-files --error-unmatch --stage -- " $@ " |
112
+ (
113
+ git ls-files --error-unmatch --stage -- " $@ " ||
114
+ echo " unmatched pathspec exists"
115
+ ) |
113
116
perl -e '
114
117
my %unmerged = ();
115
118
my ($null_sha1) = ("0" x 40);
119
+ my @out = ();
120
+ my $unmatched = 0;
116
121
while (<STDIN>) {
122
+ if (/^unmatched pathspec/) {
123
+ $unmatched = 1;
124
+ next;
125
+ }
117
126
chomp;
118
127
my ($mode, $sha1, $stage, $path) =
119
128
/^([0-7]+) ([0-9a-f]{40}) ([0-3])\t(.*)$/;
120
129
next unless $mode eq "160000";
121
130
if ($stage ne "0") {
122
131
if (!$unmerged{$path}++) {
123
- print "$mode $null_sha1 U\t$path\n";
132
+ push @out, "$mode $null_sha1 U\t$path\n";
124
133
}
125
134
next;
126
135
}
127
- print "$_\n";
136
+ push @out, "$_\n";
137
+ }
138
+ if ($unmatched) {
139
+ print "#unmatched\n";
140
+ } else {
141
+ print for (@out);
128
142
}
129
143
'
130
144
}
131
145
146
+ die_if_unmatched ()
147
+ {
148
+ if test " $1 " = " #unmatched"
149
+ then
150
+ exit 1
151
+ fi
152
+ }
153
+
132
154
#
133
155
# Map submodule path to submodule name
134
156
#
@@ -385,6 +407,7 @@ cmd_foreach()
385
407
module_list |
386
408
while read mode sha1 stage sm_path
387
409
do
410
+ die_if_unmatched " $mode "
388
411
if test -e " $sm_path " /.git
389
412
then
390
413
say " $( eval_gettext " Entering '\$ prefix\$ sm_path'" ) "
@@ -437,6 +460,7 @@ cmd_init()
437
460
module_list " $@ " |
438
461
while read mode sha1 stage sm_path
439
462
do
463
+ die_if_unmatched " $mode "
440
464
name=$( module_name " $sm_path " ) || exit
441
465
442
466
# Copy url setting when it is not set yet
@@ -537,6 +561,7 @@ cmd_update()
537
561
err=
538
562
while read mode sha1 stage sm_path
539
563
do
564
+ die_if_unmatched " $mode "
540
565
if test " $stage " = U
541
566
then
542
567
echo >&2 " Skipping unmerged submodule $sm_path "
@@ -932,6 +957,7 @@ cmd_status()
932
957
module_list " $@ " |
933
958
while read mode sha1 stage sm_path
934
959
do
960
+ die_if_unmatched " $mode "
935
961
name=$( module_name " $sm_path " ) || exit
936
962
url=$( git config submodule." $name " .url)
937
963
displaypath=" $prefix$sm_path "
@@ -1000,6 +1026,7 @@ cmd_sync()
1000
1026
module_list " $@ " |
1001
1027
while read mode sha1 stage sm_path
1002
1028
do
1029
+ die_if_unmatched " $mode "
1003
1030
name=$( module_name " $sm_path " )
1004
1031
url=$( git config -f .gitmodules --get submodule." $name " .url)
1005
1032
0 commit comments