bug#61767: install: options --compare (-C) and --preserve-timestamps are mutually exclusive

Pádraig Brady <[email protected]> Mon, 2 Mar 2026 11:11:14 +0000
Newsgroups gmane.comp.gnu.core-utils.bugs
Message-ID <[email protected]>
On 01/03/2026 23:54, Collin Funk wrote:
> Pádraig Brady <[email protected]> writes:
> 
>> Yes I can see the intent of disallowing -p with -C.
>> I.e. if there is no content,ownership,perm change
>> then don't update anything in the destination, including timestamps.
>> I.e. -C is for performance, and -p would lose some of that.
>>
>> However if the user explicitly wants the timestamps updated
>> there should be no problem with that.
>> As for performance implications, there may be some, especially for repeated install runs,
>> as the updated mtime would be written to disk and the meta-data cache
>> would be invalidated.
>> But if the user wants up to date mtime then it doesn't completely invalidate
>> the performance obtained with -C, as the page cache shouldn't be invalidated,
>> and we would still be avoiding data writes.
> 
> Here is a proposed patch that allows the options to be used together.

It's best not to set timestamps in two places.
Could we adjust copy_file to return OK,FAIL,SKIP enum
and then adjust the conditionals in install_file_in_file() ?

Also we could add a line to the test to be more robust:

   echo a > a || framework_failure_
   echo a > b || framework_failure_
   touch -d 2026-01-01 a || framework_failure_
   test b -nt a || framework_failure_   # Handle systems with bad time

thanks,
Padraig