]> git.ipfire.org Git - thirdparty/coreutils.git/commit
install: avoid redundant metadata updates with -C
authorMateusz Nosek <mateusznosek0@gmail.com>
Thu, 16 Jul 2026 11:04:57 +0000 (12:04 +0100)
committerPádraig Brady <P@draigBrady.com>
Thu, 16 Jul 2026 11:28:03 +0000 (12:28 +0100)
commitb4bc8f361b24536734cc6f85b070d718bffe11a3
treee9a352e8a679b6477fda2a7c2681bd5ade24c99a
parent09f3fc5f70812eb0f1b476b11cf125a1a974b244
install: avoid redundant metadata updates with -C

"install -C" (--compare) has always called chown/chmod on the
destination even after determining that copying was unnecessary,
ever since --compare was added in commit v7.0-182-gdac5f12c6.
need_copy() already verifies that the destination's mode, owner, and
group match (and, with --preserve-context, that the SELinux context
matches too) before skipping the copy, so re-applying them is
redundant, and can needlessly fail on a destination that cannot be
chown/chmod'd even though nothing would actually change, e.g. one
marked immutable with chattr +i.

* src/install.c (install_file_in_file): Skip metadata updates
if we already skipped the data, as previous checks ensure
that the metadata is already as required.
* tests/install/install-C-immutable.sh: Add a test.
(based on tests/rm/empty-immutable-skip.sh).
* tests/local.mk: Reference the new test.
* NEWS: Mention the improvement.
NEWS
src/install.c
tests/install/install-C-immutable.sh [new file with mode: 0755]
tests/local.mk