]> git.99rst.org Git - git.git/commit
apply --reject: overwrite existing `.rej` symlink if it exists
authorJohannes Schindelin <redacted>
Thu, 9 Mar 2023 15:02:54 +0000 (16:02 +0100)
committerJohannes Schindelin <redacted>
Mon, 17 Apr 2023 19:15:38 +0000 (21:15 +0200)
commit9db05711c98efc14f414d4c87135a34c13586e0b
tree20f2b635d2612ce45fd88178a0012d884f667795
parent2f3b28f27234a0130583131a6785c44e3dd1cac4
apply --reject: overwrite existing `.rej` symlink if it exists

The `git apply --reject` is expected to write out `.rej` files in case
one or more hunks fail to apply cleanly. Historically, the command
overwrites any existing `.rej` files. The idea being that
apply/reject/edit cycles are relatively common, and the generated `.rej`
files are not considered precious.

But the command does not overwrite existing `.rej` symbolic links, and
instead follows them. This is unsafe because the same patch could
potentially create such a symbolic link and point at arbitrary paths
outside the current worktree, and `git apply` would write the contents
of the `.rej` file into that location.

Therefore, let's make sure that any existing `.rej` file or symbolic
link is removed before writing it.

Reported-by: RyotaK <redacted>
Helped-by: Taylor Blau <redacted>
Helped-by: Junio C Hamano <redacted>
Helped-by: Linus Torvalds <redacted>
Signed-off-by: Johannes Schindelin <redacted>
apply.c
t/t4115-apply-symlink.sh
git clone https://git.99rst.org/PROJECT