git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH/RFC 1/3] t3030-merge-recursive: Test known breakage with empty work tree

From
Brad King <brad.king@kitware.com>
Date
Jan 24, 2014, 15:01 UTC
Message-ID
<bee33fbfe83408a69085d58db302b3e72edf16a4.1390574981.git.brad.king@kitware.com>
In-Reply-To
<cover.1390574980.git.brad.king@kitware.com>

Add test cases that use 'merge-recursive' plumbing with a temporary index and empty work tree. Populate the index using 'read-tree' and 'update-index --ignore-missing --refresh' to prepare for merge without actually checking all files out to disk. Verify that each merge produces its expected tree while displaying no error diagnostics.

This approach can be used to compute tree merges while checking out only conflicting files to disk (which is useful for server-side scripts). Prior to commit 5b448b85 (merge-recursive: When we detect we can skip an update, actually skip it, 2011-08-11) this worked cleanly in all cases. Since that commit, merge-recursive displays a diagnostic such as

 error: addinfo_cache failed for path 'e'

when "our" side has a rename (to 'e'). The diagnostic does not influence the return code and the merge appears to succeed, but it causes this test case to fail.

Signed-off-by: Brad King <brad.king@kitware.com>
---
 t/t3030-merge-recursive.sh | 47 ++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 47 insertions(+)
diff --git a/t/t3030-merge-recursive.sh b/t/t3030-merge-recursive.sh
index 2f96100..b6d3ed0 100755
--- a/t/t3030-merge-recursive.sh
+++ b/t/t3030-merge-recursive.sh
@@ -257,6 +257,7 @@ test_expect_success 'setup 8' '
 	git add e &&
 	test_tick &&
 	git commit -m "rename a->e" &&
+	c7=$(git rev-parse --verify HEAD) &&
 	git checkout rename-ln &&
 	git mv a e &&
 	test_ln_s_add e a &&
@@ -517,6 +518,52 @@ test_expect_success 'reset and bind merge' '
 
 '
 
+test_expect_failure 'merge-recursive w/ empty work tree - ours has rename' '
+	(
+	 GIT_WORK_TREE="$PWD/ours-has-rename-work" &&
+	 export GIT_WORK_TREE &&
+	 GIT_INDEX_FILE="$PWD/ours-has-rename-index" &&
+	 export GIT_INDEX_FILE &&
+	 mkdir "$GIT_WORK_TREE" &&
+	 git read-tree -i -m $c7 &&
+	 git update-index --ignore-missing --refresh &&
+	 git merge-recursive $c0 -- $c7 $c3 &&
+	 git ls-files -s >actual-files
+	) 2>actual-err &&
+	>expected-err &&
+	cat >expected-files <<-EOF &&
+	100644 $o3 0	b/c
+	100644 $o0 0	c
+	100644 $o0 0	d/e
+	100644 $o0 0	e
+	EOF
+	test_cmp expected-files actual-files &&
+	test_cmp expected-err actual-err
+'
+
+test_expect_success 'merge-recursive w/ empty work tree - theirs has rename' '
+	(
+	 GIT_WORK_TREE="$PWD/theirs-has-rename-work" &&
+	 export GIT_WORK_TREE &&
+	 GIT_INDEX_FILE="$PWD/theirs-has-rename-index" &&
+	 export GIT_INDEX_FILE &&
+	 mkdir "$GIT_WORK_TREE" &&
+	 git read-tree -i -m $c3 &&
+	 git update-index --ignore-missing --refresh &&
+	 git merge-recursive $c0 -- $c3 $c7 &&
+	 git ls-files -s >actual-files
+	) 2>actual-err &&
+	>expected-err &&
+	cat >expected-files <<-EOF &&
+	100644 $o3 0	b/c
+	100644 $o0 0	c
+	100644 $o0 0	d/e
+	100644 $o0 0	e
+	EOF
+	test_cmp expected-files actual-files &&
+	test_cmp expected-err actual-err
+'
+
 test_expect_success 'merge removes empty directories' '
 
 	git reset --hard master &&
-- 
1.8.5.2
Previous: Brad KingNext: Jonathan Nieder
Message 2 of 21 in “merge-recursive: Avoid diagnostic on empty work tree”
  1. 0/3 merge-recursive: Avoid diagnostic on empty work treeBrad King, Jan 24, 2014
  2. 1/3 t3030-merge-recursive: Test known breakage with empty work treeBrad King, Jan 24, 2014
  3. Jonathan NiederJan 24, 2014
  4. Brad KingJan 24, 2014
  5. 2/3 read-cache.c: Thread lstat error through make_cache_entry signatureBrad King, Jan 24, 2014
  6. 3/3 merge-recursive: Tolerate missing file when HEAD is up to dateBrad King, Jan 24, 2014
  7. Junio C HamanoJan 24, 2014
  8. Brad KingJan 24, 2014
  9. 0/3 merge-recursive: Avoid diagnostic on empty work treeBrad King, Jan 24, 2014
  10. 1/3 t3030-merge-recursive: Test known breakage with empty work treeBrad King, Jan 24, 2014
  11. 2/3 read-cache.c: Optionally tolerate missing files in make_cache_entryBrad King, Jan 24, 2014
  12. Junio C HamanoJan 24, 2014
  13. 3/3 merge-recursive.c: Tolerate missing files while refreshing indexBrad King, Jan 24, 2014
  14. 0/3 merge-recursive: Avoid diagnostic on empty work treeBrad King, Jan 27, 2014
  15. 1/4 t3030-merge-recursive: Test known breakage with empty work treeBrad King, Jan 27, 2014
  16. 2/4 read-cache.c: Refactor --ignore-missing implementationBrad King, Jan 27, 2014
  17. Junio C HamanoJan 27, 2014
  18. 3/4 read-cache.c: Extend make_cache_entry refresh flag with optionsBrad King, Jan 27, 2014
  19. 4/4 merge-recursive.c: Tolerate missing files while refreshing indexBrad King, Jan 27, 2014
  20. Fwd: [PATCH/RFC 3/3] merge-recursive: Tolerate missing file when HEAD is up to datenewren, Jan 24, 2014
  21. Brad KingJan 24, 2014

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.