aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xgit-am.sh2
-rwxr-xr-xgit-submodule.sh11
-rwxr-xr-xt/t7400-submodule-basic.sh10
3 files changed, 20 insertions, 3 deletions
diff --git a/git-am.sh b/git-am.sh
index 774383fb6..6d1848b6c 100755
--- a/git-am.sh
+++ b/git-am.sh
@@ -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
diff --git a/git-submodule.sh b/git-submodule.sh
index 7c2e060ae..8e234a402 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" ||
diff --git a/t/t7400-submodule-basic.sh b/t/t7400-submodule-basic.sh
index af690ec6c..0f2ccc6cf 100755
--- a/t/t7400-submodule-basic.sh
+++ b/t/t7400-submodule-basic.sh
@@ -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 &&