Skip to content

Improve is_git_repo() function mechanism of checking git repo to support newest git behavior #35

@TemaSM

Description

@TemaSM

Description:
If you run git redate inside directory owned by another user, git will exit with error and printing message like this:

fatal: unsafe repository ('/path/to/project/folder' is owned by someone else)
To add an exception for this directory, call:

        git config --global --add safe.directory /path/to/project/folder

- that's new behavior of git, more info:
https://github.blog/2022-04-12-git-security-vulnerability-announced/
https://stackoverflow.com/questions/71849415/i-cannot-add-the-parent-directory-to-safe-directory-in-git

Proposal:
Improve is_git_repo function to handle this type of error

git-redate/git-redate

Lines 3 to 10 in 843b964

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
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions