From 27f683e6f4eb87cdc4582bc2cd030b9e74ae0095 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Gannaz?= Date: Tue, 29 Apr 2014 10:14:53 +0200 Subject: [PATCH] stop process when no rx .git-local/ exists --- git-local | 10 ++++++++++ 1 file changed, 10 insertions(+) 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 "--")