git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Add test for filter-branch on a subdirectory that's been added and deleted and re-added
@ 2008-02-25 19:45 Kevin Ballard
  0 siblings, 0 replies; 7+ messages in thread
From: Kevin Ballard @ 2008-02-25 19:45 UTC (permalink / raw)
  To: git, Junio C Hamano; +Cc: Kevin Ballard

---
 t/t7003-filter-branch.sh |   13 +++++++++++++
 1 files changed, 13 insertions(+), 0 deletions(-)

diff --git a/t/t7003-filter-branch.sh b/t/t7003-filter-branch.sh
index 868babc..9972343 100755
--- a/t/t7003-filter-branch.sh
+++ b/t/t7003-filter-branch.sh
@@ -179,4 +179,17 @@ test_expect_success 'Name needing quotes' '
 
 '
 
+test_expect_success 'Subdirectory filter on non-contiguous folder' '
+	mkdir foo &&
+	touch foo/bar &&
+	git add foo &&
+	git commit -m "Adding foo" &&
+	git rm -r foo &&
+	git commit -m "Removing foo" &&
+	mkdir foo &&
+	touch foo/bar &&
+	git commit -m "Re-adding foo" &&
+	git filter-branch --subdirectory-filter foo
+'
+
 test_done
-- 
1.5.4.3.222.gb0bf5


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH] Add test for filter-branch on a subdirectory that's been added and deleted and re-added
@ 2008-03-08 11:50 Kevin Ballard
  2008-03-08 11:52 ` Kevin Ballard
  2008-03-08 18:41 ` Junio C Hamano
  0 siblings, 2 replies; 7+ messages in thread
From: Kevin Ballard @ 2008-03-08 11:50 UTC (permalink / raw)
  To: git, Junio C Hamano; +Cc: Kevin Ballard

Add a currently-failing test for the case when git-filter-branch
is run with the --subdirectory-filter referencing a folder that
has been added, deleted, and re-added. Such an action should work,
but as this test shows it ends up blowing up.
---
 t/t7003-filter-branch.sh |   13 +++++++++++++
 1 files changed, 13 insertions(+), 0 deletions(-)

diff --git a/t/t7003-filter-branch.sh b/t/t7003-filter-branch.sh
index 868babc..933157b 100755
--- a/t/t7003-filter-branch.sh
+++ b/t/t7003-filter-branch.sh
@@ -179,4 +179,17 @@ test_expect_success 'Name needing quotes' '
 
 '
 
+test_expect_success 'Subdirectory filter on folder with non-contiguous history' '
+	mkdir foo &&
+	touch foo/bar &&
+	git add foo &&
+	git commit -m "Adding foo" &&
+	git rm -r foo &&
+	git commit -m "Removing foo" &&
+	mkdir foo &&
+	touch foo/bar &&
+	git commit -m "Re-adding foo" &&
+	git filter-branch --subdirectory-filter foo
+'
+
 test_done
-- 
1.5.4.3.487.g5a92


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH] Add test for filter-branch on a subdirectory that's been added and deleted and re-added
  2008-03-08 11:50 Kevin Ballard
@ 2008-03-08 11:52 ` Kevin Ballard
  2008-03-08 18:41 ` Junio C Hamano
  1 sibling, 0 replies; 7+ messages in thread
From: Kevin Ballard @ 2008-03-08 11:52 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Git Mailing List

Damnit, I just send those patches without the Signed-Off line. Should  
I re-send, or is it acceptable to just say I'm signing off on these  
and anyone is free to add my Signed-Off line when committing?

-Kevin Ballard

On Mar 8, 2008, at 6:50 AM, Kevin Ballard wrote:

> Add a currently-failing test for the case when git-filter-branch
> is run with the --subdirectory-filter referencing a folder that
> has been added, deleted, and re-added. Such an action should work,
> but as this test shows it ends up blowing up.
> ---
> t/t7003-filter-branch.sh |   13 +++++++++++++
> 1 files changed, 13 insertions(+), 0 deletions(-)
>
> diff --git a/t/t7003-filter-branch.sh b/t/t7003-filter-branch.sh
> index 868babc..933157b 100755
> --- a/t/t7003-filter-branch.sh
> +++ b/t/t7003-filter-branch.sh
> @@ -179,4 +179,17 @@ test_expect_success 'Name needing quotes' '
>
> '
>
> +test_expect_success 'Subdirectory filter on folder with non- 
> contiguous history' '
> +	mkdir foo &&
> +	touch foo/bar &&
> +	git add foo &&
> +	git commit -m "Adding foo" &&
> +	git rm -r foo &&
> +	git commit -m "Removing foo" &&
> +	mkdir foo &&
> +	touch foo/bar &&
> +	git commit -m "Re-adding foo" &&
> +	git filter-branch --subdirectory-filter foo
> +'
> +
> test_done
> -- 
> 1.5.4.3.487.g5a92
>
> --
> To unsubscribe from this list: send the line "unsubscribe git" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

-- 
Kevin Ballard
http://kevin.sb.org
kevin@sb.org
http://www.tildesoft.com



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] Add test for filter-branch on a subdirectory that's been added and deleted and re-added
  2008-03-08 11:50 Kevin Ballard
  2008-03-08 11:52 ` Kevin Ballard
@ 2008-03-08 18:41 ` Junio C Hamano
  2008-03-08 18:45   ` Kevin Ballard
  1 sibling, 1 reply; 7+ messages in thread
From: Junio C Hamano @ 2008-03-08 18:41 UTC (permalink / raw)
  To: Kevin Ballard; +Cc: git

Kevin Ballard <kevin@sb.org> writes:

> Add a currently-failing test for the case when git-filter-branch
> is run with the --subdirectory-filter referencing a folder that
> has been added, deleted, and re-added. Such an action should work,
> but as this test shows it ends up blowing up.

Such a test is a very good incentive to the people involved in the failing
part of the system to fix, and is greatly appreciated.  However,

 * please mark "currently-failing" test with "test_expect_failure";

 * please hint (after --- lines) if you will shortly be following up with
   a fix patch yourself, or if you are only reporting a bug.

I can fix-up and forge your Sign-off.

> diff --git a/t/t7003-filter-branch.sh b/t/t7003-filter-branch.sh
> index 868babc..933157b 100755
> --- a/t/t7003-filter-branch.sh
> +++ b/t/t7003-filter-branch.sh
> @@ -179,4 +179,17 @@ test_expect_success 'Name needing quotes' '
>  
>  '
>  
> +test_expect_success 'Subdirectory filter on folder with non-contiguous history' '
> +	mkdir foo &&
> +	touch foo/bar &&
> +	git add foo &&
> +	git commit -m "Adding foo" &&
> +	git rm -r foo &&
> +	git commit -m "Removing foo" &&
> +	mkdir foo &&
> +	touch foo/bar &&
> +	git commit -m "Re-adding foo" &&
> +	git filter-branch --subdirectory-filter foo
> +'
> +
>  test_done
> -- 
> 1.5.4.3.487.g5a92
>
> --
> To unsubscribe from this list: send the line "unsubscribe git" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] Add test for filter-branch on a subdirectory that's been added and deleted and re-added
  2008-03-08 18:41 ` Junio C Hamano
@ 2008-03-08 18:45   ` Kevin Ballard
  2008-03-08 20:25     ` Junio C Hamano
  0 siblings, 1 reply; 7+ messages in thread
From: Kevin Ballard @ 2008-03-08 18:45 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git

On Mar 8, 2008, at 1:41 PM, Junio C Hamano wrote:

> Kevin Ballard <kevin@sb.org> writes:
>
>> Add a currently-failing test for the case when git-filter-branch
>> is run with the --subdirectory-filter referencing a folder that
>> has been added, deleted, and re-added. Such an action should work,
>> but as this test shows it ends up blowing up.
>
> Such a test is a very good incentive to the people involved in the  
> failing
> part of the system to fix, and is greatly appreciated.  However,
>
> * please mark "currently-failing" test with "test_expect_failure";

Ahh, didn't know about that. In retrospect I should have been able to  
guess, though.

> * please hint (after --- lines) if you will shortly be following up  
> with
>   a fix patch yourself, or if you are only reporting a bug.

Ah. Yeah, I'm only reporting a bug. I don't know anything about how  
this stuff works, and the bug doesn't bite me, it bit someone else  
instead, I just thought it deserved to be documented somewhere as a  
failure.

> I can fix-up and forge your Sign-off.

That would be great, thanks.

>> diff --git a/t/t7003-filter-branch.sh b/t/t7003-filter-branch.sh
>> index 868babc..933157b 100755
>> --- a/t/t7003-filter-branch.sh
>> +++ b/t/t7003-filter-branch.sh
>> @@ -179,4 +179,17 @@ test_expect_success 'Name needing quotes' '
>>
>> '
>>
>> +test_expect_success 'Subdirectory filter on folder with non- 
>> contiguous history' '
>> +	mkdir foo &&
>> +	touch foo/bar &&
>> +	git add foo &&
>> +	git commit -m "Adding foo" &&
>> +	git rm -r foo &&
>> +	git commit -m "Removing foo" &&
>> +	mkdir foo &&
>> +	touch foo/bar &&
>> +	git commit -m "Re-adding foo" &&
>> +	git filter-branch --subdirectory-filter foo
>> +'
>> +
>> test_done
>> -- 
>> 1.5.4.3.487.g5a92
>>
>> --
>> To unsubscribe from this list: send the line "unsubscribe git" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>

-- 
Kevin Ballard
http://kevin.sb.org
kevin@sb.org
http://www.tildesoft.com



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] Add test for filter-branch on a subdirectory that's been added and deleted and re-added
  2008-03-08 18:45   ` Kevin Ballard
@ 2008-03-08 20:25     ` Junio C Hamano
  2008-03-08 20:39       ` Kevin Ballard
  0 siblings, 1 reply; 7+ messages in thread
From: Junio C Hamano @ 2008-03-08 20:25 UTC (permalink / raw)
  To: Kevin Ballard; +Cc: git

This will hopefully be the final version.

-- >8 --
filter-branch: handle "disappearing tree" case correctly in subdir filter

The subdirectory filter had a bug to notice that the commit in question
did not have anything in the path-limited part of the tree.  $commit:$path
does not name an empty tree when $path does not appear in $commit.

This should fix it.  The additional test in t7003 is originally from Kevin
Ballard but with fixups.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
---

 * -f is needed because the previous one is about aborting the filter and
    leaving the "original" namespace.

 git-filter-branch.sh     |   11 ++++++++++-
 t/t7003-filter-branch.sh |   24 ++++++++++++++++++++++++
 2 files changed, 34 insertions(+), 1 deletions(-)

diff --git a/git-filter-branch.sh b/git-filter-branch.sh
index 49e13f0..010353a 100755
--- a/git-filter-branch.sh
+++ b/git-filter-branch.sh
@@ -252,7 +252,16 @@ while read commit parents; do
 		git read-tree -i -m $commit
 		;;
 	*)
-		git read-tree -i -m $commit:"$filter_subdir"
+		# The commit may not have the subdirectory at all
+		err=$(git read-tree -i -m $commit:"$filter_subdir" 2>&1) || {
+			if ! git rev-parse --verify $commit:"$filter_subdir" 2>/dev/null
+			then
+				rm -f "$GIT_INDEX_FILE"
+			else
+				echo >&2 "$err"
+				false
+			fi
+		}
 	esac || die "Could not initialize the index"
 
 	GIT_COMMIT=$commit
diff --git a/t/t7003-filter-branch.sh b/t/t7003-filter-branch.sh
index 868babc..6e14bf1 100755
--- a/t/t7003-filter-branch.sh
+++ b/t/t7003-filter-branch.sh
@@ -179,4 +179,28 @@ test_expect_success 'Name needing quotes' '
 
 '
 
+test_expect_success 'Subdirectory filter with disappearing trees' '
+	git reset --hard &&
+	git checkout master &&
+
+	mkdir foo &&
+	touch foo/bar &&
+	git add foo &&
+	test_tick &&
+	git commit -m "Adding foo" &&
+
+	git rm -r foo &&
+	test_tick &&
+	git commit -m "Removing foo" &&
+
+	mkdir foo &&
+	touch foo/bar &&
+	git add foo &&
+	test_tick &&
+	git commit -m "Re-adding foo" &&
+
+	git filter-branch -f --subdirectory-filter foo &&
+	test $(git rev-list master | wc -l) = 3
+'
+
 test_done

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH] Add test for filter-branch on a subdirectory that's been added and deleted and re-added
  2008-03-08 20:25     ` Junio C Hamano
@ 2008-03-08 20:39       ` Kevin Ballard
  0 siblings, 0 replies; 7+ messages in thread
From: Kevin Ballard @ 2008-03-08 20:39 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git

On Mar 8, 2008, at 3:25 PM, Junio C Hamano wrote:

> This will hopefully be the final version.

Assuming that the lack of a GIT_INDEX_FILE doesn't break git-checkout- 
index, git-diff-index, git-update-index, or anything that an --index- 
filter might run (I assume it doesn't, but I didn't test all the  
relevant commands), then this looks fine by me.

-Kevin

>
> -- >8 --
> filter-branch: handle "disappearing tree" case correctly in subdir  
> filter
>
> The subdirectory filter had a bug to notice that the commit in  
> question
> did not have anything in the path-limited part of the tree.  $commit: 
> $path
> does not name an empty tree when $path does not appear in $commit.
>
> This should fix it.  The additional test in t7003 is originally from  
> Kevin
> Ballard but with fixups.
>
> Signed-off-by: Junio C Hamano <gitster@pobox.com>
> ---
>
> * -f is needed because the previous one is about aborting the filter  
> and
>    leaving the "original" namespace.
>
> git-filter-branch.sh     |   11 ++++++++++-
> t/t7003-filter-branch.sh |   24 ++++++++++++++++++++++++
> 2 files changed, 34 insertions(+), 1 deletions(-)
>
> diff --git a/git-filter-branch.sh b/git-filter-branch.sh
> index 49e13f0..010353a 100755
> --- a/git-filter-branch.sh
> +++ b/git-filter-branch.sh
> @@ -252,7 +252,16 @@ while read commit parents; do
> 		git read-tree -i -m $commit
> 		;;
> 	*)
> -		git read-tree -i -m $commit:"$filter_subdir"
> +		# The commit may not have the subdirectory at all
> +		err=$(git read-tree -i -m $commit:"$filter_subdir" 2>&1) || {
> +			if ! git rev-parse --verify $commit:"$filter_subdir" 2>/dev/null
> +			then
> +				rm -f "$GIT_INDEX_FILE"
> +			else
> +				echo >&2 "$err"
> +				false
> +			fi
> +		}
> 	esac || die "Could not initialize the index"
>
> 	GIT_COMMIT=$commit
> diff --git a/t/t7003-filter-branch.sh b/t/t7003-filter-branch.sh
> index 868babc..6e14bf1 100755
> --- a/t/t7003-filter-branch.sh
> +++ b/t/t7003-filter-branch.sh
> @@ -179,4 +179,28 @@ test_expect_success 'Name needing quotes' '
>
> '
>
> +test_expect_success 'Subdirectory filter with disappearing trees' '
> +	git reset --hard &&
> +	git checkout master &&
> +
> +	mkdir foo &&
> +	touch foo/bar &&
> +	git add foo &&
> +	test_tick &&
> +	git commit -m "Adding foo" &&
> +
> +	git rm -r foo &&
> +	test_tick &&
> +	git commit -m "Removing foo" &&
> +
> +	mkdir foo &&
> +	touch foo/bar &&
> +	git add foo &&
> +	test_tick &&
> +	git commit -m "Re-adding foo" &&
> +
> +	git filter-branch -f --subdirectory-filter foo &&
> +	test $(git rev-list master | wc -l) = 3
> +'
> +
> test_done
>

-- 
Kevin Ballard
http://kevin.sb.org
kevin@sb.org
http://www.tildesoft.com



^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2008-03-08 20:40 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-02-25 19:45 [PATCH] Add test for filter-branch on a subdirectory that's been added and deleted and re-added Kevin Ballard
  -- strict thread matches above, loose matches on Subject: below --
2008-03-08 11:50 Kevin Ballard
2008-03-08 11:52 ` Kevin Ballard
2008-03-08 18:41 ` Junio C Hamano
2008-03-08 18:45   ` Kevin Ballard
2008-03-08 20:25     ` Junio C Hamano
2008-03-08 20:39       ` Kevin Ballard

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).