summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--apply.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/apply.c b/apply.c
index c06f7014a2..ad58cd1c77 100644
--- a/apply.c
+++ b/apply.c
@@ -2301,7 +2301,15 @@ 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);
- convert_to_git(&the_index, path, buf->buf, buf->len, buf, safe_crlf);
+ /*
+ * "git apply" without "--index/--cached" should never look
+ * at the index; the target file may not have been added to
+ * the index yet, and we may not even be in any Git repository.
+ * Pass NULL to convert_to_git() to stress this; the function
+ * should never look at the index when explicit crlf option
+ * is given.
+ */
+ convert_to_git(NULL, path, buf->buf, buf->len, buf, safe_crlf);
return 0;
default:
return -1;