This commit implements git-mv
Subsystems (2)
PATCH 1/1 This commit implements git-mv
It superceeds git-rename by adding functionality to move multiple files, directories or symlinks into another directory. It also provides according documentation.
The implementation renames multiple files, using the arguments from the command line to produce an array of sources and destinations. In a first pass, all requested renames are checked for errors, and overwriting of existing files is only allowed with '-f'. The actual renaming is done in a second pass.
This ensures that any error condition is checked before anything is changed.
---
The recent request on the list for "mv" in GIT reminded me about an addition to git-rename I made a week ago. I renamed it to "git-mv" and added some documentation.
If this works, we can remove git-rename sometimes in the future.
I should complement this command with tests. Also, a nice addition would be to support an interactive mode like 'mv', by asking if files should be overwritten.
By the way, it also checks for a request to move a directory into itself, which of course is an error.
Option "-k" is good for this:
E.g. a "git-mv -k * dir" moves all revision controlled files and directories (but not "dir"!) into "dir". "-k" makes sure that the errors (trying to move "dir" into itself, or move files without revision control around) will not terminate the command but silently ignored and skipped.
"-k" was taken from "make": Continue even on an error.
Josef
Documentation/git-mv.txt | 51 +++++++++++++ Makefile | 2 git-mv.perl | 185 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 237 insertions(+), 1 deletions(-) create mode 100644 Documentation/git-mv.txt create mode 100755 git-mv.perl
applies-to: b9f56dae60decf015079f5feef4544e7177b143a 0baacba7907046796e5a15eb2b191c1e2cb48793
Documentation/git-mv.txt new file +51 -0
@@ -0,0 +1,51 @@ +git-mv(1) +========= + +NAME +---- +git-mv - Script used to move or rename a file, directory or symlink. + + +SYNOPSIS +-------- +'git-mv' [-f] [-n] <source> <destination> +'git-mv' [-f] [-k] [-n] <source> ... <destination directory> + +DESCRIPTION +----------- +This script is used to move or rename a file, directory or symlink. +In the first form, it renames <source>, which must exist and be either +a file, symlink or directory, to <destination>, which must not exist. +In the second form, the last argument has to be an existing +directory; the given sources will be moved into this directory. + +The index is updated after successful completion, but the change must still be +committed. + +OPTIONS +------- +-f:: + Force renaming or moving even targets exist +-k:: + Skip move or rename actions which would lead to an error + condition. An error happens when a source is neither existing nor + controlled by GIT, or when it would overwrite an existing + file unless '-f' is given. +-n:: + Do nothing; only show what would happen + + +Author +------ +Written by Linus Torvalds <[email protected]> +Rewritten by Ryan Anderson <[email protected]> +Move functionality added by Josef Weidendorfer <[email protected]> + +Documentation +-------------- +Documentation by David Greaves, Junio C Hamano and the git-list <[email protected]>. + +GIT +--- +Part of the gitlink:git[7] suite +
Makefile +1 -1
@@ -94,7 +94,7 @@ SCRIPT_SH = \ SCRIPT_PERL = \ git-archimport.perl git-cvsimport.perl git-relink.perl \ git-rename.perl git-shortlog.perl git-fmt-merge-msg.perl \ - git-findtags.perl git-svnimport.perl + git-findtags.perl git-svnimport.perl git-mv.perl SCRIPT_PYTHON = \ git-merge-recursive.py
git-mv.perl new file +185 -0
185 lines not on this page · raw message
---
0.99.8.GIT