{"thread":{"id":"24866","subject":"[PATCH] filter-branch: retire --remap-to-ancestor","startedAt":"2010-08-26T09:22:33Z","lastAt":"2010-08-27T20:44:56Z","messageCount":3,"participants":["Csaba Henk","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"149058","messageId":"20100826092233.GA32617@acharya.in.gluster.com","threadId":"24866","inReplyTo":null,"subject":"[PATCH] filter-branch: retire --remap-to-ancestor","fromName":"Csaba Henk","fromEmail":"csaba@gluster.com","sentAt":"2010-08-26T09:22:33Z","receivedAt":"2010-08-26T09:22:33Z","isPatch":true,"sender":{"key":"csaba@gluster.com","avatar":"https://avatars.githubusercontent.com/u/43937?v=4"},"body":"We can be clever and know by ourselves when we need the behavior\nimplied by \"--remap-to-ancestor\". No need to encumber users by having\nthem exposed to it as a tunable.\n---\n git-filter-branch.sh     |   14 ++++++++------\n t/t7003-filter-branch.sh |    4 ++--\n 2 files changed, 10 insertions(+), 8 deletions(-)\n\ndiff --git a/git-filter-branch.sh b/git-filter-branch.sh\nindex 88fb0f0..fd5caaa 100755\n--- a/git-filter-branch.sh\n+++ b/git-filter-branch.sh\n@@ -138,11 +138,6 @@ do\n \t\tforce=t\n \t\tcontinue\n \t\t;;\n-\t--remap-to-ancestor)\n-\t\tshift\n-\t\tremap_to_ancestor=t\n-\t\tcontinue\n-\t\t;;\n \t--prune-empty)\n \t\tshift\n \t\tprune_empty=t\n@@ -265,7 +260,14 @@ mkdir ../map || die \"Could not create map/ directory\"\n \n # we need \"--\" only if there are no path arguments in $@\n nonrevs=$(git rev-parse --no-revs \"$@\") || exit\n-test -z \"$nonrevs\" && dashdash=-- || dashdash=\n+if test -z \"$nonrevs\"\n+then\n+\tdashdash=--\n+else\n+\tdashdash=\n+\tremap_to_ancestor=t\n+fi\n+\n rev_args=$(git rev-parse --revs-only \"$@\")\n \n case \"$filter_subdir\" in\ndiff --git a/t/t7003-filter-branch.sh b/t/t7003-filter-branch.sh\nindex 2c55801..486c453 100755\n--- a/t/t7003-filter-branch.sh\n+++ b/t/t7003-filter-branch.sh\n@@ -289,7 +289,7 @@ test_expect_success 'Prune empty commits' '\n \ttest_cmp expect actual\n '\n \n-test_expect_success '--remap-to-ancestor with filename filters' '\n+test_expect_success 'filename filters work even if the given files are not changed in branch head' '\n \tgit checkout master &&\n \tgit reset --hard A &&\n \ttest_commit add-foo foo 1 &&\n@@ -299,7 +299,7 @@ test_expect_success '--remap-to-ancestor with filename filters' '\n \torig_invariant=$(git rev-parse invariant) &&\n \tgit branch moved-bar &&\n \ttest_commit change-foo foo 2 &&\n-\tgit filter-branch -f --remap-to-ancestor \\\n+\tgit filter-branch -f \\\n \t\tmoved-foo moved-bar A..master \\\n \t\t-- -- foo &&\n \ttest $(git rev-parse moved-foo) = $(git rev-parse moved-bar) &&\n-- \n1.7.2.2\n"},{"id":"149071","messageId":"7vtymhl2a8.fsf@alter.siamese.dyndns.org","threadId":"24866","inReplyTo":"20100826092233.GA32617@acharya.in.gluster.com","subject":"Re: [PATCH] filter-branch: retire --remap-to-ancestor","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2010-08-26T17:19:43Z","receivedAt":"2010-08-26T17:19:43Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Csaba Henk <csaba@gluster.com> writes:\n\n> We can be clever and know by ourselves when we need the behavior\n> implied by \"--remap-to-ancestor\". No need to encumber users by having\n> them exposed to it as a tunable.\n> ---\n\nSign-off?\n\n> diff --git a/git-filter-branch.sh b/git-filter-branch.sh\n> index 88fb0f0..fd5caaa 100755\n> --- a/git-filter-branch.sh\n> +++ b/git-filter-branch.sh\n> @@ -138,11 +138,6 @@ do\n>  \t\tforce=t\n>  \t\tcontinue\n>  \t\t;;\n> -\t--remap-to-ancestor)\n> -\t\tshift\n> -\t\tremap_to_ancestor=t\n> -\t\tcontinue\n> -\t\t;;\n\nThis is not friendly to people who already wrote their own scripts and/or\ntrained their fingers to use this option.  It would be better to just\naccept the option silently and do nothing.  Even better, do not touch this\npart at all, so that people can ask for this option when there is no\npathspec (as far as I can see, there is no harm in doing so).\n\n> @@ -265,7 +260,14 @@ mkdir ../map || die \"Could not create map/ directory\"\n>  \n>  # we need \"--\" only if there are no path arguments in $@\n>  nonrevs=$(git rev-parse --no-revs \"$@\") || exit\n> -test -z \"$nonrevs\" && dashdash=-- || dashdash=\n> +if test -z \"$nonrevs\"\n> +then\n> +\tdashdash=--\n> +else\n> +\tdashdash=\n> +\tremap_to_ancestor=t\n> +fi\n\nThe above is fine.\n\nIf you were paranoid, you could make this default assignment conditional,\ni.e.\n\n\t: ${remap_to_ancestor:=t}\n\nwhich would then allow people to say --no-remap-to-ancestor when using\npathspecs (for whatever reason), if you add:\n\n\t--no-remap-to-ancestor)\n\t\tshift\n                remap_to_ancestor=f\n\t\tcontinue\n                ;;\n\nin the command line parser loop.  You would need to change the remapping\nlogic to trigger when $remap_to_ancestor is set to 't' if you did so.\n\nBut I don't think the paranoia is necessary here.\n\n> diff --git a/t/t7003-filter-branch.sh b/t/t7003-filter-branch.sh\n> index 2c55801..486c453 100755\n> --- a/t/t7003-filter-branch.sh\n> +++ b/t/t7003-filter-branch.sh\n> @@ -289,7 +289,7 @@ test_expect_success 'Prune empty commits' '\n>  \ttest_cmp expect actual\n>  '\n>  \n> -test_expect_success '--remap-to-ancestor with filename filters' '\n> +test_expect_success 'filename filters work even if the given files are not changed in branch head' '\n>  \tgit checkout master &&\n>  \tgit reset --hard A &&\n>  \ttest_commit add-foo foo 1 &&\n> @@ -299,7 +299,7 @@ test_expect_success '--remap-to-ancestor with filename filters' '\n>  \torig_invariant=$(git rev-parse invariant) &&\n>  \tgit branch moved-bar &&\n>  \ttest_commit change-foo foo 2 &&\n> -\tgit filter-branch -f --remap-to-ancestor \\\n> +\tgit filter-branch -f \\\n>  \t\tmoved-foo moved-bar A..master \\\n>  \t\t-- -- foo &&\n>  \ttest $(git rev-parse moved-foo) = $(git rev-parse moved-bar) &&\n\nThis is good, but I think it is better if the same is tested with and\nwithout the option (iow, add a test without --remap that expects the same\nresult, keeping the existing one with --remap intact).\n\nThanks.\n"},{"id":"149143","messageId":"i59848$vtg$2@dough.gmane.org","threadId":"24866","inReplyTo":"20100826092233.GA32617@acharya.in.gluster.com","subject":"[PATCH v2] filter-branch: retire --remap-to-ancestor","fromName":"Csaba Henk","fromEmail":"csaba@gluster.com","sentAt":"2010-08-27T20:44:56Z","receivedAt":"2010-08-27T20:44:56Z","isPatch":true,"sender":{"key":"csaba@gluster.com","avatar":"https://avatars.githubusercontent.com/u/43937?v=4"},"body":"We can be clever and know by ourselves when we need the behavior\nimplied by \"--remap-to-ancestor\". No need to encumber users by having\nthem exposed to it as a tunable. (Option kept for backward compatibility,\nbut it's now a no-op.)\n\nSigned-off-by: Csaba Henk <csaba@gluster.com>\n---\n Documentation/git-filter-branch.txt |   26 +++++++++++++-------------\n git-filter-branch.sh                |   10 +++++++++-\n t/t7003-filter-branch.sh            |   18 ++++++++++++++++++\n 3 files changed, 40 insertions(+), 14 deletions(-)\n\ndiff --git a/Documentation/git-filter-branch.txt b/Documentation/git-filter-branch.txt\nindex 020028c..7357c88 100644\n--- a/Documentation/git-filter-branch.txt\n+++ b/Documentation/git-filter-branch.txt\n@@ -159,18 +159,7 @@ to other tags will be rewritten to point to the underlying commit.\n --subdirectory-filter <directory>::\n \tOnly look at the history which touches the given subdirectory.\n \tThe result will contain that directory (and only that) as its\n-\tproject root.  Implies --remap-to-ancestor.\n-\n---remap-to-ancestor::\n-\tRewrite refs to the nearest rewritten ancestor instead of\n-\tignoring them.\n-+\n-Normally, positive refs on the command line are only changed if the\n-commit they point to was rewritten.  However, you can limit the extent\n-of this rewriting by using linkgit:rev-list[1] arguments, e.g., path\n-limiters.  Refs pointing to such excluded commits would then normally\n-be ignored.  With this option, they are instead rewritten to point at\n-the nearest ancestor that was not excluded.\n+\tproject root. Implies <<Remap_to_ancestor>>.\n \n --prune-empty::\n \tSome kind of filters will generate empty commits, that left the tree\n@@ -204,7 +193,18 @@ the nearest ancestor that was not excluded.\n \tArguments for 'git rev-list'.  All positive refs included by\n \tthese options are rewritten.  You may also specify options\n \tsuch as '--all', but you must use '--' to separate them from\n-\tthe 'git filter-branch' options.\n+\tthe 'git filter-branch' options. Implies <<Remap_to_ancestor>>.\n+\n+\n+[[Remap_to_ancestor]]\n+Remap to ancestor\n+~~~~~~~~~~~~~~~~~\n+\n+By using linkgit:rev-list[1] arguments, e.g., path limiters, you can limit the\n+set of revisions which get rewritten. However, positive refs on the command\n+line are distinguished: we don't let them be excluded by such limiters. For\n+this purpose, they are instead rewritten to point at the nearest ancestor that\n+was not excluded.\n \n \n Examples\ndiff --git a/git-filter-branch.sh b/git-filter-branch.sh\nindex 88fb0f0..962a93b 100755\n--- a/git-filter-branch.sh\n+++ b/git-filter-branch.sh\n@@ -139,6 +139,7 @@ do\n \t\tcontinue\n \t\t;;\n \t--remap-to-ancestor)\n+\t\t# deprecated ($remap_to_ancestor is set now automatically)\n \t\tshift\n \t\tremap_to_ancestor=t\n \t\tcontinue\n@@ -265,7 +266,14 @@ mkdir ../map || die \"Could not create map/ directory\"\n \n # we need \"--\" only if there are no path arguments in $@\n nonrevs=$(git rev-parse --no-revs \"$@\") || exit\n-test -z \"$nonrevs\" && dashdash=-- || dashdash=\n+if test -z \"$nonrevs\"\n+then\n+\tdashdash=--\n+else\n+\tdashdash=\n+\tremap_to_ancestor=t\n+fi\n+\n rev_args=$(git rev-parse --revs-only \"$@\")\n \n case \"$filter_subdir\" in\ndiff --git a/t/t7003-filter-branch.sh b/t/t7003-filter-branch.sh\nindex 2c55801..12aa63e 100755\n--- a/t/t7003-filter-branch.sh\n+++ b/t/t7003-filter-branch.sh\n@@ -307,6 +307,24 @@ test_expect_success '--remap-to-ancestor with filename filters' '\n \ttest $orig_invariant = $(git rev-parse invariant)\n '\n \n+test_expect_success 'automatic remapping to ancestor with filename filters' '\n+\tgit checkout master &&\n+\tgit reset --hard A &&\n+\ttest_commit add-foo2 foo 1 &&\n+\tgit branch moved-foo2 &&\n+\ttest_commit add-bar2 bar a &&\n+\tgit branch invariant2 &&\n+\torig_invariant=$(git rev-parse invariant2) &&\n+\tgit branch moved-bar2 &&\n+\ttest_commit change-foo2 foo 2 &&\n+\tgit filter-branch -f \\\n+\t\tmoved-foo2 moved-bar2 A..master \\\n+\t\t-- -- foo &&\n+\ttest $(git rev-parse moved-foo2) = $(git rev-parse moved-bar2) &&\n+\ttest $(git rev-parse moved-foo2) = $(git rev-parse master^) &&\n+\ttest $orig_invariant = $(git rev-parse invariant2)\n+'\n+\n test_expect_success 'setup submodule' '\n \trm -fr ?* .git &&\n \tgit init &&\n-- \n1.7.2.2\n"}]}