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

Re: [RFC/PATCHv3] submodule update: allow custom update command

From
Jens Lehmann <jens.lehmann@web.de>
Date
Jul 2, 2013, 16:56 UTC
Message-ID
<51D3064C.80901@web.de>
In-Reply-To
<1372759974-19765-1-git-send-email-judge.packham@gmail.com>
Am 02.07.2013 12:12, schrieb Chris Packham:
Show 10 quoted lines
> 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 or extending other tools.
> 
> Signed-off-by: Chris Packham <judge.packham@gmail.com>
> ---
> v3 updated as per Junio's review.
Thanks, a few comments below.
> Still needs tests. Any suggestions? I've been manually testing by setting
> submodule.$name.update to '!echo'. I haven't looked to see if there are
> existing 'submodule update' tests yet.
t7406-submodule-update.sh should be the right place.
Show 27 quoted lines
>  Documentation/git-submodule.txt | 5 ++++-
>  git-submodule.sh                | 6 ++++++
>  2 files changed, 10 insertions(+), 1 deletion(-)
> 
> diff --git a/Documentation/git-submodule.txt b/Documentation/git-submodule.txt
> index e576713..0befc20 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
> @@ -172,6 +174,7 @@ If `--force` is specified, the submodule will be checked out (using
>  `git checkout --force` if appropriate), even if the commit specified in the
>  index of the containing repository already matches the commit checked out in
>  the submodule.
> ++
>  
>  summary::
>  	Show commit summary between the given commit (defaults to HEAD) and
I'm not sure this change is necessary ;-)
Show 11 quoted lines
> diff --git a/git-submodule.sh b/git-submodule.sh
> index eb58c8e..a7c2375 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 "Unable to exec '\$command \$sha1' in submodule path '\$prefix\$sm_path'")"

Hmm, "Unable to exec" does not quite cut it, as the command was executed but returned an error, right? Maybe something like this:

   Execution of '\$command \$sha1' failed in submodule  path '\$prefix\$sm_path'
Show 7 quoted lines
> +				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'")"
> 
Previous: Chris PackhamNext: Chris Packham
Message 10 of 19 in “submodule: add 'exec' option to submodule update”
  1. submodule: add 'exec' option to submodule updateChris Packham, Jun 28, 2013
  2. Stefan NäweJun 28, 2013
  3. Fredrik GustafssonJun 28, 2013
  4. Chris PackhamJun 29, 2013
  5. Jens LehmannJun 30, 2013
  6. Chris PackhamJul 1, 2013
  7. [RFC/PATCHv2] submodule: add ability to configure update commandChris Packham, Jul 1, 2013
  8. Junio C HamanoJul 1, 2013
  9. [RFC/PATCHv3] submodule update: allow custom update commandChris Packham, Jul 2, 2013
  10. Jens LehmannJul 2, 2013
  11. Chris PackhamJul 2, 2013
  12. Jens LehmannJul 3, 2013
  13. Chris PackhamJul 3, 2013
  14. Chris PackhamJul 3, 2013
  15. Junio C HamanoJul 3, 2013
  16. [RFC/PATCHv4] submodule update: allow custom update commandChris Packham, Jul 3, 2013
  17. Junio C HamanoJul 3, 2013
  18. Junio C HamanoJul 1, 2013
  19. Chris PackhamJul 2, 2013

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.