summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: fd1fcd9)
raw | patch | inline | side by side (parent: fd1fcd9)
author | Linus Torvalds <torvalds@g5.osdl.org> | |
Sun, 24 Jul 2005 01:52:22 +0000 (18:52 -0700) | ||
committer | Linus Torvalds <torvalds@g5.osdl.org> | |
Sun, 24 Jul 2005 01:52:22 +0000 (18:52 -0700) |
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..
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..
Makefile | patch | blob | history | |
git-rename-script | [new file with mode: 0755] | patch | blob |
diff --git a/Makefile b/Makefile
index f87225d5991a040e062d51a157b86da0d780f985..e92518f857f650fed6a0a2abc632bb93a7072835 100644 (file)
--- a/Makefile
+++ b/Makefile
gitk git-cherry git-rebase-script git-relink-script git-repack-script \
git-format-patch-script git-sh-setup-script git-push-script \
git-branch-script git-parse-remote git-verify-tag-script \
- git-ls-remote-script git-clone-dumb-http
+ git-ls-remote-script git-clone-dumb-http git-rename-script
PROG= git-update-cache git-diff-files git-init-db git-write-tree \
git-read-tree git-commit-tree git-cat-file git-fsck-cache \
diff --git a/git-rename-script b/git-rename-script
--- /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"