Skip to content

Commit

Permalink
Work around ash "alternate value" expansion bug
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Ben Jackson authored and Junio C Hamano committed Apr 19, 2009
1 parent 77b96d6 commit ea10b60
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
2 changes: 1 addition & 1 deletion git-am.sh
Original file line number Diff line number Diff line change
Expand Up @@ -571,7 +571,7 @@ do
GIT_COMMITTER_DATE="$GIT_AUTHOR_DATE"
export GIT_COMMITTER_DATE
fi &&
git commit-tree $tree ${parent:+-p $parent} <"$dotest/final-commit"
git commit-tree $tree ${parent:+-p} $parent <"$dotest/final-commit"
) &&
git update-ref -m "$GIT_REFLOG_ACTION: $FIRSTLINE" HEAD $commit $parent ||
stop_here $this
Expand Down
11 changes: 9 additions & 2 deletions git-submodule.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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" ||
Expand Down
10 changes: 10 additions & 0 deletions t/t7400-submodule-basic.sh
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,16 @@ test_expect_success 'submodule add' '
)
'

test_expect_success 'submodule add --branch' '
(
cd addtest &&
git submodule add -b initial "$submodurl" submod-branch &&
git submodule init &&
cd submod-branch &&
git branch | grep initial
)
'

test_expect_success 'submodule add with ./ in path' '
(
cd addtest &&
Expand Down

0 comments on commit ea10b60

Please sign in to comment.