Skip to main content

Module mv

Module mv 

Source
Expand description

mkit mv <source>... <dest> — move or rename tracked paths, staging the change (like git mv).

Forms:

  • mv <src> <dst> — rename src to dst, or move it into dst when dst is an existing directory.
  • mv <src>... <dir> — move every source into the existing directory <dir>.

For each source the worktree file is moved and the index updated: the source path is staged as removed and the destination staged with the source’s blob (content is unchanged, so the existing object is reused) and mode. All sources are validated up front; nothing on disk or in the index is touched until every move is known to be legal, so a bad source in a batch can’t leave the worktree half-moved.

mkit has no rename detection, so mkit status reports the move as a deletion plus an addition rather than git’s R — a documented divergence; the staged result (mkit commit) is equivalent.

Scope: moves a single tracked file per source. Moving a tracked directory (mv dir newdir) is not yet supported and is refused with a clear error (follow-up).

Safety divergences:

  • refuses to overwrite an existing destination without -f (matching git’s mv clobber guard), and detects a dangling symlink at the destination as “exists” (git refuses that too);
  • refuses a destination that escapes the repository through a symlinked parent directory (git would silently follow it) — mkit keeps writes inside the repo.

Functions§

run