{"thread":{"id":"12495","subject":"[PATCH] git-submodule: Don't die when command fails for one submodule","startedAt":"2008-03-04T14:35:14Z","lastAt":"2008-03-04T20:32:27Z","messageCount":7,"participants":["Ping Yin","Johannes Schindelin","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"70946","messageId":"1204641314-2726-1-git-send-email-pkufranky@gmail.com","threadId":"12495","inReplyTo":null,"subject":"[PATCH] git-submodule: Don't die when command fails for one submodule","fromName":"Ping Yin","fromEmail":"pkufranky@gmail.com","sentAt":"2008-03-04T14:35:14Z","receivedAt":"2008-03-04T14:35:14Z","isPatch":true,"sender":{"key":"pkufranky@gmail.com","avatar":"https://avatars.githubusercontent.com/u/5346?v=4"},"body":"When handling multiple modules, init/update/status command will exit\nwhen it fails for one submodule. This patch makes the command continue\nbypassing the failure.\n\nSigned-off-by: Ping Yin <pkufranky@gmail.com>\n---\n git-submodule.sh |   51 +++++++++++++++++++++++++++++++--------------------\n 1 files changed, 31 insertions(+), 20 deletions(-)\n\ndiff --git a/git-submodule.sh b/git-submodule.sh\nindex 67d3224..2d1639c 100755\n--- a/git-submodule.sh\n+++ b/git-submodule.sh\n@@ -100,15 +100,18 @@ module_clone()\n \t# succeed but the rmdir will fail. We might want to fix this.\n \tif test -d \"$path\"\n \tthen\n-\t\trmdir \"$path\" 2>/dev/null ||\n-\t\tdie \"Directory '$path' exist, but is neither empty nor a git repository\"\n+\t\t! rmdir \"$path\" 2>/dev/null &&\n+\t\tsay \"Directory '$path' exist, but is neither empty nor a git repository\" &&\n+\t\treturn 1\n \tfi\n \n \ttest -e \"$path\" &&\n-\tdie \"A file already exist at path '$path'\"\n+\tsay \"A file already exist at path '$path'\" &&\n+\treturn 1\n \n-\tgit-clone -n \"$url\" \"$path\" ||\n-\tdie \"Clone of '$url' into submodule path '$path' failed\"\n+\t! git-clone -n \"$url\" \"$path\" &&\n+\tsay \"Clone of '$url' into submodule path '$path' failed\" &&\n+\treturn 1\n }\n \n #\n@@ -224,13 +227,14 @@ cmd_init()\n \twhile read mode sha1 stage path\n \tdo\n \t\t# Skip already registered paths\n-\t\tname=$(module_name \"$path\") || exit\n+\t\tname=$(module_name \"$path\") || continue\n \t\turl=$(git config submodule.\"$name\".url)\n \t\ttest -z \"$url\" || continue\n \n \t\turl=$(GIT_CONFIG=.gitmodules git config submodule.\"$name\".url)\n \t\ttest -z \"$url\" &&\n-\t\tdie \"No url found for submodule path '$path' in .gitmodules\"\n+\t\tsay \"No url found for submodule path '$path' in .gitmodules\" &&\n+\t\tcontinue\n \n \t\t# Possibly a url relative to parent\n \t\tcase \"$url\" in\n@@ -239,10 +243,13 @@ cmd_init()\n \t\t\t;;\n \t\tesac\n \n-\t\tgit config submodule.\"$name\".url \"$url\" ||\n-\t\tdie \"Failed to register url for submodule path '$path'\"\n+\t\tif git config submodule.\"$name\".url \"$url\"\n+\t\tthen\n+\t\t\tsay \"Submodule '$name' ($url) registered for path '$path'\"\n+\t\telse\n+\t\t\tsay \"Failed to register url for submodule path '$path'\"\n+\t\tfi\n \n-\t\tsay \"Submodule '$name' ($url) registered for path '$path'\"\n \tdone\n }\n \n@@ -277,7 +284,7 @@ cmd_update()\n \tgit ls-files --stage -- \"$@\" | grep -e '^160000 ' |\n \twhile read mode sha1 stage path\n \tdo\n-\t\tname=$(module_name \"$path\") || exit\n+\t\tname=$(module_name \"$path\") || continue\n \t\turl=$(git config submodule.\"$name\".url)\n \t\tif test -z \"$url\"\n \t\tthen\n@@ -290,21 +297,25 @@ cmd_update()\n \n \t\tif ! test -d \"$path\"/.git\n \t\tthen\n-\t\t\tmodule_clone \"$path\" \"$url\" || exit\n+\t\t\tmodule_clone \"$path\" \"$url\" || continue\n \t\t\tsubsha1=\n \t\telse\n-\t\t\tsubsha1=$(unset GIT_DIR; cd \"$path\" &&\n-\t\t\t\tgit rev-parse --verify HEAD) ||\n-\t\t\tdie \"Unable to find current revision in submodule path '$path'\"\n+\t\t\t! subsha1=$(unset GIT_DIR; cd \"$path\" &&\n+\t\t\t\tgit rev-parse --verify HEAD 2>/dev/null) &&\n+\t\t\tsay \"Unable to find current revision in submodule path '$path'\" &&\n+\t\t\tcontinue\n \t\tfi\n \n \t\tif test \"$subsha1\" != \"$sha1\"\n \t\tthen\n-\t\t\t(unset GIT_DIR; cd \"$path\" && git-fetch &&\n-\t\t\t\tgit-checkout -q \"$sha1\") ||\n-\t\t\tdie \"Unable to checkout '$sha1' in submodule path '$path'\"\n+\t\t\tif (unset GIT_DIR; cd \"$path\" && git-fetch &&\n+\t\t\t\tgit-checkout -q \"$sha1\")\n+\t\t\tthen\n+\t\t\t\tsay \"Submodule path '$path': checked out '$sha1'\"\n+\t\t\telse\n+\t\t\t\tsay \"Unable to checkout '$sha1' in submodule path '$path'\"\n+\t\t\tfi\n \n-\t\t\tsay \"Submodule path '$path': checked out '$sha1'\"\n \t\tfi\n \tdone\n }\n@@ -360,7 +371,7 @@ cmd_status()\n \tgit ls-files --stage -- \"$@\" | grep -e '^160000 ' |\n \twhile read mode sha1 stage path\n \tdo\n-\t\tname=$(module_name \"$path\") || exit\n+\t\tname=$(module_name \"$path\") || continue\n \t\turl=$(git config submodule.\"$name\".url)\n \t\tif test -z \"$url\" || ! test -d \"$path\"/.git\n \t\tthen\n-- \n1.5.4.3.347.g5314c\n\n"},{"id":"70950","messageId":"alpine.LSU.1.00.0803041500170.22527@racer.site","threadId":"12495","inReplyTo":"1204641314-2726-1-git-send-email-pkufranky@gmail.com","subject":"Re: [PATCH] git-submodule: Don't die when command fails for one submodule","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2008-03-04T15:01:28Z","receivedAt":"2008-03-04T15:01:28Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Tue, 4 Mar 2008, Ping Yin wrote:\n\n> When handling multiple modules, init/update/status command will exit \n> when it fails for one submodule. This patch makes the command continue \n> bypassing the failure.\n\nI think that you should not do this.  The failure should not be ignored.  \nMaybe continuing, but not forgetting about the error.  So:\n\n> -\t\tname=$(module_name \"$path\") || exit\n> +\t\tname=$(module_name \"$path\") || continue\n\nI do not like this.  It should remember that there was something foul, and \neventually exit with that status.\n\nCiao,\nDscho\n\n"},{"id":"70960","messageId":"46dff0320803040800o499bb77bsa033134bda43becb@mail.gmail.com","threadId":"12495","inReplyTo":"alpine.LSU.1.00.0803041500170.22527@racer.site","subject":"Re: [PATCH] git-submodule: Don't die when command fails for one submodule","fromName":"Ping Yin","fromEmail":"pkufranky@gmail.com","sentAt":"2008-03-04T16:00:44Z","receivedAt":"2008-03-04T16:00:44Z","isPatch":true,"sender":{"key":"pkufranky@gmail.com","avatar":"https://avatars.githubusercontent.com/u/5346?v=4"},"body":"On Tue, Mar 4, 2008 at 11:01 PM, Johannes Schindelin\n<Johannes.Schindelin@gmx.de> wrote:\n> Hi,\n>\n>\n>  On Tue, 4 Mar 2008, Ping Yin wrote:\n>\n>  > When handling multiple modules, init/update/status command will exit\n>  > when it fails for one submodule. This patch makes the command continue\n>  > bypassing the failure.\n>\n>  I think that you should not do this.  The failure should not be ignored.\n>  Maybe continuing, but not forgetting about the error.  So:\n>\n>\n>  > -             name=$(module_name \"$path\") || exit\n>  > +             name=$(module_name \"$path\") || continue\n>\n>  I do not like this.  It should remember that there was something foul, and\n>  eventually exit with that status.\n>\nThe error output is not lost and is in module_name\n>  Ciao,\n>  Dscho\n>\n>\n\n\n\n-- \nPing Yin\n"},{"id":"70963","messageId":"alpine.LSU.1.00.0803041602150.22527@racer.site","threadId":"12495","inReplyTo":"46dff0320803040800o499bb77bsa033134bda43becb@mail.gmail.com","subject":"Re: [PATCH] git-submodule: Don't die when command fails for one submodule","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2008-03-04T16:03:11Z","receivedAt":"2008-03-04T16:03:11Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Wed, 5 Mar 2008, Ping Yin wrote:\n\n> The error output is not lost and is in module_name\n\nThat's what I am saying: the error output is not enough.  The exit status \nneeds to indicate that there was an error, too.  Everything else is \nunusable by scripts.\n\nThank you very much,\nDscho\n\n"},{"id":"70965","messageId":"46dff0320803040806y5ed02b86p9216ddc752f3052@mail.gmail.com","threadId":"12495","inReplyTo":"alpine.LSU.1.00.0803041602150.22527@racer.site","subject":"Re: [PATCH] git-submodule: Don't die when command fails for one submodule","fromName":"Ping Yin","fromEmail":"pkufranky@gmail.com","sentAt":"2008-03-04T16:06:26Z","receivedAt":"2008-03-04T16:06:26Z","isPatch":true,"sender":{"key":"pkufranky@gmail.com","avatar":"https://avatars.githubusercontent.com/u/5346?v=4"},"body":"On Wed, Mar 5, 2008 at 12:03 AM, Johannes Schindelin\n<Johannes.Schindelin@gmx.de> wrote:\n> Hi,\n>\n>\n>  On Wed, 5 Mar 2008, Ping Yin wrote:\n>\n>  > The error output is not lost and is in module_name\n>\n>  That's what I am saying: the error output is not enough.  The exit status\n>  needs to indicate that there was an error, too.  Everything else is\n>  unusable by scripts.\n\nI think this can be done in a following patch which capture any error\nand give the right exit status.\n>\n\n\n\n-- \nPing Yin\n"},{"id":"70970","messageId":"alpine.LSU.1.00.0803041612400.22527@racer.site","threadId":"12495","inReplyTo":"46dff0320803040806y5ed02b86p9216ddc752f3052@mail.gmail.com","subject":"Re: [PATCH] git-submodule: Don't die when command fails for one submodule","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2008-03-04T16:13:31Z","receivedAt":"2008-03-04T16:13:31Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Wed, 5 Mar 2008, Ping Yin wrote:\n\n> On Wed, Mar 5, 2008 at 12:03 AM, Johannes Schindelin\n> <Johannes.Schindelin@gmx.de> wrote:\n>\n> >  On Wed, 5 Mar 2008, Ping Yin wrote:\n> >\n> >  > The error output is not lost and is in module_name\n> >\n> >  That's what I am saying: the error output is not enough.  The exit status\n> >  needs to indicate that there was an error, too.  Everything else is\n> >  unusable by scripts.\n> \n> I think this can be done in a following patch which capture any error\n> and give the right exit status.\n\nThat's horrible!  Are you seriously suggesting breaking a perfectly fine \nparadigm in one patch, just to fix it in the next one?\n\n*Shudders*,\nDscho\n"},{"id":"70990","messageId":"7vzlte44dg.fsf@gitster.siamese.dyndns.org","threadId":"12495","inReplyTo":"46dff0320803040806y5ed02b86p9216ddc752f3052@mail.gmail.com","subject":"Re: [PATCH] git-submodule: Don't die when command fails for one submodule","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-03-04T20:32:27Z","receivedAt":"2008-03-04T20:32:27Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Ping Yin\" <pkufranky@gmail.com> writes:\n\n> On Wed, Mar 5, 2008 at 12:03 AM, Johannes Schindelin\n> <Johannes.Schindelin@gmx.de> wrote:\n>> Hi,\n>>\n>>\n>>  On Wed, 5 Mar 2008, Ping Yin wrote:\n>>\n>>  > The error output is not lost and is in module_name\n>>\n>>  That's what I am saying: the error output is not enough.  The exit status\n>>  needs to indicate that there was an error, too.  Everything else is\n>>  unusable by scripts.\n>\n> I think this can be done in a following patch which capture any error\n> and give the right exit status.\n\nPlease.\n\n\"You are absolutely right.  I'll fix it in my next round to do frotz and\nxyzzy as you suggested.  I want to make my next round better with fixes\nand improvements based on other comments I will receive during this round,\nso it will be at least in a few days.  Thanks.\"\n\nThat's how I want to see things work around here.\n\n"}]}