Skip to content

Commit 29d9af5

Browse files
bradkinggitster
authored andcommitted
t3030-merge-recursive: test known breakage with empty work tree
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 2f93541 commit 29d9af5

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed

t/t3030-merge-recursive.sh

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,7 @@ test_expect_success 'setup 8' '
257257
git add e &&
258258
test_tick &&
259259
git commit -m "rename a->e" &&
260+
c7=$(git rev-parse --verify HEAD) &&
260261
git checkout rename-ln &&
261262
git mv a e &&
262263
test_ln_s_add e a &&
@@ -517,6 +518,52 @@ test_expect_success 'reset and bind merge' '
517518
518519
'
519520

521+
test_expect_failure 'merge-recursive w/ empty work tree - ours has rename' '
522+
(
523+
GIT_WORK_TREE="$PWD/ours-has-rename-work" &&
524+
export GIT_WORK_TREE &&
525+
GIT_INDEX_FILE="$PWD/ours-has-rename-index" &&
526+
export GIT_INDEX_FILE &&
527+
mkdir "$GIT_WORK_TREE" &&
528+
git read-tree -i -m $c7 &&
529+
git update-index --ignore-missing --refresh &&
530+
git merge-recursive $c0 -- $c7 $c3 &&
531+
git ls-files -s >actual-files
532+
) 2>actual-err &&
533+
>expected-err &&
534+
cat >expected-files <<-EOF &&
535+
100644 $o3 0 b/c
536+
100644 $o0 0 c
537+
100644 $o0 0 d/e
538+
100644 $o0 0 e
539+
EOF
540+
test_cmp expected-files actual-files &&
541+
test_cmp expected-err actual-err
542+
'
543+
544+
test_expect_success 'merge-recursive w/ empty work tree - theirs has rename' '
545+
(
546+
GIT_WORK_TREE="$PWD/theirs-has-rename-work" &&
547+
export GIT_WORK_TREE &&
548+
GIT_INDEX_FILE="$PWD/theirs-has-rename-index" &&
549+
export GIT_INDEX_FILE &&
550+
mkdir "$GIT_WORK_TREE" &&
551+
git read-tree -i -m $c3 &&
552+
git update-index --ignore-missing --refresh &&
553+
git merge-recursive $c0 -- $c3 $c7 &&
554+
git ls-files -s >actual-files
555+
) 2>actual-err &&
556+
>expected-err &&
557+
cat >expected-files <<-EOF &&
558+
100644 $o3 0 b/c
559+
100644 $o0 0 c
560+
100644 $o0 0 d/e
561+
100644 $o0 0 e
562+
EOF
563+
test_cmp expected-files actual-files &&
564+
test_cmp expected-err actual-err
565+
'
566+
520567
test_expect_success 'merge removes empty directories' '
521568
522569
git reset --hard master &&

0 commit comments

Comments
 (0)