@@ -73,26 +73,48 @@ resolve_relative_url ()
73
73
#
74
74
module_list ()
75
75
{
76
- git ls-files --error-unmatch --stage -- " $@ " |
76
+ (
77
+ git ls-files --error-unmatch --stage -- " $@ " ||
78
+ echo " unmatched pathspec exists"
79
+ ) |
77
80
perl -e '
78
81
my %unmerged = ();
79
82
my ($null_sha1) = ("0" x 40);
83
+ my @out = ();
84
+ my $unmatched = 0;
80
85
while (<STDIN>) {
86
+ if (/^unmatched pathspec/) {
87
+ $unmatched = 1;
88
+ next;
89
+ }
81
90
chomp;
82
91
my ($mode, $sha1, $stage, $path) =
83
92
/^([0-7]+) ([0-9a-f]{40}) ([0-3])\t(.*)$/;
84
93
next unless $mode eq "160000";
85
94
if ($stage ne "0") {
86
95
if (!$unmerged{$path}++) {
87
- print "$mode $null_sha1 U\t$path\n";
96
+ push @out, "$mode $null_sha1 U\t$path\n";
88
97
}
89
98
next;
90
99
}
91
- print "$_\n";
100
+ push @out, "$_\n";
101
+ }
102
+ if ($unmatched) {
103
+ print "#unmatched\n";
104
+ } else {
105
+ print for (@out);
92
106
}
93
107
'
94
108
}
95
109
110
+ die_if_unmatched ()
111
+ {
112
+ if test " $1 " = " #unmatched"
113
+ then
114
+ exit 1
115
+ fi
116
+ }
117
+
96
118
#
97
119
# Map submodule path to submodule name
98
120
#
@@ -346,6 +368,7 @@ cmd_foreach()
346
368
module_list |
347
369
while read mode sha1 stage sm_path
348
370
do
371
+ die_if_unmatched " $mode "
349
372
if test -e " $sm_path " /.git
350
373
then
351
374
say " $( eval_gettext " Entering '\$ prefix\$ sm_path'" ) "
@@ -398,6 +421,7 @@ cmd_init()
398
421
module_list " $@ " |
399
422
while read mode sha1 stage sm_path
400
423
do
424
+ die_if_unmatched " $mode "
401
425
name=$( module_name " $sm_path " ) || exit
402
426
403
427
# Copy url setting when it is not set yet
@@ -498,6 +522,7 @@ cmd_update()
498
522
err=
499
523
while read mode sha1 stage sm_path
500
524
do
525
+ die_if_unmatched " $mode "
501
526
if test " $stage " = U
502
527
then
503
528
echo >&2 " Skipping unmerged submodule $sm_path "
@@ -893,6 +918,7 @@ cmd_status()
893
918
module_list " $@ " |
894
919
while read mode sha1 stage sm_path
895
920
do
921
+ die_if_unmatched " $mode "
896
922
name=$( module_name " $sm_path " ) || exit
897
923
url=$( git config submodule." $name " .url)
898
924
displaypath=" $prefix$sm_path "
@@ -961,6 +987,7 @@ cmd_sync()
961
987
module_list " $@ " |
962
988
while read mode sha1 stage sm_path
963
989
do
990
+ die_if_unmatched " $mode "
964
991
name=$( module_name " $sm_path " )
965
992
url=$( git config -f .gitmodules --get submodule." $name " .url)
966
993
0 commit comments