{"thread":{"id":"24102","subject":"[PATCH] Git.pm: better error message","startedAt":"2010-06-14T01:00:22Z","lastAt":"2010-06-17T23:47:31Z","messageCount":5,"participants":["Philippe Bruhat (BooK)","Jeff King"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"143622","messageId":"1276477222-21465-1-git-send-email-book@cpan.org","threadId":"24102","inReplyTo":null,"subject":"[PATCH] Git.pm: better error message","fromName":"Philippe Bruhat (BooK)","fromEmail":"book@cpan.org","sentAt":"2010-06-14T01:00:22Z","receivedAt":"2010-06-14T01:00:22Z","isPatch":true,"sender":{"key":"book@cpan.org","avatar":"https://avatars.githubusercontent.com/u/44421?v=4"},"body":"-d doesn't set $! if the directory doesn't exist\n\nSigned-off-by: Philippe Bruhat (BooK) <book@cpan.org>\n---\n perl/Git.pm |    4 ++--\n 1 files changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/perl/Git.pm b/perl/Git.pm\nindex 1926dc9..2a3920b 100644\n--- a/perl/Git.pm\n+++ b/perl/Git.pm\n@@ -172,7 +172,7 @@ sub repository {\n \t}\n \n \tif (defined $opts{Directory}) {\n-\t\t-d $opts{Directory} or throw Error::Simple(\"Directory not found: $!\");\n+\t\t-d $opts{Directory} or throw Error::Simple(\"Directory not found: $opts{Directory}\");\n \n \t\tmy $search = Git->repository(WorkingCopy => $opts{Directory});\n \t\tmy $dir;\n@@ -545,7 +545,7 @@ sub wc_chdir {\n \t\tor throw Error::Simple(\"bare repository\");\n \n \t-d $self->wc_path().'/'.$subdir\n-\t\tor throw Error::Simple(\"subdir not found: $!\");\n+\t\tor throw Error::Simple(\"subdir not found: $subdir\");\n \t# Of course we will not \"hold\" the subdirectory so anyone\n \t# can delete it now and we will never know. But at least we tried.\n \n-- \n1.7.0.4\n"},{"id":"143640","messageId":"20100614071046.GA5639@sigill.intra.peff.net","threadId":"24102","inReplyTo":"1276477222-21465-1-git-send-email-book@cpan.org","subject":"Re: [PATCH] Git.pm: better error message","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2010-06-14T07:10:46Z","receivedAt":"2010-06-14T07:10:46Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Mon, Jun 14, 2010 at 03:00:22AM +0200, Philippe Bruhat (BooK) wrote:\n\n> -d doesn't set $! if the directory doesn't exist\n\nReally?\n\n  $ perl -e '-d \"bogus\" or die \"fail: $!\"'\n  fail: No such file or directory at -e line 1.\n\nOn the other hand:\n\n  $ touch file\n  perl -e '-d \"file\" or die \"fail: $!\"'\n  fail:  at -e line 1.\n\nSo perhaps it is best not to rely on $!. Also, this is with perl 5.10.\nIs it different with other versions?\n\n-Peff\n"},{"id":"143647","messageId":"20100614091916.GB31387@swoosh","threadId":"24102","inReplyTo":"20100614071046.GA5639@sigill.intra.peff.net","subject":"Re: [PATCH] Git.pm: better error message","fromName":"Philippe Bruhat (BooK)","fromEmail":"book@cpan.org","sentAt":"2010-06-14T09:19:16Z","receivedAt":"2010-06-14T09:19:16Z","isPatch":true,"sender":{"key":"book@cpan.org","avatar":"https://avatars.githubusercontent.com/u/44421?v=4"},"body":"On Mon, Jun 14, 2010 at 03:10:46AM -0400, Jeff King wrote:\n> On Mon, Jun 14, 2010 at 03:00:22AM +0200, Philippe Bruhat (BooK) wrote:\n> \n> > -d doesn't set $! if the directory doesn't exist\n> \n> Really?\n> \n>   $ perl -e '-d \"bogus\" or die \"fail: $!\"'\n>   fail: No such file or directory at -e line 1.\n> \n> On the other hand:\n> \n>   $ touch file\n>   perl -e '-d \"file\" or die \"fail: $!\"'\n>   fail:  at -e line 1.\n> \n> So perhaps it is best not to rely on $!. Also, this is with perl 5.10.\n> Is it different with other versions?\n\nCome to think of it, it probably makes sense: -d probably depends on stat\nto get the information about the file, and that fails harder when the\nfile in question doesn't exists.\n\nI guess the best would be to put the directory name in the error message\n(always interesting information), and keep $! in case it was set by an\nharder error.\n\n-- \n Philippe Bruhat (BooK)\n\n There is no solution to a problem of sheer greed.\n                                    (Moral from Groo The Wanderer #94 (Epic))\n"},{"id":"143648","messageId":"20100614092024.GA7854@sigill.intra.peff.net","threadId":"24102","inReplyTo":"20100614091916.GB31387@swoosh","subject":"Re: [PATCH] Git.pm: better error message","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2010-06-14T09:20:25Z","receivedAt":"2010-06-14T09:20:25Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Mon, Jun 14, 2010 at 11:19:16AM +0200, Philippe Bruhat (BooK) wrote:\n\n> Come to think of it, it probably makes sense: -d probably depends on stat\n> to get the information about the file, and that fails harder when the\n> file in question doesn't exists.\n\nYeah, that makes sense to me.\n\n> I guess the best would be to put the directory name in the error message\n> (always interesting information), and keep $! in case it was set by an\n> harder error.\n\nAgreed.\n\n-Peff\n"},{"id":"143893","messageId":"1276818451-17003-1-git-send-email-book@cpan.org","threadId":"24102","inReplyTo":"1276477222-21465-1-git-send-email-book@cpan.org","subject":"[PATCH] Git.pm: better error message","fromName":"Philippe Bruhat (BooK)","fromEmail":"book@cpan.org","sentAt":"2010-06-17T23:47:31Z","receivedAt":"2010-06-17T23:47:31Z","isPatch":true,"sender":{"key":"book@cpan.org","avatar":"https://avatars.githubusercontent.com/u/44421?v=4"},"body":"Provide the bad directory name alongside with $!\n\nNote: $! is set if there is \"No such file or directory\",\nbut isn't set if the file exists but is not a directory.\n\nSigned-off-by: Philippe Bruhat (BooK) <book@cpan.org>\n---\n perl/Git.pm |    4 ++--\n 1 files changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/perl/Git.pm b/perl/Git.pm\nindex 1926dc9..6cb0dd1 100644\n--- a/perl/Git.pm\n+++ b/perl/Git.pm\n@@ -172,7 +172,7 @@ sub repository {\n \t}\n \n \tif (defined $opts{Directory}) {\n-\t\t-d $opts{Directory} or throw Error::Simple(\"Directory not found: $!\");\n+\t\t-d $opts{Directory} or throw Error::Simple(\"Directory not found: $opts{Directory} $!\");\n \n \t\tmy $search = Git->repository(WorkingCopy => $opts{Directory});\n \t\tmy $dir;\n@@ -545,7 +545,7 @@ sub wc_chdir {\n \t\tor throw Error::Simple(\"bare repository\");\n \n \t-d $self->wc_path().'/'.$subdir\n-\t\tor throw Error::Simple(\"subdir not found: $!\");\n+\t\tor throw Error::Simple(\"subdir not found: $subdir $!\");\n \t# Of course we will not \"hold\" the subdirectory so anyone\n \t# can delete it now and we will never know. But at least we tried.\n \n-- \n1.7.0.4\n"}]}