Skip to content

Commit 3c37a2e

Browse files
committed
apply: do not read from the filesystem under --index
We currently read the preimage to apply a patch from the index only when the --cached option is given. Do so also when the command is running under the --index option. With --index, the index entry and the working tree file for a path that is involved in a patch must be identical, so this should not affect the result, but by reading from the index, we will get the protection to avoid reading an unintended path beyond a symbolic link automatically. Signed-off-by: Junio C Hamano <[email protected]>
1 parent c536c07 commit 3c37a2e

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

builtin/apply.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3136,7 +3136,7 @@ static int load_patch_target(struct strbuf *buf,
31363136
const char *name,
31373137
unsigned expected_mode)
31383138
{
3139-
if (cached) {
3139+
if (cached || check_index) {
31403140
if (read_file_or_gitlink(ce, buf))
31413141
return error(_("read of %s failed"), name);
31423142
} else if (name) {

0 commit comments

Comments
 (0)