5 # 28-Jan-2009 Clemens Buchacher <clemens.buchacher@infineon.com>
11 # If two files have the same target, or if files 'a', 'b', are renamed to
12 # 'b', 'c', respectively, in the wrong order. The file may be overwritten.
14 # o subentry conflicts
16 # If both a directory and its contained files are moved, this can have
24 echo -n "$prog: error: "
28 OPT
=`getopt -o f -- "$@"` ||
exit 1
33 while test "$1" != "--"
37 *) echo "unkown option: $1"; exit 1;;
50 echo `echo "$1" | sha1sum - | cut -f1 -d' '` "$1"
56 echo "# This program is under development. Use at your own risk!";
57 echo "# Remove all content to abort";
60 if ! ${EDITOR:=vi} "$newnames"
67 cat "$newnames" |
grep -v '^\s*\(#.*\)\?$' | \
68 while read sha1 newname
70 if ! expr "$sha1" : '[0-9a-f]\{40\}$' >/dev
/null
72 error
"invalid hash: $sha1"
75 oldname
=`sed -n "/^$sha1\s\+/ {s/^$sha1\s\+//p; q}" "$orignames"`
78 error
"unknown hash: $sha1"
81 if test "$oldname" != "$newname"
83 echo "\`$oldname' -> \`$newname'"
84 if test -z "$force" && test -e "$newname"
86 error
"rename would overwrite existing file"
88 mv -f "$oldname" "$newname"