Improving block file change detection#5071
Improving block file change detection#5071jtyr wants to merge 2 commits intoMidnightCommander:masterfrom
Conversation
|
Please add a detailed info to the commit message. |
Signed-off-by: Jiri Tyr <jiri.tyr@gmail.com>
…ations Signed-off-by: Jiri Tyr <jiri.tyr@gmail.com>
|
@mc-worker Please could you clarify why the commit message needs more detail? The PR description already contains the full explanation of the changes. Is there a reason the commit message needs to duplicate that information? |
|
PR descriptions are the equivalent of cover letters in git-send-email, or the part below the '---' line of individual commit messages seen by git-am. also, they are proprietary to the hosting platform. |
Your few-words commit messages in #5070 and #5071 tells almost nothing people who will look to the git history about what bugs and how are fixed. There are no references to corresponding PRs. The first commit message in a branch should respect the following pattern:
PR description and git commit message are independent entities. In my point of view, the git history should be self-sufficient to offline work with and should not require to address to online resources.
|
Summary
Fixes two related issues with editor macro scripts and the block file.
Problem 1: Block file not saved before macro execution
edit_block_process_cmd()runs a numbered macro script that may reference%b(the block file). However, the selected block is not written to the block file before the script runs, so%bpoints to a stale or nonexistent file.The fix is to save the selected block to
EDIT_HOME_BLOCK_FILEat the start ofedit_block_process_cmd(), before callingedit_user_menu().Problem 2: Block file modification missed due to second-precision timestamps
edit_user_menu()detects whether a macro script modified the block file by comparingst_sizeandst_mtimebefore and after execution. Scripts that rearrange bytes without changing file size (e.g., word-wrap replacing spaces with newlines) and complete within the same second produce identicalst_sizeandst_mtime, causing a false negative - the editor does not reload the modified block.The fix is to use nanosecond-precision
st_mtim(viaHAVE_STRUCT_STAT_ST_MTIM, already detected by configure) instead of second-precisionst_mtime. Falls back tost_mtimeon platforms without nanosecond support.Test plan
st_mtim- should compile and fall back to second-precision comparison