threads / patch / 58740

patchdocumentation: update git-submodule documentation

Subject: [PATCH] documentation: update git-submodule documentation

## tl;dr

3 messages between Nov 3, 2022 and Nov 4, 2022. Diffs are folded; open one to read it.

replies: 2people: 3as markdown or json

James via GitGitGadget· Nov 3, 2022, 10:26 UTC · lore
From: James <jdm12989@gmail.com>

Removes reference to custom code execution which is called out by gitmodules as not allowed.

Signed-off-by: James <jdm12989@gmail.com>
---
    Update git-submodule.txt
    
    Remove info about custom commands being allowed in the submodule update
    command to align with the gitmodules docs which states "For security
    reasons, the !command form is not accepted here."
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-1401%2FEnochPrime%2Fsubmodule-docs-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-1401/EnochPrime/submodule-docs-v1
Pull-Request: https://github.com/gitgitgadget/git/pull/1401
 Documentation/git-submodule.txt | 6 ------
 1 file changed, 6 deletions(-)
Show changes to Documentation/git-submodule.txt +0 −6
diff --git a/Documentation/git-submodule.txt b/Documentation/git-submodule.txt
index 4d3ab6b9f92..b40ac72f753 100644
--- a/Documentation/git-submodule.txt
+++ b/Documentation/git-submodule.txt
@@ -163,12 +163,6 @@ checked out in the submodule.
 The following 'update' procedures are only available via the
 `submodule.<name>.update` configuration variable:
 
-	custom command;; arbitrary shell command that takes a single
-	    argument (the sha1 of the commit recorded in the
-	    superproject) is executed. When `submodule.<name>.update`
-	    is set to '!command', the remainder after the exclamation mark
-	    is the custom command.
-
 	none;; the submodule is not updated.
 
 If the submodule is not yet initialized, and you just want to use the

base-commit: c03801e19cb8ab36e9c0d17ff3d5e0c3b0f24193
-- 
gitgitgadget
Ævar Arnfjörð Bjarmason· Nov 3, 2022, 12:14 UTC · re: James via GitGitGadget · lore

Re: [PATCH] documentation: update git-submodule documentation

On Thu, Nov 03 2022, James via GitGitGadget wrote:
Show 37 quoted lines
> From: James <jdm12989@gmail.com>
>
> Removes reference to custom code execution which is called out by
> gitmodules as not allowed.
>
> Signed-off-by: James <jdm12989@gmail.com>
> ---
>     Update git-submodule.txt
>     
>     Remove info about custom commands being allowed in the submodule update
>     command to align with the gitmodules docs which states "For security
>     reasons, the !command form is not accepted here."
>
> Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-1401%2FEnochPrime%2Fsubmodule-docs-v1
> Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-1401/EnochPrime/submodule-docs-v1
> Pull-Request: https://github.com/gitgitgadget/git/pull/1401
>
>  Documentation/git-submodule.txt | 6 ------
>  1 file changed, 6 deletions(-)
>
> diff --git a/Documentation/git-submodule.txt b/Documentation/git-submodule.txt
> index 4d3ab6b9f92..b40ac72f753 100644
> --- a/Documentation/git-submodule.txt
> +++ b/Documentation/git-submodule.txt
> @@ -163,12 +163,6 @@ checked out in the submodule.
>  The following 'update' procedures are only available via the
>  `submodule.<name>.update` configuration variable:
>  
> -	custom command;; arbitrary shell command that takes a single
> -	    argument (the sha1 of the commit recorded in the
> -	    superproject) is executed. When `submodule.<name>.update`
> -	    is set to '!command', the remainder after the exclamation mark
> -	    is the custom command.
> -
>  	none;; the submodule is not updated.
>  
>  If the submodule is not yet initialized, and you just want to use the
Hrm?
	
	diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c
	index a7683d35299..80e897d5f29 100644
	--- a/builtin/submodule--helper.c
	+++ b/builtin/submodule--helper.c
	@@ -2247,6 +2247,7 @@ static int run_update_command(const struct update_data *ud, int subforce)
	 	case SM_UPDATE_COMMAND:
	 		cp.use_shell = 1;
	 		strvec_push(&cp.args, ud->update_strategy.command);
	+		BUG("unused??");
	 		break;
	 	default:
	 		BUG("unexpected update strategy type: %d",
	
Will show you that this is used, i.e. this failure in
t7406-submodule-update.sh:
	
	[...]
	+ cd super
	+ git config submodule.submodule.update !git checkout
	+ cd super/submodule
	+ git reset --hard HEAD^
	HEAD is now at 0c90624 upstream
	+ cd super
	+ cd submodule
	+ compare_head
	+ git rev-list --max-count=1 main
	+ sha_main=0c90624ab7f1aaa301d3bb79f60dcfed1ec4897f
	+ git rev-list --max-count=1 HEAD
	+ sha_head=0c90624ab7f1aaa301d3bb79f60dcfed1ec4897f
	+ test 0c90624ab7f1aaa301d3bb79f60dcfed1ec4897f = 0c90624ab7f1aaa301d3bb79f60dcfed1ec4897f
	+ git submodule update submodule
	BUG: builtin/submodule--helper.c:2250: unused??
	Aborted

I think what you may be confused by is that this isn't allowed in the in-tree .gitmodules file, and indeed you can see another BUG() in determine_submodule_update_strategy() for a panic if we'd ever get as far as reading "command" from there.

But that's not what this part of the docs dicsusses, as the paragraph shown above the removed lines in the context notes.

James McCandlish· Nov 4, 2022, 11:25 UTC · re: Ævar Arnfjörð Bjarmason · lore

Re: [PATCH] documentation: update git-submodule documentation

Sorry about the confusion. Just so I'm 100% clear: the `submodule.<name>.update` referencing a gitconfig and not gitmodules?

On Thu, Nov 3, 2022 at 8:17 AM Ævar Arnfjörð Bjarmason <avarab@gmail.com> wrote:
Show 85 quoted lines
>
>
> On Thu, Nov 03 2022, James via GitGitGadget wrote:
>
> > From: James <jdm12989@gmail.com>
> >
> > Removes reference to custom code execution which is called out by
> > gitmodules as not allowed.
> >
> > Signed-off-by: James <jdm12989@gmail.com>
> > ---
> >     Update git-submodule.txt
> >
> >     Remove info about custom commands being allowed in the submodule update
> >     command to align with the gitmodules docs which states "For security
> >     reasons, the !command form is not accepted here."
> >
> > Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-1401%2FEnochPrime%2Fsubmodule-docs-v1
> > Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-1401/EnochPrime/submodule-docs-v1
> > Pull-Request: https://github.com/gitgitgadget/git/pull/1401
> >
> >  Documentation/git-submodule.txt | 6 ------
> >  1 file changed, 6 deletions(-)
> >
> > diff --git a/Documentation/git-submodule.txt b/Documentation/git-submodule.txt
> > index 4d3ab6b9f92..b40ac72f753 100644
> > --- a/Documentation/git-submodule.txt
> > +++ b/Documentation/git-submodule.txt
> > @@ -163,12 +163,6 @@ checked out in the submodule.
> >  The following 'update' procedures are only available via the
> >  `submodule.<name>.update` configuration variable:
> >
> > -     custom command;; arbitrary shell command that takes a single
> > -         argument (the sha1 of the commit recorded in the
> > -         superproject) is executed. When `submodule.<name>.update`
> > -         is set to '!command', the remainder after the exclamation mark
> > -         is the custom command.
> > -
> >       none;; the submodule is not updated.
> >
> >  If the submodule is not yet initialized, and you just want to use the
>
> Hrm?
>
>         diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c
>         index a7683d35299..80e897d5f29 100644
>         --- a/builtin/submodule--helper.c
>         +++ b/builtin/submodule--helper.c
>         @@ -2247,6 +2247,7 @@ static int run_update_command(const struct update_data *ud, int subforce)
>                 case SM_UPDATE_COMMAND:
>                         cp.use_shell = 1;
>                         strvec_push(&cp.args, ud->update_strategy.command);
>         +               BUG("unused??");
>                         break;
>                 default:
>                         BUG("unexpected update strategy type: %d",
>
> Will show you that this is used, i.e. this failure in
> t7406-submodule-update.sh:
>
>         [...]
>         + cd super
>         + git config submodule.submodule.update !git checkout
>         + cd super/submodule
>         + git reset --hard HEAD^
>         HEAD is now at 0c90624 upstream
>         + cd super
>         + cd submodule
>         + compare_head
>         + git rev-list --max-count=1 main
>         + sha_main=0c90624ab7f1aaa301d3bb79f60dcfed1ec4897f
>         + git rev-list --max-count=1 HEAD
>         + sha_head=0c90624ab7f1aaa301d3bb79f60dcfed1ec4897f
>         + test 0c90624ab7f1aaa301d3bb79f60dcfed1ec4897f = 0c90624ab7f1aaa301d3bb79f60dcfed1ec4897f
>         + git submodule update submodule
>         BUG: builtin/submodule--helper.c:2250: unused??
>         Aborted
>
> I think what you may be confused by is that this isn't allowed in the
> in-tree .gitmodules file, and indeed you can see another BUG() in
> determine_submodule_update_strategy() for a panic if we'd ever get as
> far as reading "command" from there.
>
> But that's not what this part of the docs dicsusses, as the paragraph
> shown above the removed lines in the context notes.
-- 
James McCandlish

← back to recent threads