git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Elijah Newren <newren@gmail.com>
To: git@vger.kernel.org
Cc: Elijah Newren <newren@gmail.com>
Subject: [PATCH v5 06/34] directory rename detection: testcases to avoid taking detection too far
Date: Wed, 27 Dec 2017 20:13:24 -0800	[thread overview]
Message-ID: <20171228041352.27880-7-newren@gmail.com> (raw)
In-Reply-To: <20171228041352.27880-1-newren@gmail.com>

Signed-off-by: Elijah Newren <newren@gmail.com>
---
 t/t6043-merge-rename-directories.sh | 150 ++++++++++++++++++++++++++++++++++++
 1 file changed, 150 insertions(+)

diff --git a/t/t6043-merge-rename-directories.sh b/t/t6043-merge-rename-directories.sh
index acf49d6b4..433d99584 100755
--- a/t/t6043-merge-rename-directories.sh
+++ b/t/t6043-merge-rename-directories.sh
@@ -564,4 +564,154 @@ test_expect_success '2b-check: Directory split into two on one side, with equal
 #   messages are handled correctly.
 ###########################################################################
 
+
+###########################################################################
+# SECTION 3: Path in question is the source path for some rename already
+#
+# Combining cases from Section 1 and trying to handle them could lead to
+# directory renaming detection being over-applied.  So, this section
+# provides some good testcases to check that the implementation doesn't go
+# too far.
+###########################################################################
+
+# Testcase 3a, Avoid implicit rename if involved as source on other side
+#   (Related to testcases 1c and 1f)
+#   Commit O: z/{b,c,d}
+#   Commit A: z/{b,c,d} (no change)
+#   Commit B: y/{b,c}, x/d
+#   Expected: y/{b,c}, x/d
+test_expect_success '3a-setup: Avoid implicit rename if involved as source on other side' '
+	test_create_repo 3a &&
+	(
+		cd 3a &&
+
+		mkdir z &&
+		echo b >z/b &&
+		echo c >z/c &&
+		echo d >z/d &&
+		git add z &&
+		test_tick &&
+		git commit -m "O" &&
+
+		git branch O &&
+		git branch A &&
+		git branch B &&
+
+		git checkout A &&
+		test_tick &&
+		git commit --allow-empty -m "A" &&
+
+		git checkout B &&
+		mkdir y &&
+		mkdir x &&
+		git mv z/b y/ &&
+		git mv z/c y/ &&
+		git mv z/d x/ &&
+		rmdir z &&
+		test_tick &&
+		git commit -m "B"
+	)
+'
+
+test_expect_success '3a-check: Avoid implicit rename if involved as source on other side' '
+	(
+		cd 3a &&
+
+		git checkout A^0 &&
+
+		git merge -s recursive B^0 &&
+
+		test 3 -eq $(git ls-files -s | wc -l) &&
+
+		git rev-parse >actual \
+			HEAD:y/b HEAD:y/c HEAD:x/d &&
+		git rev-parse >expect \
+			O:z/b O:z/c O:z/d &&
+		test_cmp expect actual
+	)
+'
+
+# Testcase 3b, Avoid implicit rename if involved as source on other side
+#   (Related to testcases 5c and 7c, also kind of 1e and 1f)
+#   Commit O: z/{b,c,d}
+#   Commit A: y/{b,c}, x/d
+#   Commit B: z/{b,c}, w/d
+#   Expected: y/{b,c}, CONFLICT:(z/d -> x/d vs. w/d)
+#   NOTE: We're particularly checking that since z/d is already involved as
+#         a source in a file rename on the same side of history, that we don't
+#         get it involved in directory rename detection.  If it were, we might
+#         end up with CONFLICT:(z/d -> y/d vs. x/d vs. w/d), i.e. a
+#         rename/rename/rename(1to3) conflict, which is just weird.
+test_expect_success '3b-setup: Avoid implicit rename if involved as source on current side' '
+	test_create_repo 3b &&
+	(
+		cd 3b &&
+
+		mkdir z &&
+		echo b >z/b &&
+		echo c >z/c &&
+		echo d >z/d &&
+		git add z &&
+		test_tick &&
+		git commit -m "O" &&
+
+		git branch O &&
+		git branch A &&
+		git branch B &&
+
+		git checkout A &&
+		mkdir y &&
+		mkdir x &&
+		git mv z/b y/ &&
+		git mv z/c y/ &&
+		git mv z/d x/ &&
+		rmdir z &&
+		test_tick &&
+		git commit -m "A" &&
+
+		git checkout B &&
+		mkdir w &&
+		git mv z/d w/ &&
+		test_tick &&
+		git commit -m "B"
+	)
+'
+
+test_expect_success '3b-check: Avoid implicit rename if involved as source on current side' '
+	(
+		cd 3b &&
+
+		git checkout A^0 &&
+
+		test_must_fail git merge -s recursive B^0 >out &&
+
+		test 5 -eq $(git ls-files -s | wc -l) &&
+		test 3 -eq $(git ls-files -u | wc -l) &&
+		test 1 -eq $(git ls-files -o | wc -l) &&
+
+		git rev-parse >actual \
+			:0:y/b :0:y/c :1:z/d :2:x/d :3:w/d &&
+		git rev-parse >expect \
+			O:z/b O:z/c O:z/d O:z/d O:z/d &&
+		test_cmp expect actual &&
+
+		test ! -f z/d &&
+		git hash-object >actual \
+			x/d w/d &&
+		git rev-parse >expect \
+			O:z/d O:z/d &&
+		test_cmp expect actual &&
+
+		test_i18ngrep CONFLICT.*rename/rename.*z/d.*x/d.*w/d out &&
+		test_i18ngrep ! CONFLICT.*rename/rename.*y/d
+	)
+'
+
+###########################################################################
+# Rules suggested by section 3:
+#
+#   Avoid directory-rename-detection for a path, if that path is the source
+#   of a rename on either side of a merge.
+###########################################################################
+
 test_done
-- 
2.15.0.408.g8e199d483


  parent reply	other threads:[~2017-12-28  4:15 UTC|newest]

Thread overview: 46+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-28  4:13 [PATCH v5 00/34] Add directory rename detection to git Elijah Newren
2017-12-28  4:13 ` [PATCH v5 01/34] Tighten and correct a few testcases for merging and cherry-picking Elijah Newren
2017-12-28  4:13 ` [PATCH v5 02/34] merge-recursive: fix logic ordering issue Elijah Newren
2017-12-28  4:13 ` [PATCH v5 03/34] merge-recursive: add explanation for src_entry and dst_entry Elijah Newren
2017-12-28  4:13 ` [PATCH v5 04/34] directory rename detection: basic testcases Elijah Newren
2018-01-03  1:18   ` SZEDER Gábor
2018-01-03  3:43     ` Elijah Newren
2017-12-28  4:13 ` [PATCH v5 05/34] directory rename detection: directory splitting testcases Elijah Newren
2017-12-28  4:13 ` Elijah Newren [this message]
2017-12-28  4:13 ` [PATCH v5 07/34] directory rename detection: partially renamed directory testcase/discussion Elijah Newren
2017-12-28  4:13 ` [PATCH v5 08/34] directory rename detection: files/directories in the way of some renames Elijah Newren
2017-12-28  4:13 ` [PATCH v5 09/34] directory rename detection: testcases checking which side did the rename Elijah Newren
2017-12-28  4:13 ` [PATCH v5 10/34] directory rename detection: more involved edge/corner testcases Elijah Newren
2017-12-28  4:13 ` [PATCH v5 11/34] directory rename detection: testcases exploring possibly suboptimal merges Elijah Newren
2017-12-28  4:13 ` [PATCH v5 12/34] directory rename detection: miscellaneous testcases to complete coverage Elijah Newren
2017-12-28  4:13 ` [PATCH v5 13/34] directory rename detection: tests for handling overwriting untracked files Elijah Newren
2018-01-04  0:52   ` SZEDER Gábor
2018-01-04 21:10     ` Elijah Newren
2018-01-05 14:37       ` SZEDER Gábor
2018-01-05 20:31       ` Thomas Gummerer
2018-01-05 20:33         ` Elijah Newren
2017-12-28  4:13 ` [PATCH v5 14/34] directory rename detection: tests for handling overwriting dirty files Elijah Newren
2017-12-28  4:13 ` [PATCH v5 15/34] merge-recursive: move the get_renames() function Elijah Newren
2017-12-28  4:13 ` [PATCH v5 16/34] merge-recursive: introduce new functions to handle rename logic Elijah Newren
2017-12-28  4:13 ` [PATCH v5 17/34] merge-recursive: fix leaks of allocated renames and diff_filepairs Elijah Newren
2017-12-28  4:13 ` [PATCH v5 18/34] merge-recursive: make !o->detect_rename codepath more obvious Elijah Newren
2017-12-28  4:13 ` [PATCH v5 19/34] merge-recursive: split out code for determining diff_filepairs Elijah Newren
2017-12-28  4:13 ` [PATCH v5 20/34] merge-recursive: add a new hashmap for storing directory renames Elijah Newren
2017-12-28  4:13 ` [PATCH v5 21/34] merge-recursive: make a helper function for cleanup for handle_renames Elijah Newren
2017-12-28  4:13 ` [PATCH v5 22/34] merge-recursive: add get_directory_renames() Elijah Newren
2017-12-28  4:13 ` [PATCH v5 23/34] merge-recursive: check for directory level conflicts Elijah Newren
2017-12-28  4:13 ` [PATCH v5 24/34] merge-recursive: add a new hashmap for storing file collisions Elijah Newren
2017-12-28  4:13 ` [PATCH v5 25/34] merge-recursive: add computation of collisions due to dir rename & merging Elijah Newren
2017-12-28  4:13 ` [PATCH v5 26/34] merge-recursive: check for file level conflicts then get new name Elijah Newren
2017-12-28  4:13 ` [PATCH v5 27/34] merge-recursive: when comparing files, don't include trees Elijah Newren
2017-12-28  4:13 ` [PATCH v5 28/34] merge-recursive: apply necessary modifications for directory renames Elijah Newren
2017-12-28  4:13 ` [PATCH v5 29/34] merge-recursive: avoid clobbering untracked files with " Elijah Newren
2017-12-28  4:13 ` [PATCH v5 30/34] merge-recursive: fix overwriting dirty files involved in renames Elijah Newren
2017-12-28  4:13 ` [PATCH v5 31/34] merge-recursive: fix remaining directory rename + dirty overwrite cases Elijah Newren
2017-12-28  4:13 ` [PATCH v5 32/34] directory rename detection: new testcases showcasing a pair of bugs Elijah Newren
2017-12-28  4:13 ` [PATCH v5 33/34] merge-recursive: avoid spurious rename/rename conflict from dir renames Elijah Newren
2017-12-28  4:13 ` [PATCH v5 34/34] merge-recursive: ensure we write updates for directory-renamed file Elijah Newren
2018-01-03  0:02 ` [PATCH v5 00/34] Add directory rename detection to git Elijah Newren
2018-01-03 10:57   ` Johannes Sixt
2018-01-03 21:02     ` Elijah Newren
2018-01-03 22:23       ` Johannes Sixt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20171228041352.27880-7-newren@gmail.com \
    --to=newren@gmail.com \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).