git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [RFC] submodule: change submodule.<name>.branch default from master to HEAD

From
Eric Sunshine <sunshine@sunshineco.com>
Date
Mar 28, 2014, 03:43 UTC
Message-ID
<CAPig+cT7tmxvYz+sLQY68SgF6osM+pAj-gFb7xvyuH+Gnw5xrg@mail.gmail.com>
In-Reply-To
<c66d89d854407469b6fd223213a09e5d60eeec0a.1395977055.git.wking@tremily.us>
On Thu, Mar 27, 2014 at 11:36 PM, W. Trevor King <wking@tremily.us> wrote:
Show 40 quoted lines
> gitmodule(5) mentioned 'master' as the default remote branch, but
> folks using checkout-style updates are unlikely to care which upstream
> branch their commit comes from (they only care that the clone fetches
> that commit).  If they haven't set submodule.<name>.branch, it makes
> more sense to mirror 'git clone' and use the subproject's HEAD than to
> default to 'master' (which may not even exist).
>
> After the initial clone, subsequent updates may be local or remote.
> Local updates (integrating gitlink changes) have no need to fetch a
> specific remote branch, and get along just fine without
> submodule.<name>.branch.  Remote updates do need a remote branch, but
> HEAD works as well here as it did for the initial clone.
>
> Reported-by: Johan Herland <johan@herland.net>
> Signed-off-by: W. Trevor King <wking@tremily.us>
> ---
> diff --git a/Documentation/git-submodule.txt b/Documentation/git-submodule.txt
> index 46c1eeb..c485a17 100644
> --- a/Documentation/git-submodule.txt
> +++ b/Documentation/git-submodule.txt
> @@ -284,7 +284,7 @@ OPTIONS
>         the superproject's recorded SHA-1 to update the submodule, use the
>         status of the submodule's remote-tracking branch.  The remote used
>         is branch's remote (`branch.<name>.remote`), defaulting to `origin`.
> -       The remote branch used defaults to `master`, but the branch name may
> +       The remote branch used defaults to `HEAD`, but the branch name may
>         be overridden by setting the `submodule.<name>.branch` option in
>         either `.gitmodules` or `.git/config` (with `.git/config` taking
>         precedence).
> diff --git a/Documentation/gitmodules.txt b/Documentation/gitmodules.txt
> index f539e3f..1aecce9 100644
> --- a/Documentation/gitmodules.txt
> +++ b/Documentation/gitmodules.txt
> @@ -53,8 +53,9 @@ submodule.<name>.update::
>
>  submodule.<name>.branch::
>         A remote branch name for tracking updates in the upstream submodule.
> -       If the option is not specified, it defaults to 'master'.  See the
> -       `--remote` documentation in linkgit:git-submodule[1] for details.
> +       If the option is not specified, it defaults to the subproject's
Did you mean s/subproject/submodule/ ?
Show 36 quoted lines
> +       HEAD.  See the `--remote` documentation in linkgit:git-submodule[1]
> +       for details.
>  +
>  This branch name is also used for the local branch created by
>  non-checkout cloning updates.  See the `update` documentation in
> diff --git a/git-submodule.sh b/git-submodule.sh
> index 6135cfa..5f08e6c 100755
> --- a/git-submodule.sh
> +++ b/git-submodule.sh
> @@ -819,8 +819,8 @@ cmd_update()
>                 name=$(module_name "$sm_path") || exit
>                 url=$(git config submodule."$name".url)
>                 config_branch=$(get_submodule_config "$name" branch)
> -               branch="${config_branch:-master}"
> -               local_branch="$branch"
> +               branch="${config_branch:-HEAD}"
> +               local_branch="$config_branch"
>                 if ! test -z "$update"
>                 then
>                         update_module=$update
> @@ -860,7 +860,12 @@ Maybe you want to use 'update --init'?")"
>
>                 if ! test -d "$sm_path"/.git -o -f "$sm_path"/.git
>                 then
> -                       start_point="origin/${branch}"
> +                       if test -n "$config_branch"
> +                       then
> +                               start_point="origin/$branch"
> +                       else
> +                               start_point=""
> +                       fi
>                         module_clone "$sm_path" "$name" "$url" "$reference" "$depth" "$start_point" "$local_branch" || exit
>                         cloned_modules="$cloned_modules;$name"
>                         subsha1=
> --
> 1.9.1.352.gd393d14.dirty
Previous: W. Trevor KingNext: W. Trevor King
Message 18 of 29 in “Possible regression in master? (submodules without a "master" branch)”
  1. Johan HerlandMar 27, 2014
  2. W. Trevor KingMar 27, 2014
  3. W. Trevor KingMar 27, 2014
  4. Jens LehmannMar 27, 2014
  5. Junio C HamanoMar 27, 2014
  6. Jens LehmannMar 27, 2014
  7. Johan HerlandMar 27, 2014
  8. W. Trevor KingMar 28, 2014
  9. Junio C HamanoMar 27, 2014
  10. Jens LehmannMar 27, 2014
  11. W. Trevor KingMar 27, 2014
  12. Junio C HamanoMar 27, 2014
  13. Heiko VoigtMar 27, 2014
  14. Jens LehmannMar 27, 2014
  15. Johan HerlandMar 27, 2014
  16. W. Trevor KingMar 28, 2014
  17. [RFC] submodule: change submodule.<name>.branch default from master to HEADW. Trevor King, Mar 28, 2014
  18. Eric SunshineMar 28, 2014
  19. W. Trevor KingMar 28, 2014
  20. W. Trevor KingMar 28, 2014
  21. Jens LehmannMar 28, 2014
  22. W. Trevor KingMar 28, 2014
  23. Jens LehmannMar 31, 2014
  24. Junio C HamanoMar 28, 2014
  25. Jens LehmannMar 31, 2014
  26. W. Trevor KingMar 31, 2014
  27. Junio C HamanoMar 31, 2014
  28. submodule.<path>.branch vs. submodule.<name>.branch (was: Possible regression in master? (submodules without a "master" branch).W. Trevor King, Mar 27, 2014
  29. Junio C HamanoMar 27, 2014

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.