aboutsummaryrefslogtreecommitdiffstats
path: root/git-rename-script
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@g5.osdl.org>2005-07-23 18:52:22 -0700
committerLinus Torvalds <torvalds@g5.osdl.org>2005-07-23 18:52:22 -0700
commit399144f21c1b3bcd4c9dadd4f534118475de840d (patch)
treeb8a2ac7f44f605bb446a2cf67a6604417b83c120 /git-rename-script
parentfd1fcd9f57406cd5f278adb6b3ceeb1b7637062a (diff)
downloadgit-399144f21c1b3bcd4c9dadd4f534118475de840d.tar.gz
Add a "git rename" to help with - surprise surprise - renames
It's stupid. We'd want to rename directories too, but this doesn't do that yet - easy enough to do per se, we just need to carefully list all the pathnames that got moved (and remember to ignore the files that weren't tracked but are in the subdirectory that got moved). Doing the directory case will require a bit more scripting.. Something like oldfiles=($(git-ls-files | grep '^$src')) newfiles=($(git-ls-files | sed ':^$src: s:^$src:$dst:')) mv $src $dst && git-update-cache --add --remove -- "${oldfiles[@]}" "${newfiles[@]}" might do it, except it needs to be done right, and carefully. Methinks perl is probably better at this. Hint hint..
Diffstat (limited to 'git-rename-script')
-rwxr-xr-xgit-rename-script7
1 files changed, 7 insertions, 0 deletions
diff --git a/git-rename-script b/git-rename-script
new file mode 100755
index 0000000000..3952382dbc
--- /dev/null
+++ b/git-rename-script
@@ -0,0 +1,7 @@
+#!/bin/sh
+
+. git-sh-setup-script || die "Not a git archive"
+
+[ -f "$1" ] || [ -h "$1" ] || die "git rename: bad source"
+[ -e "$2" ] && die "git rename: destination already exists"
+mv -- "$1" "$2" && git-update-cache --add --remove -- "$1" "$2"