Hi, as far as I can tell GNU patch is supposed to preserve uid/gid of changed files when it has the permission to do so. I noticed an edge case where patch has the permission to but does not preserve gid.
I attached a shell script which should reproduce the issue. The problem seems to be set_file_attributes assumes that the "to" file has been created with uid/gid set to geteuid/geteuid which is not always the case for example when the directory has the setgid bit set. I think the fix could be to pass tmpoutst/fromst to set_file_attributes and use that st_uid/st_gid instead of euid/egid (if st_uid/st_gid are != -1). Is this something that should be done?
test.sh
Description: application/shellscript
