Code

Merge branch 'maint'
[git.git] / perl / Git.pm
index dde9105df8464911451830321e4da1cbae924955..7d7f2b1d367b505676032878615b2843eb64ed7b 100644 (file)
@@ -166,11 +166,12 @@ sub repository {
                }
        }
 
-       if (not defined $opts{Repository} and not defined $opts{WorkingCopy}) {
-               $opts{Directory} ||= '.';
+       if (not defined $opts{Repository} and not defined $opts{WorkingCopy}
+               and not defined $opts{Directory}) {
+               $opts{Directory} = '.';
        }
 
-       if ($opts{Directory}) {
+       if (defined $opts{Directory}) {
                -d $opts{Directory} or throw Error::Simple("Directory not found: $!");
 
                my $search = Git->repository(WorkingCopy => $opts{Directory});
@@ -204,14 +205,14 @@ sub repository {
 
                        unless (-d "$dir/refs" and -d "$dir/objects" and -e "$dir/HEAD") {
                                # Mimick git-rev-parse --git-dir error message:
-                               throw Error::Simple('fatal: Not a git repository');
+                               throw Error::Simple("fatal: Not a git repository: $dir");
                        }
                        my $search = Git->repository(Repository => $dir);
                        try {
                                $search->command('symbolic-ref', 'HEAD');
                        } catch Git::Error::Command with {
                                # Mimick git-rev-parse --git-dir error message:
-                               throw Error::Simple('fatal: Not a git repository');
+                               throw Error::Simple("fatal: Not a git repository: $dir");
                        }
 
                        $opts{Repository} = abs_path($dir);
@@ -1010,8 +1011,8 @@ sub _temp_cache {
        my $temp_fd = \$TEMP_FILEMAP{$name};
        if (defined $$temp_fd and $$temp_fd->opened) {
                if ($TEMP_FILES{$$temp_fd}{locked}) {
-                       throw Error::Simple("Temp file with moniker '",
-                               $name, "' already in use");
+                       throw Error::Simple("Temp file with moniker '" .
+                               $name . "' already in use");
                }
        } else {
                if (defined $$temp_fd) {