Skip to content

Commit

Permalink
filter-branch: also don't fail in map() if a commit cannot be mapped
Browse files Browse the repository at this point in the history
The map() function can be used by filters to map a commit id to its
rewritten id. Such a mapping may not exist, in which case the identity
mapping is used (the commit is returned unchanged).

In the rewrite loop, this mapping is also needed, but was done
explicitly in the same way. Use the map() function instead.

Signed-off-by: Johannes Sixt <johannes.sixt@telecom.at>
Acked-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Johannes Sixt authored and Junio C Hamano committed Jun 6, 2007
1 parent 2766ce2 commit 3520e1e
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions git-filter-branch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,8 @@ USAGE="git-filter-branch [-d TEMPDIR] [FILTERS] DESTBRANCH [REV-RANGE]"

map()
{
[ -r "$workdir/../map/$1" ] || return 1
# if it was not rewritten, take the original
test -r "$workdir/../map/$1" || echo "$1"
cat "$workdir/../map/$1"
}

Expand Down Expand Up @@ -347,14 +348,9 @@ while read commit; do

parentstr=
for parent in $(get_parents $commit); do
if [ -r "../map/$parent" ]; then
for reparent in $(cat "../map/$parent"); do
parentstr="$parentstr -p $reparent"
done
else
# if it was not rewritten, take the original
parentstr="$parentstr -p $parent"
fi
for reparent in $(map "$parent"); do
parentstr="$parentstr -p $reparent"
done
done
if [ "$filter_parent" ]; then
parentstr="$(echo "$parentstr" | eval "$filter_parent")"
Expand Down

0 comments on commit 3520e1e

Please sign in to comment.