From: Junio C Hamano Date: Wed, 02 Aug 2017 20:58:37 GMT Subject: Re: core.autocrlf=true causes `git apply` to fail on patch generated with `git diff-index HEAD --patch` Message-ID: In-Reply-To: Torsten Bögershausen writes: > My very first investigation shows that a patch like this could fix > the problem: > > diff --git a/apply.c b/apply.c > index f2d599141d..66b8387360 100644 > --- a/apply.c > +++ b/apply.c > @@ -2278,6 +2278,8 @@ static int read_old_data(struct stat *st, const > char *path, struct strbuf *buf) > case S_IFREG: > if (strbuf_read_file(buf, path, st->st_size) != > st->st_size) > return error(_("unable to open or read %s"), path); > + if (would_convert_to_git(&the_index, path)) > + read_cache(); > convert_to_git(&the_index, path, buf->buf, buf->len, > buf, 0); Sorry, but it is unclear why this is a "fix" to me. We may not even be doing "git apply --index" or "git apply --cached" that care about the state recorded in the index, but just the plain vanilla "git apply", which could even be outside any repository.