<p>With git 2.19 and later I have an error when discarding changes on a modified file (checkout).</p>
<p>The error occurs while executing the .git/hooks/post-checkout and it says:</p>
<blockquote>
<p>cp: '.git/hooks/post-checkout' and '.git/hooks/post-checkout' are the same file</p>
</blockquote>
<p>The problem is that GIT_DIR env var is no more set... Thus this codes erroneously think that we are not ran as hook:</p>
<pre><code>is_run_as_hook() {
    test -n "$GIT_DIR"
}
</code></pre>
<p>It seems that the GIT_DIR change was un-intentional, but the fact that GIT_DIR was set also was un-intentional...<br>
See <a href="https://public-inbox.org/git/20180826004150.GA31168@sigill.intra.peff.net/t/" rel="nofollow">https://public-inbox.org/git/20180826004150.GA31168@sigill.intra.peff.net/t/</a></p>
<p>We now must find a way to recognize whether we are ran from a hook or not...<br>
I have asked on SO if ever it can help <a href="https://stackoverflow.com/questions/55627720/how-to-recognize-if-git-hook-script-is-really-run-as-a-hook" rel="nofollow">https://stackoverflow.com/questions/55627720/how-to-recognize-if-git-hook-script-is-really-run-as-a-hook</a></p>

<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br />You are receiving this because you are subscribed to this thread.<br />Reply to this email directly, <a href="https://github.com/OpenSmalltalk/opensmalltalk-vm/issues/389">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/AhLyW7I1BvA3fn6894exQ33e2AkRNuBkks5vfu81gaJpZM4cpAcn">mute the thread</a>.<img src="https://github.com/notifications/beacon/AhLyW9cqxz5sNDgg5K8eiHW4Ue7gykMxks5vfu81gaJpZM4cpAcn.gif" height="1" width="1" alt="" /></p>
<script type="application/json" data-scope="inboxmarkup">{"api_version":"1.0","publisher":{"api_key":"05dde50f1d1a384dd78767c55493e4bb","name":"GitHub"},"entity":{"external_key":"github/OpenSmalltalk/opensmalltalk-vm","title":"OpenSmalltalk/opensmalltalk-vm","subtitle":"GitHub repository","main_image_url":"https://github.githubassets.com/images/email/message_cards/header.png","avatar_image_url":"https://github.githubassets.com/images/email/message_cards/avatar.png","action":{"name":"Open in GitHub","url":"https://github.com/OpenSmalltalk/opensmalltalk-vm"}},"updates":{"snippets":[{"icon":"DESCRIPTION","message":"GIT_DIR environment variable is no longer set in git hooks (#389)"}],"action":{"name":"View Issue","url":"https://github.com/OpenSmalltalk/opensmalltalk-vm/issues/389"}}}</script>
<script type="application/ld+json">[
{
"@context": "http://schema.org",
"@type": "EmailMessage",
"potentialAction": {
"@type": "ViewAction",
"target": "https://github.com/OpenSmalltalk/opensmalltalk-vm/issues/389",
"url": "https://github.com/OpenSmalltalk/opensmalltalk-vm/issues/389",
"name": "View Issue"
},
"description": "View this Issue on GitHub",
"publisher": {
"@type": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
}
]</script>