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>
Ben Jackson committed
Apr 18, 2009 at 20:42 UTC
ea10b60c910e4a23483f47f17becc5e58f07ebe9
3 files changed
+20
-3
git-am.sh
+1
-1
@@ -571,7 +571,7 @@ do
571
GIT_COMMITTER_DATE="$GIT_AUTHOR_DATE"
572
export GIT_COMMITTER_DATE
573
fi &&
574
- git commit-tree $tree ${parent:+-p $parent} <"$dotest/final-commit"
574
+ git commit-tree $tree ${parent:+-p} $parent <"$dotest/final-commit"
575
) &&
576
git update-ref -m "$GIT_REFLOG_ACTION: $FIRSTLINE" HEAD $commit $parent ||
577
stop_here $this
git-submodule.sh
+9
-2
@@ -204,8 +204,15 @@ cmd_add()
204
else
205
206
module_clone "$path" "$realrepo" || exit
207
- (unset GIT_DIR; cd "$path" && git checkout -f -q ${branch:+-b "$branch" "origin/$branch"}) ||
208
- die "Unable to checkout submodule '$path'"
207
+ (
208
+ unset GIT_DIR
209
+ cd "$path" &&
210
+ # ash fails to wordsplit ${branch:+-b "$branch"...}
211
+ case "$branch" in
212
+ '') git checkout -f -q ;;
213
+ ?*) git checkout -f -q -b "$branch" "origin/$branch" ;;
214
+ esac
215
+ ) || die "Unable to checkout submodule '$path'"
216
fi
217
218
git add "$path" ||
t/t7400-submodule-basic.sh
+10
@@ -64,6 +64,16 @@ test_expect_success 'submodule add' '
64
)
65
'
66
67
+test_expect_success 'submodule add --branch' '
68
+ (
69
+ cd addtest &&
70
+ git submodule add -b initial "$submodurl" submod-branch &&
71
+ git submodule init &&
72
+ cd submod-branch &&
73
+ git branch | grep initial
74
+ )
75
+'
76
+
77
test_expect_success 'submodule add with ./ in path' '
78
(
79
cd addtest &&