public inbox for git@vger.kernel.org 
 help / color / mirror / Atom feed
From: Johannes Sixt <J.Sixt@eudaptics•com>
To: Johannes Schindelin <Johannes.Schindelin@gmx•de>
Cc: git@vger•kernel.org
Subject: Re: [PATCH] Add git-filter-branch
Date: Wed, 06 Jun 2007 09:43:41 +0200	[thread overview]
Message-ID: <466665AD.CF5B85DF@eudaptics.com> (raw)
In-Reply-To: Pine.LNX.4.64.0706051537360.4046@racer.site

Johannes Schindelin wrote:
> Okay, then. Are you okay with keeping the same options? (See proposed
> patch below.)

I can live with it. But what do you think of this in addtion? It
replaces -k, -r, -s in favor of rev-list arguments.

> Just out of curiousity, do you have any timing data?

I did one test run through 8118 commits which took 18 minutes. But it
turns out that I have a buglet here in git-commit-tree, which would
not accept committer dates before 2000-1-1 00:00:01 UTC, but since the
first commit is from 1999, this test rewrote the entire history, which
was not intended.

--- 8< ---
From: Johannes Sixt <johannes.sixt@telecom•at>

filter-branch: Use rev-list arguments to specify revision ranges.

A subset of commits in a branch used to be specified by options (-k, -r)
as well as the branch tip itself (-s). It is more natural (for git users)
to specify revision ranges like 'master..next' instead. This makes it so.
If no range is specified it defaults to 'HEAD'.

As a consequence, the new name of the filtered branch must be the first
non-option argument. All remaining arguments are passed to 'git rev-list'
unmodified.

The tip of the branch that gets filtered is implied: It is the first
commit that git rev-list would print for the specified range.

Signed-off-by: Johannes Sixt <johannes.sixt@telecom•at>
---
 git-filter-branch.sh     |   39 ++++++++++++---------------------------
 t/t7003-filter-branch.sh |    2 +-
 2 files changed, 13 insertions(+), 28 deletions(-)

diff --git a/git-filter-branch.sh b/git-filter-branch.sh
index 9e12a6c..190a492 100644
--- a/git-filter-branch.sh
+++ b/git-filter-branch.sh
@@ -42,15 +42,6 @@
 #	does this in the '.git-rewrite/' directory but you can override
 #	that choice by this parameter.
 #
-# -r STARTREV:: The commit id to start the rewrite at
-#	Normally, the command will rewrite the entire history. If you
-#	pass this argument, though, this will be the first commit it
-#	will rewrite and keep the previous commits intact.
-#
-# -k KEEPREV:: A commit id until which _not_ to rewrite history
-#	If you pass this argument, this commit and all of its
-#	predecessors are kept intact.
-#
 # Filters
 # ~~~~~~~
 # The filters are applied in the order as listed below. The COMMAND
@@ -164,27 +155,31 @@
 # and all children of the merge will become merge commits with P1,P2
 # as their parents instead of the merge commit.
 #
-# To restrict rewriting to only part of the history, use -r or -k or both.
+# To restrict rewriting to only part of the history, specify a revision
+# range in addition to the new branch name. The new branch name will
+# point to the top-most revision that a 'git rev-list' of this range
+# will print.
+#
 # Consider this history:
 #
 #	     D--E--F--G--H
 #	    /     /
 #	A--B-----C
 #
-# To rewrite only commits F,G,H, use:
+# To rewrite commits D,E,F,G,H, use:
 #
-#	git-filter-branch -r F ...
+#	git-filter-branch ... new-H C..H
 #
 # To rewrite commits E,F,G,H, use one of these:
 #
-#	git-filter-branch -r E -k C ...
-#	git-filter-branch -k D -k C ...
+#	git-filter-branch ... new-H C..H --not D
+#	git-filter-branch ... new-H D..H --not C
 
 # Testsuite: TODO
 
 set -e
 
-USAGE="git-filter-branch [-d TEMPDIR] [-r STARTREV]... [-k KEEPREV]... [-s SRCBRANCH] [FILTERS] DESTBRANCH"
+USAGE="git-filter-branch [-d TEMPDIR] [FILTERS] DESTBRANCH [REV-RANGE]"
 . git-sh-setup
 
 map()
@@ -233,7 +228,6 @@ get_parents () {
 }
 
 tempdir=.git-rewrite
-unchanged=" "
 filter_env=
 filter_tree=
 filter_index=
@@ -241,7 +235,6 @@ filter_parent=
 filter_msg=cat
 filter_commit='git-commit-tree "$@"'
 filter_tag_name=
-srcbranch=HEAD
 while case "$#" in 0) usage;; esac
 do
 	case "$1" in
@@ -266,12 +259,6 @@ do
 	-d)
 		tempdir="$OPTARG"
 		;;
-	-r)
-		unchanged="$(get_parents "$OPTARG") $unchanged"
-		;;
-	-k)
-		unchanged="$(git-rev-parse "$OPTARG"^{commit}) $unchanged"
-		;;
 	--env-filter)
 		filter_env="$OPTARG"
 		;;
@@ -293,9 +280,6 @@ do
 	--tag-name-filter)
 		filter_tag_name="$OPTARG"
 		;;
-	-s)
-		srcbranch="$OPTARG"
-		;;
 	*)
 		usage
 		;;
@@ -303,6 +287,7 @@ do
 done
 
 dstbranch="$1"
+shift
 test -n "$dstbranch" || die "missing branch name"
 git-show-ref "refs/heads/$dstbranch" 2> /dev/null &&
 	die "branch $dstbranch already exists"
@@ -328,7 +313,7 @@ ret=0
 
 mkdir ../map # map old->new commit ids for rewriting parents
 
-git-rev-list --reverse --topo-order $srcbranch --not $unchanged >../revs
+git-rev-list --reverse --topo-order --default HEAD "$@" >../revs
 commits=$(cat ../revs | wc -l | tr -d " ")
 
 test $commits -eq 0 && die "Found nothing to rewrite"
diff --git a/t/t7003-filter-branch.sh b/t/t7003-filter-branch.sh
index 520963a..89b405b 100755
--- a/t/t7003-filter-branch.sh
+++ b/t/t7003-filter-branch.sh
@@ -46,7 +46,7 @@ test_expect_success 'test that the file was renamed' '
 
 git tag oldD H3~4
 test_expect_success 'rewrite one branch, keeping a side branch' '
-	git-filter-branch --tree-filter "mv b boh || :" -k D -s oldD modD
+	git-filter-branch --tree-filter "mv b boh || :" modD D..oldD
 '
 
 test_expect_success 'common ancestor is still common (unchanged)' '
-- 
1.5.2.1.114.gc6c36

  reply	other threads:[~2007-06-06  7:43 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 [this message]
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             ` [PATCH] filter-branch: also don't fail in map() if a commit cannot be mapped Johannes Sixt
2007-06-06 17:50               ` 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=466665AD.CF5B85DF@eudaptics.com \
    --to=j.sixt@eudaptics$(echo .)com \
    --cc=Johannes.Schindelin@gmx$(echo .)de \
    --cc=git@vger$(echo .)kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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