Re: RFC: Missing blob hook might be invoked infinitely recursively
From: Jonathan Nieder <hidden>
Date: 2017-06-29 19:25:20
Hi, Jonathan Tan wrote:
Suppose you have missing blob AB12 and CD34 that you now need, so fetch-blob is invoked. It sends the literals AB12 and CD34 to a new server endpoint and obtains a packfile, which it then pipes through "git index-pack". The issue is that "git index-pack" wants to try to access AB12 and CD34 in the local repo in order to do a SHA-1 collision check, and therefore fetch-blob is invoked once again, creating infinite recursion.
[...]
2. Add support for an environment variable to Git that suppresses access to the missing blob manifest, in effect, suppressing invocation of the hook. This allows anyone (the person configuring Git or the hook writer) to suppress this access, although they might need in-depth knowledge to know whether the hook is meant to be run with such access suppressed or required.
Small tweak: what if Git itself sets that environment variable when invoking the hook? A fetch-blob hook author can then explicitly unset the environment variable to request recursion if they need it. I should credit Shawn Pearce for saying this a little more clearly offline a moment ago. Thanks, Jonathan