Skip to content

Commit

Permalink
t3030-merge-recursive: test known breakage with empty work tree
Browse files Browse the repository at this point in the history
Sometimes when working with a large repository it can be useful to try
out a merge and only check out conflicting files to disk (for example as
a speed optimization on a server).  Until v1.7.7-rc1~28^2~20
(merge-recursive: When we detect we can skip an update, actually skip
it, 2011-08-11), it was possible to do so with the following idiom:

	# Prepare a temporary index and empty work tree.
	GIT_INDEX_FILE="$PWD/tmp-$$-index" &&
	export GIT_INDEX_FILE &&
	GIT_WORK_TREE="$PWD/tmp-$$-work" &&
	export GIT_WORK_TREE &&
	mkdir "$GIT_WORK_TREE" &&

	# Convince the index that our side is on disk.
	git read-tree -i -m $ours &&
	git update-index --ignore-missing --refresh &&

	# Merge their side into our side.
	bases=$(git merge-base --all $ours $theirs) &&
	git merge-recursive $bases -- $ours $theirs &&
	tree=$(git write-tree)

Nowadays, that still works and the exit status is the same, but
merge-recursive produces a diagnostic if "our" side renamed a file:

	error: addinfo_cache failed for path 'dst'

Add a test to document this regression.

Signed-off-by: Brad King <brad.king@kitware.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Brad King authored and Junio C Hamano committed Feb 24, 2014
1 parent 2f93541 commit 29d9af5
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions t/t3030-merge-recursive.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 &&
Expand Down Expand Up @@ -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 &&
Expand Down

0 comments on commit 29d9af5

Please sign in to comment.