git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Brandon Williams <bmwill@google.com>
To: Stefan Beller <sbeller@google.com>
Cc: gitster@pobox.com, git@vger.kernel.org, judge.packham@gmail.com,
	olsonse@umich.edu
Subject: Re: [PATCHv2] submodule update: run custom update script for initial populating as well
Date: Wed, 25 Jan 2017 15:41:58 -0800	[thread overview]
Message-ID: <20170125234158.GE83343@google.com> (raw)
In-Reply-To: <20170125233742.30370-1-sbeller@google.com>

On 01/25, Stefan Beller wrote:
> In 1b4735d9f3 (submodule: no [--merge|--rebase] when newly cloned,
> 2011-02-17), all actions were defaulted to checkout for populating
> a submodule initially, because merging or rebasing makes no sense
> in that situation.
> 
> Other commands however do make sense, such as the custom command
> that was added later (6cb5728c43, submodule update: allow custom
> command to update submodule working tree, 2013-07-03).
> 
> I am unsure about the "none" command, as I can see an initial
> checkout there as a useful thing. On the other hand going strictly
> by our own documentation, we should do nothing in case of "none"
> as well, because the user asked for it.
> 
> Reported-by: Han-Wen Nienhuys <hanwen@google.com>
> Signed-off-by: Stefan Beller <sbeller@google.com>
> ---
>  git-submodule.sh            |  5 ++++-
>  t/t7406-submodule-update.sh | 15 +++++++++++++++
>  2 files changed, 19 insertions(+), 1 deletion(-)
> 
> diff --git a/git-submodule.sh b/git-submodule.sh
> index 9788175979..63fc4fe9bc 100755
> --- a/git-submodule.sh
> +++ b/git-submodule.sh
> @@ -607,7 +607,10 @@ cmd_update()
>  		if test $just_cloned -eq 1
>  		then
>  			subsha1=
> -			update_module=checkout
> +			case "$update_module" in
> +			merge | rebase | none)
> +				update_module=checkout ;;
> +			esac
>  		else
>  			subsha1=$(sanitize_submodule_env; cd "$sm_path" &&
>  				git rev-parse --verify HEAD) ||
> diff --git a/t/t7406-submodule-update.sh b/t/t7406-submodule-update.sh
> index 725bbed1f8..2f83243c7d 100755
> --- a/t/t7406-submodule-update.sh
> +++ b/t/t7406-submodule-update.sh
> @@ -441,6 +441,19 @@ test_expect_success 'submodule update - command in .git/config catches failure -
>  	test_i18ncmp actual expect
>  '
>  
> +test_expect_success 'submodule update - command run for initial population of submodule' '
> +	cat <<-\ EOF >expect
> +	Execution of '\''false $submodulesha1'\'' failed in submodule path '\''submodule'\''
> +	EOF
> +	(
> +		cd super &&
> +		rm -rf submodule
> +		test_must_fail git submodule update >../actual
> +	)
> +	test_cmp expect actual
> +	git -C super submodule update --checkout
> +'

You can probably get away without the subshell:

rm -rf super/submodule
test_must_fail git -C super submodule upsate >actual

> +
>  cat << EOF >expect
>  Execution of 'false $submodulesha1' failed in submodule path '../super/submodule'
>  Failed to recurse into submodule path '../super'
> @@ -493,6 +506,7 @@ test_expect_success 'submodule init picks up merge' '
>  '
>  
>  test_expect_success 'submodule update --merge  - ignores --merge  for new submodules' '
> +	test_config -C super submodule.submodule.update checkout &&
>  	(cd super &&
>  	 rm -rf submodule &&
>  	 git submodule update submodule &&
> @@ -505,6 +519,7 @@ test_expect_success 'submodule update --merge  - ignores --merge  for new submod
>  '
>  
>  test_expect_success 'submodule update --rebase - ignores --rebase for new submodules' '
> +	test_config -C super submodule.submodule.update checkout &&
>  	(cd super &&
>  	 rm -rf submodule &&
>  	 git submodule update submodule &&
> -- 
> 2.11.0.495.g04f60290a0.dirty
> 

-- 
Brandon Williams

  reply	other threads:[~2017-01-25 23:42 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-13 19:43 [PATCH] submodule update: run custom update script for initial populating as well Stefan Beller
2017-01-13 23:42 ` Junio C Hamano
2017-01-13 23:52   ` Stefan Beller
2017-01-13 23:58 ` Junio C Hamano
2017-01-14  0:00   ` Stefan Beller
2017-01-25 23:37     ` [PATCHv2] " Stefan Beller
2017-01-25 23:41       ` Brandon Williams [this message]
2017-01-25 23:48         ` [PATCHv3] " Stefan Beller

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=20170125234158.GE83343@google.com \
    --to=bmwill@google.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=judge.packham@gmail.com \
    --cc=olsonse@umich.edu \
    --cc=sbeller@google.com \
    /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.
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 NNTP newsgroup(s).