Re: [PATCH/FIXUP 6/2] apply: clarify read_old_data() is about no-index case
- From
Torsten Bögershausen <tboegi@web.de>
- Date
- Aug 17, 2017, 06:24 UTC
- Message-ID
- <20170817062450.GA28592@tor.lan>
- In-Reply-To
- <xmqqbmnfl5tm.fsf@gitster.mtv.corp.google.com>
On Wed, Aug 16, 2017 at 11:34:45AM -0700, Junio C Hamano wrote:
Show 10 quoted lines
> With the previous fixes to CRLF handling in place, read_old_data() > knows what it wants convert_to_git() to do with respect to CRLF. In > fact, this codepath is about applying a patch to a file in the > filesystem, which may not exist in the index, or may exist but may > not match what is recorded in the index, or in the extreme case, we > may not even be in a Git repository. If convert_to_git() peeked at > the index while doing its work, it *would* be a bug. > > Pass NULL instead of &the_index to the function to make sure we > catch future bugs to clarify this.
Thanks for the work, and now our emails crossed.
Calling convert_to_git(NULL,...) makes Git crash today, see t4124, my latest version, "LF in repo, CRLF in working tree) Unless we re-define the meaning of "NULL" into "don't do CRLF conversions, like SAFE_CRLF_KEEP_CRLF does. The combination of convert_to_git(NULL,...,SAFE_CRLF_KEEP_CRLF) is OK, but all others must supply an &index.
At a very first glance the end result may look like this: - Take my changes in convert.[ch] - Take your changes/commit in apply.c (except the NULL, see above) - Take my changes in t4124.
I don't have time to look at this today or tomorrow, please give a hint if you are working further.