@matheusbsbs / matheus-bagliano / commits / 7ec344d802
Fork 0

filter-branch: retire --remap-to-ancestor

We can be clever and know by ourselves when we need the behavior implied by "--remap-to-ancestor". No need to encumber users by having them exposed to it as a tunable. (Option kept for backward compatibility, but it's now a no-op.) Signed-off-by: Csaba Henk <csaba@gluster.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Csaba Henk committed Aug 27, 2010 at 20:44 UTC 7ec344d802970782036146e29ba2213e86d49fe1
3 files changed +40 -14
Documentation/git-filter-branch.txt
+13 -13
@@ -159,18 +159,7 @@ to other tags will be rewritten to point to the underlying commit.
159 --subdirectory-filter <directory>::
160 Only look at the history which touches the given subdirectory.
161 The result will contain that directory (and only that) as its
162 - project root. Implies --remap-to-ancestor.
163 -
164 ---remap-to-ancestor::
165 - Rewrite refs to the nearest rewritten ancestor instead of
166 - ignoring them.
167 -+
168 -Normally, positive refs on the command line are only changed if the
169 -commit they point to was rewritten. However, you can limit the extent
170 -of this rewriting by using linkgit:rev-list[1] arguments, e.g., path
171 -limiters. Refs pointing to such excluded commits would then normally
172 -be ignored. With this option, they are instead rewritten to point at
173 -the nearest ancestor that was not excluded.
162 + project root. Implies <<Remap_to_ancestor>>.
163
164 --prune-empty::
165 Some kind of filters will generate empty commits, that left the tree
@@ -204,7 +193,18 @@ the nearest ancestor that was not excluded.
193 Arguments for 'git rev-list'. All positive refs included by
194 these options are rewritten. You may also specify options
195 such as '--all', but you must use '--' to separate them from
207 - the 'git filter-branch' options.
196 + the 'git filter-branch' options. Implies <<Remap_to_ancestor>>.
197 +
198 +
199 +[[Remap_to_ancestor]]
200 +Remap to ancestor
201 +~~~~~~~~~~~~~~~~~
202 +
203 +By using linkgit:rev-list[1] arguments, e.g., path limiters, you can limit the
204 +set of revisions which get rewritten. However, positive refs on the command
205 +line are distinguished: we don't let them be excluded by such limiters. For
206 +this purpose, they are instead rewritten to point at the nearest ancestor that
207 +was not excluded.
208
209
210 Examples
git-filter-branch.sh
+9 -1
@@ -139,6 +139,7 @@ do
139 continue
140 ;;
141 --remap-to-ancestor)
142 + # deprecated ($remap_to_ancestor is set now automatically)
143 shift
144 remap_to_ancestor=t
145 continue
@@ -265,7 +266,14 @@ mkdir ../map || die "Could not create map/ directory"
266
267 # we need "--" only if there are no path arguments in $@
268 nonrevs=$(git rev-parse --no-revs "$@") || exit
268 -test -z "$nonrevs" && dashdash=-- || dashdash=
269 +if test -z "$nonrevs"
270 +then
271 + dashdash=--
272 +else
273 + dashdash=
274 + remap_to_ancestor=t
275 +fi
276 +
277 rev_args=$(git rev-parse --revs-only "$@")
278
279 case "$filter_subdir" in
t/t7003-filter-branch.sh
+18
@@ -307,6 +307,24 @@ test_expect_success '--remap-to-ancestor with filename filters' '
307 test $orig_invariant = $(git rev-parse invariant)
308 '
309
310 +test_expect_success 'automatic remapping to ancestor with filename filters' '
311 + git checkout master &&
312 + git reset --hard A &&
313 + test_commit add-foo2 foo 1 &&
314 + git branch moved-foo2 &&
315 + test_commit add-bar2 bar a &&
316 + git branch invariant2 &&
317 + orig_invariant=$(git rev-parse invariant2) &&
318 + git branch moved-bar2 &&
319 + test_commit change-foo2 foo 2 &&
320 + git filter-branch -f \
321 + moved-foo2 moved-bar2 A..master \
322 + -- -- foo &&
323 + test $(git rev-parse moved-foo2) = $(git rev-parse moved-bar2) &&
324 + test $(git rev-parse moved-foo2) = $(git rev-parse master^) &&
325 + test $orig_invariant = $(git rev-parse invariant2)
326 +'
327 +
328 test_expect_success 'setup submodule' '
329 rm -fr ?* .git &&
330 git init &&