Skip to content

Commit ea10b60

Browse files
bjjgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 77b96d6 commit ea10b60

File tree

3 files changed

+20
-3
lines changed

3 files changed

+20
-3
lines changed

git-am.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -571,7 +571,7 @@ do
571571
GIT_COMMITTER_DATE="$GIT_AUTHOR_DATE"
572572
export GIT_COMMITTER_DATE
573573
fi &&
574-
git commit-tree $tree ${parent:+-p $parent} <"$dotest/final-commit"
574+
git commit-tree $tree ${parent:+-p} $parent <"$dotest/final-commit"
575575
) &&
576576
git update-ref -m "$GIT_REFLOG_ACTION: $FIRSTLINE" HEAD $commit $parent ||
577577
stop_here $this

git-submodule.sh

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,8 +204,15 @@ cmd_add()
204204
else
205205

206206
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'"
209216
fi
210217

211218
git add "$path" ||

t/t7400-submodule-basic.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,16 @@ test_expect_success 'submodule add' '
6464
)
6565
'
6666

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+
6777
test_expect_success 'submodule add with ./ in path' '
6878
(
6979
cd addtest &&

0 commit comments

Comments
 (0)