threads / patch / 33630

patchmerge-tree: fix typo in "both changed identically"

Subject: [PATCH] merge-tree: fix typo in "both changed identically"

## tl;dr

5 messages between Apr 27, 2013 and Apr 28, 2013. Diffs are folded; open one to read it.

replies: 4people: 3as markdown or json

John Keeping· Apr 27, 2013, 13:03 UTC · lore

Commit aacecc3 (merge-tree: don't print entries that match "local" - 2013-04-07) had a typo causing the "same in both" check to be incorrect and check if both the base and "their" versions are empty instead of checking that both the "our" and "their" versions are empty. Fix this.

Reported-by: René Scharfe <rene.scharfe@lsrfire.ath.cx>
Signed-off-by: John Keeping <john@keeping.me.uk>
---
 builtin/merge-tree.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Show changes to builtin/merge-tree.c +1 −1
diff --git a/builtin/merge-tree.c b/builtin/merge-tree.c
index ed25d81..ec49917 100644
--- a/builtin/merge-tree.c
+++ b/builtin/merge-tree.c
@@ -302,7 +302,7 @@ static void unresolved(const struct traverse_info *info, struct name_entry n[3])
 static int threeway_callback(int n, unsigned long mask, unsigned long dirmask, struct name_entry *entry, struct traverse_info *info)
 {
 	/* Same in both? */
-	if (same_entry(entry+1, entry+2) || both_empty(entry+0, entry+2)) {
+	if (same_entry(entry+1, entry+2) || both_empty(entry+1, entry+2)) {
 		/* Modified, added or removed identically */
 		resolve(info, NULL, entry+1);
 		return mask;
-- 
1.8.2.1.715.gb260f47
René Scharfe· Apr 27, 2013, 13:23 UTC · re: John Keeping · lore

Re: [PATCH] merge-tree: fix typo in "both changed identically"

How about squashing in this test?
René
---
 t/t4300-merge-tree.sh | 13 +++++++++++++
 1 file changed, 13 insertions(+)
Show changes to t/t4300-merge-tree.sh +13 −0
diff --git a/t/t4300-merge-tree.sh b/t/t4300-merge-tree.sh
index bd43b3d..2defb42 100755
--- a/t/t4300-merge-tree.sh
+++ b/t/t4300-merge-tree.sh
@@ -205,6 +205,19 @@ EXPECTED
 	test_cmp expected actual
 '
 
+test_expect_success 'file remove A, B (same)' '
+	cat >expected <<\EXPECTED &&
+EXPECTED
+
+	git reset --hard initial &&
+	test_commit "rm-a-b-base" "ONE" "AAA" &&
+	git rm ONE &&
+	git commit -m "rm-a-b" &&
+	git tag "rm-a-b" &&
+	git merge-tree rm-a-b-base rm-a-b rm-a-b >actual &&
+	test_cmp expected actual
+'
+
 test_expect_success 'file change A, remove B' '
 	cat >expected <<\EXPECTED &&
 removed in remote
-- 
1.8.2.1
John Keeping· Apr 27, 2013, 13:38 UTC · re: René Scharfe · lore

Re: [PATCH] merge-tree: fix typo in "both changed identically"

On Sat, Apr 27, 2013 at 03:23:18PM +0200, René Scharfe wrote:
Show 26 quoted lines
> How about squashing in this test?
> 
> René
> 
> ---
>  t/t4300-merge-tree.sh | 13 +++++++++++++
>  1 file changed, 13 insertions(+)
> 
> diff --git a/t/t4300-merge-tree.sh b/t/t4300-merge-tree.sh
> index bd43b3d..2defb42 100755
> --- a/t/t4300-merge-tree.sh
> +++ b/t/t4300-merge-tree.sh
> @@ -205,6 +205,19 @@ EXPECTED
>  	test_cmp expected actual
>  '
>  
> +test_expect_success 'file remove A, B (same)' '
> +	cat >expected <<\EXPECTED &&
> +EXPECTED
> +
> +	git reset --hard initial &&
> +	test_commit "rm-a-b-base" "ONE" "AAA" &&
> +	git rm ONE &&
> +	git commit -m "rm-a-b" &&
> +	git tag "rm-a-b" &&
> +	git merge-tree rm-a-b-base rm-a-b rm-a-b >actual &&

I'm not sure about using the same "our" and "their" refs here. The existing tests go out of their way to create separate commits - although since they contain identical trees I don't think that actually buys us anything.

Since this test does fail without my patch, it clearly does trigger the affected code, so I think it's fine as is.

Show 8 quoted lines
> +	test_cmp expected actual
> +'
> +
>  test_expect_success 'file change A, remove B' '
>  	cat >expected <<\EXPECTED &&
>  removed in remote
> -- 
> 1.8.2.1
John Keeping· Apr 27, 2013, 13:40 UTC · re: John Keeping · lore

[PATCH v2] merge-tree: fix typo in "both changed identically"

Commit aacecc3 (merge-tree: don't print entries that match "local" - 2013-04-07) had a typo causing the "same in both" check to be incorrect and check if both the base and "their" versions are removed instead of checking that both the "our" and "their" versions are removed. Fix this.

Reported-by: René Scharfe <rene.scharfe@lsrfire.ath.cx>
Test-written-by: René Scharfe <rene.scharfe@lsrfire.ath.cx>
Signed-off-by: John Keeping <john@keeping.me.uk>
---
Changes since v1:
- Add test from René
- s/empty/removed/g in the commit message
 builtin/merge-tree.c  |  2 +-
 t/t4300-merge-tree.sh | 13 +++++++++++++
 2 files changed, 14 insertions(+), 1 deletion(-)
Show changes to 2 files +14 −1

builtin/merge-tree.c, t/t4300-merge-tree.sh

diff --git a/builtin/merge-tree.c b/builtin/merge-tree.c
index ed25d81..ec49917 100644
--- a/builtin/merge-tree.c
+++ b/builtin/merge-tree.c
@@ -302,7 +302,7 @@ static void unresolved(const struct traverse_info *info, struct name_entry n[3])
 static int threeway_callback(int n, unsigned long mask, unsigned long dirmask, struct name_entry *entry, struct traverse_info *info)
 {
 	/* Same in both? */
-	if (same_entry(entry+1, entry+2) || both_empty(entry+0, entry+2)) {
+	if (same_entry(entry+1, entry+2) || both_empty(entry+1, entry+2)) {
 		/* Modified, added or removed identically */
 		resolve(info, NULL, entry+1);
 		return mask;
diff --git a/t/t4300-merge-tree.sh b/t/t4300-merge-tree.sh
index bd43b3d..2defb42 100755
--- a/t/t4300-merge-tree.sh
+++ b/t/t4300-merge-tree.sh
@@ -205,6 +205,19 @@ EXPECTED
 	test_cmp expected actual
 '
 
+test_expect_success 'file remove A, B (same)' '
+	cat >expected <<\EXPECTED &&
+EXPECTED
+
+	git reset --hard initial &&
+	test_commit "rm-a-b-base" "ONE" "AAA" &&
+	git rm ONE &&
+	git commit -m "rm-a-b" &&
+	git tag "rm-a-b" &&
+	git merge-tree rm-a-b-base rm-a-b rm-a-b >actual &&
+	test_cmp expected actual
+'
+
 test_expect_success 'file change A, remove B' '
 	cat >expected <<\EXPECTED &&
 removed in remote
-- 
1.8.3.rc0.149.g98a72f2.dirty

← back to recent threads