#
# git-filter-branch ... new-H C..H --not D
# git-filter-branch ... new-H D..H --not C
+#
+# To move the whole tree into a subdirectory, or remove it from there:
+#
+# git-filter-branch --index-filter \
+# 'git-ls-files -s | sed "s-\t-&newsubdir/-" |
+# GIT_INDEX_FILE=$GIT_INDEX_FILE.new \
+# git-update-index --index-info &&
+# mv $GIT_INDEX_FILE.new $GIT_INDEX_FILE' directorymoved
# Testsuite: TODO
echo "[ -n \"\$GIT_${uid}_NAME\" ] || export GIT_${uid}_NAME=\"\${GIT_${uid}_EMAIL%%@*}\""
}
-# list all parent's object names for a given commit
-get_parents () {
- case "$filter_subdir" in
- "")
- git-rev-list -1 --parents "$1"
- ;;
- *)
- git-rev-list -1 --parents "$1" -- "$filter_subdir"
- esac | sed "s/^[0-9a-f]*//"
-}
-
tempdir=.git-rewrite
filter_env=
filter_tree=
case "$filter_subdir" in
"")
- git-rev-list --reverse --topo-order --default HEAD "$@"
+ git-rev-list --reverse --topo-order --default HEAD \
+ --parents "$@"
;;
*)
- git-rev-list --reverse --topo-order --default HEAD "$@" \
- -- "$filter_subdir"
+ git-rev-list --reverse --topo-order --default HEAD \
+ --parents --full-history "$@" -- "$filter_subdir"
esac > ../revs
commits=$(cat ../revs | wc -l | tr -d " ")
test $commits -eq 0 && die "Found nothing to rewrite"
i=0
-while read commit; do
+while read commit parents; do
i=$(($i+1))
printf "$commit ($i/$commits) "
eval "$filter_index" < /dev/null
parentstr=
- for parent in $(get_parents $commit); do
+ for parent in $parents; do
for reparent in $(map "$parent"); do
parentstr="$parentstr -p $reparent"
done
tee ../map/$commit
done <../revs
-src_head=$(tail -n 1 ../revs)
+src_head=$(tail -n 1 ../revs | sed -e 's/ .*//')
target_head=$(head -n 1 ../map/$src_head)
case "$target_head" in
'')