diff options
author | Junio C Hamano <gitster@pobox.com> | 2010-09-15 12:39:32 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2010-09-15 12:39:32 -0700 |
commit | 43d268e9dd5a454abc2e6ae676202773ffd54537 (patch) | |
tree | e096b12d724bec7b963e29a92f660a4fb98bf594 | |
parent | d42cb5804f9c52b88b6dfe709a659e31394ea2ae (diff) | |
parent | 7ec344d802970782036146e29ba2213e86d49fe1 (diff) | |
download | git-43d268e9dd5a454abc2e6ae676202773ffd54537.tar.gz git-43d268e9dd5a454abc2e6ae676202773ffd54537.tar.xz |
Merge branch 'ch/filter-branch-deprecate-remap-to-ancestor'
* ch/filter-branch-deprecate-remap-to-ancestor:
filter-branch: retire --remap-to-ancestor
-rw-r--r-- | Documentation/git-filter-branch.txt | 26 | ||||
-rwxr-xr-x | git-filter-branch.sh | 10 | ||||
-rwxr-xr-x | t/t7003-filter-branch.sh | 18 |
3 files changed, 40 insertions, 14 deletions
diff --git a/Documentation/git-filter-branch.txt b/Documentation/git-filter-branch.txt index 020028cf9..7357c8879 100644 --- a/Documentation/git-filter-branch.txt +++ b/Documentation/git-filter-branch.txt @@ -159,18 +159,7 @@ to other tags will be rewritten to point to the underlying commit. --subdirectory-filter <directory>:: Only look at the history which touches the given subdirectory. The result will contain that directory (and only that) as its - project root. Implies --remap-to-ancestor. - ---remap-to-ancestor:: - Rewrite refs to the nearest rewritten ancestor instead of - ignoring them. -+ -Normally, positive refs on the command line are only changed if the -commit they point to was rewritten. However, you can limit the extent -of this rewriting by using linkgit:rev-list[1] arguments, e.g., path -limiters. Refs pointing to such excluded commits would then normally -be ignored. With this option, they are instead rewritten to point at -the nearest ancestor that was not excluded. + project root. Implies <<Remap_to_ancestor>>. --prune-empty:: Some kind of filters will generate empty commits, that left the tree @@ -204,7 +193,18 @@ the nearest ancestor that was not excluded. Arguments for 'git rev-list'. All positive refs included by these options are rewritten. You may also specify options such as '--all', but you must use '--' to separate them from - the 'git filter-branch' options. + the 'git filter-branch' options. Implies <<Remap_to_ancestor>>. + + +[[Remap_to_ancestor]] +Remap to ancestor +~~~~~~~~~~~~~~~~~ + +By using linkgit:rev-list[1] arguments, e.g., path limiters, you can limit the +set of revisions which get rewritten. However, positive refs on the command +line are distinguished: we don't let them be excluded by such limiters. For +this purpose, they are instead rewritten to point at the nearest ancestor that +was not excluded. Examples diff --git a/git-filter-branch.sh b/git-filter-branch.sh index 88fb0f070..962a93b58 100755 --- a/git-filter-branch.sh +++ b/git-filter-branch.sh @@ -139,6 +139,7 @@ do continue ;; --remap-to-ancestor) + # deprecated ($remap_to_ancestor is set now automatically) shift remap_to_ancestor=t continue @@ -265,7 +266,14 @@ mkdir ../map || die "Could not create map/ directory" # we need "--" only if there are no path arguments in $@ nonrevs=$(git rev-parse --no-revs "$@") || exit -test -z "$nonrevs" && dashdash=-- || dashdash= +if test -z "$nonrevs" +then + dashdash=-- +else + dashdash= + remap_to_ancestor=t +fi + rev_args=$(git rev-parse --revs-only "$@") case "$filter_subdir" in diff --git a/t/t7003-filter-branch.sh b/t/t7003-filter-branch.sh index 2c55801ee..12aa63e7a 100755 --- a/t/t7003-filter-branch.sh +++ b/t/t7003-filter-branch.sh @@ -307,6 +307,24 @@ test_expect_success '--remap-to-ancestor with filename filters' ' test $orig_invariant = $(git rev-parse invariant) ' +test_expect_success 'automatic remapping to ancestor with filename filters' ' + git checkout master && + git reset --hard A && + test_commit add-foo2 foo 1 && + git branch moved-foo2 && + test_commit add-bar2 bar a && + git branch invariant2 && + orig_invariant=$(git rev-parse invariant2) && + git branch moved-bar2 && + test_commit change-foo2 foo 2 && + git filter-branch -f \ + moved-foo2 moved-bar2 A..master \ + -- -- foo && + test $(git rev-parse moved-foo2) = $(git rev-parse moved-bar2) && + test $(git rev-parse moved-foo2) = $(git rev-parse master^) && + test $orig_invariant = $(git rev-parse invariant2) +' + test_expect_success 'setup submodule' ' rm -fr ?* .git && git init && |