Thread (13 messages) flat view 13 messages, 2 authors, 2017-08-17

Re: core.autocrlf=true causes `git apply` to fail on patch generated with `git diff-index HEAD --patch`

From: Junio C Hamano <hidden>
Date: 2017-08-02 20:58:52

Possibly related (same subject, not in this thread)

Torsten Bögershausen [off-list ref] writes:
quoted hunk
  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.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help