threads / patch / 9120

patchgit-submodule fixes for call to git config --get-regexp

Subject: [PATCH] git-submodule fixes for call to git config --get-regexp

## tl;dr

3 messages between Jul 20, 2007 and Jul 20, 2007. Diffs are folded; open one to read it.

replies: 2people: 3as markdown or json

Chris Larson· Jul 20, 2007, 17:23 UTC · lore
Two minor git-submodule fixes:
* Escape !'s in the git config --get-regexp, so submodule paths can
contain them.
* Be more explicit about the value regex, otherwise things get confused if one
  submodule name is a prefix of another (since --get-regexp can return
  multiple values).
Signed-off-by: Chris Larson <clarson@kergoth.com>

--- git-submodule.sh.old 2007-07-20 10:13:22.578125000 -0700 +++ git-submodule.sh 2007-07-20 10:14:56.281250000 -0700

Show changes to diff +2 −1
@@ -46,7 +46,8 @@ get_repo_base() {
 #
 module_name()
 {
-       name=$(GIT_CONFIG=.gitmodules git config --get-regexp
'^submodule\..*\.path$' "$1" |
+       path=$(echo "$1" | sed -e 's/\!/\\!/g')
+       name=$(GIT_CONFIG=.gitmodules git config --get-regexp
'^submodule\..*\.path$' "^$path$" |
        sed -nre 's/^submodule\.(.+)\.path .+$/\1/p')
        test -z "$name" &&
        die "No submodule mapping found in .gitmodules for path '$path'"
-- 
Chris Larson - clarson at kergoth dot com
Dedicated Engineer - MontaVista - clarson at mvista dot com
Core Developer/Architect - TSLib, BitBake, OpenEmbedded, OpenZaurus
Junio C Hamano· Jul 20, 2007, 18:07 UTC · re: Chris Larson · lore

Re: [PATCH] git-submodule fixes for call to git config --get-regexp

"Chris Larson" <clarson@kergoth.com> writes:
> Two minor git-submodule fixes:
> * Escape !'s in the git config --get-regexp, so submodule paths can
> contain them.
Show 9 quoted lines
> --- git-submodule.sh.old	2007-07-20 10:13:22.578125000 -0700
> +++ git-submodule.sh	2007-07-20 10:14:56.281250000 -0700
> @@ -46,7 +46,8 @@ get_repo_base() {
> #
> module_name()
> {
> -       name=$(GIT_CONFIG=.gitmodules git config --get-regexp
> '^submodule\..*\.path$' "$1" |
> +       path=$(echo "$1" | sed -e 's/\!/\\!/g')

My first reaction was if it shouldn't be done for only the '!' at the very beginning, to defeat "do_not_match" logic, but it would not hurt if we have extra "\!" in the middle.

Once you introduce that sed to munge the path string, I suspect you would also want and can afford to quote extended regular expression metacharacters as well.

Show 10 quoted lines
> +       name=$(GIT_CONFIG=.gitmodules git config --get-regexp
> '^submodule\..*\.path$' "^$path$" |
>        sed -nre 's/^submodule\.(.+)\.path .+$/\1/p')
>        test -z "$name" &&
>        die "No submodule mapping found in .gitmodules for path '$path'"
>
> -- 
> Chris Larson - clarson at kergoth dot com
> Dedicated Engineer - MontaVista - clarson at mvista dot com
> Core Developer/Architect - TSLib, BitBake, OpenEmbedded, OpenZaurus
Johannes Schindelin· Jul 20, 2007, 18:36 UTC · re: Junio C Hamano · lore

Re: [PATCH] git-submodule fixes for call to git config --get-regexp

Hi,
On Fri, 20 Jul 2007, Junio C Hamano wrote:
Show 5 quoted lines
> "Chris Larson" <clarson@kergoth.com> writes:
> 
> > +       name=$(GIT_CONFIG=.gitmodules git config --get-regexp
> > '^submodule\..*\.path$' "^$path$" |
> >        sed -nre 's/^submodule\.(.+)\.path .+$/\1/p')

I wonder why it is a regular expression to begin with, since we seem to prefer shell patterns on paths.

However, _if_ we already go with regexps, why not just put it into the "sed" call, which is _already_ there, and leave "git config" alone? IOW call

	git config --get-regexp '^submodule\..*\.path$' |
		sed -nre 's/^submodule\.(.*$path.*)\.path .+$\1/p'
Hmm?

Ciao, Dscho

← back to recent threads