git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Johannes Sixt <johannes.sixt@telecom.at>
To: git@vger.kernel.org, johannes.schindelin@gmx.de
Cc: Johannes Sixt <johannes.sixt@telecom.at>
Subject: [PATCH] filter-branch: also don't fail in map() if a commit cannot be mapped
Date: Wed,  6 Jun 2007 17:36:31 +0200	[thread overview]
Message-ID: <1181144191777-git-send-email-johannes.sixt@telecom.at> (raw)
In-Reply-To: <Pine.LNX.4.64.0706051537360.4046@racer.site>

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>
---
 git-filter-branch.sh |   14 +++++---------
 1 files changed, 5 insertions(+), 9 deletions(-)

diff --git a/git-filter-branch.sh b/git-filter-branch.sh
index fbbb044..9e12a6c 100644
--- a/git-filter-branch.sh
+++ b/git-filter-branch.sh
@@ -189,7 +189,8 @@ USAGE="git-filter-branch [-d TEMPDIR] [-r STARTREV]... [-k KEEPREV]... [-s SRCBR
 
 map()
 {
-	[ -r "$workdir/../map/$1" ] || return 1
+	# if it was not rewritten, take the original
+	[ -r "$workdir/../map/$1" ] || echo "$1"
 	cat "$workdir/../map/$1"
 }
 
@@ -362,14 +363,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")"
-- 
1.5.2.1.120.gd732

  parent reply	other threads:[~2007-06-06 15:36 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-06-03  0:31 [PATCH] Add git-filter-branch Johannes Schindelin
2007-06-03  0:46 ` Jakub Narebski
2007-06-03  0:50   ` Johannes Schindelin
2007-06-03 10:28     ` Jakub Narebski
2007-06-03 18:36       ` Steven Grimm
2007-06-03 23:07       ` Johannes Schindelin
2007-06-05 10:18     ` Jonas Fonseca
2007-06-05 10:26       ` David Kastrup
2007-06-05 10:30       ` Junio C Hamano
2007-06-05 10:34         ` Jonas Fonseca
2007-06-05 13:55           ` Johannes Schindelin
2007-06-06 15:24           ` [PATCH] filter-branch: use $(($i+1)) instead of $((i+1)) Johannes Schindelin
2007-06-04  7:18 ` [PATCH] Add git-filter-branch Johannes Sixt
2007-06-04  7:59   ` Johannes Sixt
2007-06-04 16:11   ` Johannes Schindelin
2007-06-04 16:34     ` Johannes Sixt
2007-06-04 17:55       ` Johannes Schindelin
2007-06-05  7:01         ` Johannes Sixt
2007-06-05 15:58           ` Johannes Schindelin
2007-06-06  7:43             ` Johannes Sixt
2007-06-06  8:17               ` Junio C Hamano
2007-06-06 15:00               ` Johannes Schindelin
2007-06-06 15:22                 ` Johannes Sixt
2007-06-06 17:59                   ` Johannes Schindelin
2007-06-06 15:36             ` Johannes Sixt [this message]
2007-06-06 17:50               ` [PATCH] filter-branch: also don't fail in map() if a commit cannot be mapped Johannes Schindelin
2007-06-06 18:38                 ` [PATCH v2] " Johannes Sixt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1181144191777-git-send-email-johannes.sixt@telecom.at \
    --to=johannes.sixt@telecom.at \
    --cc=git@vger.kernel.org \
    --cc=johannes.schindelin@gmx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).