Am 26.11.2012 22:00, schrieb W. Trevor King:
> From: "W. Trevor King" <wk...@tremily.us>
> 
> This allows users to override the .gitmodules value with a
> per-repository value.

Your intentions makes lots of sense, but your patch does more than
that. Copying the branch setting into .git/config sets the initial
branch setting into stone. That makes it impossible to have a branch
"foo" in the superproject using a branch "bar" in a submodule and
another superproject branch "frotz" using branch "nitfol" for the
same submodule. You should use the branch setting from .git/config
if present and fall back to the branch setting from .gitmodules if
not, which would enable the user to have her own setting if she
doesn't like what upstream provides but would still enable others
to follow different submodule branches in different superproject
branches.

> Signed-off-by: W. Trevor King <wk...@tremily.us>
> ---
>  Documentation/config.txt   |  9 +++++----
>  git-submodule.sh           |  7 +++++++
>  t/t7400-submodule-basic.sh | 18 ++++++++++++++++++
>  3 files changed, 30 insertions(+), 4 deletions(-)
> 
> diff --git a/Documentation/config.txt b/Documentation/config.txt
> index 11f320b..1304499 100644
> --- a/Documentation/config.txt
> +++ b/Documentation/config.txt
> @@ -1994,10 +1994,11 @@ status.submodulesummary::
>  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::
> diff --git a/git-submodule.sh b/git-submodule.sh
> index 6eed008..c51b6ae 100755
> --- a/git-submodule.sh
> +++ b/git-submodule.sh
> @@ -505,6 +505,13 @@ cmd_init()
>               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
>  }
>  
> diff --git a/t/t7400-submodule-basic.sh b/t/t7400-submodule-basic.sh
> index fc08647..3dc8237 100755
> --- a/t/t7400-submodule-basic.sh
> +++ b/t/t7400-submodule-basic.sh
> @@ -236,6 +236,24 @@ test_expect_success 'submodule add --local-branch=<name> 
> --branch' '
>       )
>  '
>  
> +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
> 

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to