Questions About rename_file

Jon Forrest <[email protected]> Thu, 17 Mar 2022 10:37:09 -0700
Newsgroups gmane.comp.gnu.make.devel
Message-ID <[email protected]>
1) The documentation says:

"if the file does not exist, and it is found via directory search"

How can a file be found via directory search if it does not exist?
Do you mean if the file does not exist in the file hash?

2) The documentation says:

"If an out-of-date target is found by directory search in a directory
that also appears in GPATH, then that pathname is not thrown away. The
target is rebuilt using the expanded path.".

What's an expanded path in this case?

3) When a file is renamed by rename_file(), rename_file() calls
rehash_file() which tries to merge the file structures of the two files
together. The comment in the code says:

/* TO_FILE already exists under TO_HNAME.
    We must retain TO_FILE and merge FROM_FILE into it.  */

Perhaps naively I'm surprised that this merging is done.
Just because FROM_FILE and TO_FILE have the same name
doesn't mean it makes sense to merge their file
structures. The history of the two files could be completely
different. I would have expected it to be an error for FROM_FILE
to be renamed to TO_FILE. Indeed the code, calls error() to print
error messages but goes on to do the merging.

Thanks, as always, for your insights.

Jon