diff options
-rw-r--r-- | Documentation/git-submodule.txt | 2 | ||||
-rwxr-xr-x | git-submodule.sh | 4 | ||||
-rwxr-xr-x | t/t7400-submodule-basic.sh | 1 |
3 files changed, 7 insertions, 0 deletions
diff --git a/Documentation/git-submodule.txt b/Documentation/git-submodule.txt index 8bf173a906..b1996f1a63 100644 --- a/Documentation/git-submodule.txt +++ b/Documentation/git-submodule.txt @@ -208,6 +208,8 @@ OPTIONS -b:: --branch:: Branch of repository to add as submodule. + The name of the branch is recorded as `submodule.<path>.branch` in + `.gitmodules` for `update --remote`. -f:: --force:: diff --git a/git-submodule.sh b/git-submodule.sh index 6ae51c6c72..22ec5b63b4 100755 --- a/git-submodule.sh +++ b/git-submodule.sh @@ -417,6 +417,10 @@ Use -f if you really want to add it." >&2 git config -f .gitmodules submodule."$sm_name".path "$sm_path" && git config -f .gitmodules submodule."$sm_name".url "$repo" && + if test -n "$branch" + then + git config -f .gitmodules submodule."$sm_name".branch "$branch" + fi && git add --force .gitmodules || die "$(eval_gettext "Failed to register submodule '\$sm_path'")" } diff --git a/t/t7400-submodule-basic.sh b/t/t7400-submodule-basic.sh index de7d45352e..2683cba7e3 100755 --- a/t/t7400-submodule-basic.sh +++ b/t/t7400-submodule-basic.sh @@ -133,6 +133,7 @@ test_expect_success 'submodule add --branch' ' ( cd addtest && git submodule add -b initial "$submodurl" submod-branch && + test "initial" = "$(git config -f .gitmodules submodule.submod-branch.branch)" && git submodule init ) && |