{"thread":{"id":"12572","subject":"Re: [PATCH] Add test for filter-branch on a subdirectory that's been added and deleted and re-added","startedAt":"2008-03-08T11:50:07Z","lastAt":"2008-03-08T20:39:53Z","messageCount":7,"participants":["Kevin Ballard","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"299036","messageId":"1204977007-7267-3-git-send-email-kevin@sb.org","threadId":"12572","inReplyTo":null,"subject":"[PATCH] Add test for filter-branch on a subdirectory that's been added and deleted and re-added","fromName":"Kevin Ballard","fromEmail":"kevin@sb.org","sentAt":"2008-03-08T11:50:07Z","receivedAt":"2008-03-08T11:50:07Z","isPatch":true,"sender":{"key":"kevin@sb.org","avatar":"https://avatars.githubusercontent.com/u/714?v=4"},"body":"Add a currently-failing test for the case when git-filter-branch\nis run with the --subdirectory-filter referencing a folder that\nhas been added, deleted, and re-added. Such an action should work,\nbut as this test shows it ends up blowing up.\n---\n t/t7003-filter-branch.sh |   13 +++++++++++++\n 1 files changed, 13 insertions(+), 0 deletions(-)\n\ndiff --git a/t/t7003-filter-branch.sh b/t/t7003-filter-branch.sh\nindex 868babc..933157b 100755\n--- a/t/t7003-filter-branch.sh\n+++ b/t/t7003-filter-branch.sh\n@@ -179,4 +179,17 @@ test_expect_success 'Name needing quotes' '\n \n '\n \n+test_expect_success 'Subdirectory filter on folder with non-contiguous history' '\n+\tmkdir foo &&\n+\ttouch foo/bar &&\n+\tgit add foo &&\n+\tgit commit -m \"Adding foo\" &&\n+\tgit rm -r foo &&\n+\tgit commit -m \"Removing foo\" &&\n+\tmkdir foo &&\n+\ttouch foo/bar &&\n+\tgit commit -m \"Re-adding foo\" &&\n+\tgit filter-branch --subdirectory-filter foo\n+'\n+\n test_done\n-- \n1.5.4.3.487.g5a92\n\n"},{"id":"71414","messageId":"A766C00E-2A8B-4DAF-A8F4-9B99D6D18F3A@sb.org","threadId":"12572","inReplyTo":"1204977007-7267-3-git-send-email-kevin@sb.org","subject":"Re: [PATCH] Add test for filter-branch on a subdirectory that's been added and deleted and re-added","fromName":"Kevin Ballard","fromEmail":"kevin@sb.org","sentAt":"2008-03-08T11:52:05Z","receivedAt":"2008-03-08T11:52:05Z","isPatch":true,"sender":{"key":"kevin@sb.org","avatar":"https://avatars.githubusercontent.com/u/714?v=4"},"body":"Damnit, I just send those patches without the Signed-Off line. Should  \nI re-send, or is it acceptable to just say I'm signing off on these  \nand anyone is free to add my Signed-Off line when committing?\n\n-Kevin Ballard\n\nOn Mar 8, 2008, at 6:50 AM, Kevin Ballard wrote:\n\n> Add a currently-failing test for the case when git-filter-branch\n> is run with the --subdirectory-filter referencing a folder that\n> has been added, deleted, and re-added. Such an action should work,\n> but as this test shows it ends up blowing up.\n> ---\n> t/t7003-filter-branch.sh |   13 +++++++++++++\n> 1 files changed, 13 insertions(+), 0 deletions(-)\n>\n> diff --git a/t/t7003-filter-branch.sh b/t/t7003-filter-branch.sh\n> index 868babc..933157b 100755\n> --- a/t/t7003-filter-branch.sh\n> +++ b/t/t7003-filter-branch.sh\n> @@ -179,4 +179,17 @@ test_expect_success 'Name needing quotes' '\n>\n> '\n>\n> +test_expect_success 'Subdirectory filter on folder with non- \n> contiguous history' '\n> +\tmkdir foo &&\n> +\ttouch foo/bar &&\n> +\tgit add foo &&\n> +\tgit commit -m \"Adding foo\" &&\n> +\tgit rm -r foo &&\n> +\tgit commit -m \"Removing foo\" &&\n> +\tmkdir foo &&\n> +\ttouch foo/bar &&\n> +\tgit commit -m \"Re-adding foo\" &&\n> +\tgit filter-branch --subdirectory-filter foo\n> +'\n> +\n> test_done\n> -- \n> 1.5.4.3.487.g5a92\n>\n> --\n> To unsubscribe from this list: send the line \"unsubscribe git\" in\n> the body of a message to majordomo@vger.kernel.org\n> More majordomo info at  http://vger.kernel.org/majordomo-info.html\n\n-- \nKevin Ballard\nhttp://kevin.sb.org\nkevin@sb.org\nhttp://www.tildesoft.com\n\n\n"},{"id":"71428","messageId":"7vzlt9t5wr.fsf@gitster.siamese.dyndns.org","threadId":"12572","inReplyTo":"1204977007-7267-3-git-send-email-kevin@sb.org","subject":"Re: [PATCH] Add test for filter-branch on a subdirectory that's been added and deleted and re-added","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-03-08T18:41:24Z","receivedAt":"2008-03-08T18:41:24Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Kevin Ballard <kevin@sb.org> writes:\n\n> Add a currently-failing test for the case when git-filter-branch\n> is run with the --subdirectory-filter referencing a folder that\n> has been added, deleted, and re-added. Such an action should work,\n> but as this test shows it ends up blowing up.\n\nSuch a test is a very good incentive to the people involved in the failing\npart of the system to fix, and is greatly appreciated.  However,\n\n * please mark \"currently-failing\" test with \"test_expect_failure\";\n\n * please hint (after --- lines) if you will shortly be following up with\n   a fix patch yourself, or if you are only reporting a bug.\n\nI can fix-up and forge your Sign-off.\n\n> diff --git a/t/t7003-filter-branch.sh b/t/t7003-filter-branch.sh\n> index 868babc..933157b 100755\n> --- a/t/t7003-filter-branch.sh\n> +++ b/t/t7003-filter-branch.sh\n> @@ -179,4 +179,17 @@ test_expect_success 'Name needing quotes' '\n>  \n>  '\n>  \n> +test_expect_success 'Subdirectory filter on folder with non-contiguous history' '\n> +\tmkdir foo &&\n> +\ttouch foo/bar &&\n> +\tgit add foo &&\n> +\tgit commit -m \"Adding foo\" &&\n> +\tgit rm -r foo &&\n> +\tgit commit -m \"Removing foo\" &&\n> +\tmkdir foo &&\n> +\ttouch foo/bar &&\n> +\tgit commit -m \"Re-adding foo\" &&\n> +\tgit filter-branch --subdirectory-filter foo\n> +'\n> +\n>  test_done\n> -- \n> 1.5.4.3.487.g5a92\n>\n> --\n> To unsubscribe from this list: send the line \"unsubscribe git\" in\n> the body of a message to majordomo@vger.kernel.org\n> More majordomo info at  http://vger.kernel.org/majordomo-info.html\n"},{"id":"71429","messageId":"91DF7A2E-540B-4AD6-91B2-BDB0B04EFC71@sb.org","threadId":"12572","inReplyTo":"7vzlt9t5wr.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH] Add test for filter-branch on a subdirectory that's been added and deleted and re-added","fromName":"Kevin Ballard","fromEmail":"kevin@sb.org","sentAt":"2008-03-08T18:45:17Z","receivedAt":"2008-03-08T18:45:17Z","isPatch":true,"sender":{"key":"kevin@sb.org","avatar":"https://avatars.githubusercontent.com/u/714?v=4"},"body":"On Mar 8, 2008, at 1:41 PM, Junio C Hamano wrote:\n\n> Kevin Ballard <kevin@sb.org> writes:\n>\n>> Add a currently-failing test for the case when git-filter-branch\n>> is run with the --subdirectory-filter referencing a folder that\n>> has been added, deleted, and re-added. Such an action should work,\n>> but as this test shows it ends up blowing up.\n>\n> Such a test is a very good incentive to the people involved in the  \n> failing\n> part of the system to fix, and is greatly appreciated.  However,\n>\n> * please mark \"currently-failing\" test with \"test_expect_failure\";\n\nAhh, didn't know about that. In retrospect I should have been able to  \nguess, though.\n\n> * please hint (after --- lines) if you will shortly be following up  \n> with\n>   a fix patch yourself, or if you are only reporting a bug.\n\nAh. Yeah, I'm only reporting a bug. I don't know anything about how  \nthis stuff works, and the bug doesn't bite me, it bit someone else  \ninstead, I just thought it deserved to be documented somewhere as a  \nfailure.\n\n> I can fix-up and forge your Sign-off.\n\nThat would be great, thanks.\n\n>> diff --git a/t/t7003-filter-branch.sh b/t/t7003-filter-branch.sh\n>> index 868babc..933157b 100755\n>> --- a/t/t7003-filter-branch.sh\n>> +++ b/t/t7003-filter-branch.sh\n>> @@ -179,4 +179,17 @@ test_expect_success 'Name needing quotes' '\n>>\n>> '\n>>\n>> +test_expect_success 'Subdirectory filter on folder with non- \n>> contiguous history' '\n>> +\tmkdir foo &&\n>> +\ttouch foo/bar &&\n>> +\tgit add foo &&\n>> +\tgit commit -m \"Adding foo\" &&\n>> +\tgit rm -r foo &&\n>> +\tgit commit -m \"Removing foo\" &&\n>> +\tmkdir foo &&\n>> +\ttouch foo/bar &&\n>> +\tgit commit -m \"Re-adding foo\" &&\n>> +\tgit filter-branch --subdirectory-filter foo\n>> +'\n>> +\n>> test_done\n>> -- \n>> 1.5.4.3.487.g5a92\n>>\n>> --\n>> To unsubscribe from this list: send the line \"unsubscribe git\" in\n>> the body of a message to majordomo@vger.kernel.org\n>> More majordomo info at  http://vger.kernel.org/majordomo-info.html\n>\n\n-- \nKevin Ballard\nhttp://kevin.sb.org\nkevin@sb.org\nhttp://www.tildesoft.com\n\n\n"},{"id":"71433","messageId":"7vmyp9t1ut.fsf_-_@gitster.siamese.dyndns.org","threadId":"12572","inReplyTo":"91DF7A2E-540B-4AD6-91B2-BDB0B04EFC71@sb.org","subject":"Re* [PATCH] Add test for filter-branch on a subdirectory that's been added and deleted and re-added","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-03-08T20:08:58Z","receivedAt":"2008-03-08T20:08:58Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Kevin Ballard <kevin@sb.org> writes:\n\n> On Mar 8, 2008, at 1:41 PM, Junio C Hamano wrote:\n>\n>> Such a test is a very good incentive to the people involved in the\n>> failing\n>> part of the system to fix, and is greatly appreciated.  However,\n>>\n>> * please mark \"currently-failing\" test with \"test_expect_failure\";\n>\n> Ahh, didn't know about that. In retrospect I should have been able to\n> guess, though.\n>\n>> * please hint (after --- lines) if you will shortly be following up\n>> with\n>>   a fix patch yourself, or if you are only reporting a bug.\n>\n> Ah. Yeah, I'm only reporting a bug. I don't know anything about how\n> this stuff works, and the bug doesn't bite me, it bit someone else\n> instead, I just thought it deserved to be documented somewhere as a\n> failure.\n>\n>> I can fix-up and forge your Sign-off.\n>\n> That would be great, thanks.\n\nHeh, your test is broken.  You are not re-adding foo.\n\nHere is a fix.\n\n---\n\n git-filter-branch.sh     |   11 ++++++++++-\n t/t7003-filter-branch.sh |    5 ++++-\n 2 files changed, 14 insertions(+), 2 deletions(-)\n\ndiff --git a/git-filter-branch.sh b/git-filter-branch.sh\nindex 49e13f0..8382212 100755\n--- a/git-filter-branch.sh\n+++ b/git-filter-branch.sh\n@@ -252,7 +252,16 @@ while read commit parents; do\n \t\tgit read-tree -i -m $commit\n \t\t;;\n \t*)\n-\t\tgit read-tree -i -m $commit:\"$filter_subdir\"\n+\t\t# The commit may not have the subdirectory at all\n+\t\terr=$(git read-tree -i -m $commit:\"$filter_subdir\" 2>&1) || {\n+\t\t    if ! git rev-parse $commit:\"$filter_subdir\" 2>&1\n+\t\t\tthen\n+\t\t\t\trm -f \"$GIT_INDEX_FILE\"\n+\t\t\telse\n+\t\t\t\techo >&2 \"$err\"\n+\t\t\t\tfalse\n+\t\t\tfi\n+\t\t}\n \tesac || die \"Could not initialize the index\"\n \n \tGIT_COMMIT=$commit\ndiff --git a/t/t7003-filter-branch.sh b/t/t7003-filter-branch.sh\nindex 2ea8e3b..8f92fef 100755\n--- a/t/t7003-filter-branch.sh\n+++ b/t/t7003-filter-branch.sh\n@@ -188,8 +188,11 @@ test_expect_failure 'Subdirectory filter on folder with non-contiguous history'\n \tgit commit -m \"Removing foo\" &&\n \tmkdir foo &&\n \ttouch foo/bar &&\n+\tgit add foo &&\n \tgit commit -m \"Re-adding foo\" &&\n-\tgit filter-branch --subdirectory-filter foo\n+\n+\tgit filter-branch --subdirectory-filter foo &&\n+\ttest $(git rev-list master | wc -l) = 3\n '\n \n test_done\n"},{"id":"71435","messageId":"7vejalt12h.fsf@gitster.siamese.dyndns.org","threadId":"12572","inReplyTo":"91DF7A2E-540B-4AD6-91B2-BDB0B04EFC71@sb.org","subject":"Re: [PATCH] Add test for filter-branch on a subdirectory that's been added and deleted and re-added","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-03-08T20:25:58Z","receivedAt":"2008-03-08T20:25:58Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"This will hopefully be the final version.\n\n-- >8 --\nfilter-branch: handle \"disappearing tree\" case correctly in subdir filter\n\nThe subdirectory filter had a bug to notice that the commit in question\ndid not have anything in the path-limited part of the tree.  $commit:$path\ndoes not name an empty tree when $path does not appear in $commit.\n\nThis should fix it.  The additional test in t7003 is originally from Kevin\nBallard but with fixups.\n\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n\n * -f is needed because the previous one is about aborting the filter and\n    leaving the \"original\" namespace.\n\n git-filter-branch.sh     |   11 ++++++++++-\n t/t7003-filter-branch.sh |   24 ++++++++++++++++++++++++\n 2 files changed, 34 insertions(+), 1 deletions(-)\n\ndiff --git a/git-filter-branch.sh b/git-filter-branch.sh\nindex 49e13f0..010353a 100755\n--- a/git-filter-branch.sh\n+++ b/git-filter-branch.sh\n@@ -252,7 +252,16 @@ while read commit parents; do\n \t\tgit read-tree -i -m $commit\n \t\t;;\n \t*)\n-\t\tgit read-tree -i -m $commit:\"$filter_subdir\"\n+\t\t# The commit may not have the subdirectory at all\n+\t\terr=$(git read-tree -i -m $commit:\"$filter_subdir\" 2>&1) || {\n+\t\t\tif ! git rev-parse --verify $commit:\"$filter_subdir\" 2>/dev/null\n+\t\t\tthen\n+\t\t\t\trm -f \"$GIT_INDEX_FILE\"\n+\t\t\telse\n+\t\t\t\techo >&2 \"$err\"\n+\t\t\t\tfalse\n+\t\t\tfi\n+\t\t}\n \tesac || die \"Could not initialize the index\"\n \n \tGIT_COMMIT=$commit\ndiff --git a/t/t7003-filter-branch.sh b/t/t7003-filter-branch.sh\nindex 868babc..6e14bf1 100755\n--- a/t/t7003-filter-branch.sh\n+++ b/t/t7003-filter-branch.sh\n@@ -179,4 +179,28 @@ test_expect_success 'Name needing quotes' '\n \n '\n \n+test_expect_success 'Subdirectory filter with disappearing trees' '\n+\tgit reset --hard &&\n+\tgit checkout master &&\n+\n+\tmkdir foo &&\n+\ttouch foo/bar &&\n+\tgit add foo &&\n+\ttest_tick &&\n+\tgit commit -m \"Adding foo\" &&\n+\n+\tgit rm -r foo &&\n+\ttest_tick &&\n+\tgit commit -m \"Removing foo\" &&\n+\n+\tmkdir foo &&\n+\ttouch foo/bar &&\n+\tgit add foo &&\n+\ttest_tick &&\n+\tgit commit -m \"Re-adding foo\" &&\n+\n+\tgit filter-branch -f --subdirectory-filter foo &&\n+\ttest $(git rev-list master | wc -l) = 3\n+'\n+\n test_done\n"},{"id":"71437","messageId":"E6873C4A-ACCC-4E51-B32E-41F1AAA56339@sb.org","threadId":"12572","inReplyTo":"7vejalt12h.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH] Add test for filter-branch on a subdirectory that's been added and deleted and re-added","fromName":"Kevin Ballard","fromEmail":"kevin@sb.org","sentAt":"2008-03-08T20:39:53Z","receivedAt":"2008-03-08T20:39:53Z","isPatch":true,"sender":{"key":"kevin@sb.org","avatar":"https://avatars.githubusercontent.com/u/714?v=4"},"body":"On Mar 8, 2008, at 3:25 PM, Junio C Hamano wrote:\n\n> This will hopefully be the final version.\n\nAssuming that the lack of a GIT_INDEX_FILE doesn't break git-checkout- \nindex, git-diff-index, git-update-index, or anything that an --index- \nfilter might run (I assume it doesn't, but I didn't test all the  \nrelevant commands), then this looks fine by me.\n\n-Kevin\n\n>\n> -- >8 --\n> filter-branch: handle \"disappearing tree\" case correctly in subdir  \n> filter\n>\n> The subdirectory filter had a bug to notice that the commit in  \n> question\n> did not have anything in the path-limited part of the tree.  $commit: \n> $path\n> does not name an empty tree when $path does not appear in $commit.\n>\n> This should fix it.  The additional test in t7003 is originally from  \n> Kevin\n> Ballard but with fixups.\n>\n> Signed-off-by: Junio C Hamano <gitster@pobox.com>\n> ---\n>\n> * -f is needed because the previous one is about aborting the filter  \n> and\n>    leaving the \"original\" namespace.\n>\n> git-filter-branch.sh     |   11 ++++++++++-\n> t/t7003-filter-branch.sh |   24 ++++++++++++++++++++++++\n> 2 files changed, 34 insertions(+), 1 deletions(-)\n>\n> diff --git a/git-filter-branch.sh b/git-filter-branch.sh\n> index 49e13f0..010353a 100755\n> --- a/git-filter-branch.sh\n> +++ b/git-filter-branch.sh\n> @@ -252,7 +252,16 @@ while read commit parents; do\n> \t\tgit read-tree -i -m $commit\n> \t\t;;\n> \t*)\n> -\t\tgit read-tree -i -m $commit:\"$filter_subdir\"\n> +\t\t# The commit may not have the subdirectory at all\n> +\t\terr=$(git read-tree -i -m $commit:\"$filter_subdir\" 2>&1) || {\n> +\t\t\tif ! git rev-parse --verify $commit:\"$filter_subdir\" 2>/dev/null\n> +\t\t\tthen\n> +\t\t\t\trm -f \"$GIT_INDEX_FILE\"\n> +\t\t\telse\n> +\t\t\t\techo >&2 \"$err\"\n> +\t\t\t\tfalse\n> +\t\t\tfi\n> +\t\t}\n> \tesac || die \"Could not initialize the index\"\n>\n> \tGIT_COMMIT=$commit\n> diff --git a/t/t7003-filter-branch.sh b/t/t7003-filter-branch.sh\n> index 868babc..6e14bf1 100755\n> --- a/t/t7003-filter-branch.sh\n> +++ b/t/t7003-filter-branch.sh\n> @@ -179,4 +179,28 @@ test_expect_success 'Name needing quotes' '\n>\n> '\n>\n> +test_expect_success 'Subdirectory filter with disappearing trees' '\n> +\tgit reset --hard &&\n> +\tgit checkout master &&\n> +\n> +\tmkdir foo &&\n> +\ttouch foo/bar &&\n> +\tgit add foo &&\n> +\ttest_tick &&\n> +\tgit commit -m \"Adding foo\" &&\n> +\n> +\tgit rm -r foo &&\n> +\ttest_tick &&\n> +\tgit commit -m \"Removing foo\" &&\n> +\n> +\tmkdir foo &&\n> +\ttouch foo/bar &&\n> +\tgit add foo &&\n> +\ttest_tick &&\n> +\tgit commit -m \"Re-adding foo\" &&\n> +\n> +\tgit filter-branch -f --subdirectory-filter foo &&\n> +\ttest $(git rev-list master | wc -l) = 3\n> +'\n> +\n> test_done\n>\n\n-- \nKevin Ballard\nhttp://kevin.sb.org\nkevin@sb.org\nhttp://www.tildesoft.com\n\n\n"}]}