submodule.<name>.path::
submodule.<name>.url::
submodule.<name>.update::
- The path within this project, URL, and the updating strategy
- for a submodule. These variables are initially populated
- by 'git submodule init'; edit them to override the
- URL and other values found in the `.gitmodules` file. See
+submodule.<name>.branch::
+ The path within this project, URL, the updating strategy, and the
+ local branch name for a submodule. These variables are initially
+ populated by 'git submodule init'; edit them to override the URL and
+ other values found in the `.gitmodules` file. See
linkgit:git-submodule[1] and linkgit:gitmodules[5] for details.
submodule.<name>.fetchRecurseSubmodules::
test -n "$(git config submodule."$name".update)" ||
git config submodule."$name".update "$upd" ||
die "$(eval_gettext "Failed to register update mode for submodule path '\$sm_path'")"
+
+ # Copy "branch" setting when it is not set yet
+ branch="$(git config -f .gitmodules submodule."$name".branch)"
+ test -z "$branch" ||
+ test -n "$(git config submodule."$name".branch)" ||
+ git config submodule."$name".branch "$branch" ||
+ die "$(eval_gettext "Failed to register branch for submodule path '\$sm_path'")"
done
}
)
'
+test_expect_success 'init should register submodule branch in .git/config' '
+ (
+ cd addtest &&
+ git submodule init &&
+ test "$(git config submodule.submod-follow.branch)" = "final"
+ )
+'
+
+test_expect_success 'local config should override .gitmodules branch' '
+ (
+ cd addtest &&
+ rm -fr submod-follow &&
+ git config submodule.submod-follow.branch initial
+ git submodule init &&
+ test "$(git config submodule.submod-follow.branch)" = "initial"
+ )
+'
+
test_expect_success 'setup - add an example entry to .gitmodules' '
GIT_CONFIG=.gitmodules \
git config submodule.example.url git://example.com/init.git