Repository navigation
fix(mv): refuse directory onto non-directory without backup (Refs #1649) - #1661
caomengxuan666 wants to merge 2 commits into
Conversation
GNU copy.c copy(): moving a directory onto an existing non-directory is refused with 'cannot overwrite non-directory %s with directory %s' (copy.c:2448-2463) unless backups are in effect; the mirror arm is copy.c:2489-2500. MoveFileExW would otherwise silently replace the file (data loss, rc=0). Gate runs after the backup step and is skipped when a backup was made; --backup=none still refuses. Refs #1649
Captain review: FAIL — one finding (rework)Reviewed head F2 — symlink-to-dir src onto a file is falsely refused (regression)
The new gate ( Rework: the gate's src-type query needs lstat-equivalent semantics (e.g. Verified green (banked)
CI — one red, not a product verdictRuns 43577219204 (GNU differential) success; 43577219310 (CMake Windows) failure with only Merge notes
|
…rk after review FAIL)
Summary
mv dir a.txt(dest is a regular file): GNU refuses withmv: cannot overwrite non-directory 'a.txt' with directory 'dir', rc=1. WinuxCmd 1.2.1 returned rc=0 and replaced the file with the directory (data loss).Fix: type-mismatch overwrite guard in
move_single_path(src/commands/mv.cpp, +34), placed after the backup step, before the rename — GNUcopy.ccopy()arms: dir→non-dircopy.c:2448-2463, mirrorcopy.c:2489-2500. Skipped when a backup was just made (--backupallowed, dest moved aside);--backup=nonestill refuses. Symlinks are followed viaGetFileAttributesW, like GNU'sstat.Verification
--backupallows /--backup=nonerefuses /-Tmirror refuses / move-into-dir locks pass / symlink-to-file refuses naming the link.tests/unit/mv/mv_unit_test.cpp(issue shape,--backupallow,--backup=nonerefuse,-Tmirror, two move-into locks, symlink-to-file).git diff --checkclean. i18n extract on the head tree: 3619 messages, zero containingcannot overwrite— the new messages are concatenations, invisible to the extractor, so no drift and no i18n-repo sync is triggered.Refs #1649