git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] filter-branch: Simplify parent computation.
@ 2007-06-08 21:28 Johannes Sixt
  2007-06-08 21:29 ` Johannes Schindelin
  2007-06-09 20:44 ` Junio C Hamano
  0 siblings, 2 replies; 4+ messages in thread
From: Johannes Sixt @ 2007-06-08 21:28 UTC (permalink / raw)
  To: git; +Cc: Johannes Schindelin

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

diff --git a/git-filter-branch.sh b/git-filter-branch.sh
index 4990729..4ef4570 100755
--- a/git-filter-branch.sh
+++ b/git-filter-branch.sh
@@ -229,17 +229,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=
@@ -332,18 +321,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 "\rRewriting commits... ($i/$commits)"
 
@@ -377,7 +367,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
@@ -398,7 +388,7 @@ while read commit; do
 		done > ../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
 '')
-- 
1.5.2

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/2] filter-branch: Simplify parent computation.
  2007-06-08 21:28 [PATCH 1/2] filter-branch: Simplify parent computation Johannes Sixt
@ 2007-06-08 21:29 ` Johannes Schindelin
  2007-06-09 20:44 ` Junio C Hamano
  1 sibling, 0 replies; 4+ messages in thread
From: Johannes Schindelin @ 2007-06-08 21:29 UTC (permalink / raw)
  To: Johannes Sixt; +Cc: git

Hi,

Acked-by: Johannes Schindelin <johannes.schindelin@gmx.de>

for both patches. They look obviously correct to me.

Ciao,
Dscho

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/2] filter-branch: Simplify parent computation.
  2007-06-08 21:28 [PATCH 1/2] filter-branch: Simplify parent computation Johannes Sixt
  2007-06-08 21:29 ` Johannes Schindelin
@ 2007-06-09 20:44 ` Junio C Hamano
  2007-06-10  7:14   ` Johannes Schindelin
  1 sibling, 1 reply; 4+ messages in thread
From: Junio C Hamano @ 2007-06-09 20:44 UTC (permalink / raw)
  To: Johannes Sixt; +Cc: git, Johannes Schindelin

Johannes Sixt <johannes.sixt@telecom.at> writes:

> @@ -332,18 +321,19 @@ mkdir ../map # map old->new commit ids for rewriting 
> parents
>  

Crap.  Why is this patch line-wrapped X-<.

> ... 
>  i=0
> -while read commit; do
> +while read commit parents; do
>  	i=$(($i+1))
>  	printf "\rRewriting commits... ($i/$commits)"
>  

Crap.  Where did that "\rRewriting commits..." come from?
The other Johannes had the same in his patch.

> @@ -398,7 +388,7 @@ while read commit; do
>  		done > ../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
>  '')

Crap.  I seem to have "tee" there that stores them to ../map/$commit.

Anyway, I've manually fixed up the offending three patches (two
from you and one from the other Johannes) and pushed the results
out on 'next'.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/2] filter-branch: Simplify parent computation.
  2007-06-09 20:44 ` Junio C Hamano
@ 2007-06-10  7:14   ` Johannes Schindelin
  0 siblings, 0 replies; 4+ messages in thread
From: Johannes Schindelin @ 2007-06-10  7:14 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Johannes Sixt, git

Hi,

On Sat, 9 Jun 2007, Junio C Hamano wrote:

> Anyway, I've manually fixed up the offending three patches (two from you 
> and one from the other Johannes) and pushed the results out on 'next'.

Sorry. I guess we were just beaming patches back and forth, applying them 
in our local repos, and working from there.

I promise to try better.

Ciao,
Dscho

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2007-06-10  7:17 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-06-08 21:28 [PATCH 1/2] filter-branch: Simplify parent computation Johannes Sixt
2007-06-08 21:29 ` Johannes Schindelin
2007-06-09 20:44 ` Junio C Hamano
2007-06-10  7:14   ` Johannes Schindelin

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).