From 4cbe353eb102be1d2cf9ac4eaac67c0e43607793 Mon Sep 17 00:00:00 2001 From: Jonathan Lai Date: Sun, 22 Jan 2017 00:41:08 -0800 Subject: [PATCH] Add check to see if the current directory is a git repo --- git-redate | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/git-redate b/git-redate index 5040aa6..1d56730 100755 --- a/git-redate +++ b/git-redate @@ -1,5 +1,16 @@ #!/bin/bash +is_git_repo() { + git rev-parse --show-toplevel > /dev/null 2>&1 + result=$? + if test $result != 0; then + >&2 echo 'Not a git repo!' + exit $result + fi +} + +is_git_repo + while [[ $# -gt 1 ]] do key="$1"