diff --git a/git-local b/git-local index a5fe868..f8425e2 100755 --- a/git-local +++ b/git-local @@ -53,15 +53,18 @@ for ($ARGV[0]) { when ('status') { shift @ARGV; GetOptions($cmd_opts, "verbose|v"); + require_local_repo(); local_status($cmd_opts, @ARGV); } when ('add') { shift @ARGV; $cmd_opts = { gitignore => 1 }; GetOptions($cmd_opts, "gitignore!"); + require_local_repo(); local_add($cmd_opts, @ARGV); } default { + require_local_repo(); local_git(@ARGV); } } @@ -102,6 +105,13 @@ BEGIN { or die("Could not append to file!"); } + sub require_local_repo { + die( + "A git-local repository could not be found or read in\n $localdir\n" + . "Consider using\n git local init\n" + ) unless -d -r -x $localdir; + } + sub local_status { my $o = shift; my @files = grep { /^[^-]/ } @_; # TODO: better parsing (notably for "--")