3 # Rename or move files in the repository
4 # Copyright (c) Petr Baudis, 2005
6 # Takes either two filenames and removes a file from the first one to
7 # the second one, or a list of filenames and a dirname and moves all
8 # the files to the directory. The changes will be executed in your working
9 # tree immediately, but recorded to the repository only at the time of the
12 # Note that so far, GIT/Cogito does not track file renames/moves per se.
13 # Therefore, doing `cg-mv` is currently the same as doing `cg-rm`, `cg-add`
14 # from the Cogito perspective, and no special information is recorded that
15 # the file moved around. When any rename tracking gets involved currently,
16 # it is purely heuristical method executed at the time of examination.
20 # -f:: Force overwriting of existing files
21 # Remove the target file if it already exists.
25 USAGE
="cg-mv [-f] FILE... DEST"
27 .
"${COGITO_LIB}"cg-Xlib ||
exit 1
38 [ -n "${ARGS[*]}" ] || usage
40 # Strip trailing / which is something GIT does not bear well, as well as
41 # some relpath issues. Allegedly fixed in GIT in 90924d55c... (post-1.2.4)
43 for arg
in "${ARGS[@]}"; do
44 ARGS2
[${#ARGS2[@]}]="$_git_relpath${arg%/}"
47 git-mv
$force "${ARGS2[@]}"