Fix submodule sync with relative submodule URLs
PATCH 1/1 Fix submodule sync with relative submodule URLs
--- git-submodule.sh | 8 ++++++++ 1 files changed, 8 insertions(+), 0 deletions(-)
git-submodule.sh +8 -0
@@ -634,6 +634,14 @@ cmd_sync() do name=$(module_name "$path") url=$(git config -f .gitmodules --get submodule."$name".url) + + # Possibly a url relative to parent + case "$url" in + ./*|../*) + url=$(resolve_relative_url "$url") || exit + ;; + esac + if test -e "$path"/.git then (
Signature · 1 line
1.6.0.1.400.gd2470
PATCH 1/1 git-submodule: remove unnecessary exits when calling resolve_relative_url
resolve_relative_url calls die() when no remote url exists so these calls to exit can be removed.
---
This applies on top of the first
"Fix submodule sync with relative submodule URLs" patch by Johan Herland. Shawn's comments made me realize that the resolve_relative_url callers could be cleaned up.
git-submodule.sh | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-)
git-submodule.sh +4 -4
@@ -155,7 +155,7 @@ cmd_add() case "$repo" in ./*|../*) # dereference source url relative to parent's url - realrepo=$(resolve_relative_url "$repo") || exit + realrepo=$(resolve_relative_url "$repo") ;; *:*|/*) # absolute url
@@ -184,7 +184,7 @@ cmd_add() case "$repo" in ./*|../*) - url=$(resolve_relative_url "$repo") || exit + url=$(resolve_relative_url "$repo") ;; *) url="$repo"
@@ -270,7 +270,7 @@ cmd_init() # Possibly a url relative to parent case "$url" in ./*|../*) - url=$(resolve_relative_url "$url") || exit + url=$(resolve_relative_url "$url") ;; esac
@@ -638,7 +638,7 @@ cmd_sync() # Possibly a url relative to parent case "$url" in ./*|../*) - url=$(resolve_relative_url "$url") || exit + url=$(resolve_relative_url "$url") ;; esac
Signature · 1 line
1.6.0.2.307.gc4275
Re: [PATCH] git-submodule: remove unnecessary exits when calling resolve_relative_url
Quoted 2 lines · David Aguilar
resolve_relative_urlcallsdie()when no remote url exists so these calls to exit can be removed.
...
git-submodule.sh cmd_add() · line 159
Quoted 7 lines
git-submodule.sh +1
-1@@ -155,7 +155,7 @@ cmd_add() case "$repo" in ./*|../*) # dereference source url relative to parent's url - realrepo=$(resolve_relative_url "$repo") || exit + realrepo=$(resolve_relative_url "$repo") ;;
Did you test it? The command inside $(...) is run in its own sub-process, therefore, the die() does not exit the caller, just the sub-process, and the || exit *is* required.
BTW, I think that || exit is sufficient; you don't need to add another error message - the one that resolve_relative_url() prints is sufficient.
-- Hannes
Re: [PATCH] git-submodule: remove unnecessary exits when calling resolve_relative_url
Quoted 16 lines · Johannes Sixt
Quoted 2 lines · David Aguilar
resolve_relative_urlcallsdie()when no remote url exists so these calls to exit can be removed....
git-submodule.sh cmd_add() · line 159
Quoted 7 lines
git-submodule.sh +1
-1@@ -155,7 +155,7 @@ cmd_add() case "$repo" in ./*|../*) # dereference source url relative to parent's url - realrepo=$(resolve_relative_url "$repo") || exit + realrepo=$(resolve_relative_url "$repo") ;;Did you test it? The command inside $(...) is run in its own sub-process, therefore, the
die()does not exit the caller, just the sub-process, and the || exit *is* required.
Quoted 2 lines
BTW, I think that || exit is sufficient; you don't need to add another error message - the one that
resolve_relative_url()prints is sufficient.
Exactly.
I think we just need a "|| exit" after each of these $(resolve_relative_url) calls. The original patch that started this discussion just needs a "|| exit".
die with an additional message is just too verbose.
Signature · 1 line
Shawn.
Re: [PATCH] git-submodule: remove unnecessary exits when calling resolve_relative_url
Quoted 9 lines · Shawn O. Pearce
Quoted 7 lines · Johannes Sixt
Did you test it? The command inside $(...) is run in its own sub-process, therefore, the
die()does not exit the caller, just the sub-process, and the || exit *is* required.BTW, I think that || exit is sufficient; you don't need to add another error message - the one that
resolve_relative_url()prints is sufficient.
Quoted 5 lines
Exactly.
I think we just need a "|| exit" after each of these $(resolve_relative_url) calls. The original patch that started this discussion just needs a "|| exit".
The original patch did exactly that:
http://article.gmane.org/gmane.comp.version-control.git/96493
Have fun!
...Johan
Signature · 2 lines
Johan Herland, <[email protected]> www.herland.net
Quoted 25 lines · Johan Herland
Signed-off-by Johan Herland <[email protected]>--- git-submodule.sh | 8 ++++++++ 1 files changed, 8 insertions(+), 0 deletions(-)git-submodule.sh +8
-1@@ -634,6 +634,14 @@ cmd_sync() do name=$(module_name "$path") url=$(git config -f .gitmodules --get submodule."$name".url) + + # Possibly a url relative to parent + case "$url" in + ./*|../*) + url=$(resolve_relative_url "$url") || exit + ;; + esac + if test -e "$path"/.git then ( --
Quoted 2 lines
1.6.0.1.400.gd2470
Instead of just doing an "|| exit" shouldn't it report an explanation of the error?
Other than that, it looks good to me.
Mark, Junio?
Signature · 1 line
David
PATCH 1/1 Fix submodule sync with relative submodule URLs
---
Quoted 3 lines · David Aguilar
Instead of just doing an "|| exit" shouldn't it report an explanation of the error?
Other than that, it looks good to me.
Fixed. Thanks.
...Johan
git-submodule.sh | 9 +++++++++ 1 files changed, 9 insertions(+), 0 deletions(-)
git-submodule.sh +9 -0
@@ -634,6 +634,15 @@ cmd_sync() do name=$(module_name "$path") url=$(git config -f .gitmodules --get submodule."$name".url) + + # Possibly a url relative to parent + case "$url" in + ./*|../*) + url=$(resolve_relative_url "$url") || + die "failed to resolve relative submodule url for '$name'" + ;; + esac + if test -e "$path"/.git then (
Signature · 1 line
1.6.0.2.463.g7f0eb
Quoted 6 lines · Johan Herland
Quoted 3 lines · David Aguilar
Instead of just doing an "|| exit" shouldn't it report an explanation of the error?
Other than that, it looks good to me.Fixed. Thanks.
OK, time for the drive-by patch commenting. I've largely stayed out of git-submodule related code, but I just looked at in the context of applying this patch.
There are three callers to resolve_relative_url in master and next. All three callers just "|| exit" when resolve_relative_url fails.
The only reason resolve_relative_url can fail is when there is no remote.$remote.url configuration option set for the current default remote ("origin"?).
I guess I'm unclear about why cmd_sync is different from the existing callers.
Quoted 20 lines
git-submodule.sh +9
-0@@ -634,6 +634,15 @@ cmd_sync() do name=$(module_name "$path") url=$(git config -f .gitmodules --get submodule."$name".url) + + # Possibly a url relative to parent + case "$url" in + ./*|../*) + url=$(resolve_relative_url "$url") || + die "failed to resolve relative submodule url for '$name'" + ;; + esac + if test -e "$path"/.git then (
Signature · 1 line
Shawn.
Quoted 2 lines · Shawn O. Pearce
I guess I'm unclear about why
cmd_syncis different from the existing callers.
It's not any different as far as I'm concerned. We should probably add helpful error messages to the other callers as well.
...Johan
Signature · 2 lines
Johan Herland, <[email protected]> www.herland.net
Quoted 15 lines · Shawn O. Pearce
Quoted 6 lines · Johan Herland
Quoted 3 lines · David Aguilar
Instead of just doing an "|| exit" shouldn't it report an explanation of the error?
Other than that, it looks good to me.Fixed. Thanks.
OK, time for the drive-by patch commenting. I've largely stayed out of git-submodule related code, but I just looked at in the context of applying this patch.
There are three callers to
resolve_relative_urlin master and next. All three callers just "|| exit" whenresolve_relative_urlfails.
Quoted 6 lines
The only reason
resolve_relative_urlcan fail is when there is no remote.$remote.url configuration option set for the current default remote ("origin"?).I guess I'm unclear about why
cmd_syncis different from the existing callers.
Right, it's not. resolve_relative_url() is already calling die() when that error condition is met, so the "|| exit" thing can be removed entirely. I sent a patch on top of Johan's first patch to remove the "|| exit" calls in all callers of resolve_relative_url. That seems like the right thing to do; in the very least it makes it easier to read. What do you think?
Quoted 24 lines
Quoted 21 lines
git-submodule.sh +9
-0@@ -634,6 +634,15 @@ cmd_sync() do name=$(module_name "$path") url=$(git config -f .gitmodules --get submodule."$name".url) + + # Possibly a url relative to parent + case "$url" in + ./*|../*) + url=$(resolve_relative_url "$url") || + die "failed to resolve relative submodule url for '$name'" + ;; + esac + if test -e "$path"/.git then (Signature · 1 line
Shawn.
Signature · 1 line
David