diff options
author | Junio C Hamano <gitster@pobox.com> | 2012-08-29 14:50:15 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2012-08-29 14:50:15 -0700 |
commit | 1c0fa76be7d7417080a36f8603c7e9c2511509ea (patch) | |
tree | 26907418b8d05c20a5e956b85b324cfb8b841c79 /git-submodule.sh | |
parent | 97349a2a74fdd42afd5a1f8e8e92cddf47f28193 (diff) | |
parent | be9d0a3a4cbd736911afc10154c7a541129503bd (diff) | |
download | git-1c0fa76be7d7417080a36f8603c7e9c2511509ea.tar.gz |
Merge branch 'hv/submodule-path-unmatch'
* hv/submodule-path-unmatch:
Let submodule command exit with error status if path does not exist
Diffstat (limited to 'git-submodule.sh')
-rwxr-xr-x | git-submodule.sh | 33 |
1 files changed, 30 insertions, 3 deletions
diff --git a/git-submodule.sh b/git-submodule.sh index aac575e74f..08405249ed 100755 --- a/git-submodule.sh +++ b/git-submodule.sh @@ -109,26 +109,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 # @@ -385,6 +407,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'")" @@ -437,6 +460,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 @@ -537,6 +561,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" @@ -932,6 +957,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" @@ -1000,6 +1026,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) |