git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Heiko Voigt <hvoigt@hvoigt.net>
To: "W. Trevor King" <wking@tremily.us>
Cc: Git <git@vger.kernel.org>, Junio C Hamano <gitster@pobox.com>,
	Jeff King <peff@peff.net>, Phil Hord <phil.hord@gmail.com>,
	Shawn Pearce <spearce@spearce.org>,
	Jens Lehmann <Jens.Lehmann@web.de>,
	Nahor <nahor.j+gmane@gmail.com>
Subject: Re: [PATCH v4 3/4] git-submodule update: Add --branch option
Date: Tue, 27 Nov 2012 19:51:42 +0100	[thread overview]
Message-ID: <20121127185142.GB4185@book.hvoigt.net> (raw)
In-Reply-To: <95edff1c97c513c555652014f9c2bbf61c8e7560.1353962698.git.wking@tremily.us>

On Mon, Nov 26, 2012 at 04:00:18PM -0500, W. Trevor King wrote:
> From: "W. Trevor King" <wking@tremily.us>
> 
> This allows users to checkout the current
> superproject-recorded-submodule-sha as a branch, avoiding the detached
> head state that the standard submodule update creates.  This may be
> useful for the existing --rebase/--merge workflows which already avoid
> detached heads.
> 
> It is also useful if you want easy tracking of upstream branches.  The
> particular upstream branch to be tracked is configured locally with
> .git/modules/<name>/config.  With the new option Ævar's suggested
> 
>   $ git submodule foreach 'git checkout $(git config --file $toplevel/.gitm
> odules submodule.$name.branch) && git pull'
> 
> reduces to a
> 
>   $ git submodule update --branch
> 
> after each supermodule .gitmodules edit, and a
> 
>   $ git submodule foreach 'git pull'
> 
> whenever you feel like updating the submodules.  Your still on you're
> own to commit (or not) the updated submodule hashes in the
> superproject's .gitmodules.
> 
> Signed-off-by: W. Trevor King <wking@tremily.us>
> ---
>  Documentation/git-submodule.txt | 20 +++++++++++------
>  git-submodule.sh                | 48 +++++++++++++++++++++++++++++----------
>  t/t7406-submodule-update.sh     | 50 ++++++++++++++++++++++++++++++++++++++++-
>  3 files changed, 98 insertions(+), 20 deletions(-)
> 
> diff --git a/Documentation/git-submodule.txt b/Documentation/git-submodule.txt
> index d0b4436..34392a1 100644
> --- a/Documentation/git-submodule.txt
> +++ b/Documentation/git-submodule.txt
> @@ -13,7 +13,7 @@ SYNOPSIS
>  	      [-f|--force] [--reference <repository>] [--] <repository> [<path>]
>  'git submodule' [--quiet] status [--cached] [--recursive] [--] [<path>...]
>  'git submodule' [--quiet] init [--] [<path>...]
> -'git submodule' [--quiet] update [--init] [-N|--no-fetch] [--rebase]
> +'git submodule' [--quiet] update [--init] [-N|--no-fetch] [--branch] [--rebase]
>  	      [--reference <repository>] [--merge] [--recursive] [--] [<path>...]
>  'git submodule' [--quiet] summary [--cached|--files] [(-n|--summary-limit) <n>]
>  	      [commit] [--] [<path>...]
> @@ -136,11 +136,11 @@ init::
>  
>  update::
>  	Update the registered submodules, i.e. clone missing submodules and
> -	checkout the commit specified in the index of the containing repository.
> -	This will make the submodules HEAD be detached unless `--rebase` or
> -	`--merge` is specified or the key `submodule.$name.update` is set to
> -	`rebase`, `merge` or `none`. `none` can be overridden by specifying
> -	`--checkout`.
> +	checkout the commit specified in the index of the containing
> +	repository.  This will make the submodules HEAD be detached unless
> +	`--branch`, `--rebase`, `--merge` is specified or the key
> +	`submodule.$name.update` is set to `branch`, `rebase`, `merge` or
> +	`none`. `none` can be overridden by specifying `--checkout`.
>  +
>  If the submodule is not yet initialized, and you just want to use the
>  setting as stored in .gitmodules, you can automatically initialize the
> @@ -207,7 +207,13 @@ OPTIONS
>  
>  -b::
>  --branch::
> -	Branch of repository to add as submodule.
> +	When used with the add command, gives the branch of repository to
> +	add as submodule.
> ++
> +When used with the update command, checks out a branch named
> +`submodule.<name>.branch` (as set by `--local-branch`) pointing at the
> +current HEAD SHA-1.  This is useful for commands like `update
> +--rebase` that do not work on detached heads.

Since you are reusing this option for update it further convinces me
that reusing it for add makes sense and simplifies the logic for users.

I think an optional argument for --branch would be nice in the update
case:

	$ git submodule update --branch=master

would then allow a user that has not configured anything (except the
branch tracking info in the submodule of course) to pull all submodules
master branches.

> diff --git a/git-submodule.sh b/git-submodule.sh
> index c51b6ae..28eb4b1 100755
> --- a/git-submodule.sh
> +++ b/git-submodule.sh
> @@ -627,7 +631,7 @@ Maybe you want to use 'update --init'?")"
>  			die "$(eval_gettext "Unable to find current revision in submodule path '\$sm_path'")"
>  		fi
>  
> -		if test "$subsha1" != "$sha1" -o -n "$force"
> +		if test "$subsha1" != "$sha1" -o -n "$force" -o "$update_module" = "branch"

As said before I think separating your code from the current update
logic will simplify the handling below.

>  		then
>  			subforce=$force
>  			# If we don't already have a -f flag and the submodule has never been checked out
> @@ -650,16 +654,21 @@ Maybe you want to use 'update --init'?")"
>  			case ";$cloned_modules;" in
>  			*";$name;"*)
>  				# then there is no local change to integrate
> -				update_module= ;;
> +				case "$update_module" in
> +					rebase|merge)
> +						update_module=
> +						;;
> +				esac
> +				;;
>  			esac
>  
>  			must_die_on_failure=
>  			case "$update_module" in
>  			rebase)
>  				command="git rebase"
> -				die_msg="$(eval_gettext "Unable to rebase '\$sha1' in submodule path '\$sm_path'")"
> +				die_msg="$(eval_gettext "Unable to rebase '\$sha1' in submodule path '\$sm_path'")"	
>  				say_msg="$(eval_gettext "Submodule path '\$sm_path': rebased into '\$sha1'")"
> -				must_die_on_failure=yes
> +			must_die_on_failure=yes

Please always cleanup whitespace changes.

>  				;;
>  			merge)
>  				command="git merge"
> @@ -674,15 +683,30 @@ Maybe you want to use 'update --init'?")"
>  				;;
>  			esac
>  
>  			then
> -				die_with_status 2 "$die_msg"
> -			else
> -				err="${err};$die_msg"
> -				continue
> +				if (clear_local_git_env; cd "$sm_path" &&
> +					git branch -f "$branch" "$sha1" &&
> +					git checkout "$branch")

You wrote in earlier emails that you wanted to protect the user from
non-fastforward changes. So I would expect a

	$ git pull --ff-only

here and the setup of that in the initialization of the submodule.

BTW, I am more and more convinced that an automatically manufactured
commit on update with --branch should be the default. What do other
think? Sascha raised a concern that he would not want this, but as far as
I understood he let the CI-server do that so I see no downside to
natively adding that to git. People who want to manually craft those
commits can still amend the generated commit. Since this is all about
helping people keeping their submodules updated why not go the full way?

Cheers Heiko

  reply	other threads:[~2012-11-27 18:52 UTC|newest]

Thread overview: 156+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-22 16:34 [PATCH] git-submodule add: Record branch name in .gitmodules W. Trevor King
     [not found] ` <CABURp0pqg7XC6makK2OcundMabV9AtcBNGNK6Q0TMZfJbt3anw@mail.gmail.com>
2012-10-22 22:55   ` W. Trevor King
2012-10-24 18:12     ` Phil Hord
2012-10-25  1:12       ` W. Trevor King
2012-10-26 13:37         ` Jeff King
2012-10-23 19:16 ` Nahor
2012-10-23 19:44   ` W. Trevor King
2012-10-23 20:44     ` W. Trevor King
2012-10-23 21:57       ` [PATCH v2] git-submodule add: Add -r/--record option W. Trevor King
2012-10-24 19:15         ` Jens Lehmann
2012-10-25  0:53           ` W. Trevor King
2012-10-28 20:48             ` Jens Lehmann
2012-10-28 21:16               ` W. Trevor King
2012-10-28 21:59               ` Shawn Pearce
2012-10-28 22:34                 ` W. Trevor King
2012-10-29  5:34                   ` Jeff King
2012-10-29 10:45                     ` W. Trevor King
2012-10-29 10:58                       ` Jeff King
2012-10-29 11:29                         ` W. Trevor King
2012-10-29 11:43                           ` Jeff King
2012-10-29 17:38                             ` Phil Hord
2012-10-29 21:36                               ` Jeff King
2012-10-29 22:21                                 ` Phil Hord
2012-10-29 22:27                                   ` Jeff King
2012-11-09  3:35                                     ` [PATCH v3 0/3] " W. Trevor King
2012-11-09  3:35                                     ` [PATCH v3 1/3] " W. Trevor King
2012-11-09  7:34                                       ` Junio C Hamano
2012-11-09 16:29                                         ` Heiko Voigt
2012-11-10 19:02                                           ` W. Trevor King
2012-11-17 15:04                                             ` Heiko Voigt
2012-11-17 19:20                                               ` W. Trevor King
2012-11-17 21:31                                                 ` Heiko Voigt
2012-11-17 22:00                                                   ` W. Trevor King
2012-11-20  0:49                                                 ` Junio C Hamano
2012-11-20  1:16                                                   ` W. Trevor King
2012-11-20  5:39                                                     ` Junio C Hamano
2012-11-20 12:19                                                       ` W. Trevor King
2012-11-20 19:52                                                         ` Junio C Hamano
2012-11-23 15:55                                                           ` Heiko Voigt
2012-11-23 16:23                                                             ` W. Trevor King
2012-11-23 16:30                                                               ` W. Trevor King
2012-11-23 17:54                                                               ` W. Trevor King
2012-11-26 21:00                                                                 ` [PATCH v4 0/4] git-submodule add: Add --local-branch option W. Trevor King
2012-11-26 21:00                                                                   ` [PATCH v4 1/4] " W. Trevor King
2012-11-26 21:00                                                                   ` [PATCH v4 2/4] git-submodule init: Record submodule.<name>.branch in repository config W. Trevor King
2012-11-27 23:19                                                                     ` Jens Lehmann
2012-11-28  0:40                                                                       ` W. Trevor King
2012-11-30 17:53                                                                       ` [RFC] remove/deprecate 'submodule init' and 'sync' W. Trevor King
2012-11-30 18:17                                                                         ` W. Trevor King
2012-11-30 23:52                                                                         ` Phil Hord
2012-12-01 12:48                                                                           ` W. Trevor King
2012-12-01 15:42                                                                             ` Jens Lehmann
2012-12-01 15:56                                                                           ` Jens Lehmann
2012-12-01 16:37                                                                             ` W. Trevor King
2012-12-01 16:45                                                                             ` [PATCH] submodule: add 'deinit' command Jens Lehmann
2012-12-02  2:00                                                                               ` Junio C Hamano
2012-12-02 19:55                                                                                 ` Jens Lehmann
2012-12-03  7:58                                                                                   ` Junio C Hamano
2012-12-04 21:48                                                                                     ` [PATCH v2] " Jens Lehmann
2012-12-04 23:06                                                                                       ` Junio C Hamano
2012-12-12 15:08                                                                                       ` Michael J Gruber
2012-12-12 17:22                                                                                         ` Jens Lehmann
2012-12-12 19:32                                                                                           ` Junio C Hamano
2012-12-12 22:25                                                                                             ` Jens Lehmann
2012-12-12 22:34                                                                                               ` Junio C Hamano
2012-12-12 23:09                                                                                                 ` W. Trevor King
2012-12-12 23:35                                                                                                   ` Junio C Hamano
2012-12-13  0:28                                                                                                     ` W. Trevor King
2012-12-13 15:47                                                                                               ` Marc Branchaud
2012-12-01 15:38                                                                         ` [RFC] remove/deprecate 'submodule init' and 'sync' Jens Lehmann
2012-12-01 16:30                                                                           ` W. Trevor King
2012-12-01 17:25                                                                             ` Jens Lehmann
2012-12-01 17:49                                                                               ` W. Trevor King
2012-12-01 18:04                                                                                 ` Jens Lehmann
2012-12-01 18:16                                                                                   ` W. Trevor King
2012-12-02 19:09                                                                                     ` W. Trevor King
2012-12-02 20:29                                                                                       ` Jens Lehmann
2012-12-02 21:11                                                                                         ` W. Trevor King
2012-12-01 16:54                                                                         ` W. Trevor King
2012-12-03 15:38                                                                           ` W. Trevor King
2012-11-26 21:00                                                                   ` [PATCH v4 3/4] git-submodule update: Add --branch option W. Trevor King
2012-11-27 18:51                                                                     ` Heiko Voigt [this message]
2012-11-27 20:21                                                                       ` W. Trevor King
2012-11-26 21:00                                                                   ` [PATCH v4 4/4] Hack fix for 'submodule update does not fetch already present commits' W. Trevor King
2012-11-27 18:31                                                                   ` [PATCH v4 0/4] git-submodule add: Add --local-branch option Heiko Voigt
2012-11-27 19:04                                                                     ` W. Trevor King
2012-11-27 19:16                                                                     ` Heiko Voigt
2012-11-27 19:01                                                                 ` W. Trevor King
2012-11-27 21:18                                                                   ` [PATCH v4 4/4] Hack fix for 'submodule update does not fetch already present commits' W. Trevor King
2012-11-27 23:28                                                                   ` Re: [PATCH v4 0/4] git-submodule add: Add --local-branch option Heiko Voigt
2012-11-28  2:42                                                                     ` W. Trevor King
2012-11-29 18:51                                                                       ` Phil Hord
2012-11-23 17:24                                                             ` [PATCH v3 1/3] git-submodule add: Add -r/--record option Sascha Cunz
2012-11-23 16:03                                                         ` Heiko Voigt
2012-11-28 13:09                                           ` [PATCH v4 0/4] git-submodule add: Add --local-branch option (summary) W. Trevor King
2012-11-28 16:53                                             ` W. Trevor King
2012-11-28 19:30                                               ` [PATCH v5 0/2] submodule update: add --remote for submodule's upstream changes W. Trevor King
2012-11-28 19:30                                                 ` [PATCH v5 1/2] " W. Trevor King
2012-11-28 19:30                                                 ` [PATCH v5 2/2] submodule add: If --branch is given, record it in .gitmodules W. Trevor King
2012-11-29 16:12                                                 ` [RFC] git-submodule update: Add --commit option W. Trevor King
2012-11-29 16:21                                                   ` W. Trevor King
2012-11-29 16:27                                                   ` W. Trevor King
2012-11-29 19:13                                                 ` [PATCH v5 0/2] submodule update: add --remote for submodule's upstream changes W. Trevor King
2012-11-30  1:11                                                   ` Phil Hord
2012-11-30  3:27                                                     ` W. Trevor King
2012-12-02  3:17                                                       ` [PATCH v6 0/4] " W. Trevor King
2012-12-02  3:17                                                         ` [PATCH v6 1/4] submodule: add get_submodule_config helper funtion W. Trevor King
2012-12-03 19:30                                                           ` Junio C Hamano
2012-12-04  0:17                                                             ` W. Trevor King
2012-12-11 18:58                                                               ` [PATCH v7 0/3] submodule update: add --remote for submodule's upstream changes W. Trevor King
2012-12-11 18:58                                                                 ` [PATCH v7 1/3] submodule: add get_submodule_config helper funtion W. Trevor King
2012-12-11 18:58                                                                 ` [PATCH v7 2/3] submodule update: add --remote for submodule's upstream changes W. Trevor King
2012-12-12 17:43                                                                   ` Phil Hord
2012-12-12 19:54                                                                     ` Junio C Hamano
2012-12-12 23:02                                                                     ` W. Trevor King
2012-12-19 16:03                                                                       ` [PATCH v8 0/3] " wking
2012-12-19 16:03                                                                         ` [PATCH v8 1/3] submodule: add get_submodule_config helper funtion wking
2012-12-21  8:20                                                                           ` Heiko Voigt
2012-12-21 11:04                                                                             ` W. Trevor King
2012-12-19 16:03                                                                         ` [PATCH v8 2/3] submodule update: add --remote for submodule's upstream changes wking
2012-12-19 16:03                                                                         ` [PATCH v8 3/3] submodule add: If --branch is given, record it in .gitmodules wking
2012-12-19 17:43                                                                           ` Junio C Hamano
2012-12-21  8:18                                                                         ` [PATCH v8 0/3] submodule update: add --remote for submodule's upstream changes Heiko Voigt
2012-12-11 18:58                                                                 ` [PATCH v7 3/3] submodule add: If --branch is given, record it in .gitmodules W. Trevor King
2012-12-12  5:42                                                                 ` [PATCH v7 0/3] submodule update: add --remote for submodule's upstream changes Junio C Hamano
2012-12-12 15:24                                                                   ` W. Trevor King
2012-12-12 18:19                                                                     ` Junio C Hamano
2012-12-12 22:44                                                                       ` W. Trevor King
2012-12-02  3:17                                                         ` [PATCH v6 2/4] " W. Trevor King
2012-12-03 16:46                                                           ` Junio C Hamano
2012-12-03 18:15                                                             ` W. Trevor King
2012-12-03 18:38                                                               ` W. Trevor King
2012-12-03 20:29                                                                 ` Junio C Hamano
2012-12-02  3:17                                                         ` [PATCH v6 3/4] submodule add: If --branch is given, record it in .gitmodules W. Trevor King
2012-12-02  3:17                                                         ` [PATCH v6 4/4] submodule update: add submodule.<name>.remote config option W. Trevor King
2012-12-02 19:32                                                       ` [PATCH v5 0/2] submodule update: add --remote for submodule's upstream changes Jens Lehmann
2012-11-10 18:44                                         ` [PATCH v3 1/3] git-submodule add: Add -r/--record option W. Trevor King
2012-11-11 10:33                                           ` Junio C Hamano
2012-11-11 15:00                                             ` W. Trevor King
2012-11-17 15:30                                               ` Heiko Voigt
2012-11-28 19:42                                             ` W. Trevor King
2012-11-28 20:08                                               ` Junio C Hamano
     [not found]                                       ` <20121109104607.GC4406@ftbfs.org>
2012-11-10 19:11                                         ` W. Trevor King
2012-11-09  3:35                                     ` [PATCH v3 2/3] git-submodule foreach: export .gitmodules settings as variables W. Trevor King
2012-11-09 16:45                                       ` Heiko Voigt
2012-11-10 19:21                                         ` W. Trevor King
2012-11-09  3:35                                     ` [PATCH v3 3/3] git-submodule: Motivate --record with an example use case W. Trevor King
2012-10-25 22:14         ` [PATCH v2] git-submodule add: Add -r/--record option W. Trevor King
2012-10-26 14:00           ` Jeff King
2012-10-23 21:45     ` [PATCH] git-submodule add: Record branch name in .gitmodules Nahor
2012-10-23 20:36   ` Jens Lehmann
2012-10-23 20:55     ` W. Trevor King
2012-10-23 22:02     ` Nahor
2012-10-24 19:10       ` Jens Lehmann
  -- strict thread matches above, loose matches on Subject: below --
2012-11-28 18:28 [PATCH] submodule update: document exisiting -r form for --rebase W. Trevor King
2012-11-28 19:02 ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20121127185142.GB4185@book.hvoigt.net \
    --to=hvoigt@hvoigt.net \
    --cc=Jens.Lehmann@web.de \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=nahor.j+gmane@gmail.com \
    --cc=peff@peff.net \
    --cc=phil.hord@gmail.com \
    --cc=spearce@spearce.org \
    --cc=wking@tremily.us \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).