summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 9840906)
raw | patch | inline | side by side (parent: 9840906)
author | Johannes Sixt <johannes.sixt@telecom.at> | |
Wed, 6 Jun 2007 07:43:41 +0000 (09:43 +0200) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Wed, 6 Jun 2007 19:49:16 +0000 (12:49 -0700) |
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>
Acked-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
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>
Acked-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
git-filter-branch.sh | patch | blob | history | |
t/t7003-filter-branch.sh | patch | blob | history |
diff --git a/git-filter-branch.sh b/git-filter-branch.sh
index f2b0e273ba993b6102066b6fd9e9c52096424037..29e0d027cae84c10055fe7383d9fbd000eba35ea 100755 (executable)
--- a/git-filter-branch.sh
+++ b/git-filter-branch.sh
# 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
# 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()
}
tempdir=.git-rewrite
-unchanged=" "
filter_env=
filter_tree=
filter_index=
filter_msg=cat
filter_commit='git-commit-tree "$@"'
filter_tag_name=
-srcbranch=HEAD
while case "$#" in 0) usage;; esac
do
case "$1" in
-d)
tempdir="$OPTARG"
;;
- -r)
- unchanged="$(get_parents "$OPTARG") $unchanged"
- ;;
- -k)
- unchanged="$(git-rev-parse "$OPTARG"^{commit}) $unchanged"
- ;;
--env-filter)
filter_env="$OPTARG"
;;
--tag-name-filter)
filter_tag_name="$OPTARG"
;;
- -s)
- srcbranch="$OPTARG"
- ;;
*)
usage
;;
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"
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"
index 6e2be5be0e55838b1c9e1f7426b3ba1cdbad1395..3739cb191d2c3875e201f4a110af57b444f4d3a1 100755 (executable)
--- a/t/t7003-filter-branch.sh
+++ b/t/t7003-filter-branch.sh
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)' '