summaryrefslogtreecommitdiff
path: root/git-filter-branch.sh
diff options
context:
space:
mode:
authorJohannes Sixt <johannes.sixt@telecom.at>2007-06-08 21:28:39 (GMT)
committerJunio C Hamano <gitster@pobox.com>2007-06-09 19:20:20 (GMT)
commit813b4734fcb82e541658b33b8563387c197d6247 (patch)
treedab2ae07264c3b8684334dfa7051904c134a3d61 /git-filter-branch.sh
parent685ef546b62d063c72b401cd38b83a879301aac4 (diff)
downloadgit-813b4734fcb82e541658b33b8563387c197d6247.zip
git-813b4734fcb82e541658b33b8563387c197d6247.tar.gz
git-813b4734fcb82e541658b33b8563387c197d6247.tar.bz2
filter-branch: Simplify parent computation.
We can use git rev-list --parents when we list the commits to rewrite. It is not necessary to run git rev-list --parents for each commit in the loop. Signed-off-by: Johannes Sixt <johannes.sixt@telecom.at> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'git-filter-branch.sh')
-rwxr-xr-xgit-filter-branch.sh24
1 files changed, 7 insertions, 17 deletions
diff --git a/git-filter-branch.sh b/git-filter-branch.sh
index efb8f2d..cb43b59 100755
--- a/git-filter-branch.sh
+++ b/git-filter-branch.sh
@@ -226,17 +226,6 @@ set_ident () {
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=
@@ -329,18 +318,19 @@ mkdir ../map # map old->new commit ids for rewriting parents
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 "$@" -- "$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) "
@@ -374,7 +364,7 @@ while read commit; do
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
@@ -389,7 +379,7 @@ while read commit; do
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
'')