diff --git a/bin/hledger-git b/bin/hledger-git index 3911edccfdd..16607801ae5 100755 --- a/bin/hledger-git +++ b/bin/hledger-git @@ -62,12 +62,11 @@ EOF fi } -# TODO: also look in parent directories ensure_git_repo() { - if [[ ! -d "$DIR/.git" ]]; then - $GIT init "$DIR" - echo "Created git repo in $DIR" - fi + if [[ $($GIT rev-parse --is-inside-work-tree 2> /dev/null) != true ]]; then + $GIT init "$DIR" + echo "Created git repo in $DIR" + fi } # * Commands