With git 2.19 and later I have an error when discarding changes on a modified file (checkout).

The error occurs while executing the .git/hooks/post-checkout and it says:

cp: '.git/hooks/post-checkout' and '.git/hooks/post-checkout' are the same file

The problem is that GIT_DIR env var is no more set... Thus this codes erroneously think that we are not ran as hook:

is_run_as_hook() {
    test -n "$GIT_DIR"
}

It seems that the GIT_DIR change was un-intentional, but the fact that GIT_DIR was set also was un-intentional...
See https://public-inbox.org/git/20180826004150.GA31168@sigill.intra.peff.net/t/

We now must find a way to recognize whether we are ran from a hook or not...
I have asked on SO if ever it can help https://stackoverflow.com/questions/55627720/how-to-recognize-if-git-hook-script-is-really-run-as-a-hook


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or mute the thread.