summaryrefslogtreecommitdiff
path: root/git-submodule.sh
diff options
context:
space:
mode:
authorBen Jackson <ben@ben.com>2009-04-18 20:42:07 -0700
committerJunio C Hamano <gitster@pobox.com>2009-04-18 21:37:46 -0700
commitea10b60c910e4a23483f47f17becc5e58f07ebe9 (patch)
tree6ea690864253a52b15cf35c1a2a4dd5ee20e9c99 /git-submodule.sh
parent77b96d6dbf65f736a63b8a0bb5f810edbf895a09 (diff)
downloadgit-ea10b60c910e4a23483f47f17becc5e58f07ebe9.tar.gz
Work around ash "alternate value" expansion bug
Ash (used as /bin/sh on many distros) has a shell expansion bug for the form ${var:+word word}. The result is a single argument "word word". Work around by using ${var:+word} ${var:+word} or equivalent. Signed-off-by: Ben Jackson <ben@ben.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'git-submodule.sh')
-rwxr-xr-xgit-submodule.sh11
1 files changed, 9 insertions, 2 deletions
diff --git a/git-submodule.sh b/git-submodule.sh
index 7c2e060ae7..8e234a4028 100755
--- a/git-submodule.sh
+++ b/git-submodule.sh
@@ -204,8 +204,15 @@ cmd_add()
else
module_clone "$path" "$realrepo" || exit
- (unset GIT_DIR; cd "$path" && git checkout -f -q ${branch:+-b "$branch" "origin/$branch"}) ||
- die "Unable to checkout submodule '$path'"
+ (
+ unset GIT_DIR
+ cd "$path" &&
+ # ash fails to wordsplit ${branch:+-b "$branch"...}
+ case "$branch" in
+ '') git checkout -f -q ;;
+ ?*) git checkout -f -q -b "$branch" "origin/$branch" ;;
+ esac
+ ) || die "Unable to checkout submodule '$path'"
fi
git add "$path" ||