git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Fix submodule sync with relative submodule URLs
@ 2008-09-22 16:08 Johan Herland
  2008-09-24  7:29 ` David Aguilar
  2008-09-25 11:21 ` [PATCH] git-submodule: remove unnecessary exits when calling resolve_relative_url David Aguilar
  0 siblings, 2 replies; 10+ messages in thread
From: Johan Herland @ 2008-09-22 16:08 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git, David Aguilar, Mark Levedahl

Signed-off-by: Johan Herland <johan@herland.net>
---
 git-submodule.sh |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/git-submodule.sh b/git-submodule.sh
index 1c39b59..92be0fe 100755
--- a/git-submodule.sh
+++ b/git-submodule.sh
@@ -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
 		(
-- 
1.6.0.1.400.gd2470

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCH] Fix submodule sync with relative submodule URLs
  2008-09-22 16:08 [PATCH] Fix submodule sync with relative submodule URLs Johan Herland
@ 2008-09-24  7:29 ` David Aguilar
  2008-09-24  9:31   ` Johan Herland
  2008-09-25 11:21 ` [PATCH] git-submodule: remove unnecessary exits when calling resolve_relative_url David Aguilar
  1 sibling, 1 reply; 10+ messages in thread
From: David Aguilar @ 2008-09-24  7:29 UTC (permalink / raw)
  To: Johan Herland; +Cc: Junio C Hamano, git, Mark Levedahl

On Mon, Sep 22, 2008 at 9:08 AM, Johan Herland <johan@herland.net> wrote:
> Signed-off-by: Johan Herland <johan@herland.net>
> ---
>  git-submodule.sh |    8 ++++++++
>  1 files changed, 8 insertions(+), 0 deletions(-)
>
> diff --git a/git-submodule.sh b/git-submodule.sh
> index 1c39b59..92be0fe 100755
> --- a/git-submodule.sh
> +++ b/git-submodule.sh
> @@ -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
>                (
> --
> 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?


-- 
 David

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH] Fix submodule sync with relative submodule URLs
  2008-09-24  7:29 ` David Aguilar
@ 2008-09-24  9:31   ` Johan Herland
  2008-09-24 16:19     ` Shawn O. Pearce
  0 siblings, 1 reply; 10+ messages in thread
From: Johan Herland @ 2008-09-24  9:31 UTC (permalink / raw)
  To: git; +Cc: David Aguilar, Junio C Hamano, Mark Levedahl

Signed-off-by: Johan Herland <johan@herland.net>
---

On Wednesday 24 September 2008, David Aguilar wrote:
> 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(-)

diff --git a/git-submodule.sh b/git-submodule.sh
index 1c39b59..f89bdbe 100755
--- a/git-submodule.sh
+++ b/git-submodule.sh
@@ -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
 		(
-- 
1.6.0.2.463.g7f0eb

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCH] Fix submodule sync with relative submodule URLs
  2008-09-24  9:31   ` Johan Herland
@ 2008-09-24 16:19     ` Shawn O. Pearce
  2008-09-24 16:41       ` Johan Herland
  2008-09-25 11:38       ` David Aguilar
  0 siblings, 2 replies; 10+ messages in thread
From: Shawn O. Pearce @ 2008-09-24 16:19 UTC (permalink / raw)
  To: Johan Herland; +Cc: git, David Aguilar, Junio C Hamano, Mark Levedahl

Johan Herland <johan@herland.net> wrote:
> On Wednesday 24 September 2008, David Aguilar wrote:
> > 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.

> diff --git a/git-submodule.sh b/git-submodule.sh
> index 1c39b59..f89bdbe 100755
> --- a/git-submodule.sh
> +++ b/git-submodule.sh
> @@ -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
>  		(

-- 
Shawn.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] Fix submodule sync with relative submodule URLs
  2008-09-24 16:19     ` Shawn O. Pearce
@ 2008-09-24 16:41       ` Johan Herland
  2008-09-25 11:38       ` David Aguilar
  1 sibling, 0 replies; 10+ messages in thread
From: Johan Herland @ 2008-09-24 16:41 UTC (permalink / raw)
  To: Shawn O. Pearce; +Cc: git, David Aguilar, Junio C Hamano, Mark Levedahl

On Wednesday 24 September 2008, Shawn O. Pearce wrote:
> I guess I'm unclear about why cmd_sync is 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

-- 
Johan Herland, <johan@herland.net>
www.herland.net

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH] git-submodule: remove unnecessary exits when calling resolve_relative_url
  2008-09-22 16:08 [PATCH] Fix submodule sync with relative submodule URLs Johan Herland
  2008-09-24  7:29 ` David Aguilar
@ 2008-09-25 11:21 ` David Aguilar
  2008-09-25 12:19   ` Johannes Sixt
  1 sibling, 1 reply; 10+ messages in thread
From: David Aguilar @ 2008-09-25 11:21 UTC (permalink / raw)
  To: gitster; +Cc: git, johan, spearce, mlevedahl, David Aguilar

resolve_relative_url calls die() when no remote url exists so these calls to
exit can be removed.

Signed-off-by: David Aguilar <davvid@gmail.com>
---

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(-)

diff --git a/git-submodule.sh b/git-submodule.sh
index 92be0fe..533d1cc 100755
--- a/git-submodule.sh
+++ b/git-submodule.sh
@@ -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
 
-- 
1.6.0.2.307.gc4275

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCH] Fix submodule sync with relative submodule URLs
  2008-09-24 16:19     ` Shawn O. Pearce
  2008-09-24 16:41       ` Johan Herland
@ 2008-09-25 11:38       ` David Aguilar
  1 sibling, 0 replies; 10+ messages in thread
From: David Aguilar @ 2008-09-25 11:38 UTC (permalink / raw)
  To: Shawn O. Pearce; +Cc: Johan Herland, git, Junio C Hamano, Mark Levedahl

On  0, "Shawn O. Pearce" <spearce@spearce.org> wrote:
> Johan Herland <johan@herland.net> wrote:
> > On Wednesday 24 September 2008, David Aguilar wrote:
> > > 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.

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?




> 
> > diff --git a/git-submodule.sh b/git-submodule.sh
> > index 1c39b59..f89bdbe 100755
> > --- a/git-submodule.sh
> > +++ b/git-submodule.sh
> > @@ -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
> >  		(
> 
> -- 
> Shawn.

-- 

	David

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] git-submodule: remove unnecessary exits when calling resolve_relative_url
  2008-09-25 11:21 ` [PATCH] git-submodule: remove unnecessary exits when calling resolve_relative_url David Aguilar
@ 2008-09-25 12:19   ` Johannes Sixt
  2008-09-25 14:54     ` Shawn O. Pearce
  0 siblings, 1 reply; 10+ messages in thread
From: Johannes Sixt @ 2008-09-25 12:19 UTC (permalink / raw)
  To: David Aguilar; +Cc: gitster, git, johan, spearce, mlevedahl

David Aguilar schrieb:
> resolve_relative_url calls die() when no remote url exists so these calls to
> exit can be removed.
...
> @@ -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

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] git-submodule: remove unnecessary exits when calling resolve_relative_url
  2008-09-25 12:19   ` Johannes Sixt
@ 2008-09-25 14:54     ` Shawn O. Pearce
  2008-09-25 14:58       ` Johan Herland
  0 siblings, 1 reply; 10+ messages in thread
From: Shawn O. Pearce @ 2008-09-25 14:54 UTC (permalink / raw)
  To: Johannes Sixt; +Cc: David Aguilar, gitster, git, johan, mlevedahl

Johannes Sixt <j.sixt@viscovery.net> wrote:
> David Aguilar schrieb:
> > resolve_relative_url calls die() when no remote url exists so these calls to
> > exit can be removed.
> ...
> > @@ -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.

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.


-- 
Shawn.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] git-submodule: remove unnecessary exits when calling resolve_relative_url
  2008-09-25 14:54     ` Shawn O. Pearce
@ 2008-09-25 14:58       ` Johan Herland
  0 siblings, 0 replies; 10+ messages in thread
From: Johan Herland @ 2008-09-25 14:58 UTC (permalink / raw)
  To: Shawn O. Pearce; +Cc: git, Johannes Sixt, David Aguilar, gitster, mlevedahl

On Thursday 25 September 2008, Shawn O. Pearce wrote:
> Johannes Sixt <j.sixt@viscovery.net> wrote:
> > 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.
>
> 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


-- 
Johan Herland, <johan@herland.net>
www.herland.net

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2008-09-25 15:01 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-09-22 16:08 [PATCH] Fix submodule sync with relative submodule URLs Johan Herland
2008-09-24  7:29 ` David Aguilar
2008-09-24  9:31   ` Johan Herland
2008-09-24 16:19     ` Shawn O. Pearce
2008-09-24 16:41       ` Johan Herland
2008-09-25 11:38       ` David Aguilar
2008-09-25 11:21 ` [PATCH] git-submodule: remove unnecessary exits when calling resolve_relative_url David Aguilar
2008-09-25 12:19   ` Johannes Sixt
2008-09-25 14:54     ` Shawn O. Pearce
2008-09-25 14:58       ` Johan Herland

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).