All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] fast-import: fix segfault and tests
@ 2014-08-28 14:54 Maxim Bublis
  2014-08-28 14:54 ` [PATCH 1/2] t9300: test filedelete root Maxim Bublis
  2014-08-28 14:54 ` [PATCH 2/2] fast-import: fix segfault in store_tree() Maxim Bublis
  0 siblings, 2 replies; 7+ messages in thread
From: Maxim Bublis @ 2014-08-28 14:54 UTC (permalink / raw)
  To: git; +Cc: Maxim Bublis

Removing root tree with filedelete command would lead to segmentation fault
in store_tree(). First patch from patch series adds test to show incorrect
behaviour and second one fixes bug by sanity check and load_tree() usage.

Maxim Bublis (2):
  t9300: test filedelete root
  fast-import: fix segfault in store_tree()

 fast-import.c          |  6 +++++-
 t/t9300-fast-import.sh | 46 ++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 51 insertions(+), 1 deletion(-)

-- 
1.8.5.2 (Apple Git-48)

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

* [PATCH 1/2] t9300: test filedelete root
  2014-08-28 14:54 [PATCH 0/2] fast-import: fix segfault and tests Maxim Bublis
@ 2014-08-28 14:54 ` Maxim Bublis
  2014-08-28 22:30   ` Junio C Hamano
  2014-08-28 14:54 ` [PATCH 2/2] fast-import: fix segfault in store_tree() Maxim Bublis
  1 sibling, 1 reply; 7+ messages in thread
From: Maxim Bublis @ 2014-08-28 14:54 UTC (permalink / raw)
  To: git; +Cc: Maxim Bublis

Add new fast-import test series for filedelete command.

Signed-off-by: Maxim Bublis <satori@yandex-team.ru>
---
 t/t9300-fast-import.sh | 46 ++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 46 insertions(+)

diff --git a/t/t9300-fast-import.sh b/t/t9300-fast-import.sh
index 5fc9ef2..3d557b3 100755
--- a/t/t9300-fast-import.sh
+++ b/t/t9300-fast-import.sh
@@ -3017,4 +3017,50 @@ test_expect_success 'T: empty reset doesnt delete branch' '
 	git rev-parse --verify refs/heads/not-to-delete
 '
 
+###
+### series U (filedelete)
+###
+
+cat >input <<INPUT_END
+commit refs/heads/U
+committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+data <<COMMIT
+test setup
+COMMIT
+M 100644 inline hello.c
+data <<BLOB
+blob 1
+BLOB
+
+INPUT_END
+
+test_expect_success 'U: initialize for U tests' '
+	git fast-import <input
+'
+
+cat >input <<INPUT_END
+commit refs/heads/U
+committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+data <<COMMIT
+must succeed
+COMMIT
+from refs/heads/U^0
+D ""
+
+INPUT_END
+
+test_expect_success 'U: filedelete root succeeds' '
+    git fast-import <input
+'
+
+cat >expect <<EOF
+:100644 000000 c18147dc648481eeb65dc5e66628429a64843327 0000000000000000000000000000000000000000 D	hello.c
+EOF
+
+git diff-tree -M -r U^1 U >actual
+
+test_expect_success 'U: validate filedelete result' '
+	compare_diff_raw expect actual
+'
+
 test_done
-- 
1.8.5.2 (Apple Git-48)

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

* [PATCH 2/2] fast-import: fix segfault in store_tree()
  2014-08-28 14:54 [PATCH 0/2] fast-import: fix segfault and tests Maxim Bublis
  2014-08-28 14:54 ` [PATCH 1/2] t9300: test filedelete root Maxim Bublis
@ 2014-08-28 14:54 ` Maxim Bublis
  2014-08-28 23:16   ` Junio C Hamano
  1 sibling, 1 reply; 7+ messages in thread
From: Maxim Bublis @ 2014-08-28 14:54 UTC (permalink / raw)
  To: git; +Cc: Maxim Bublis

Branch tree is NULLified by filedelete command if we are trying
to delete root tree. Add sanity check and use load_tree() in that case.

Signed-off-by: Maxim Bublis <satori@yandex-team.ru>
---
 fast-import.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/fast-import.c b/fast-import.c
index d73f58c..b77f12c 100644
--- a/fast-import.c
+++ b/fast-import.c
@@ -1419,7 +1419,7 @@ static void mktree(struct tree_content *t, int v, struct strbuf *b)
 
 static void store_tree(struct tree_entry *root)
 {
-	struct tree_content *t = root->tree;
+	struct tree_content *t;
 	unsigned int i, j, del;
 	struct last_object lo = { STRBUF_INIT, 0, 0, /* no_swap */ 1 };
 	struct object_entry *le = NULL;
@@ -1427,6 +1427,10 @@ static void store_tree(struct tree_entry *root)
 	if (!is_null_sha1(root->versions[1].sha1))
 		return;
 
+	if (!root->tree)
+		load_tree(root)
+	t = root->tree;
+
 	for (i = 0; i < t->entry_count; i++) {
 		if (t->entries[i]->tree)
 			store_tree(t->entries[i]);
-- 
1.8.5.2 (Apple Git-48)

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

* Re: [PATCH 1/2] t9300: test filedelete root
  2014-08-28 14:54 ` [PATCH 1/2] t9300: test filedelete root Maxim Bublis
@ 2014-08-28 22:30   ` Junio C Hamano
  2014-08-29 11:37     ` Maxim Bublis
  0 siblings, 1 reply; 7+ messages in thread
From: Junio C Hamano @ 2014-08-28 22:30 UTC (permalink / raw)
  To: Maxim Bublis; +Cc: git

Maxim Bublis <satori@yandex-team.ru> writes:

> Add new fast-import test series for filedelete command.
>
> Signed-off-by: Maxim Bublis <satori@yandex-team.ru>
> ---

You may have been concentrating on the "delete root" case, but as
long as you claim "We add a series to test filedelete command", it
would be sensible to test more typical cases of deleting files, not
the entire tree as well, no?  Perhaps add three paths in the initial
commit e.g. hello.c, good/night.txt and good/bye.txt, first remove
good/night.txt and validate the result, then remove good/ directory
and validate the result, and finally remove the whole thing and
validate the result, or something like that?

In a patch series that introduces a demonstration of existing
breakage and then fixes the breakage in a separate patch, mark the
test that shows the known breakage with test_expect_failure and then
turn that line into test_expect_success in the later patch that
fixes the breakage.

What the test checks and the fix in 2/2 both looked sensible from a
cursory read.

Thanks.

>  t/t9300-fast-import.sh | 46 ++++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 46 insertions(+)
>
> diff --git a/t/t9300-fast-import.sh b/t/t9300-fast-import.sh
> index 5fc9ef2..3d557b3 100755
> --- a/t/t9300-fast-import.sh
> +++ b/t/t9300-fast-import.sh
> @@ -3017,4 +3017,50 @@ test_expect_success 'T: empty reset doesnt delete branch' '
>  	git rev-parse --verify refs/heads/not-to-delete
>  '
>  
> +###
> +### series U (filedelete)
> +###
> +
> +cat >input <<INPUT_END
> +commit refs/heads/U
> +committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
> +data <<COMMIT
> +test setup
> +COMMIT
> +M 100644 inline hello.c
> +data <<BLOB
> +blob 1
> +BLOB
> +
> +INPUT_END
> +
> +test_expect_success 'U: initialize for U tests' '
> +	git fast-import <input
> +'
> +
> +cat >input <<INPUT_END
> +commit refs/heads/U
> +committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
> +data <<COMMIT
> +must succeed
> +COMMIT
> +from refs/heads/U^0
> +D ""
> +
> +INPUT_END
> +
> +test_expect_success 'U: filedelete root succeeds' '
> +    git fast-import <input
> +'
> +
> +cat >expect <<EOF
> +:100644 000000 c18147dc648481eeb65dc5e66628429a64843327 0000000000000000000000000000000000000000 D	hello.c
> +EOF
> +
> +git diff-tree -M -r U^1 U >actual
> +
> +test_expect_success 'U: validate filedelete result' '
> +	compare_diff_raw expect actual
> +'
> +
>  test_done

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

* Re: [PATCH 2/2] fast-import: fix segfault in store_tree()
  2014-08-28 14:54 ` [PATCH 2/2] fast-import: fix segfault in store_tree() Maxim Bublis
@ 2014-08-28 23:16   ` Junio C Hamano
  2014-08-29 11:40     ` Maxim Bublis
  0 siblings, 1 reply; 7+ messages in thread
From: Junio C Hamano @ 2014-08-28 23:16 UTC (permalink / raw)
  To: Maxim Bublis; +Cc: git

Maxim Bublis <satori@yandex-team.ru> writes:

> Branch tree is NULLified by filedelete command if we are trying
> to delete root tree. Add sanity check and use load_tree() in that case.
>
> Signed-off-by: Maxim Bublis <satori@yandex-team.ru>
> ---
>  fast-import.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/fast-import.c b/fast-import.c
> index d73f58c..b77f12c 100644
> --- a/fast-import.c
> +++ b/fast-import.c
> @@ -1419,7 +1419,7 @@ static void mktree(struct tree_content *t, int v, struct strbuf *b)
>  
>  static void store_tree(struct tree_entry *root)
>  {
> -	struct tree_content *t = root->tree;
> +	struct tree_content *t;
>  	unsigned int i, j, del;
>  	struct last_object lo = { STRBUF_INIT, 0, 0, /* no_swap */ 1 };
>  	struct object_entry *le = NULL;
> @@ -1427,6 +1427,10 @@ static void store_tree(struct tree_entry *root)
>  	if (!is_null_sha1(root->versions[1].sha1))
>  		return;
>  
> +	if (!root->tree)
> +		load_tree(root)

Missing ';'

> +	t = root->tree;
> +
>  	for (i = 0; i < t->entry_count; i++) {
>  		if (t->entries[i]->tree)
>  			store_tree(t->entries[i]);

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

* Re: [PATCH 1/2] t9300: test filedelete root
  2014-08-28 22:30   ` Junio C Hamano
@ 2014-08-29 11:37     ` Maxim Bublis
  0 siblings, 0 replies; 7+ messages in thread
From: Maxim Bublis @ 2014-08-29 11:37 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git

On 29 авг. 2014 г., at 2:30, Junio C Hamano <gitster@pobox.com> wrote:

> You may have been concentrating on the "delete root" case, but as
> long as you claim "We add a series to test filedelete command", it
> would be sensible to test more typical cases of deleting files, not
> the entire tree as well, no?  Perhaps add three paths in the initial
> commit e.g. hello.c, good/night.txt and good/bye.txt, first remove
> good/night.txt and validate the result, then remove good/ directory
> and validate the result, and finally remove the whole thing and
> validate the result, or something like that?

Sure, I’ll add more tests for filedelete command.

> In a patch series that introduces a demonstration of existing
> breakage and then fixes the breakage in a separate patch, mark the
> test that shows the known breakage with test_expect_failure and then
> turn that line into test_expect_success in the later patch that
> fixes the breakage.

Ok, thanks.

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

* Re: [PATCH 2/2] fast-import: fix segfault in store_tree()
  2014-08-28 23:16   ` Junio C Hamano
@ 2014-08-29 11:40     ` Maxim Bublis
  0 siblings, 0 replies; 7+ messages in thread
From: Maxim Bublis @ 2014-08-29 11:40 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git


On 29 авг. 2014 г., at 3:16, Junio C Hamano <gitster@pobox.com> wrote:

> Missing ‘;'

Thanks, I’ll fix it. What a stupid mistype, I was writing some amount of Go code recently and it doesn’t use semicolons.

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

end of thread, other threads:[~2014-08-29 11:50 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-08-28 14:54 [PATCH 0/2] fast-import: fix segfault and tests Maxim Bublis
2014-08-28 14:54 ` [PATCH 1/2] t9300: test filedelete root Maxim Bublis
2014-08-28 22:30   ` Junio C Hamano
2014-08-29 11:37     ` Maxim Bublis
2014-08-28 14:54 ` [PATCH 2/2] fast-import: fix segfault in store_tree() Maxim Bublis
2014-08-28 23:16   ` Junio C Hamano
2014-08-29 11:40     ` Maxim Bublis

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.