git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCH 0/2] git-merge-file: do not add LF at EOF while applying unrelated change
@ 2014-06-28 19:37 Max Kirillov
  2014-06-28 19:37 ` [PATCH 1/2] t6023-merge-file.sh: fix and mark as broken invalid tests Max Kirillov
  2014-06-28 19:37 ` [PATCH 2/2] git-merge-file: do not add LF at EOF while applying unrelated change Max Kirillov
  0 siblings, 2 replies; 3+ messages in thread
From: Max Kirillov @ 2014-06-28 19:37 UTC (permalink / raw
  To: Bert Wesarg, Junio C Hamano, Johannes Schindelin; +Cc: git, Max Kirillov

Hi.

I have noticed that cherry-pick adds trailing newlines when it is not
expected to - the change does not contain its addition. Here is the fix
for it.

The fix is quite debugging-driven, without detailed analysis of how
exactly this "add_nl" parameter works in all cases. But it passes all
tests. I have added some more where I felt there were not enough.

Also I have noticed that some tests in the t6023, which related to the
behavior contain a mistake which makes them meaningless. I have fixed it
and marked the tests as expected failure, because they are failing after
that. Hopely they will be fixed some day.

Max Kirillov (2):
  t6023-merge-file.sh: fix and mark as broken invalid tests
  git-merge-file: do not add LF at EOF while applying unrelated change

 t/t6023-merge-file.sh | 72 ++++++++++++++++++++++++++++++++++++++++++++++++---
 xdiff/xmerge.c        |  4 +--
 2 files changed, 71 insertions(+), 5 deletions(-)

-- 
2.0.0.526.g5318336

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

* [PATCH 1/2] t6023-merge-file.sh: fix and mark as broken invalid tests
  2014-06-28 19:37 [PATCH 0/2] git-merge-file: do not add LF at EOF while applying unrelated change Max Kirillov
@ 2014-06-28 19:37 ` Max Kirillov
  2014-06-28 19:37 ` [PATCH 2/2] git-merge-file: do not add LF at EOF while applying unrelated change Max Kirillov
  1 sibling, 0 replies; 3+ messages in thread
From: Max Kirillov @ 2014-06-28 19:37 UTC (permalink / raw
  To: Bert Wesarg, Junio C Hamano, Johannes Schindelin; +Cc: git, Max Kirillov

Tests "merge without conflict (missing LF at EOF" and "merge result
added missing LF" are meaningless - the first one is identical to
"merge without conflict" and the second compares results of those
identical tests, which are always same.

This has been so since their addition in ba1f5f3537. Probably "new4.txt"
was meant to be used instead of "new2.txt". Unfortunately, the current
merge-file breaks with new4 - conflict is reported. They also fail at
that revision if fixed.

Fix the file reference to "new4.txt" and mark the tests as failing -
they look like legitimate expectations, just not satisfied at time
being.

Signed-off-by: Max Kirillov <max@max630.net>
---
 t/t6023-merge-file.sh | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/t/t6023-merge-file.sh b/t/t6023-merge-file.sh
index d9f3439..6da921c 100755
--- a/t/t6023-merge-file.sh
+++ b/t/t6023-merge-file.sh
@@ -77,10 +77,10 @@ test_expect_success "merge without conflict (--quiet)" \
 	"git merge-file --quiet test.txt orig.txt new2.txt"
 
 cp new1.txt test2.txt
-test_expect_success "merge without conflict (missing LF at EOF)" \
-	"git merge-file test2.txt orig.txt new2.txt"
+test_expect_failure "merge without conflict (missing LF at EOF)" \
+	"git merge-file test2.txt orig.txt new4.txt"
 
-test_expect_success "merge result added missing LF" \
+test_expect_failure "merge result added missing LF" \
 	"test_cmp test.txt test2.txt"
 
 cp test.txt backup.txt
-- 
2.0.0.526.g5318336

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

* [PATCH 2/2] git-merge-file: do not add LF at EOF while applying unrelated change
  2014-06-28 19:37 [PATCH 0/2] git-merge-file: do not add LF at EOF while applying unrelated change Max Kirillov
  2014-06-28 19:37 ` [PATCH 1/2] t6023-merge-file.sh: fix and mark as broken invalid tests Max Kirillov
@ 2014-06-28 19:37 ` Max Kirillov
  1 sibling, 0 replies; 3+ messages in thread
From: Max Kirillov @ 2014-06-28 19:37 UTC (permalink / raw
  To: Bert Wesarg, Junio C Hamano, Johannes Schindelin; +Cc: git, Max Kirillov

If 'current-file' does not contain LF at EOF, and change between
'base-file' and 'other-file' does not change any line close to EOF, the
3-way merge should not add LF to EOF.  This is what 'diff3 -m' does, and
seems to be a reasonable expectation.

The change which introduced the behavior is cd1d61c44f and was about
union merge. The union merges are tested in the t6026-merge-attr, and
merge-file in general are tested in t6023-merge-file. Add tests
"merge conflicting with --.." there, to verify that the fix does not
break anything.

Also add tests "merge without conflict (missing LF at EOF, away from
change in the other file)" and "merge does not add LF away of change",
to demonstrate the changed behavior.

Signed-off-by: Max Kirillov <max@max630.net>
---
 t/t6023-merge-file.sh | 66 +++++++++++++++++++++++++++++++++++++++++++++++++++
 xdiff/xmerge.c        |  4 ++--
 2 files changed, 68 insertions(+), 2 deletions(-)

diff --git a/t/t6023-merge-file.sh b/t/t6023-merge-file.sh
index 6da921c..21d1b85 100755
--- a/t/t6023-merge-file.sh
+++ b/t/t6023-merge-file.sh
@@ -83,6 +83,23 @@ test_expect_failure "merge without conflict (missing LF at EOF)" \
 test_expect_failure "merge result added missing LF" \
 	"test_cmp test.txt test2.txt"
 
+cp new4.txt test3.txt
+test_expect_success "merge without conflict (missing LF at EOF, away from change in the other file)" \
+	"git merge-file --quiet test3.txt new2.txt new3.txt"
+
+cat > expect.txt << EOF
+DOMINUS regit me,
+et nihil mihi deerit.
+In loco pascuae ibi me collocavit,
+super aquam refectionis educavit me;
+animam meam convertit,
+deduxit me super semitas jusitiae,
+EOF
+printf "propter nomen suum." >> expect.txt
+
+test_expect_success "merge does not add LF away of change" \
+	"test_cmp test3.txt expect.txt"
+
 cp test.txt backup.txt
 test_expect_success "merge with conflicts" \
 	"test_must_fail git merge-file test.txt orig.txt new3.txt"
@@ -107,6 +124,55 @@ EOF
 test_expect_success "expected conflict markers" "test_cmp test.txt expect.txt"
 
 cp backup.txt test.txt
+
+cat > expect.txt << EOF
+Dominus regit me, et nihil mihi deerit.
+In loco pascuae ibi me collocavit,
+super aquam refectionis educavit me;
+animam meam convertit,
+deduxit me super semitas jusitiae,
+propter nomen suum.
+Nam et si ambulavero in medio umbrae mortis,
+non timebo mala, quoniam tu mecum es:
+virga tua et baculus tuus ipsa me consolata sunt.
+EOF
+test_expect_success "merge conflicting with --ours" \
+	"git merge-file --ours test.txt orig.txt new3.txt && test_cmp test.txt expect.txt"
+cp backup.txt test.txt
+
+cat > expect.txt << EOF
+DOMINUS regit me,
+et nihil mihi deerit.
+In loco pascuae ibi me collocavit,
+super aquam refectionis educavit me;
+animam meam convertit,
+deduxit me super semitas jusitiae,
+propter nomen suum.
+Nam et si ambulavero in medio umbrae mortis,
+non timebo mala, quoniam tu mecum es:
+virga tua et baculus tuus ipsa me consolata sunt.
+EOF
+test_expect_success "merge conflicting with --theirs" \
+	"git merge-file --theirs test.txt orig.txt new3.txt && test_cmp test.txt expect.txt"
+cp backup.txt test.txt
+
+cat > expect.txt << EOF
+Dominus regit me, et nihil mihi deerit.
+DOMINUS regit me,
+et nihil mihi deerit.
+In loco pascuae ibi me collocavit,
+super aquam refectionis educavit me;
+animam meam convertit,
+deduxit me super semitas jusitiae,
+propter nomen suum.
+Nam et si ambulavero in medio umbrae mortis,
+non timebo mala, quoniam tu mecum es:
+virga tua et baculus tuus ipsa me consolata sunt.
+EOF
+test_expect_success "merge conflicting with --union" \
+	"git merge-file --union test.txt orig.txt new3.txt && test_cmp test.txt expect.txt"
+cp backup.txt test.txt
+
 test_expect_success "merge with conflicts, using -L" \
 	"test_must_fail git merge-file -L 1 -L 2 test.txt orig.txt new3.txt"
 
diff --git a/xdiff/xmerge.c b/xdiff/xmerge.c
index 9e13b25..5f7a95a 100644
--- a/xdiff/xmerge.c
+++ b/xdiff/xmerge.c
@@ -245,11 +245,11 @@ static int xdl_fill_merge_buffer(xdfenv_t *xe1, const char *name1,
 					      dest ? dest + size : NULL);
 			/* Postimage from side #1 */
 			if (m->mode & 1)
-				size += xdl_recs_copy(xe1, m->i1, m->chg1, 1,
+				size += xdl_recs_copy(xe1, m->i1, m->chg1, 0,
 						      dest ? dest + size : NULL);
 			/* Postimage from side #2 */
 			if (m->mode & 2)
-				size += xdl_recs_copy(xe2, m->i2, m->chg2, 1,
+				size += xdl_recs_copy(xe2, m->i2, m->chg2, 0,
 						      dest ? dest + size : NULL);
 		} else
 			continue;
-- 
2.0.0.526.g5318336

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

end of thread, other threads:[~2014-06-28 19:38 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-06-28 19:37 [PATCH 0/2] git-merge-file: do not add LF at EOF while applying unrelated change Max Kirillov
2014-06-28 19:37 ` [PATCH 1/2] t6023-merge-file.sh: fix and mark as broken invalid tests Max Kirillov
2014-06-28 19:37 ` [PATCH 2/2] git-merge-file: do not add LF at EOF while applying unrelated change Max Kirillov

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).