{"thread":{"id":"13954","subject":"[PATCH] git-submodule - Fix errors regarding resolve_relative_url","startedAt":"2008-06-14T17:09:41Z","lastAt":"2008-06-14T19:36:29Z","messageCount":3,"participants":["Mark Levedahl","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"79864","messageId":"1213463381-3316-1-git-send-email-mlevedahl@gmail.com","threadId":"13954","inReplyTo":null,"subject":"[PATCH] git-submodule - Fix errors regarding resolve_relative_url","fromName":"Mark Levedahl","fromEmail":"mlevedahl@gmail.com","sentAt":"2008-06-14T17:09:41Z","receivedAt":"2008-06-14T17:09:41Z","isPatch":true,"sender":{"key":"mdl123@verizon.net","avatar":"https://avatars.githubusercontent.com/u/5302462?v=4"},"body":"git-submodule was invoking \"die\" from within resolve-relative-url, but\nthis does not actually cause the script to exit. Fix this by returning\nthe error to the caller and have the caller exit.\n\nWhile we're at it, clean up the quoting on invocation of\nresolve_relative_url as it was wrong.\n\nSigned-off-by: Mark Levedahl <mlevedahl@gmail.com>\n---\n git-submodule.sh |   11 +++++++----\n 1 files changed, 7 insertions(+), 4 deletions(-)\n\ndiff --git a/git-submodule.sh b/git-submodule.sh\nindex 4bd2b8e..7cb4edf 100755\n--- a/git-submodule.sh\n+++ b/git-submodule.sh\n@@ -45,8 +45,10 @@ resolve_relative_url ()\n \tbranch=\"$(git symbolic-ref HEAD 2>/dev/null)\"\n \tremote=\"$(git config branch.${branch#refs/heads/}.remote)\"\n \tremote=\"${remote:-origin}\"\n-\tremoteurl=\"$(git config remote.$remote.url)\" ||\n-\t\tdie \"remote ($remote) does not have a url in .git/config\"\n+\tremoteurl=$(git config remote.$remote.url) || {\n+\t\techo >&2 \"remote ($remote) does not have a url defined in .git/config\"\n+\t\treturn 1\n+\t}\n \turl=\"$1\"\n \twhile test -n \"$url\"\n \tdo\n@@ -178,7 +180,8 @@ cmd_add()\n \t\tcase \"$repo\" in\n \t\t./*|../*)\n \t\t\t# dereference source url relative to parent's url\n-\t\t\trealrepo=\"$(resolve_relative_url $repo)\" ;;\n+\t\t\trealrepo=$(resolve_relative_url \"$repo\") || exit 1\n+\t\t\t;;\n \t\t*)\n \t\t\t# Turn the source into an absolute path if\n \t\t\t# it is local\n@@ -246,7 +249,7 @@ cmd_init()\n \t\t# Possibly a url relative to parent\n \t\tcase \"$url\" in\n \t\t./*|../*)\n-\t\t\turl=\"$(resolve_relative_url \"$url\")\"\n+\t\t\turl=$(resolve_relative_url \"$url\") || exit 1\n \t\t\t;;\n \t\tesac\n \n-- \n1.5.6.rc2.67.g19fe3\n"},{"id":"79873","messageId":"7vd4mjhnwk.fsf@gitster.siamese.dyndns.org","threadId":"13954","inReplyTo":"1213463381-3316-1-git-send-email-mlevedahl@gmail.com","subject":"Re: [PATCH] git-submodule - Fix errors regarding resolve_relative_url","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-06-14T18:28:11Z","receivedAt":"2008-06-14T18:28:11Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Mark Levedahl <mlevedahl@gmail.com> writes:\n\n> git-submodule was invoking \"die\" from within resolve-relative-url, but\n> this does not actually cause the script to exit. Fix this by returning\n> the error to the caller and have the caller exit.\n\nThanks for catching this.  But don't you think the first hunk is\nunnecessary?\n\n> While we're at it, clean up the quoting on invocation of\n> resolve_relative_url as it was wrong.\n\nYup.  if you make it pass through the non-zero exit status that would be\nperfect, like this:\n\n    realrepo=$(resolve_relative_url \"$repo\") || exit\n"},{"id":"79879","messageId":"1213472189-252-1-git-send-email-mlevedahl@gmail.com","threadId":"13954","inReplyTo":"7vd4mjhnwk.fsf@gitster.siamese.dyndns.org","subject":"[PATCH] git-submodule - Fix errors regarding resolve_relative_url","fromName":"Mark Levedahl","fromEmail":"mlevedahl@gmail.com","sentAt":"2008-06-14T19:36:29Z","receivedAt":"2008-06-14T19:36:29Z","isPatch":true,"sender":{"key":"mdl123@verizon.net","avatar":"https://avatars.githubusercontent.com/u/5302462?v=4"},"body":"git-submodule was invoking \"die\" from within resolve-relative-url, but\nthe error return was ignored by the callers. Fix this.\n\nWhile we're at it, clean up the quoting on invocation of\nresolve_relative_url as it was wrong.\n\nSigned-off-by: Mark Levedahl <mlevedahl@gmail.com>\n---\n git-submodule.sh |    5 +++--\n 1 files changed, 3 insertions(+), 2 deletions(-)\n\ndiff --git a/git-submodule.sh b/git-submodule.sh\nindex 4bd2b8e..9c890d3 100755\n--- a/git-submodule.sh\n+++ b/git-submodule.sh\n@@ -178,7 +178,8 @@ cmd_add()\n \t\tcase \"$repo\" in\n \t\t./*|../*)\n \t\t\t# dereference source url relative to parent's url\n-\t\t\trealrepo=\"$(resolve_relative_url $repo)\" ;;\n+\t\t\trealrepo=$(resolve_relative_url \"$repo\") || exit\n+\t\t\t;;\n \t\t*)\n \t\t\t# Turn the source into an absolute path if\n \t\t\t# it is local\n@@ -246,7 +247,7 @@ cmd_init()\n \t\t# Possibly a url relative to parent\n \t\tcase \"$url\" in\n \t\t./*|../*)\n-\t\t\turl=\"$(resolve_relative_url \"$url\")\"\n+\t\t\turl=$(resolve_relative_url \"$url\") || exit\n \t\t\t;;\n \t\tesac\n \n-- \n1.5.6.rc2.65.gcb6b9\n"}]}