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: gitster@pobox.com, Elijah Newren <newren@gmail.com>
Subject: [PATCH 1/2] t1015: demonstrate directory/file conflict recovery failures
Date: Tue, 10 Jul 2018 22:18:33 -0700	[thread overview]
Message-ID: <20180711051834.28181-2-newren@gmail.com> (raw)
In-Reply-To: <20180711051834.28181-1-newren@gmail.com>

Several "recovery" commands outright fail or do not fully recover
when directory-file conflicts are present.  This includes:
  * git read-tree --reset HEAD
  * git am --skip
  * git am --abort
  * git merge --abort
  * git reset --hard

Add testcases documenting these shortcomings.

Signed-off-by: Elijah Newren <newren@gmail.com>
---
 t/t1015-read-index-unmerged.sh | 123 +++++++++++++++++++++++++++++++++
 1 file changed, 123 insertions(+)
 create mode 100755 t/t1015-read-index-unmerged.sh

diff --git a/t/t1015-read-index-unmerged.sh b/t/t1015-read-index-unmerged.sh
new file mode 100755
index 000000000..bbd64587c
--- /dev/null
+++ b/t/t1015-read-index-unmerged.sh
@@ -0,0 +1,123 @@
+#!/bin/sh
+
+test_description='Test various callers of read_index_unmerged'
+. ./test-lib.sh
+
+test_expect_success 'setup modify/delete + directory/file conflict' '
+	test_create_repo df_plus_modify_delete &&
+	(
+		cd df_plus_modify_delete &&
+
+		printf "a\nb\nc\nd\ne\nf\ng\nh\n" >letters &&
+		git add letters &&
+		git commit -m initial &&
+
+		git checkout -b modify &&
+		# Throw in letters.txt for sorting order fun
+		# ("letters.txt" sorts between "letters" and "letters/file")
+		echo i >>letters &&
+		echo "version 2" >letters.txt &&
+		git add letters letters.txt &&
+		git commit -m modified &&
+
+		git checkout -b delete HEAD^ &&
+		git rm letters &&
+		mkdir letters &&
+		>letters/file &&
+		echo "version 1" >letters.txt &&
+		git add letters letters.txt &&
+		git commit -m deleted
+	)
+'
+
+test_expect_failure 'read-tree --reset cleans unmerged entries' '
+	test_when_finished "git -C df_plus_modify_delete clean -f" &&
+	test_when_finished "git -C df_plus_modify_delete reset --hard" &&
+	(
+		cd df_plus_modify_delete &&
+
+		git checkout delete^0 &&
+		test_must_fail git merge modify &&
+
+		git read-tree --reset HEAD &&
+		git ls-files -u >conflicts &&
+		test_must_be_empty conflicts
+	)
+'
+
+test_expect_failure 'One reset --hard cleans unmerged entries' '
+	test_when_finished "git -C df_plus_modify_delete clean -f" &&
+	test_when_finished "git -C df_plus_modify_delete reset --hard" &&
+	(
+		cd df_plus_modify_delete &&
+
+		git checkout delete^0 &&
+		test_must_fail git merge modify &&
+
+		git reset --hard &&
+		test_path_is_missing .git/MERGE_HEAD &&
+		git ls-files -u >conflicts &&
+		test_must_be_empty conflicts
+	)
+'
+
+test_expect_success 'setup directory/file conflict + simple edit/edit' '
+	test_create_repo df_plus_edit_edit &&
+	(
+		cd df_plus_edit_edit &&
+
+		test_seq 1 10 >numbers &&
+		git add numbers &&
+		git commit -m initial &&
+
+		git checkout -b d-edit &&
+		mkdir foo &&
+		echo content >foo/bar &&
+		git add foo &&
+		echo 11 >>numbers &&
+		git add numbers &&
+		git commit -m "directory and edit" &&
+
+		git checkout -b f-edit d-edit^1 &&
+		echo content >foo &&
+		git add foo &&
+		echo eleven >>numbers &&
+		git add numbers &&
+		git commit -m "file and edit"
+	)
+'
+
+test_expect_failure 'git merge --abort succeeds despite D/F conflict' '
+	test_when_finished "git -C df_plus_edit_edit clean -f" &&
+	test_when_finished "git -C df_plus_edit_edit reset --hard" &&
+	(
+		cd df_plus_edit_edit &&
+
+		git checkout f-edit^0 &&
+		test_must_fail git merge d-edit^0 &&
+
+		git merge --abort &&
+		test_path_is_missing .git/MERGE_HEAD &&
+		git ls-files -u >conflicts &&
+		test_must_be_empty conflicts
+	)
+'
+
+test_expect_failure 'git am --skip succeeds despite D/F conflict' '
+	test_when_finished "git -C df_plus_edit_edit clean -f" &&
+	test_when_finished "git -C df_plus_edit_edit reset --hard" &&
+	(
+		cd df_plus_edit_edit &&
+
+		git checkout f-edit^0 &&
+		git format-patch -1 d-edit &&
+		test_must_fail git am -3 0001*.patch &&
+
+		git am --skip &&
+		test_path_is_missing .git/rebase-apply &&
+		git ls-files -u >conflicts &&
+		test_must_be_empty conflicts
+	)
+'
+
+test_done
-- 
2.18.0.138.g557c5d94c.dirty


  reply	other threads:[~2018-07-11  5:18 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-11  5:18 [PATCH 0/2] Address recovery failures with directory/file conflicts Elijah Newren
2018-07-11  5:18 ` Elijah Newren [this message]
2018-07-11  9:21   ` [PATCH 1/2] t1015: demonstrate directory/file conflict recovery failures Eric Sunshine
2018-07-11 18:23     ` Elijah Newren
2018-07-11  5:18 ` [PATCH 2/2] read-cache: fix directory/file conflict handling in read_index_unmerged() Elijah Newren
2018-07-11 17:03   ` Junio C Hamano
2018-07-11 18:24     ` Elijah Newren
2018-07-13 16:33 ` [PATCH v2 0/2] Address recovery failures with directory/file conflicts Elijah Newren
2018-07-13 16:33   ` [PATCH v2 1/2] t1015: demonstrate directory/file conflict recovery failures Elijah Newren
2018-07-13 16:33   ` [PATCH v2 2/2] read-cache: fix directory/file conflict handling in read_index_unmerged() Elijah Newren
2018-07-13 16:45   ` [PATCH v2 0/2] Address recovery failures with directory/file conflicts Elijah Newren
2018-07-31 17:12   ` [PATCH v3 " Elijah Newren
2018-07-31 17:12     ` [PATCH v3 1/2] t1015: demonstrate directory/file conflict recovery failures Elijah Newren
2018-07-31 17:12     ` [PATCH v3 2/2] read-cache: fix directory/file conflict handling in read_index_unmerged() Elijah Newren

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=20180711051834.28181-2-newren@gmail.com \
    --to=newren@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    /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).