public inbox for git@vger.kernel.org 
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox•com>
To: Chris Packham <judge.packham@gmail•com>
Cc: git@vger•kernel.org, Jens.Lehmann@web•de, iveqy@iveqy•com,
	stefan.naewe@atlas-elektronik•com, hvoigt@hvoigt•net
Subject: Re: [RFC/PATCHv4] submodule update: allow custom update command
Date: Wed, 03 Jul 2013 10:17:50 -0700	[thread overview]
Message-ID: <7v4ncbh8ap.fsf@alter.siamese.dyndns.org> (raw)
In-Reply-To: <1372842122-15568-1-git-send-email-judge.packham@gmail.com> (Chris Packham's message of "Wed, 3 Jul 2013 21:02:02 +1200")

Chris Packham <judge.packham@gmail•com> writes:

> Users can set submodule.$name.update to '!command' which will cause
> 'command' to be run instead of checkout/merge/rebase.  This allows the
> user some finer grained control over how the update is done. The primary
> motivation for this was interoperability with stgit however being able
> to intercept the submodule update process may prove useful for
> integrating with or extensions to other tools.
>
> Signed-off-by: Chris Packham <judge.packham@gmail•com>
> ---
> v4 adds a couple of simple tests - an equivalent of update=checkout and a test
> to make sure we detect a failure reported by the update command.

I think this can drop RFC/ now ;-)

Will replace what was queued and merge to 'next' unless I hear
otherwise within a few days.

Thanks.

>
>  Documentation/git-submodule.txt |  4 +++-
>  git-submodule.sh                |  6 ++++++
>  t/t7406-submodule-update.sh     | 29 +++++++++++++++++++++++++++++
>  3 files changed, 38 insertions(+), 1 deletion(-)
>
> diff --git a/Documentation/git-submodule.txt b/Documentation/git-submodule.txt
> index e576713..2f18f7d 100644
> --- a/Documentation/git-submodule.txt
> +++ b/Documentation/git-submodule.txt
> @@ -159,7 +159,9 @@ update::
>  	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`. Setting the key `submodule.$name.update` to `!command`
> +	will cause `command` to be run. `command` can be any arbitrary shell
> +	command that takes a single argument, namely the sha1 to update to.
>  +
>  If the submodule is not yet initialized, and you just want to use the
>  setting as stored in .gitmodules, you can automatically initialize the
> diff --git a/git-submodule.sh b/git-submodule.sh
> index eb58c8e..e7579f0 100755
> --- a/git-submodule.sh
> +++ b/git-submodule.sh
> @@ -799,6 +799,12 @@ Maybe you want to use 'update --init'?")"
>  				say_msg="$(eval_gettext "Submodule path '\$prefix\$sm_path': merged in '\$sha1'")"
>  				must_die_on_failure=yes
>  				;;
> +			!*)
> +				command="${update_module#!}"
> +				die_msg="$(eval_gettext "Execution of '\$command \$sha1' failed in submodule  path '\$prefix\$sm_path'")"
> +				say_msg="$(eval_gettext "Submodule path '\$prefix\$sm_path': '\$command \$sha1'")"
> +				must_die_on_failure=yes
> +				;;
>  			*)
>  				command="git checkout $subforce -q"
>  				die_msg="$(eval_gettext "Unable to checkout '\$sha1' in submodule path '\$prefix\$sm_path'")"
> diff --git a/t/t7406-submodule-update.sh b/t/t7406-submodule-update.sh
> index a4ffea0..48d1279 100755
> --- a/t/t7406-submodule-update.sh
> +++ b/t/t7406-submodule-update.sh
> @@ -279,6 +279,35 @@ test_expect_success 'submodule update - checkout in .git/config' '
>  	)
>  '
>  
> +test_expect_success 'submodule update - command in .git/config' '
> +	(cd super &&
> +	 git config submodule.submodule.update "!git checkout"
> +	) &&
> +	(cd super/submodule &&
> +	  git reset --hard HEAD^
> +	) &&
> +	(cd super &&
> +	 (cd submodule &&
> +	  compare_head
> +	 ) &&
> +	 git submodule update submodule &&
> +	 cd submodule &&
> +	 ! compare_head
> +	)
> +'
> +
> +test_expect_success 'submodule update - command in .git/config catches failure' '
> +	(cd super &&
> +	 git config submodule.submodule.update "!false"
> +	) &&
> +	(cd super/submodule &&
> +	  git reset --hard HEAD^
> +	) &&
> +	(cd super &&
> +	 test_must_fail git submodule update submodule
> +	)
> +'
> +
>  test_expect_success 'submodule init picks up rebase' '
>  	(cd super &&
>  	 git config -f .gitmodules submodule.rebasing.update rebase &&

  reply	other threads:[~2013-07-03 17:18 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-28  9:53 [RFC/PATCH] submodule: add 'exec' option to submodule update Chris Packham
2013-06-28 10:13 ` Stefan Näwe
2013-06-28 10:42 ` Fredrik Gustafsson
2013-06-29  9:11   ` Chris Packham
2013-06-30 15:30     ` Jens Lehmann
2013-07-01  9:21       ` Chris Packham
2013-07-01 10:11       ` [RFC/PATCHv2] submodule: add ability to configure update command Chris Packham
2013-07-01 16:26         ` Junio C Hamano
2013-07-02 10:12           ` [RFC/PATCHv3] submodule update: allow custom " Chris Packham
2013-07-02 16:56             ` Jens Lehmann
2013-07-02 23:26               ` Chris Packham
2013-07-03  6:55                 ` Jens Lehmann
2013-07-03  7:54                   ` Chris Packham
2013-07-03  8:50                     ` Chris Packham
2013-07-03 17:09                       ` Junio C Hamano
2013-07-03  9:02               ` [RFC/PATCHv4] " Chris Packham
2013-07-03 17:17                 ` Junio C Hamano [this message]
2013-07-01 16:48         ` [RFC/PATCHv2] submodule: add ability to configure " Junio C Hamano
2013-07-02  9:59           ` Chris Packham

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

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

  git send-email \
    --in-reply-to=7v4ncbh8ap.fsf@alter.siamese.dyndns.org \
    --to=gitster@pobox$(echo .)com \
    --cc=Jens.Lehmann@web$(echo .)de \
    --cc=git@vger$(echo .)kernel.org \
    --cc=hvoigt@hvoigt$(echo .)net \
    --cc=iveqy@iveqy$(echo .)com \
    --cc=judge.packham@gmail$(echo .)com \
    --cc=stefan.naewe@atlas-elektronik$(echo .)com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox