diff options
author | W. Trevor King <wking@tremily.us> | 2012-12-19 11:03:33 -0500 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2012-12-19 09:40:51 -0800 |
commit | b928922727d6691a3bdc28160f93f25712c565f6 (patch) | |
tree | 2030ba639d8a6f5e579e87478ecbbd807074bf6b /git-submodule.sh | |
parent | 06b1abb5bd38b3cb1972907b059c7f95a197a7a5 (diff) | |
download | git-b928922727d6691a3bdc28160f93f25712c565f6.tar.gz |
submodule add: If --branch is given, record it in .gitmodules
This allows you to easily record a submodule.<name>.branch option in
.gitmodules when you add a new submodule. With this patch,
$ git submodule add -b <branch> <repository> [<path>]
$ git config -f .gitmodules submodule.<path>.branch <branch>
reduces to
$ git submodule add -b <branch> <repository> [<path>]
This means that future calls to
$ git submodule update --remote ...
will get updates from the same branch that you used to initialize the
submodule, which is usually what you want.
Signed-off-by: W. Trevor King <wking@tremily.us>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'git-submodule.sh')
-rwxr-xr-x | git-submodule.sh | 4 |
1 files changed, 4 insertions, 0 deletions
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'")" } |