summaryrefslogtreecommitdiff
path: root/git-submodule.sh
diff options
context:
space:
mode:
authorLibravatar Junio C Hamano <gitster@pobox.com>2012-09-11 11:08:55 -0700
committerLibravatar Junio C Hamano <gitster@pobox.com>2012-09-11 11:08:55 -0700
commitfe31b2afac2fbae25086ecd00a1f57bcd74e9148 (patch)
treea8cd92a66b66bb3e351254c86b61f67ac5361806 /git-submodule.sh
parentMerge branch 'mz/empty-rebase-test' into maint-1.7.11 (diff)
parentLet submodule command exit with error status if path does not exist (diff)
downloadtgif-fe31b2afac2fbae25086ecd00a1f57bcd74e9148.tar.xz
Merge branch 'hv/submodule-path-unmatch' into maint-1.7.11
* hv/submodule-path-unmatch: Let submodule command exit with error status if path does not exist
Diffstat (limited to 'git-submodule.sh')
-rwxr-xr-xgit-submodule.sh33
1 files changed, 30 insertions, 3 deletions
diff --git a/git-submodule.sh b/git-submodule.sh
index 30fa93a8a0..dd3ae0e1a0 100755
--- a/git-submodule.sh
+++ b/git-submodule.sh
@@ -73,26 +73,48 @@ resolve_relative_url ()
#
module_list()
{
- git ls-files --error-unmatch --stage -- "$@" |
+ (
+ git ls-files --error-unmatch --stage -- "$@" ||
+ echo "unmatched pathspec exists"
+ ) |
perl -e '
my %unmerged = ();
my ($null_sha1) = ("0" x 40);
+ my @out = ();
+ my $unmatched = 0;
while (<STDIN>) {
+ if (/^unmatched pathspec/) {
+ $unmatched = 1;
+ next;
+ }
chomp;
my ($mode, $sha1, $stage, $path) =
/^([0-7]+) ([0-9a-f]{40}) ([0-3])\t(.*)$/;
next unless $mode eq "160000";
if ($stage ne "0") {
if (!$unmerged{$path}++) {
- print "$mode $null_sha1 U\t$path\n";
+ push @out, "$mode $null_sha1 U\t$path\n";
}
next;
}
- print "$_\n";
+ push @out, "$_\n";
+ }
+ if ($unmatched) {
+ print "#unmatched\n";
+ } else {
+ print for (@out);
}
'
}
+die_if_unmatched ()
+{
+ if test "$1" = "#unmatched"
+ then
+ exit 1
+ fi
+}
+
#
# Map submodule path to submodule name
#
@@ -346,6 +368,7 @@ cmd_foreach()
module_list |
while read mode sha1 stage sm_path
do
+ die_if_unmatched "$mode"
if test -e "$sm_path"/.git
then
say "$(eval_gettext "Entering '\$prefix\$sm_path'")"
@@ -398,6 +421,7 @@ cmd_init()
module_list "$@" |
while read mode sha1 stage sm_path
do
+ die_if_unmatched "$mode"
name=$(module_name "$sm_path") || exit
# Copy url setting when it is not set yet
@@ -498,6 +522,7 @@ cmd_update()
err=
while read mode sha1 stage sm_path
do
+ die_if_unmatched "$mode"
if test "$stage" = U
then
echo >&2 "Skipping unmerged submodule $sm_path"
@@ -893,6 +918,7 @@ cmd_status()
module_list "$@" |
while read mode sha1 stage sm_path
do
+ die_if_unmatched "$mode"
name=$(module_name "$sm_path") || exit
url=$(git config submodule."$name".url)
displaypath="$prefix$sm_path"
@@ -961,6 +987,7 @@ cmd_sync()
module_list "$@" |
while read mode sha1 stage sm_path
do
+ die_if_unmatched "$mode"
name=$(module_name "$sm_path")
url=$(git config -f .gitmodules --get submodule."$name".url)