Re: core.autocrlf=true causes `git apply` to fail on patch generated with `git diff-index HEAD --patch`
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Aug 2, 2017, 20:58 UTC
- Message-ID
- <xmqq4ltpsn42.fsf@gitster.mtv.corp.google.com>
- In-Reply-To
- <cceaf377-73e0-e733-20ba-c4e547226382@web.de>
Torsten Bögershausen <tboegi@web.de> writes:
Show 17 quoted lines
> 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.